Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e30a8293ac | ||
|
|
174f8b360f | ||
|
|
d0389af061 | ||
|
|
7c8a52cafe |
+20
-6
@@ -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,6 +791,9 @@ void startSendingUplink(bool firstTime)
|
||||
fConfirmed = true;
|
||||
}
|
||||
|
||||
os_runloop_once();
|
||||
//gCatena.poll();
|
||||
|
||||
if (firstTime) {
|
||||
if (config_data.debug_level > 0) {
|
||||
gCatena.SafePrintf("SendBuffer firstTime\n");
|
||||
@@ -813,6 +824,7 @@ static void sendBufferDoneCb(
|
||||
pFn = settleDoneCb;
|
||||
if (! fStatus)
|
||||
{
|
||||
send_in_progress = false;
|
||||
if (!gLoRaWAN.IsProvisioned())
|
||||
{
|
||||
// we'll talk about it at the callback.
|
||||
@@ -948,8 +960,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(".");
|
||||
@@ -961,8 +974,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) {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ enum {
|
||||
|
|
||||
\****************************************************************************/
|
||||
|
||||
static const int32_t fwVersion = 20200527;
|
||||
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;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
@@ -96,9 +96,11 @@ long ReadScale(char channel)
|
||||
long readings[num_scale_readings]; // create arry to hold readings
|
||||
for (int i = 0; i < num_scale_readings; i++) {
|
||||
//while (digitalRead(interruptPin) == LOW) {
|
||||
long mytimer = millis();
|
||||
while (! myScale.available()) {
|
||||
// we set a timeout of 10 seconds for the measurement...
|
||||
if ((millis() - startTime) > 10000) {
|
||||
if ((millis() - mytimer) > 10000) {
|
||||
// Timeout reading scale...
|
||||
Wire.endTransmission(true);
|
||||
if (debug_level > 0) {
|
||||
gCatena.SafePrintf("Timeout while reading scale...\n");
|
||||
@@ -107,11 +109,14 @@ long ReadScale(char channel)
|
||||
}
|
||||
delay(1);
|
||||
}
|
||||
long reading = myScale.getReading();
|
||||
long reading;
|
||||
if (myScale.available()) {
|
||||
reading = myScale.getReading();
|
||||
readings[i] = reading;
|
||||
}
|
||||
if (debug_level > 0) {
|
||||
gCatena.SafePrintf("Reading: %d\n", reading);
|
||||
}
|
||||
readings[i] = reading; // fill the array with instantaneous readings from the scale
|
||||
delay(10);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user