Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes device stuck in while ((lora_read_reg(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0) #26

Open
krupis opened this issue Jul 30, 2023 · 0 comments

Comments

@krupis
Copy link

krupis commented Jul 30, 2023

Hello, first of all I want to say thanks for providing this easy to use lora library. However, I have noticed an issue where my device is stuck when trying to send lora packet. I have added some extra printf statements in lora_send_packet() function:

void lora_send_packet(uint8_t *buf, int size)
{
   /*
    * Transfer data to radio.
    */
   lora_idle();
   lora_write_reg(REG_FIFO_ADDR_PTR, 0);

   for (int i = 0; i < size; i++)
      lora_write_reg(REG_FIFO, *buf++);

   lora_write_reg(REG_PAYLOAD_LENGTH, size);

   /*
    * Start transmission and wait for conclusion.
    */
   printf("Starting transmission \n");
   lora_write_reg(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
   while ((lora_read_reg(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0)
      vTaskDelay(2);

   lora_write_reg(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
   printf("Transmission done \n");
}

and from the serial logs I see:

[1B][0;32mI (0) cpu_start: Starting scheduler on APP CPU.[1B][0m
Initializing lora 
[1B][0;32mI (313) gpio: GPIO[20]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [1B][0m
[1B][0;32mI (323) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [1B][0m
Setting frequency 
Enablig crc 
create lora tx task 
Starting transmission 
56: Transmission done 
packet sent...
01:06: Starting transmission 
Transmission done 
packet sent...
01:16: Starting transmission 
Transmission done 
packet sent...
01:26: Starting transmission 
Transmission done 
packet sent...
01:36: Starting transmission 

I have enabled timestamps in the serial terminal (Termite) and as you can see after the device boots up, first transmission is completed 56 seconds after the device start. After that, it transmits periodically after every 10 seconds as it is supposed to.

It almost feels like the LoRa module needs to "warmup" before it can send the message.

Did anyone else had this issue? And could help me figure out what could be the cause?

Its very important to me as I do not want my device to stay on for 56 seconds unnecessary since I am working on battery powered lora device, I need my device to send the message ASAP and go to sleep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant