mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 17:32:18 +00:00
Set device hostname with hardwire ID #445
This commit is contained in:
parent
5ebac0cd54
commit
848760e5bf
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = tbeam # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
|
default_envs = tbeam # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
|
||||||
|
;default_envs = heltec # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
; common is not currently used
|
; common is not currently used
|
||||||
@ -33,6 +34,8 @@ build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/n
|
|||||||
; leave this commented out to avoid breaking Windows
|
; leave this commented out to avoid breaking Windows
|
||||||
;upload_port = /dev/ttyUSB0
|
;upload_port = /dev/ttyUSB0
|
||||||
;monitor_port = /dev/ttyUSB0
|
;monitor_port = /dev/ttyUSB0
|
||||||
|
upload_port = /dev/cu.SLAB_USBtoUART
|
||||||
|
monitor_port = /dev/cu.SLAB_USBtoUART
|
||||||
|
|
||||||
; the default is esptool
|
; the default is esptool
|
||||||
; upload_protocol = esp-prog
|
; upload_protocol = esp-prog
|
||||||
|
@ -937,7 +937,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
} else if (getWifiDisconnectReason() == 14) {
|
} else if (getWifiDisconnectReason() == 14) {
|
||||||
display->drawString(x, y + FONT_HEIGHT * 1, "MIC_FAILURE");
|
display->drawString(x, y + FONT_HEIGHT * 1, "MIC_FAILURE");
|
||||||
} else if (getWifiDisconnectReason() == 15) {
|
} else if (getWifiDisconnectReason() == 15) {
|
||||||
display->drawString(x, y + FONT_HEIGHT * 1, "4WAY_HANDSHAKE_TIMEOUT");
|
display->drawString(x, y + FONT_HEIGHT * 1, "AP Handshake Timeout");
|
||||||
} else if (getWifiDisconnectReason() == 16) {
|
} else if (getWifiDisconnectReason() == 16) {
|
||||||
display->drawString(x, y + FONT_HEIGHT * 1, "GROUP_KEY_UPDATE_TIMEOUT");
|
display->drawString(x, y + FONT_HEIGHT * 1, "GROUP_KEY_UPDATE_TIMEOUT");
|
||||||
} else if (getWifiDisconnectReason() == 17) {
|
} else if (getWifiDisconnectReason() == 17) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "meshwifi/meshhttp.h"
|
#include "meshwifi/meshhttp.h"
|
||||||
|
#include "target_specific.h"
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
@ -16,11 +17,17 @@ static WiFiServerPort *apiPort;
|
|||||||
|
|
||||||
uint8_t wifiDisconnectReason = 0;
|
uint8_t wifiDisconnectReason = 0;
|
||||||
|
|
||||||
|
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
||||||
|
static char ourHost[16];
|
||||||
|
|
||||||
bool isWifiAvailable()
|
bool isWifiAvailable()
|
||||||
{
|
{
|
||||||
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||||
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
||||||
|
|
||||||
|
//strcpy(radioConfig.preferences.wifi_ssid, "");
|
||||||
|
//strcpy(radioConfig.preferences.wifi_password, "");
|
||||||
|
|
||||||
if (*wifiName && *wifiPsw) {
|
if (*wifiName && *wifiPsw) {
|
||||||
|
|
||||||
// Once every 10 seconds, try to reconnect.
|
// Once every 10 seconds, try to reconnect.
|
||||||
@ -57,9 +64,6 @@ void initWifi()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//strcpy(radioConfig.preferences.wifi_ssid, "");
|
|
||||||
//strcpy(radioConfig.preferences.wifi_password, "");
|
|
||||||
|
|
||||||
if (radioConfig.has_preferences) {
|
if (radioConfig.has_preferences) {
|
||||||
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||||
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
||||||
@ -77,11 +81,18 @@ void initWifi()
|
|||||||
dnsServer.start(53, "*", apIP);
|
dnsServer.start(53, "*", apIP);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
uint8_t dmac[6];
|
||||||
|
getMacAddr(dmac);
|
||||||
|
sprintf(ourHost, "Meshtastic-%02x%02x", dmac[4], dmac[5]);
|
||||||
|
|
||||||
|
Serial.println(ourHost);
|
||||||
|
|
||||||
WiFi.mode(WIFI_MODE_STA);
|
WiFi.mode(WIFI_MODE_STA);
|
||||||
|
WiFi.setHostname(ourHost);
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
// esp_wifi_set_ps(WIFI_PS_NONE); // Disable power saving
|
// esp_wifi_set_ps(WIFI_PS_NONE); // Disable power saving
|
||||||
|
|
||||||
//WiFiEventId_t eventID = WiFi.onEvent(
|
// WiFiEventId_t eventID = WiFi.onEvent(
|
||||||
WiFi.onEvent(
|
WiFi.onEvent(
|
||||||
[](WiFiEvent_t event, WiFiEventInfo_t info) {
|
[](WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.print("\nWiFi lost connection. Reason: ");
|
Serial.print("\nWiFi lost connection. Reason: ");
|
||||||
|
Loading…
Reference in New Issue
Block a user