Skip to content

Device re-joins once per day after being silent for 2 hours #25

@jpmeijers

Description

@jpmeijers

Behaviour I observe

Looking at the frame counter of my device over a couple of days I see the following:

image

The device transmits an uplink every 10 minutes. Once per day the device goes silent for almost 2 hours, then performs a re-join, and then continues for another day before repeating the same behaviour.

Intended behaviour

The device should only join after startup and transmit a frame every 10 minutes. The frame counter should increase forever, until it overflows or the device is restarted.

My device needs to be low power, so it goes to sleep between transmissions. To make sure a transmission is done before going to sleep, I use a blocking transmit function that looks like this:

void tx_blocking(uint8_t* radioPacket, uint8_t packetLength)
{
  do_send(&sendjob, radioPacket, packetLength);

  while(LMIC.opmode & (OP_JOINING|OP_TXRXPEND)) {
    os_runstep();
    delay(10);
  }
  while( (LMIC.opmode & OP_TXDATA) /*&& (millis() - start < TX_TIMEOUT)*/ )
  {
    os_runstep();
    delay(10);
  }

  Serial.println("TX done");
}

My board wakes up every 8 seconds to perform periodic tasks. To make sure the millis() and micros() timers of Arduino continue counting correctly, I update them directly after each wakeup as follows:

void updateMillis(unsigned long new_millis){
  uint8_t oldSREG = SREG;
  cli();
  timer0_millis += new_millis;
  //timer0_overflow_count += 7812; // 4us per timer tick, overflow at 256, 1024us per overflow, 8000000us/1024 = 7812.5
  timer0_overflow_count+= 8 * 64 * clockCyclesPerMicrosecond();
  sei();
  
  SREG = oldSREG;
}

I have not yet been able to capture debug logs when the rejoin happens. I currently have two theories:

  • BasicMac performs a re-join for some reason.
  • My WDT resets the board because something delays for more than 24 seconds.

I will update this issue when I have discovered the reason for the re-join.

In the meantime, is there a low power best practice for using BasicMac? And am I somehow doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions