Skip to content

Commit

Permalink
Merge pull request #140 from LaCoolCo/enhancement/Wi-Fix
Browse files Browse the repository at this point in the history
Fix WiFi mode at boot
  • Loading branch information
3rwww1 authored Jun 20, 2018
2 parents d93cf80 + d3bb17b commit 46eefdf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core/CoolBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define SEND_MSG_BATCH 10

void CoolBoard::begin() {
WiFi.mode(WIFI_STA);
if (!SPIFFS.begin()) {
this->spiffsProblem();
}
Expand Down Expand Up @@ -179,7 +180,8 @@ int CoolBoard::connect() {

void CoolBoard::sendSavedMessages() {
int savedLogNumber;
while ((savedLogNumber = CoolFileSystem::lastSavedLogNumber()) && !this->shouldLog()) {
while ((savedLogNumber = CoolFileSystem::lastSavedLogNumber()) &&
!this->shouldLog()) {
INFO_VAR("Sending saved log number:", savedLogNumber);
String jsonData = CoolFileSystem::getSavedLogAsString(savedLogNumber);
DEBUG_VAR("Saved JSON data to send:", jsonData);
Expand All @@ -205,7 +207,7 @@ void CoolBoard::handleActuators(JsonObject &reported) {
}
DEBUG_LOG("Collecting onboard actuator data...");
if (this->coolBoardActuator.doAction(reported, int(tm.Hour),
int(tm.Minute))) {
int(tm.Minute))) {
this->coolBoardActuator.write(1);
reported["ActB"] = 1;
} else {
Expand Down Expand Up @@ -302,7 +304,8 @@ void CoolBoard::update(const char *answer) {
firmwareJson.printTo(otaUpdateConfig);
otaUpdateConfig.close();
DEBUG_JSON("Saved OTA HTTPS update configuration to: ", firmwareJson);
INFO_LOG("New firmaware update received, your board will now reboot to apply...");
INFO_LOG("New firmaware update received, your board will now reboot "
"to apply...");
delay(100);
ESP.restart();
}
Expand Down Expand Up @@ -438,7 +441,7 @@ void CoolBoard::startAP() {
this->coolWifi->connectAP();
yield();
if (this->coolWifi->state() == WL_CONNECTED) {
this->coolBoardLed.blink(GREEN, 5);
this->coolBoardLed.blink(GREEN, 5);
} else {
this->coolBoardLed.blink(RED, 10);
}
Expand Down Expand Up @@ -539,8 +542,8 @@ void CoolBoard::mqttLog(String data) {

bool CoolBoard::mqttPublish(String data) {
return (this->coolPubSubClient->publish(this->mqttOutTopic.c_str(),
(byte *)(data.c_str()), data.length(),
false));
(byte *)(data.c_str()), data.length(),
false));
}

bool CoolBoard::mqttListen() {
Expand Down

0 comments on commit 46eefdf

Please sign in to comment.