refactor a bit

This commit is contained in:
Joerg Lehmann 2020-05-29 16:16:12 +02:00
parent d0389af061
commit 174f8b360f
3 changed files with 26 additions and 12 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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))
{