Lora-net / packet_forwarder

A LoRa packet forwarder is a program running on the host of a LoRa gateway that forwards RF packets receive by the concentrator to a server through a IP/UDP link, and emits RF packets that are sent by the server. This project is associated to the lora_gateway repository for SX1301 chip. For SX1302/1303, the repository sx1302_hal must be used.
Other
724 stars 668 forks source link

Busy waiting in thread_up #79

Closed antonsergeyev closed 6 years ago

antonsergeyev commented 6 years ago

There is an inefficiency issue related to a loop in thread_up function that polls gateway for new packets, and then waits for 10ms if no new packets were found. Is there any way to refactor this into event-based solution? Or at least make a time when packet was received more deterministic (because right now there is an inherent uncertainty of 10ms).

We are currently trying to implement time synchronization protocol for LoRaWAN, and this issue seems to be the largest source of time error in the whole system. Of course, this delay can be reduced from 10ms down to 1ms by changing the constant, but in principal, this doesn't solve the issue with busy wait approach.

With physical LoRa, we expect time sync to be accurate in microsecond level, because of single-hop architecture - but the inefficient software layer doesn't allow that.

x893 commented 6 years ago

You need implement kernel module for interrupt processing. See interrupt support for gpio (Wiring for RasPi or other). I port packet forwarder to STM32 platform and now can use interrupt with SX1301/08 on RX and TX complete.

nestorayuso commented 6 years ago

read this https://github.com/Lora-net/lora_gateway/wiki/SX1301-GPIO-output-configuration if you want to use some GPIOs as a interrupt source

antonsergeyev commented 6 years ago

@nestorayuso @x893 thanks, will look into that