Skip to content

Rework WiFi states and better handle restart #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: release_candidate
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion Firmware/RTK_Everywhere/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void wifiDisplayNetworkData() {}
void wifiDisplaySoftApStatus() {}
bool wifiEspNowOff(const char * fileName, uint32_t lineNumber) {return true;}
bool wifiEspNowOn(const char * fileName, uint32_t lineNumber) {return false;}
void wifiEspNowSetChannel(WIFI_CHANNEL_t channel) {}
void wifiEspNowChannelSet(WIFI_CHANNEL_t channel) {}
int wifiNetworkCount() {return 0;}
void wifiResetTimeout() {}
IPAddress wifiSoftApGetIpAddress() {return IPAddress((uint32_t)0);}
Expand Down
11 changes: 11 additions & 0 deletions Firmware/RTK_Everywhere/HTTP_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ void httpClientUpdate()
if (!httpSecureClient->connect(THINGSTREAM_SERVER, HTTPS_PORT))
{
// Failed to connect to the server
int length = 1024;
char * errMessage = (char *)rtkMalloc(length, "HTTP error message");
if (errMessage)
{
memset(errMessage, 0, length);
httpSecureClient->lastError(errMessage, length - 1);
systemPrintf("Get %s failed, %s\r\n", THINGSTREAM_SERVER, errMessage);
rtkFree(errMessage, "HTTP error message");
}
else
systemPrintf("Get %s failed!\r\n", THINGSTREAM_SERVER);
systemPrintln("ERROR: Failed to connect to the Thingstream server!");
httpClientRestart(); // I _think_ we want to restart here - i.e. retry after the timeout?
break;
Expand Down
10 changes: 10 additions & 0 deletions Firmware/RTK_Everywhere/MQTT_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,16 @@ void mqttClientUpdate()
// Attempt connection to the MQTT broker
if (!mqttClient->connect(settings.pointPerfectBrokerHost, 8883))
{
// Failed to connect to the server
int length = 1024;
char * errMessage = (char *)rtkMalloc(length, "HTTP error message");
if (errMessage)
{
memset(errMessage, 0, length);
mqttSecureClient->lastError(errMessage, length - 1);
systemPrintf("MQTT Error: %s\r\n", errMessage);
rtkFree(errMessage, "HTTP error message");
}
systemPrintf("Failed to connect to MQTT broker %s\r\n", settings.pointPerfectBrokerHost);
mqttClientRestart();
break;
Expand Down
Loading