This commit is contained in:
Joerg Lehmann 2020-06-02 21:21:05 +02:00
parent f8909fc353
commit 59ce7ee44d
2 changed files with 33 additions and 20 deletions

View File

@ -704,6 +704,14 @@ void StartNewIteration() {
gCatena.SafePrintf("looks like we timed out waiting for sending to finish...\n", wait_time);
}
LMIC_clrTxData();
// we sleep 10 seconds...
start_time = millis();
while (send_in_progress && ((millis() - start_time) < 10000))
{
gCatena.poll();
yield();
}
send_in_progress = false;
}
wait_time = (uint32_t)((millis() - start_time) / 1000);
@ -765,6 +773,7 @@ void StartNewIteration() {
}
else {
if (! stop_iterations) {
if (config_data.debug_level > 0) {
gCatena.SafePrintf("light sleep; os_setTimedCallback for startNewIterationCb in %d...seconds\n", sleep_time_sec);
}
@ -774,6 +783,7 @@ void StartNewIteration() {
startNewIterationCb);
}
}
}
void startSendingUplink(bool firstTime)
{
@ -803,15 +813,27 @@ void startSendingUplink(bool firstTime)
if (config_data.debug_level > 0) {
gCatena.SafePrintf("SendBuffer firstTime\n");
}
gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
if (gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort)) {
package_counter++;
if (config_data.debug_level > 0) {
gCatena.SafePrintf("LMIC.opmode just after SendBuffer (successful): %#x\n", LMIC.opmode);
} else {
gCatena.SafePrintf("LMIC.opmode just before SendBuffer (failed): %#x\n", LMIC.opmode);
}
}
} else {
if (config_data.debug_level > 0) {
gCatena.SafePrintf("LMIC.opmode just before SendBuffer: %#x\n", LMIC.opmode);
gCatena.SafePrintf("SendBuffer not firstTime\n");
}
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
if (gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort)) {
package_counter++;
if (config_data.debug_level > 0) {
gCatena.SafePrintf("LMIC.opmode just after SendBuffer (successful): %#x\n", LMIC.opmode);
} else {
gCatena.SafePrintf("LMIC.opmode just before SendBuffer (failed): %#x\n", LMIC.opmode);
}
}
}
ClearLoraData();
@ -890,15 +912,6 @@ void doSleepAlert(const bool fDeepSleep)
}
}
// we wait an extra five seconds...
//uint32_t tNow = millis();
//while (uint32_t(millis() - tNow) < 5000)
//{
// gCatena.poll();
// yield();
//}
if (config_data.debug_level > 0) {
gCatena.SafePrintf("Now it is safe to go to sleep\n");
}

View File

@ -56,7 +56,7 @@ enum {
|
\****************************************************************************/
static const int32_t fwVersion = 20200601;
static const int32_t fwVersion = 20200602;
static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages;
static const byte MAX_VALUES_TO_SEND = 8;