Api.system.sleep.all() gets ignort

Hey

I am trying to send 3 messages 20 seconds apart after pressing a button. It is also important that it sleeps between each send to save power. Right now it just ignores my api sleep and does the while loopThis text will be hidden 3 times in a row without sleeping in between. Does anyone have an idea why this is happening?

void press_uplink_routine()
{

  int repet_times = 0;
  while(repet_times != 3)
  {

      /** Payload of Uplink */

      uint8_t data_len = 0;

      collected_data[data_len++] = (uint8_t) 1;

      Serial.println("Data Packet:");

      for (int i = 0; i < data_len; i++) 
      {
          Serial.printf("0x%02X ", collected_data[i]);
      }
      Serial.println("");

      /** Send the data package */

      if (api.lorawan.send(data_len, (uint8_t *) & collected_data, 2, true, 0)) 
     {
          Serial.println("Sending is requested");
      } 
      else 
      {
          Serial.println("Sending failed"); 
      }

      api.system.sleep.all(20000);
      repet_times++;   
  }
}

Welcome to RAK forum @O.Illerup ,

I have to change the formatting of the code you sent so we can read it better.

As I look in your code, I am thinking that you are trying to execute sleep while the transmission of uplink is still being processed. Maybe a quick test is to try to introduced a delay before executing the sleep command api.system.sleep.all(20000);.