ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.66k stars 2.97k forks source link

LoRaWAN US region with L072CZ_LWAN not working #8881

Closed paula75 closed 5 years ago

paula75 commented 5 years ago

Description

I'm working on L072CZ_LWAN1 board, using LoRaWAN. I am using mbed-cli and GCC to flash my board using the mbed-os-example-lorawan [1]. I flash the example in my board and try to use OTAA with my own gateway(sentrius) already signed in The Things Networks (US915 region).

I have 2 questions/issues to run this example correctly:

  1. When i flash the example for OTAA, i can receive the join request and join accept in TTN, but the node is unable to receive the join accept, after a while it shows a message OTAA Failed - Check Keys. After some research in the web i found a solution for this changing a parameter max_sys_error to 100 instead of the default value 10 in [2]. This solved the OTAA connection issue and the terminal shows a Connection - Succesful. Apparently this is a crystal issue or something. Maybe it would be nice to show this in a readme

  2. After i joined the otaa connection (after change the max_sys_error parameter on my board), i get a error code -1014 when try to send the sensor value:

 Mbed LoRaWANStack initialized 

 CONFIRMED message retries : 3 

 Adaptive data  r
 Mbed LoRaWANStack initialized 

 CONFIRMED message retries : 3 

 Adaptive data  rate (ADR) - Enabled 

 Connection - In Progress ...

 Connection - Successful 

 Dummy Sensor Value = 2.1 

 send() - Error code -1014 

[1] https://github.com/ARMmbed/mbed-os-example-lorawan.git [2] https://github.com/ARMmbed/mbed-os-example-lorawan/issues/21#issuecomment-366937981

Issue request type

[X] Question
[ ] Enhancement
[ ] Bug
ciarmcom commented 5 years ago

Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-197

hasnainvirk commented 5 years ago

@paula75 Setting the 'max-sys-error' to 100 ms hides the crystal issue in effect and a value this large doesn't make much sense in practise. I would recommend that you should pick up an oscilloscope and measure your clock drift and change the value of RCC_HSICALIBRATION_DEFAULT at mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h just as mentioned in the link [2] you provided.

As for the 2nd question: I wouldn't trust the error cases if the system timing is totally out. -1014 means a crypto error which should not happen in normal circumstances. If the crystal is faulty, you cannot have a good reference clock. If you can't have a good reference clock, the event queue will fall apart and so does our stack which built over event queue.