Skip to content

Commit

Permalink
Merge pull request #36 from Gadgetoid/patch-set-hostname
Browse files Browse the repository at this point in the history
Fix setHostname API
  • Loading branch information
brentru authored Jun 4, 2021
2 parents ec9e20f + e138580 commit 104c48c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Adafruit's Arduino NINA-W102 firmware 1.7.4 - 2021.06.03

* Fixed support for custom hostname in WiFi client mode

Adafruit's Arduino NINA-W102 firmware 1.7.3 - 2021.03.26

* Changed Analog Write to use full PWM range.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load-passthrough:
cp passthrough.UF2 $(BOOT_VOLUME)

load-nina:
esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 NINA_W102-1.7.3.bin
esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 NINA_W102-1.7.4.bin

load-circuitpython:
cp $(CIRCUITPYTHON_UF2) $(BOOT_VOLUME)
Expand Down
10 changes: 8 additions & 2 deletions arduino/libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ WiFiClass::WiFiClass() :
memset(&_apRecord, 0x00, sizeof(_apRecord));
memset(&_ipInfo, 0x00, sizeof(_ipInfo));
memset(&_dnsServers, 0x00, sizeof(_dnsServers));
memset(&_hostname, 0x00, sizeof(_hostname));
}

uint8_t WiFiClass::status()
Expand Down Expand Up @@ -320,7 +321,7 @@ void WiFiClass::setDNS(/*IPAddress*/uint32_t dns_server1, /*IPAddress*/uint32_t

void WiFiClass::hostname(const char* name)
{
tcpip_adapter_set_hostname(_interface == ESP_IF_WIFI_AP ? TCPIP_ADAPTER_IF_AP : TCPIP_ADAPTER_IF_STA, name);
strncpy(_hostname, name, HOSTNAME_MAX_LENGTH);
}

void WiFiClass::disconnect()
Expand Down Expand Up @@ -604,7 +605,12 @@ void WiFiClass::handleSystemEvent(system_event_t* event)

esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
sprintf(defaultHostname, "arduino-%.2x%.2x", mac[4], mac[5]);
tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, defaultHostname);
//tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, defaultHostname);
if (strlen(_hostname) == 0) {
sprintf(_hostname, "%s", defaultHostname);
}
tcpip_adapter_set_hostname(_interface == ESP_IF_WIFI_AP ? TCPIP_ADAPTER_IF_AP : TCPIP_ADAPTER_IF_STA, _hostname);


if (tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, (void**)&staNetif) == ESP_OK) {
if (staNetif->input != WiFiClass::staNetifInputHandler) {
Expand Down
2 changes: 2 additions & 0 deletions arduino/libraries/WiFi/src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef enum {
} wl_status_t;

#define MAX_SCAN_RESULTS 10
#define HOSTNAME_MAX_LENGTH 32

class WiFiClass
{
Expand Down Expand Up @@ -119,6 +120,7 @@ class WiFiClass
tcpip_adapter_ip_info_t _ipInfo;
uint32_t _dnsServers[2];

char _hostname[HOSTNAME_MAX_LENGTH+1];
netif_input_fn _staNetifInput;
netif_input_fn _apNetifInput;

Expand Down
2 changes: 1 addition & 1 deletion combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# zero terminate the pem file
outputData[0x10000 + len(certsData)] = 0

outputFilename = "NINA_W102-1.7.3.bin"
outputFilename = "NINA_W102-1.7.4.bin"
if (len(sys.argv) > 1):
outputFilename = sys.argv[1]

Expand Down
2 changes: 1 addition & 1 deletion main/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "Arduino.h"

const char FIRMWARE_VERSION[6] = "1.7.3";
const char FIRMWARE_VERSION[6] = "1.7.4";

// Optional, user-defined X.509 certificate
char CERT_BUF[1300];
Expand Down

0 comments on commit 104c48c

Please sign in to comment.