I have been testing this for some time and I cannot figure out why lorawan_send() on zephyr does not work when called from a thread, while calling it from main() works perfectly.
The OTAA join completes successfully and returns no error. If I move the lorawan_send() call directly into main(), the packet is sent correctly. However, when I call it from a separate thread, lorawan_send() fails.
Below is the code I am using.
main.c
#include <zephyr/device.h>
#include <zephyr/lorawan/lorawan.h>
#include <zephyr/kernel.h>
#define LORAWAN_DEV_EUI { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define LORAWAN_JOIN_EUI { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define LORAWAN_APP_KEY { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
CONFIG_LOG=yCONFIG_LORA=yCONFIG_LORAWAN=yCONFIG_LORAMAC_REGION_EU868=y=yCONFIG_MAIN_STACK_SIZE=4096CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096