is there any demo projects of STM32 using FreeRTOS without AWS and directly connected to the things network?
Currently there aren’t any officially supported demos of this sort.
For now I would recommend taking a look at Semtech’s LoRa stack on git:
The HAL is predominantly located at
LoRaMac-node/src/boards. There’s existing ports for some stm32 boards which include drivers for some popular LoRa radios, such as sx126x/sx127x etc. They have a porting guide here if you want to add support for other MCUs.
LoRaMac-node/src/apps/LoRaMac apps include class a/b/c examples and are aimed at bare-metal, so everything is done in big while loop or ISR. However, if you’re using FreeRTOS you can distribute the responsibilities in separate threads, such as one thread that handles responses, one that handles device state (JOINING, JOINED, etc.).
For integrating with FreeRTOS, I recommend first ensuring
radio.h works, then supporting the subsets of
LoRaMac.h that you want to use.
radio.h to abide by expected LoRaWan standard.
For TTN, you first need to ensure you are within range of a TTN gateway. You can see nearby gateways here. Depending on signal path to the gateway, and your LoRaWan datarates, you may experience range reduction for reliable comms.
For connecting to TTN with OTAA you will need to provide the stack with your
AppKey. There are instructions on how to do this on the stack’s git homepage linked above.