refactor a bit
This commit is contained in:
parent
d0389af061
commit
174f8b360f
|
|
@ -697,8 +697,16 @@ void StartNewIteration() {
|
||||||
}
|
}
|
||||||
while (send_in_progress && ((millis() - start_time) < 300000))
|
while (send_in_progress && ((millis() - start_time) < 300000))
|
||||||
{
|
{
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
yield();
|
// 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);
|
wait_time = (uint32_t)((millis() - start_time) / 1000);
|
||||||
if (config_data.debug_level > 0) {
|
if (config_data.debug_level > 0) {
|
||||||
|
|
@ -783,7 +791,8 @@ void startSendingUplink(bool firstTime)
|
||||||
fConfirmed = true;
|
fConfirmed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
|
//gCatena.poll();
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
if (config_data.debug_level > 0) {
|
if (config_data.debug_level > 0) {
|
||||||
|
|
@ -795,7 +804,8 @@ void startSendingUplink(bool firstTime)
|
||||||
if (config_data.debug_level > 0) {
|
if (config_data.debug_level > 0) {
|
||||||
gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n");
|
gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n");
|
||||||
}
|
}
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
|
//gCatena.poll();
|
||||||
delay(500);
|
delay(500);
|
||||||
gLoRaWAN.SendBuffer((uint8_t*)&lora_data_first, sizeof(LORA_data_first), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
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) {
|
if (config_data.debug_level > 0) {
|
||||||
gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n");
|
gCatena.SafePrintf("SendBuffer was not successful, we try a second time...\n");
|
||||||
}
|
}
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
|
//gCatena.poll();
|
||||||
delay(500);
|
delay(500);
|
||||||
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
||||||
}
|
}
|
||||||
|
|
@ -833,6 +844,7 @@ static void sendBufferDoneCb(
|
||||||
pFn = settleDoneCb;
|
pFn = settleDoneCb;
|
||||||
if (! fStatus)
|
if (! fStatus)
|
||||||
{
|
{
|
||||||
|
send_in_progress = false;
|
||||||
if (!gLoRaWAN.IsProvisioned())
|
if (!gLoRaWAN.IsProvisioned())
|
||||||
{
|
{
|
||||||
// we'll talk about it at the callback.
|
// we'll talk about it at the callback.
|
||||||
|
|
@ -968,8 +980,9 @@ void doSleepAlert(const bool fDeepSleep)
|
||||||
|
|
||||||
while (uint32_t(millis() - tNow) < 1000)
|
while (uint32_t(millis() - tNow) < 1000)
|
||||||
{
|
{
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
yield();
|
//gCatena.poll();
|
||||||
|
//yield();
|
||||||
}
|
}
|
||||||
if (config_data.debug_level > 2) {
|
if (config_data.debug_level > 2) {
|
||||||
gCatena.SafePrintf(".");
|
gCatena.SafePrintf(".");
|
||||||
|
|
@ -981,8 +994,9 @@ void doSleepAlert(const bool fDeepSleep)
|
||||||
uint32_t tNow = millis();
|
uint32_t tNow = millis();
|
||||||
while (uint32_t(millis() - tNow) < 100)
|
while (uint32_t(millis() - tNow) < 100)
|
||||||
{
|
{
|
||||||
gCatena.poll();
|
os_runloop_once();
|
||||||
yield();
|
//gCatena.poll();
|
||||||
|
//yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (config_data.debug_level > 2) {
|
else if (config_data.debug_level > 2) {
|
||||||
|
|
|
||||||
|
|
@ -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 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;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ NAU7802 myScale; //Create instance of the NAU7802 class
|
||||||
|
|
||||||
byte debug_level;
|
byte debug_level;
|
||||||
|
|
||||||
byte interruptPin = A0;
|
//byte interruptPin = A0;
|
||||||
|
|
||||||
void SetScalesDebugLevel(byte dbg_level)
|
void SetScalesDebugLevel(byte dbg_level)
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +47,7 @@ bool SetupScales(byte dbg_level)
|
||||||
if (debug_level > 0) {
|
if (debug_level > 0) {
|
||||||
gCatena.SafePrintf("SetupScales start\n");
|
gCatena.SafePrintf("SetupScales start\n");
|
||||||
}
|
}
|
||||||
pinMode(interruptPin, INPUT);
|
// pinMode(interruptPin, INPUT);
|
||||||
|
|
||||||
if (!myScale.begin(Wire, false))
|
if (!myScale.begin(Wire, false))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue