Hi, here I have a custom made board that has a MDBT42Q module (nRF52832 based) and has connected a RFM95W LoRA module, using this simple send lora code:
#include <zephyr/device.h> #include <zephyr/drivers/lora.h> #include <errno.h> #include <zephyr/sys/util.h> #include <zephyr/zephyr.h> #define DEFAULT_RADIO_NODE DT_ALIAS(lora0) BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_RADIO_NODE, okay), "No default LoRa radio specified in DT"); #define MAX_DATA_LEN 2 #define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL #include <zephyr/logging/log.h> LOG_MODULE_REGISTER(lora_test); char data[MAX_DATA_LEN] = {'h', 'e'}; void main(void) { const struct device *lora_dev = DEVICE_DT_GET(DEFAULT_RADIO_NODE); struct lora_modem_config config; int ret; if (!device_is_ready(lora_dev)) { LOG_ERR("%s Device not ready", lora_dev->name); return; } config.frequency = 904300000; config.bandwidth = BW_125_KHZ; config.datarate = SF_6; config.preamble_len = 8; config.coding_rate = CR_4_5; config.tx_power = 4; config.tx = true; ret = lora_config(lora_dev, &config); if (ret < 0) { LOG_ERR("LoRa config failed"); return; } while (1) { ret = lora_send(lora_dev, data, MAX_DATA_LEN); if (ret < 0) { LOG_ERR("LoRa send failed"); return; } LOG_INF("Data sent!"); k_sleep(K_MSEC(1000)); } }
I getting this error on RTT console (the custom board can only be accesses by JTAG, I'm using a JLink):
00> [00:00:00.201,507] <inf> sx127x: SX127x version 0x12 found
00> *** Booting Zephyr OS build v3.1.99-ncs1-1 ***
00>
00> [00:00:00.272,399] <dbg> lorawan: lorawan_init: LoRaMAC Initialized
00> [00:00:00.284,454] <dbg> sx12xx_common: sx12xx_lora_send: Expected air time of 2 bytes = 19ms
00> [00:00:00.334,228] <err> sx12xx_common: Packet transmission failed!
00> [00:00:00.343,811] <inf> lora_test: Data sent!
00> [00:00:01.353,454] <dbg> sx12xx_common: sx12xx_lora_send: Expected air time of 2 bytes = 19ms
00> [00:00:01.403,228] <err> sx12xx_common: Packet transmission failed!
00> [00:00:01.412,811] <inf> lora_test: Data sent!
00> [00:00:02.422,454] <dbg> sx12xx_common: sx12xx_lora_send: Expected air time of 2 bytes = 19ms
00> [00:00:02.472,167] <err> sx12xx_common: Packet transmission failed!
00> [00:00:02.481,750] <inf> lora_test: Data sent!
Really i dont underestand why the packet transmission is failing, need help about how to debug this error, the device used to build the zephyr project is the nrf52dk_nrf52832, the command used was west build -b nrf52dk_nrf52832 .. The overlay that I'm using is:
// Custom PINS
&pinctrl {
spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
<NRF_PSEL(SPIM_MOSI, 0, 18)>,
<NRF_PSEL(SPIM_MISO, 0, 14)>;
};
};
spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
<NRF_PSEL(SPIM_MOSI, 0, 18)>,
<NRF_PSEL(SPIM_MISO, 0, 14)>;
low-power-enable;
};
};
};
&spi0 {
status = "okay";
compatible = "nordic,nrf-spi";
pinctrl-0 = <&spi0_default>;
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
lora: sx1276@0 {
compatible = "semtech,sx1276";
reg = <0>;
label = "sx1276";
reset-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
dio-gpios = <&gpio0 11 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
<&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
<&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
spi-max-frequency = <10000000>;
power-amplifier-output = "pa-boost";
};
};
/ {
aliases {
lora0 = &lora;
};
};
with this prj.conf:
CONFIG_LOG=y
CONFIG_SHELL=y
CONFIG_LOG_MODE_DEFERRED=n
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_DEBUG_THREAD_INFO=y
CONFIG_PRINTK=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
# Enable SPI
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
# Enable the SX12XX radio driver for Lora
CONFIG_LORA=y
CONFIG_LORA_LOG_LEVEL_DBG=y
CONFIG_LORA_SX12XX=y
CONFIG_LORA_SX127X=y
# Enable the LoraWAN stack
CONFIG_LORAWAN=y
CONFIG_LORAWAN_LOG_LEVEL_DBG=y
CONFIG_HAS_SEMTECH_LORAMAC=y
CONFIG_HAS_SEMTECH_SOFT_SE=y
CONFIG_HAS_SEMTECH_RADIO_DRIVERS=y
# Configure LoraWAN Region to be used
CONFIG_LORAMAC_REGION_US915=y
The reference of the custom board connections are: