diff --git a/mini-beieli-node.ino b/mini-beieli-node.ino index 9b72ad8..11b1768 100644 --- a/mini-beieli-node.ino +++ b/mini-beieli-node.ino @@ -179,9 +179,6 @@ void setup_platform(void) gCatena.SafePrintf("cal_w1_factor: %d.%03d\n", (int)config_data.cal_w1_factor, (int)(config_data.cal_w1_factor * 1000) % 1000); gCatena.SafePrintf("cal_w2_factor: %d.%03d\n", (int)config_data.cal_w2_factor, (int)(config_data.cal_w2_factor * 1000) % 1000); gCatena.SafePrintf("debug_level: %d\n", (int)config_data.debug_level); - gCatena.SafePrintf("Size of config_data: %d\n", sizeof(config_data)); - gCatena.SafePrintf("Size of lora_data_first: %d\n", sizeof(lora_data_first)); - gCatena.SafePrintf("Size of lora_data: %d\n", sizeof(lora_data)); } @@ -415,6 +412,8 @@ void ClearLoraData(void) void ShowLORAData(bool firstTime) { + gCatena.SafePrintf("%010d - ShowLORAData\n", millis()); + if (firstTime) { gCatena.SafePrintf("{\n"); @@ -528,7 +527,7 @@ void ReadSensors(SENSOR_data &sensor_data) { int vbat_mv = (int)(gCatena.ReadVbat() * 1000.0f); res.vbat = GetVBatValue(vbat_mv); if (config_data.debug_level > 0) { - gCatena.SafePrintf("vBat: %d mV\n", vbat_mv); + gCatena.SafePrintf("%010d - vBat: %d mV\n", vbat_mv); } // Read Scales @@ -685,18 +684,6 @@ void StartNewIteration() { last_sensor_reading = current_sensor_reading; } - if (config_data.debug_level > 0) { - gCatena.SafePrintf("%010d - now going to sleep for %d seconds...\n", millis(), CATCFG_T_INTERVAL); - if (fUsbPower) { - gCatena.SafePrintf("USB Power is on\n"); - } else { - gCatena.SafePrintf("USB Power is off\n"); - } - //Serial.flush(); - if (config_data.debug_level > 1) { - gLed.Set(LedPattern::Sleeping); - } - } uint32_t sleep_time_sec; if (wait_time < CATCFG_T_INTERVAL) { sleep_time_sec = CATCFG_T_INTERVAL - wait_time; @@ -704,6 +691,20 @@ void StartNewIteration() { // minimal sleep time is 5 seconds sleep_time_sec = 5; } + + if (config_data.debug_level > 0) { + gCatena.SafePrintf("%010d - now going to sleep for %d seconds...\n", millis(), sleep_time_sec); + if (fUsbPower) { + gCatena.SafePrintf("%010d - USB Power is on\n", millis()); + } else { + gCatena.SafePrintf("%010d - USB Power is off\n", millis()); + } + //Serial.flush(); + if (config_data.debug_level > 1) { + gLed.Set(LedPattern::Sleeping); + } + } + if (!fUsbPower) { DoDeepSleep(sleep_time_sec); os_setTimedCallback( @@ -712,7 +713,7 @@ void StartNewIteration() { startNewIterationCb); } else { - gCatena.SafePrintf("%010d - light sleep; os_setTimedCallback for startNewIterationCb in %d...\n", millis(), sleep_time_sec); + gCatena.SafePrintf("%010d - light sleep; os_setTimedCallback for startNewIterationCb in %d...seconds\n", millis(), sleep_time_sec); os_setTimedCallback( &iterationJob, os_getTime() + sec2osticks(sleep_time_sec), @@ -722,6 +723,8 @@ void StartNewIteration() { void startSendingUplink(bool firstTime) { + send_in_progress = true; + LedPattern savedLed; if (config_data.debug_level > 1) { savedLed = gLed.Set(LedPattern::Measuring); @@ -747,14 +750,12 @@ void startSendingUplink(bool firstTime) gCatena.SafePrintf("%010d - SendBuffer firstTime\n", millis()); } gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort); - send_in_progress = true; } else { if (config_data.debug_level > 0) { gCatena.SafePrintf("%010d - SendBuffer not firstTime\n", millis()); } gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort); - send_in_progress = true; } ClearLoraData(); } @@ -851,7 +852,10 @@ static void warmupDoneCb(osjob_t* pJob) static void startNewIterationCb(osjob_t* pJob) { - gCatena.SafePrintf("%010d - startNewIterationCb\n", millis()); + if (config_data.debug_level > 0) { + gCatena.SafePrintf("%010d - startNewIterationCb\n", millis()); + } + StartNewIteration(); } diff --git a/mini_beieli_node.h b/mini_beieli_node.h index 6bf1a62..b003f16 100644 --- a/mini_beieli_node.h +++ b/mini_beieli_node.h @@ -55,7 +55,7 @@ enum { | \****************************************************************************/ -static const int32_t fwVersion = 20191121; +static const int32_t fwVersion = 20191122; static const byte MAX_VALUES_TO_SEND = 8; //static const byte MAX_VALUES_TO_SEND = 1; // Testing static const uint8_t LORA_DATA_VERSION = 1;