cancel
Showing results for 
Search instead for 
Did you mean: 

I-CUBE-LRWAN : Why send() function always failed inside while(1)

JChew.1
Associate II

Lora class c unconfirm message uplink return LORAMAC_STATUS_NO_FREE_CHANNEL_FOUND

I had downloaded en.I-CUBE_LRWAN. I am using Projects -> B-L072Z-LRWAN1 - > MDK ARM.

I am using Class C. I had try change the APP_TX_DUTYCYCLE and it does not help.

#define APP_TX_DUTYCYCLE              10000

static void OnTxTimerEvent(void *context)

{

 /*Wait for next tx slot*/

 TimerStart(&TxTimer);

 AppProcessRequest = LORA_SET;

}

static void LoraStartTx(TxEventType_t EventType)

{

 if (EventType == TX_ON_TIMER)

 {

  /* send everytime timer elapses */

  TimerInit(&TxTimer, OnTxTimerEvent);

  TimerSetValue(&TxTimer, APP_TX_DUTYCYCLE);

  OnTxTimerEvent(NULL);

 }

 else

 {

  /* send everytime button is pushed */

  GPIO_InitTypeDef initStruct = {0};

  initStruct.Mode = GPIO_MODE_IT_RISING;

  initStruct.Pull = GPIO_PULLUP;

  initStruct.Speed = GPIO_SPEED_HIGH;

  HW_GPIO_Init(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, &initStruct);

  HW_GPIO_SetIrq(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, 0, Send);

 }

}

Inside main it will check the flag AppProcessRequest .

 while (1)

 {

  if (AppProcessRequest == LORA_SET)

  {

   /*reset notification flag*/

   AppProcessRequest = LORA_RESET;

   /*Send*/

   Send(NULL);

  }

//remaining code I didnt copy here

}

By default, the original code already had a timer, based on the app duty cycle define. Once the timer timeout, it will set the flag to true. Once inside while loop it detected the flag was set, it will start to transmit in LoRa.

But the problem I face is it does hit the function and run the LoRa Sending, but it forever return me failed.

In another scenario, when I receive a packet from server, i try to use the send() function to return, it work perfectly.

Problem: Why calling the send() function inside while loop will not successful sending?

1 REPLY 1
akif
Associate II

Look for "#define LORAWAN_DUTYCYCLE_ON            false " in lora.c file. Is it false?

Also write down your "Send" function.