No join after reset but frame counter is reset

I’m debugging why my device disappears from the TTN Console. I see in the Gateway console, that it is sending (unconfirmed) uplink messages, but the frame counter is low as if started again from 0.

I pressed the reset button. The serial monitor shows this:

08:52:00.517 -> Voltage: 4204
08:52:00.517 -> Humidity: 54.70%  Temperature: 24.22°C  Pressure: 1004.94hPa 
08:52:00.517 -> AppDataSize: 18 AppData: 0 0 9 118 21 93 0 0 0 0 0 0 0 0 136 141 16 108 .
08:52:00.517 -> unconfirmed uplink sending ...
08:53:00.914 -> Into send state
08:53:00.914 -> 
08:53:01.368 -> Voltage: 4206
08:53:01.368 -> Humidity: 54.77%  Temperature: 24.24°C  Pressure: 1004.95hPa 
08:53:01.368 -> AppDataSize: 18 AppData: 0 0 9 120 21 100 0 0 0 0 0 0 0 0 136 143 16 110 .
08:53:01.368 -> unconfirmed uplink sending ...
08:53:56.912 -> Copyright @2019-2020 Heltec Automation.All rights reserved.
08:53:57.159 -> ChipID:C3A65983111D
08:53:57.159 -> 
08:53:57.159 -> Wait 3s for user key to rejoin network
08:54:00.222 -> 
08:54:00.222 -> LoRaWAN EU868 Class A start!
08:54:00.222 -> 
08:54:00.423 -> User key not detected,Use reserved Net
08:54:00.423 -> 
08:54:00.423 -> Next packet send 9413 ms later(random time from 0 to APP_TX_DUTYCYCLE)
08:54:00.423 -> 
08:54:00.423 -> Interrupt attached
08:54:00.423 -> Starting w⸮Into send state
08:54:09.843 -> 
08:54:10.292 -> Voltage: 4204
08:54:10.292 -> Humidity: 54.85%  Temperature: 24.27°C  Pressure: 1004.92hPa 
08:54:10.292 -> AppDataSize: 18 AppData: 0 0 9 123 21 109 0 0 0 0 0 0 0 0 136 140 16 108 .
08:54:10.292 -> unconfirmed uplink sending ...
08:55:11.330 -> Into send state
08:55:11.330 -> 
08:55:11.730 -> Voltage: 4206
08:55:11.730 -> Humidity: 54.75%  Temperature: 24.31°C  Pressure: 1004.92hPa 
08:55:11.783 -> AppDataSize: 18 AppData: 0 0 9 127 21 99 0 0 0 0 0 0 0 0 136 139 16 110 .
08:55:11.783 -> unconfirmed uplink sending ...
08:56:12.125 -> Into send state
08:56:12.125 -> 
08:56:12.573 -> Voltage: 4208
08:56:12.573 -> Humidity: 55.34%  Temperature: 24.37°C  Pressure: 1004.91hPa 
08:56:12.573 -> AppDataSize: 18 AppData: 0 0 9 133 21 158 0 0 0 0 0 0 0 0 136 138 16 112 .
08:56:12.573 -> unconfirmed uplink sending ...

I checked the gateway console. There is no join message. Instead the frame counter is increased to 65535 (so it turns to 0 with the next message):


(please ignore the one message from the other device)

Is this a bug that the frame counter is reset without a join?
Is there a workaround for this?
If necessary, I can provide my sketch.
Thank you very much

I’m one step further: In my setup I call LoRaWAN.ifskipjoin() as in the example https://github.com/HelTecAutomation/CubeCell-Arduino/blob/master/libraries/LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino .

void setup() {
  Serial.begin(115200);
  uint64_t chipID=getID();
  Serial.printf("ChipID:%04X%08X\r\n",(uint32_t)(chipID>>32),(uint32_t)chipID); 
  rainWoke = false;
#if(AT_SUPPORT)
  enableAt();
#endif
  deviceState = DEVICE_STATE_INIT;
  LoRaWAN.ifskipjoin();

  attachInterrupt();

  Serial.println("Starting watchdog");
  /* Enable the WDT, autofeed */
  innerWdtEnable(true);
}

When I remove the line, the join works.
So I guess it is some problem with LoRaWAN.ifskipjoin() not joining while the frame counter is reset nevertheless.
I remove the LoRaWAN.ifskipjoin() now and I’m fine with it for now.

It is 16 bits, so it will be cleared when the maximum value is reached, which is normal.

It is fine that it is rolling from 65535 to 0.
But why is it set to 65535 when I press the reset button (and call LoRaWAN.ifskipjoin() ). Shouldn’t the counter stay at the number it was before?

After resetting, it re-enters the network. So the counter will return to 0.