Set DutyCycle via LoRaWAN

need a little help with my code.
I would like to send a payload to my cubecell and change the dutycycle with it.

I can see my debug print for new DutyCycle received but how can i save it to flash like setting the dutycycle with the at commands?

//downlink data handle function
void DownLinkDataHandle(McpsIndication_t *mcpsIndication)
  Serial.printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication- 
  Serial.print("+REV DATA:");
  for(uint8_t i=0;i<mcpsIndication->BufferSize;i++) {
  for(uint8_t i=0;i<mcpsIndication->BufferSize;i++) {
     if (mcpsIndication->Buffer[i] == 220) { // DC for APP_TX_DUTYCYCLE; 0D BB A0  for 900000 
 04 93 E0 for 300000 (5min)
       APP_TX_DUTYCYCLE = mcpsIndication->Buffer[i++]<<32|mcpsIndication->Buffer[i++] 
       Serial.print("  new DutyCycle received: ");

Here is my idea:

If you set last 2 bits of the downlink are used as the value of duty cycle (e.g. FF FF = 65535mS). After the node receives the data and stores it in the flash. Then use this data as a variable and assign it to duty cycle.

You can have a try at you side. If without success, I will update an example when we back to work.

1 Like

We are not recommended that every downlink contains information to be stored in flash. Although chip manufacturers claim that the number of flash writes exceeds 100,000 times, but the actual number is only 30,000 to 50,000 times as we tested.

i know about the restrictions of flash writes.
my code should only update the dutycycle when the first byte is DC (220 DEC) with the dutycycle calculated out of the next 4 bytes.
not every downlink will have this information only when it is needed to change the dutrycycle.

my problem is i dont know how to store the value right to get the cubecell recognize the new dutycycle.

Is this example make sense to you?