Skip to content

Commit fb5eca8

Browse files
authored
Merge pull request #261 from sparkfun/BrowserConfig
Allow entry into browser config if WiFi is on
2 parents 47a109d + 1e4532c commit fb5eca8

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ bool wifiConnect(unsigned long timeout) {return false;}
152152
IPAddress wifiGetGatewayIpAddress() {return IPAddress((uint32_t)0);}
153153
IPAddress wifiGetIpAddress() {return IPAddress((uint32_t)0);}
154154
int wifiGetRssi() {return -999;}
155+
String wifiGetSsid() {return "**WiFi Not compiled**";}
155156
bool wifiIsConnected() {return false;}
156157
bool wifiIsNeeded() {return false;}
157158
int wifiNetworkCount() {return 0;}

Firmware/RTK_Everywhere/Network.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void networkDisplayIpAddress(uint8_t networkType)
389389
{
390390
strcpy(ipAddress, networkGetIpAddress(networkType).toString().c_str());
391391
if (network->type == NETWORK_TYPE_WIFI)
392-
systemPrintf("%s IP address: %s, RSSI: %d\r\n", networkName[network->type], ipAddress, wifiGetRssi());
392+
systemPrintf("%s '%s' IP address: %s, RSSI: %d\r\n", networkName[network->type], ipAddress, wifiGetSsid(), wifiGetRssi());
393393
else
394394
systemPrintf("%s IP address: %s\r\n", networkName[network->type], ipAddress);
395395

@@ -1037,6 +1037,13 @@ const char * networkTypeToString(uint8_t type)
10371037
//----------------------------------------
10381038
void networkTypeUpdate(uint8_t networkType)
10391039
{
1040+
if(inWiFiConfigMode())
1041+
{
1042+
//Avoid the full network layer while in Browser Config Mode
1043+
wifiUpdate();
1044+
return;
1045+
}
1046+
10401047
char errorMsg[64];
10411048
NETWORK_DATA *network;
10421049

Firmware/RTK_Everywhere/States.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ void stateUpdate()
421421

422422
displayWiFiConfigNotStarted(); // Display immediately during SD cluster pause
423423

424+
WIFI_STOP(); //Notify the network layer that it should stop so we can take over control of WiFi
424425
bluetoothStop();
425426
espnowStop();
426427

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void menuWiFi()
171171
// Display the WiFi IP address
172172
void wifiDisplayIpAddress()
173173
{
174-
systemPrintf("WiFi %s IP address: ", WiFi.SSID());
174+
systemPrintf("WiFi '%s' IP address: ", WiFi.SSID());
175175
systemPrint(WiFi.localIP());
176176
systemPrintf(" RSSI: %d\r\n", WiFi.RSSI());
177177

@@ -253,12 +253,14 @@ bool wifiStartAP(bool forceAP)
253253
IPAddress subnet(255, 255, 255, 0);
254254

255255
WiFi.softAPConfig(local_IP, gateway, subnet);
256-
if (WiFi.softAP("RTK Config") == false) // Must be short enough to fit OLED Width
256+
257+
const char *softApSsid = "RTK Config";
258+
if (WiFi.softAP(softApSsid) == false) // Must be short enough to fit OLED Width
257259
{
258260
systemPrintln("WiFi AP failed to start");
259261
return (false);
260262
}
261-
systemPrint("WiFi AP Started with IP: ");
263+
systemPrintf("WiFi AP '%s' started with IP: ", softApSsid);
262264
systemPrintln(WiFi.softAPIP());
263265

264266
// Start DNS Server
@@ -527,39 +529,18 @@ bool wifiConnect(unsigned long timeout)
527529

528530
int wifiResponse = WL_DISCONNECTED;
529531

530-
// WiFi.begin() is much faster than wifiMulti (requires scan time)
531-
// Use wifiMulti only if multiple credentials exist
532-
if (wifiNetworkCount() == 1)
533-
{
534-
systemPrint("Connecting WiFi");
532+
systemPrint("Connecting WiFi... ");
533+
WiFiMulti wifiMulti;
535534

536-
// Load SSID - may not be in spot 0
537-
for (int x = 0; x < MAX_WIFI_NETWORKS; x++)
538-
{
539-
if (strlen(settings.wifiNetworks[x].ssid) > 0)
540-
{
541-
WiFi.begin(settings.wifiNetworks[x].ssid, settings.wifiNetworks[x].password);
542-
break;
543-
}
544-
}
545-
546-
wifiResponse = WiFi.waitForConnectResult();
547-
}
548-
else
535+
// Load SSIDs
536+
for (int x = 0; x < MAX_WIFI_NETWORKS; x++)
549537
{
550-
systemPrint("Connecting WiFi... ");
551-
WiFiMulti wifiMulti;
552-
553-
// Load SSIDs
554-
for (int x = 0; x < MAX_WIFI_NETWORKS; x++)
555-
{
556-
if (strlen(settings.wifiNetworks[x].ssid) > 0)
557-
wifiMulti.addAP(settings.wifiNetworks[x].ssid, settings.wifiNetworks[x].password);
558-
}
559-
560-
wifiResponse = wifiMulti.run(timeout);
538+
if (strlen(settings.wifiNetworks[x].ssid) > 0)
539+
wifiMulti.addAP(settings.wifiNetworks[x].ssid, settings.wifiNetworks[x].password);
561540
}
562541

542+
wifiResponse = wifiMulti.run(timeout);
543+
563544
if (wifiResponse == WL_CONNECTED)
564545
{
565546
if (settings.enableTcpClient == true || settings.enableTcpServer == true || settings.enableUdpServer == true)
@@ -708,4 +689,9 @@ int wifiGetRssi()
708689
return WiFi.RSSI();
709690
}
710691

692+
String wifiGetSsid()
693+
{
694+
return WiFi.SSID();
695+
}
696+
711697
#endif // COMPILE_WIFI

0 commit comments

Comments
 (0)