avoid recursion

This commit is contained in:
Joerg Lehmann 2020-06-06 19:34:47 +02:00
parent 57d795c36b
commit 3a8764dcb4
2 changed files with 8 additions and 3 deletions

View File

@ -110,6 +110,7 @@ long iteration = 0; // what iteration number do we have, starts with 0
long package_counter = 0; // sent package counter long package_counter = 0; // sent package counter
bool send_in_progress = false; bool send_in_progress = false;
bool stop_iterations = false; bool stop_iterations = false;
bool start_new_iteration = false;
bool next_package_is_init_package = true; bool next_package_is_init_package = true;
uint32_t gRebootMs; uint32_t gRebootMs;
@ -374,6 +375,9 @@ void setup_uplink(void)
void loop() void loop()
{ {
gCatena.poll(); gCatena.poll();
if (start_new_iteration) {
StartNewIteration();
}
} }
void ClearLoraData(void) void ClearLoraData(void)
@ -616,6 +620,7 @@ void ReadSensors(SENSOR_data &sensor_data) {
} }
void StartNewIteration() { void StartNewIteration() {
start_new_iteration = false;
uint32_t wait_time; uint32_t wait_time;
wait_time = 0; wait_time = 0;
@ -767,7 +772,7 @@ void StartNewIteration() {
if (!fUsbPower) { if (!fUsbPower) {
DoDeepSleep(sleep_time_sec); DoDeepSleep(sleep_time_sec);
if (! stop_iterations) { if (! stop_iterations) {
StartNewIteration(); start_new_iteration = true;
} }
} }
@ -975,7 +980,7 @@ static void startNewIterationCb(osjob_t* pJob)
} }
if (! stop_iterations) { if (! stop_iterations) {
StartNewIteration(); start_new_iteration = true;
} }
} }

View File

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