Skip to content

Commit 6eb97e1

Browse files
authored
Merge pull request #682 from sparkfun/CaptivePortal
Enable Captive Portal
2 parents ab89374 + f8ec428 commit 6eb97e1

File tree

5 files changed

+170
-130
lines changed

5 files changed

+170
-130
lines changed

Firmware/RTK_Everywhere/Network.ino

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,20 @@ Network.ino
104104
//----------------------------------------
105105

106106
static const char *networkConsumerTable[] = {
107-
"HTTP_CLIENT", "NTP_SERVER", "NTRIP_CLIENT", "NTRIP_SERVER_0", "NTRIP_SERVER_1",
108-
"NTRIP_SERVER_2", "NTRIP_SERVER_3", "OTA_CLIENT", "POINTPERFECT_KEY_UPDATE", "POINTPERFECT_MQTT_CLIENT",
109-
"TCP_CLIENT", "TCP_SERVER", "UDP_SERVER", "WEB_CONFIG",
107+
"HTTP_CLIENT",
108+
"NTP_SERVER",
109+
"NTRIP_CLIENT",
110+
"NTRIP_SERVER_0",
111+
"NTRIP_SERVER_1",
112+
"NTRIP_SERVER_2",
113+
"NTRIP_SERVER_3",
114+
"OTA_CLIENT",
115+
"POINTPERFECT_KEY_UPDATE",
116+
"POINTPERFECT_MQTT_CLIENT",
117+
"TCP_CLIENT",
118+
"TCP_SERVER",
119+
"UDP_SERVER",
120+
"WEB_CONFIG",
110121
};
111122

112123
static const int networkConsumerTableEntries = sizeof(networkConsumerTable) / sizeof(networkConsumerTable[0]);
@@ -203,7 +214,8 @@ void menuTcpUdp()
203214
if (settings.enableTcpServer)
204215
{
205216
systemPrintf("8) Enable NTRIP Caster: %s\r\n", settings.enableNtripCaster ? "Enabled" : "Disabled");
206-
systemPrintf("9) Enable base Caster override: %s\r\n", settings.baseCasterOverride ? "Enabled" : "Disabled");
217+
systemPrintf("9) Enable base Caster override: %s\r\n",
218+
settings.baseCasterOverride ? "Enabled" : "Disabled");
207219
}
208220

209221
//------------------------------
@@ -898,6 +910,9 @@ void networkEvent(arduino_event_id_t event, arduino_event_info_t info)
898910
{
899911
int index;
900912

913+
if (settings.debugNetworkLayer)
914+
systemPrintf("event: %d (%s)\r\n", event, Network.eventName(event));
915+
901916
// Get the index into the networkInterfaceTable for the default interface
902917
index = networkPriority;
903918
if (index < NETWORK_OFFLINE)
@@ -944,6 +959,13 @@ void networkEvent(arduino_event_id_t event, arduino_event_info_t info)
944959
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
945960
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
946961
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
962+
case ARDUINO_EVENT_WIFI_AP_START:
963+
case ARDUINO_EVENT_WIFI_AP_STOP:
964+
case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
965+
case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:
966+
case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED:
967+
case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED:
968+
case ARDUINO_EVENT_WIFI_AP_GOT_IP6:
947969
wifi.eventHandler(event, info);
948970
break;
949971
#endif // COMPILE_WIFI
@@ -2510,9 +2532,21 @@ void networkUseDefaultInterface()
25102532
isDefault = networkInterfaceTable[index].netif->isDefault();
25112533
if (!isDefault)
25122534
networkInterfaceTable[index].netif->setDefault();
2535+
2536+
if (settings.debugNetworkLayer)
2537+
networkPrintDefaultInterface();
25132538
}
25142539
}
25152540

2541+
//----------------------------------------
2542+
// Print the default network interface specs
2543+
//----------------------------------------
2544+
void networkPrintDefaultInterface()
2545+
{
2546+
NetworkInterface *irfc = Network.getDefaultInterface();
2547+
systemPrintln(irfc->printTo(Serial));
2548+
}
2549+
25162550
//----------------------------------------
25172551
// Add a network user
25182552
//----------------------------------------

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
#include <NetworkUdp.h>
147147
#endif // COMPILE_NETWORK
148148

149-
#define RTK_MAX_CONNECTION_MSEC (15 * MILLISECONDS_IN_A_MINUTE)
149+
#define RTK_MAX_CONNECTION_MSEC (15 * MILLISECONDS_IN_A_MINUTE)
150150

151151
bool RTK_CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC =
152152
false; // Flag used by the special build of libmbedtls (libmbedcrypto) to select external memory
@@ -172,16 +172,16 @@ const uint16_t HTTPS_PORT = 443;
172172
#include <PPP.h>
173173
#endif // COMPILE_CELLULAR
174174

175-
#include <esp_mac.h> // MAC address support
176175
#include "settings.h"
176+
#include <esp_mac.h> // MAC address support
177177

178178
#define MAX_CPU_CORES 2
179179
#define IDLE_COUNT_PER_SECOND 515400 // Found by empirical sketch
180180
#define IDLE_TIME_DISPLAY_SECONDS 5
181181
#define MAX_IDLE_TIME_COUNT (IDLE_TIME_DISPLAY_SECONDS * IDLE_COUNT_PER_SECOND)
182182

183-
#define HOURS_IN_A_DAY 24L
184-
#define MINUTES_IN_AN_HOUR 60L
183+
#define HOURS_IN_A_DAY 24L
184+
#define MINUTES_IN_AN_HOUR 60L
185185
#define SECONDS_IN_A_MINUTE 60L
186186
#define MILLISECONDS_IN_A_SECOND 1000L
187187
#define MILLISECONDS_IN_A_MINUTE (SECONDS_IN_A_MINUTE * MILLISECONDS_IN_A_SECOND)
@@ -377,8 +377,8 @@ bool wifiSoftApRunning; // False: stopped, True: starting, running, stop
377377
bool wifiStationOnline; // WiFi station started successfully
378378
bool wifiStationRunning; // False: stopped, True: starting, running, stopping
379379

380-
const char * wifiSoftApSsid = "RTK Config";
381-
const char * wifiSoftApPassword = nullptr;
380+
const char *wifiSoftApSsid = "RTK Config";
381+
const char *wifiSoftApPassword = nullptr;
382382

383383
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
384384

@@ -996,7 +996,7 @@ volatile bool deadManWalking;
996996
\
997997
/* Turn on nearly all the debug prints */ \
998998
settings.debugCorrections = true; \
999-
settings.debugGnss = false; \
999+
settings.debugGnss = false; \
10001000
settings.debugHttpClientData = true; \
10011001
settings.debugHttpClientState = true; \
10021002
settings.debugLora = true; \
@@ -1041,7 +1041,7 @@ volatile bool deadManWalking;
10411041
\
10421042
/* Turn on nearly all the debug prints */ \
10431043
settings.debugCorrections = true; \
1044-
settings.debugGnss = false; \
1044+
settings.debugGnss = false; \
10451045
settings.debugHttpClientData = false; \
10461046
settings.debugHttpClientState = true; \
10471047
settings.debugLora = false; \
@@ -1240,8 +1240,8 @@ void setup()
12401240
DMW_b("loadSettings");
12411241
loadSettings(); // Attempt to load settings after SD is started so we can read the settings file if available
12421242

1243-
//DEBUG_NEARLY_EVERYTHING // Debug nearly all the things
1244-
//DEBUG_THE_ESSENTIALS // Debug the essentials - handy for measuring the boot time after a factory reset
1243+
// DEBUG_NEARLY_EVERYTHING // Debug nearly all the things
1244+
// DEBUG_THE_ESSENTIALS // Debug the essentials - handy for measuring the boot time after a factory reset
12451245

12461246
DMW_b("checkArrayDefaults");
12471247
checkArrayDefaults(); // Check for uninitialized arrays that won't be initialized by gnssConfigure

0 commit comments

Comments
 (0)