Skip to content
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

Quite Stable #66

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified espArtnetNode_2.0.0_b5g_WEMOS.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion source/ajax.ino
Original file line number Diff line number Diff line change
Expand Up @@ -741,4 +741,4 @@ void ajaxLoad(uint8_t page, JsonObject& jsonReply) {
jsonReply["message"] = "Invalid or incomplete data received.";
}
}

66 changes: 50 additions & 16 deletions source/espArtnetNode_2.0.0_b5g.ino
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ byte* dataIn;
void setup(void) {
//pinMode(4, OUTPUT);
//digitalWrite(4, LOW);

Serial.begin(74880); // to match bootloader baudrate
Serial.setDebugOutput(true);
//ESP.wdtEnable(3500);//enable SW WDT
// Make direction input to avoid boot garbage being sent out
pinMode(DMX_DIR_A, OUTPUT);
digitalWrite(DMX_DIR_A, LOW);
Expand Down Expand Up @@ -196,36 +198,44 @@ void setup(void) {
SPIFFS.begin();

// Check if SPIFFS formatted
if (SPIFFS.exists("/formatted.txt")) {
SPIFFS.format();
if (!SPIFFS.exists("/formatted.txt")) { // if formated.txt does not exits
SPIFFS.format(); // format the file system

File f = SPIFFS.open("/formatted.txt", "w");
f.print("Formatted");
f.close();
File f = SPIFFS.open("/formatted.txt", "w"); // open new file formatted.txt
f.print("Formatted"); // write "Formatted into file
f.close(); // save file
}

// Load our saved values or store defaults
if (!resetDefaults)
eepromLoad();

// Store our counters for resetting defaults
if (resetInfo.reason != REASON_DEFAULT_RST && resetInfo.reason != REASON_EXT_SYS_RST && resetInfo.reason != REASON_SOFT_RESTART)
/* if (resetInfo.reason != REASON_DEFAULT_RST && resetInfo.reason != REASON_EXT_SYS_RST && resetInfo.reason != REASON_SOFT_RESTART)
deviceSettings.wdtCounter++;
else
deviceSettings.resetCounter++;
*/

deviceSettings.wdtCounter = 0;

deviceSettings.resetCounter =0;
// Store values
eepromSave();
// eepromSave();

// Start wifi
wifiStart();

delay(10);
// Start web server
webStart();

switch (resetInfo.reason) {
case REASON_DEFAULT_RST: // normal start
case REASON_EXT_SYS_RST:
case REASON_SOFT_RESTART:

// Don't start our Artnet or DMX in firmware update mode or after multiple WDT resets
if (!deviceSettings.doFirmwareUpdate && deviceSettings.wdtCounter <= 3) {
if (!deviceSettings.doFirmwareUpdate) {// && deviceSettings.wdtCounter <= 3) {

// We only allow 1 DMX input - and RDM can't run alongside DMX in
if (deviceSettings.portAmode == TYPE_DMX_IN && deviceSettings.portBmode == TYPE_RDM_OUT)
Expand All @@ -242,19 +252,38 @@ void setup(void) {
portSetup();

} else
deviceSettings.doFirmwareUpdate = false;
deviceSettings.doFirmwareUpdate = false;
break;

case REASON_WDT_RST:
break;
case REASON_EXCEPTION_RST:
break;
case REASON_SOFT_WDT_RST:
break;
case REASON_DEEP_SLEEP_AWAKE:
// not used
break;
}


delay(10);
}

void loop(void){
// If the device lasts for 6 seconds, clear our reset timers
if (deviceSettings.resetCounter != 0 && millis() > 6000) {
/* if (deviceSettings.resetCounter != 0 && millis() > 6000) {
deviceSettings.resetCounter = 0;
deviceSettings.wdtCounter = 0;
eepromSave();
}

*/
//connect wifi if not connected
if (WiFi.status() != WL_CONNECTED) {
delay(1);
wifiStart();
return;
}
webServer.handleClient();

// Get the node details and handle Artnet
Expand Down Expand Up @@ -314,8 +343,13 @@ void loop(void){
uint32_t n = millis() + 1000;
while (millis() < n)
webServer.handleClient();

ESP.restart();
//eepromSave();//save settings before reboot
delay(10);

WiFi.forceSleepBegin();
wdt_reset();
ESP.restart();
while(1){wdt_reset();delay(10);}
}

#ifdef STATUS_LED_PIN
Expand Down Expand Up @@ -606,4 +640,4 @@ void doStatusLedOutput() {
void setStatusLed(uint8_t num, uint32_t col) {
memcpy(&statusLedData[num*3], &col, 3);
}

Loading