HelTecAutomation / CubeCell-Arduino

Heltec CubeCell Series (based on ASR6501, ASR6502 chip) Arduino support.
247 stars 138 forks source link

txDutyCycleTime/appTxDutyCycle ignored #251

Open nordblick2 opened 1 year ago

nordblick2 commented 1 year ago

Hey, i have configured my CubeCell device to send some data to TTN. Everything works, but I have problems with TX duty cycle.

I used an appTxDutyCycle of 120000ms (_uint32t appTxDutyCycle = 120000UL;). After every start/boot, the device starts sending with an interval of more or less 7 seconds. I have no idea where it comes from.

To debug it, I printed out txDutyCycleTime right after calling LoRaWAN.cycle(txDutyCycleTime); and see my expected time values (e.g 120123 including some random offset). Calculating the time since last send, it looks different. The device sends with a shorter interval, that I can't explain. Very strange!

I implemented a method for setting appTxDutyCycle remotely via TTN Console. After doing that the same output is printed on console (appTxDutyCycle as expected) but now the device also sends with the specified duty cycle. Until next boot boot. 😵‍💫

case DEVICE_STATE_CYCLE: // Schedule next packet transmission txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); LoRaWAN.cycle(txDutyCycleTime); printf("=== %dms (%d)\n", millis()-last_millis, txDutyCycleTime); delay(50); deviceState = DEVICE_STATE_SLEEP; break;

Output after booting:

TX on freq 868500000 Hz at DR 5 ===7042ms (120719) TX on freq 868500000 Hz at DR 5 Event : Tx Done RX on freq 868500000 Hz at DR 5 Event : Rx Timeout RX on freq 869525000 Hz at DR 3 Event : Rx Timeout unconfirmed uplink sending ... TX on freq 868100000 Hz at DR 5 ===7042ms (120490) TX on freq 868100000 Hz at DR 5 Event : Tx Done RX on freq 868100000 Hz at DR 5 Event : Rx Timeout RX on freq 869525000 Hz at DR 3 Event : Rx Timeout

Output after re-setting appTxDutyCycle remotely:

received confirmed downlink: rssi = -102, snr = -3, datarate = 5 config.version = 8 config.send.interval = 120

NEW TX RECEIVED: 120000 (120 seconds) Applying config (here I set appTxDutyCycle to 120000) ... unconfirmed uplink sending ... TX on freq 868300000 Hz at DR 5 ===120704ms (120110) TX on freq 868300000 Hz at DR 5

Target value for txDutyCycleTime are fine for both scenario. Does anybody experienced the same problem and give me some hits to solve that?

ScholliYT commented 1 year ago

This looks very strange to me. Can you provide the full code (e.g. on GitHub Gist)?

nordblick2 commented 1 year ago

No problem. I will put the code online later.