Change region during runtime
Closed this issue · 1 comments
I have an application which requires that the LoRaMAC region be changed during runtime. I had this tested with simpler libraries, so it is possible an it runs from the network side.
I have been struggling to make this work from the firmware side though. After being joined to the network, I try these steps:
- LmHandlerStop()
- Flush backup memory (if I don't do this it get recovered during LmHandlerConfigure)
- LmHandlerSetActiveRegion(region)
- LmHandlerJoin(ACTIVATION_TYPE_OTAA, true)
- while(LmHandlerIsBusy()) LmHandlerProcess()
This would even work, but sometimes the process just breaks or halts either during the rejoin, or the transmission. In general, it seems that it is very difficult to change the state machine to a new region during runtime. Is there any common implementation for this? Thanks.
If you don't mind I move this question to Discussions.
I suppose that you are using a modified version of this project (maybe stm32cube) as this project does not provide LmHandlerStopLmHandlerStop
and LmHandlerSetActiveRegion
API implementations.
As I don't know what modifications have been done on the derived project I cannot help.
You should ask your question to your stack provider.
You are right it is not easy to dynamically change the region but it is possible.
The reason being that this requirement appeared long time after we started implementing the stack. To make this process easier the stack implementation internals would require an heavy lifting. So far we did not had the time to work on the subject and don't know when we will have time to do it.
The procedure you describe looks to be the correct one. However please find below some comments
- For step 2 I suppose when you say flush it means erase.
- Your procedure does not indicate if
LoRaMacInitialization
API is called after step 2. Maybe it is called insideLmHandlerSetActiveRegion
- When you say the process just breaks or halts. Have you tried to debug what is going on?
Have you checked the API calls returned status?
My first though about this was to say: Are the required regions support enabled?
For instance if EU868 and US915 (default active region) regions are the ones to activate dynamically are you enabling them?
Below an example on how to do it using the command line.$ mkdir build $ cd build $ cmake -DCMAKE_BUILD_TYPE=Release \ -DTOOLCHAIN_PREFIX="<replace by toolchain path>" \ -DCMAKE_TOOLCHAIN_FILE="../cmake/toolchain-arm-none-eabi.cmake" \ -DAPPLICATION="LoRaMac" \ -DSUB_PROJECT="periodic-uplink-lpp" \ -DCLASSB_ENABLED="ON" \ -DACTIVE_REGION="LORAMAC_REGION_US915" \ -DREGION_EU868="ON" \ -DREGION_US915="ON" \ -DREGION_CN779="OFF" \ -DREGION_EU433="OFF" \ -DREGION_AU915="OFF" \ -DREGION_AS923="OFF" \ -DREGION_CN470="OFF" \ -DREGION_KR920="OFF" \ -DREGION_IN865="OFF" \ -DREGION_RU864="OFF" \ -DBOARD="<replace by your platform>" \ -DMBED_RADIO_SHIELD="<replace by your shield if any>" \ -DSECURE_ELEMENT="SOFT_SE" \ -DSECURE_ELEMENT_PRE_PROVISIONED="ON" .. $ make