diff --git a/mini-beieli-node.ino b/mini-beieli-node.ino index a45ab0f..366e66c 100644 --- a/mini-beieli-node.ino +++ b/mini-beieli-node.ino @@ -697,8 +697,16 @@ void StartNewIteration() { } while (send_in_progress && ((millis() - start_time) < 300000)) { - gCatena.poll(); - yield(); + os_runloop_once(); +// gCatena.poll(); +// yield(); + } + // handle timeout... + if (send_in_progress) { + if (config_data.debug_level > 0) { + gCatena.SafePrintf("looks like we timed out waiting for sending to finish...\n", wait_time); + } + send_in_progress = false; } wait_time = (uint32_t)((millis() - start_time) / 1000); if (config_data.debug_level > 0) { @@ -783,7 +791,8 @@ void startSendingUplink(bool firstTime) fConfirmed = true; } - gCatena.poll(); + os_runloop_once(); + //gCatena.poll(); if (firstTime) { if (config_data.debug_level > 0) { @@ -795,7 +804,8 @@ void startSendingUplink(bool firstTime) if (config_data.debug_level > 0) { gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n"); } - gCatena.poll(); + os_runloop_once(); + //gCatena.poll(); delay(500); gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort); } @@ -810,7 +820,8 @@ void startSendingUplink(bool firstTime) if (config_data.debug_level > 0) { gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n"); } - gCatena.poll(); + os_runloop_once(); + //gCatena.poll(); delay(500); gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort); } @@ -833,6 +844,7 @@ static void sendBufferDoneCb( pFn = settleDoneCb; if (! fStatus) { + send_in_progress = false; if (!gLoRaWAN.IsProvisioned()) { // we'll talk about it at the callback. @@ -968,8 +980,9 @@ void doSleepAlert(const bool fDeepSleep) while (uint32_t(millis() - tNow) < 1000) { - gCatena.poll(); - yield(); + os_runloop_once(); + //gCatena.poll(); + //yield(); } if (config_data.debug_level > 2) { gCatena.SafePrintf("."); @@ -981,8 +994,9 @@ void doSleepAlert(const bool fDeepSleep) uint32_t tNow = millis(); while (uint32_t(millis() - tNow) < 100) { - gCatena.poll(); - yield(); + os_runloop_once(); + //gCatena.poll(); + //yield(); } } else if (config_data.debug_level > 2) { diff --git a/mini_beieli_node.h b/mini_beieli_node.h index 4a3d322..93997d3 100644 --- a/mini_beieli_node.h +++ b/mini_beieli_node.h @@ -56,7 +56,7 @@ enum { | \****************************************************************************/ -static const int32_t fwVersion = 20200528; +static const int32_t fwVersion = 20200529; static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages; static const byte MAX_VALUES_TO_SEND = 8; diff --git a/mini_beieli_node_nau7802.h b/mini_beieli_node_nau7802.h index 3a014f2..3e3ad03 100644 --- a/mini_beieli_node_nau7802.h +++ b/mini_beieli_node_nau7802.h @@ -14,7 +14,7 @@ NAU7802 myScale; //Create instance of the NAU7802 class byte debug_level; -byte interruptPin = A0; +//byte interruptPin = A0; void SetScalesDebugLevel(byte dbg_level) { @@ -47,7 +47,7 @@ bool SetupScales(byte dbg_level) if (debug_level > 0) { gCatena.SafePrintf("SetupScales start\n"); } - pinMode(interruptPin, INPUT); +// pinMode(interruptPin, INPUT); if (!myScale.begin(Wire, false)) {