How to include built-in mbed features / library (lorawan)

Hello everyone!

I am using a Nucleo board with the SX1272 shield.
And I am trying the following example code from: mbed-os-example-lorawan - Simple LoRaWAN example application for mbed OS | Mbed

My platformio.ini is:

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
framework = mbed
lib_deps =
mbed-rtos
lib_ignore =
mbed-COMMON_PAL
mbed-mbedtls
build_flags =
-D PIO_FRAMEWORK_MBED_RTOS_PRESENT
-D PIO_FRAMEWORK_MBED_EVENTS_PRESENT

(ignore a few libraries, as for some reason COMMON_PAL is included)

I require the lorawan library which is included in the framework-mbed/features/
I just don’ t seem to be able to include this builtin library in PIO
(I have tried modifying quite a few files and ended up with varying errors or it simplify continues not to be included…)

Could somebody shed some light as to how I should be including a builtin library? (The other libraries in that folder I seem to be able to include with no problem…)

I’ve done this (integrating the lorwan feature of mbed-os) at least two times and it was always a compound of multiple hacks on top of hacks. I’ll try to do it more cleanly and open a github repo with a reference firmware. I’ll check back when it’s done.

Do you intend to connect this to The Things Network (TTN)? Because then you need some more hacks (wrong SF on the second receive window, frequency channel plans, …)

BTW you do need mbedtls with a modded config file (a special macro activates the inclusion of a custom config file) to activate MBEDTLS_CMAC. WIthout AES-128-CMAC the stack can’t compute any crypto (the message integraticy check, MIC).

I’ll write back here when I’m finished.

Hmmm mbed is just sounding less and less appealing…

And yes this would be for connecting to the TTN network.

This sounds like jumping through a lot of hoops, I would be interested in seeing your github repo, if you publish some reference code!

Development of the example has proceeded on GitHub - maxgerhardt/platformio-lorawan-ttn-example: Contains a firmware buildable with PlatformIO that sends data to TTN over a LoRa radio.. Further information on what had to be done to integrate this with PlatformIO will be found there. If you have questions about this, ask me via PM or file an issue in the repository.

The firmware was tested on an STM32 Nucleo L152RE board with a RFM95 (chinese SX1276 clone), but the firmware code is also switchable to an SX1272 radio and a different board.

Connection to TTN in the european EU868 band works flawlessly (after modifying some settings in the lorawan library, e.g. RX2 window being correctly on SF9 instead of SF12). The LoRa link was established from indoors to an outdoor gateway over a distance of 1.36 kilometers / 0.84 miles.

Thanks for sharing and putting it up on a repo. I am testing it on the SX1272 board, I will PM you about the code

Impressive results that you got!