Switch to ABP activation and add temperature-based relay control
- Switch from OTAA to ABP for reliable network joining - Use SHT4X temperature sensor instead of MLX90614 internal temp - Add automatic relay control based on 21°C threshold - Add manual override capability via downlink commands - Update device tree for Rev 2.1 board compatibility - Improve logging configuration to prevent message drops
This commit is contained in:
parent
8222ce611e
commit
1ca573e8cc
@ -12,12 +12,20 @@
|
|||||||
LOG_MODULE_REGISTER(lorawan_class_a);
|
LOG_MODULE_REGISTER(lorawan_class_a);
|
||||||
|
|
||||||
extern bool relais_state;
|
extern bool relais_state;
|
||||||
|
extern bool relais_manual_override;
|
||||||
const static struct device *lora_dev;
|
const static struct device *lora_dev;
|
||||||
static struct lorawan_join_config join_cfg;
|
static struct lorawan_join_config join_cfg;
|
||||||
static uint8_t dev_eui[8];
|
static uint8_t dev_eui[8];
|
||||||
|
|
||||||
|
/* OTAA keys */
|
||||||
static uint8_t app_key[] = LORAWAN_APP_KEY;
|
static uint8_t app_key[] = LORAWAN_APP_KEY;
|
||||||
static uint8_t join_eui[] = LORAWAN_APP_EUI;
|
static uint8_t join_eui[] = LORAWAN_APP_EUI;
|
||||||
|
|
||||||
|
/* ABP keys and address */
|
||||||
|
static uint32_t dev_addr = 0x5FC69401; // Little endian of {0x01, 0x94, 0xC6, 0x5F}
|
||||||
|
static uint8_t nwks_key[] = LORAWAN_NWKS_KEY;
|
||||||
|
static uint8_t apps_key[] = LORAWAN_APPS_KEY;
|
||||||
|
|
||||||
static void dl_callback(uint8_t port, uint8_t flags, int16_t rssi, int8_t snr, uint8_t len,
|
static void dl_callback(uint8_t port, uint8_t flags, int16_t rssi, int8_t snr, uint8_t len,
|
||||||
const uint8_t *hex_data)
|
const uint8_t *hex_data)
|
||||||
{
|
{
|
||||||
@ -39,6 +47,7 @@ static void dl_callback(uint8_t port, uint8_t flags, int16_t rssi, int8_t snr, u
|
|||||||
LOG_INF("Set relais 1 value");
|
LOG_INF("Set relais 1 value");
|
||||||
}
|
}
|
||||||
relais_state = relais_value;
|
relais_state = relais_value;
|
||||||
|
relais_manual_override = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +55,43 @@ struct lorawan_downlink_cb downlink_cb = {
|
|||||||
.port = LW_RECV_PORT_ANY,
|
.port = LW_RECV_PORT_ANY,
|
||||||
.cb = dl_callback};
|
.cb = dl_callback};
|
||||||
|
|
||||||
|
static void print_lorawan_ids(void)
|
||||||
|
{
|
||||||
|
LOG_INF("=== LoRaWAN Configuration ===");
|
||||||
|
|
||||||
|
/* Print DevEUI */
|
||||||
|
printk("DevEUI: ");
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", dev_eui[i]);
|
||||||
|
if (i < 7)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
|
||||||
|
/* Print AppEUI (JoinEUI) */
|
||||||
|
printk("AppEUI: ");
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", join_eui[i]);
|
||||||
|
if (i < 7)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
|
||||||
|
/* Print AppKey */
|
||||||
|
printk("AppKey: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", app_key[i]);
|
||||||
|
if (i < 15)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
|
||||||
|
LOG_INF("=============================");
|
||||||
|
}
|
||||||
|
|
||||||
void init_lorawan()
|
void init_lorawan()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,6 +99,32 @@ void init_lorawan()
|
|||||||
uint32_t uid_l = HAL_GetUIDw0();
|
uint32_t uid_l = HAL_GetUIDw0();
|
||||||
uint32_t uid_h = HAL_GetUIDw1();
|
uint32_t uid_h = HAL_GetUIDw1();
|
||||||
|
|
||||||
|
/* Debug: Check chip revisions */
|
||||||
|
uint32_t hal_version = HAL_GetHalVersion();
|
||||||
|
uint32_t rev_id = HAL_GetREVID();
|
||||||
|
uint32_t dev_id = HAL_GetDEVID();
|
||||||
|
|
||||||
|
LOG_INF("=== STM32WL CHIP REVISION INFO ===");
|
||||||
|
LOG_INF("HAL Version: 0x%08X", hal_version);
|
||||||
|
LOG_INF("Revision ID: 0x%08X", rev_id);
|
||||||
|
LOG_INF("Device ID: 0x%08X", dev_id);
|
||||||
|
LOG_INF("MCU UID: High=0x%08X, Low=0x%08X", uid_h, uid_l);
|
||||||
|
LOG_INF("================================");
|
||||||
|
|
||||||
|
// Test 3: Completely new DevEUI for ABP test (avoid any conflicts)
|
||||||
|
dev_eui[0] = 0x46;
|
||||||
|
dev_eui[1] = 0x33;
|
||||||
|
dev_eui[2] = 0x50;
|
||||||
|
dev_eui[3] = 0x04;
|
||||||
|
dev_eui[4] = 0x00;
|
||||||
|
dev_eui[5] = 0xAB;
|
||||||
|
dev_eui[6] = 0xCD;
|
||||||
|
dev_eui[7] = 0xEF; // Fresh DevEUI for ABP test
|
||||||
|
|
||||||
|
LOG_INF("Using HARDCODED DevEUI for testing (not UID-based)");
|
||||||
|
|
||||||
|
// Commented out UID-based generation
|
||||||
|
/*
|
||||||
dev_eui[0] = (uid_h >> 24) & 0xFF;
|
dev_eui[0] = (uid_h >> 24) & 0xFF;
|
||||||
dev_eui[1] = (uid_h >> 16) & 0xFF;
|
dev_eui[1] = (uid_h >> 16) & 0xFF;
|
||||||
dev_eui[2] = (uid_h >> 8) & 0xFF;
|
dev_eui[2] = (uid_h >> 8) & 0xFF;
|
||||||
@ -61,6 +133,7 @@ void init_lorawan()
|
|||||||
dev_eui[5] = (uid_l >> 16) & 0xFF;
|
dev_eui[5] = (uid_l >> 16) & 0xFF;
|
||||||
dev_eui[6] = (uid_l >> 8) & 0xFF;
|
dev_eui[6] = (uid_l >> 8) & 0xFF;
|
||||||
dev_eui[7] = (uid_l) & 0xFF;
|
dev_eui[7] = (uid_l) & 0xFF;
|
||||||
|
*/
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -82,6 +155,9 @@ void init_lorawan()
|
|||||||
LOG_INF("LoraWan started successfully");
|
LOG_INF("LoraWan started successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print all LoRaWAN configuration for debugging */
|
||||||
|
print_lorawan_ids();
|
||||||
|
|
||||||
lorawan_register_downlink_callback(&downlink_cb);
|
lorawan_register_downlink_callback(&downlink_cb);
|
||||||
|
|
||||||
join_cfg.mode = LORAWAN_ACT_OTAA;
|
join_cfg.mode = LORAWAN_ACT_OTAA;
|
||||||
@ -90,39 +166,165 @@ void init_lorawan()
|
|||||||
join_cfg.otaa.app_key = app_key;
|
join_cfg.otaa.app_key = app_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void debug_compute_join_mic(void)
|
||||||
|
{
|
||||||
|
LOG_INF("=== ACTUAL IDs USED BY LORAWAN STACK ===");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.dev_eui, 8, "join_cfg.dev_eui: ");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.otaa.join_eui, 8, "join_cfg.otaa.join_eui: ");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.otaa.app_key, 16, "join_cfg.otaa.app_key: ");
|
||||||
|
|
||||||
|
LOG_INF("=== COMPARE WITH HARDCODED VALUES ===");
|
||||||
|
LOG_HEXDUMP_INF(dev_eui, 8, "hardcoded dev_eui: ");
|
||||||
|
LOG_HEXDUMP_INF(join_eui, 8, "hardcoded join_eui: ");
|
||||||
|
LOG_HEXDUMP_INF(app_key, 16, "hardcoded app_key: ");
|
||||||
|
|
||||||
|
// Check if values match
|
||||||
|
bool dev_eui_match = (memcmp(join_cfg.dev_eui, dev_eui, 8) == 0);
|
||||||
|
bool join_eui_match = (memcmp(join_cfg.otaa.join_eui, join_eui, 8) == 0);
|
||||||
|
bool app_key_match = (memcmp(join_cfg.otaa.app_key, app_key, 16) == 0);
|
||||||
|
|
||||||
|
LOG_INF("DevEUI match: %s", dev_eui_match ? "YES" : "NO");
|
||||||
|
LOG_INF("JoinEUI match: %s", join_eui_match ? "YES" : "NO");
|
||||||
|
LOG_INF("AppKey match: %s", app_key_match ? "YES" : "NO");
|
||||||
|
|
||||||
|
if (!dev_eui_match || !join_eui_match || !app_key_match)
|
||||||
|
{
|
||||||
|
LOG_ERR("MISMATCH DETECTED! join_cfg contains different values than expected!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void join_network_otaa()
|
void join_network_otaa()
|
||||||
{
|
{
|
||||||
int8_t ret = -1;
|
int8_t ret = -1;
|
||||||
while (lorawan_join(&join_cfg) < 0)
|
LOG_INF("Starting OTAA join procedure...");
|
||||||
|
LOG_INF("Join Config: Mode=%d", join_cfg.mode);
|
||||||
|
LOG_INF("Using EU868 Region");
|
||||||
|
|
||||||
|
while ((ret = lorawan_join(&join_cfg)) < 0)
|
||||||
{
|
{
|
||||||
LOG_ERR("lorawan_join_network failed: %d, retrying..", ret);
|
const char *error_msg = "Unknown error";
|
||||||
|
switch (ret)
|
||||||
|
{
|
||||||
|
case -116:
|
||||||
|
error_msg = "Rx timeout (no network response)";
|
||||||
|
break;
|
||||||
|
case -22:
|
||||||
|
error_msg = "Invalid parameter";
|
||||||
|
break;
|
||||||
|
case -11:
|
||||||
|
error_msg = "Try again";
|
||||||
|
break;
|
||||||
|
case -5:
|
||||||
|
error_msg = "I/O error";
|
||||||
|
break;
|
||||||
|
case -16:
|
||||||
|
error_msg = "Device busy";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
LOG_ERR("LoRaWAN join failed: %d (%s), retrying in 5 seconds...", ret, error_msg);
|
||||||
|
|
||||||
|
// Debug MIC calculation on each retry
|
||||||
|
debug_compute_join_mic();
|
||||||
|
|
||||||
|
LOG_INF("DEBUG: Join attempt made with these parameters:");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.dev_eui, 8, "Used DevEUI: ");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.otaa.join_eui, 8, "Used JoinEUI: ");
|
||||||
|
LOG_HEXDUMP_INF(join_cfg.otaa.app_key, 16, "Used AppKey: ");
|
||||||
|
LOG_ERR("=== Configuration on join failure ===");
|
||||||
|
printk("DevEUI: ");
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", dev_eui[i]);
|
||||||
|
if (i < 7)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
printk("AppEUI: ");
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", join_eui[i]);
|
||||||
|
if (i < 7)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
printk("AppKey: ");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", app_key[i]);
|
||||||
|
if (i < 15)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
LOG_ERR("Check: Network server has this DevEUI registered?");
|
||||||
|
LOG_ERR("Check: AppKey matches network server?");
|
||||||
|
LOG_ERR("Check: Gateway in range and connected?");
|
||||||
|
LOG_ERR("====================================");
|
||||||
k_sleep(K_MSEC(5000));
|
k_sleep(K_MSEC(5000));
|
||||||
}
|
}
|
||||||
LOG_INF("Succesfully joined network over OTAA");
|
|
||||||
|
LOG_INF("✓ Successfully joined LoRaWAN network via OTAA");
|
||||||
|
|
||||||
|
/* Print join success with DevEUI for identification */
|
||||||
|
printk("Device ");
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
printk("%02X", dev_eui[i]);
|
||||||
|
if (i < 7)
|
||||||
|
printk(":");
|
||||||
|
}
|
||||||
|
printk(" joined network\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void join_network_abp()
|
||||||
|
{
|
||||||
|
LOG_INF("Starting ABP activation...");
|
||||||
|
LOG_INF("DevAddr: 0x%08X", dev_addr);
|
||||||
|
LOG_HEXDUMP_INF(nwks_key, 16, "NwkSKey: ");
|
||||||
|
LOG_HEXDUMP_INF(apps_key, 16, "AppSKey: ");
|
||||||
|
|
||||||
|
/* Configure ABP parameters */
|
||||||
|
join_cfg.mode = LORAWAN_ACT_ABP;
|
||||||
|
join_cfg.dev_eui = dev_eui;
|
||||||
|
join_cfg.abp.dev_addr = dev_addr;
|
||||||
|
join_cfg.abp.nwk_skey = nwks_key;
|
||||||
|
join_cfg.abp.app_skey = apps_key;
|
||||||
|
|
||||||
|
int ret = lorawan_join(&join_cfg);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
LOG_ERR("ABP activation failed: %d", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INF("✓ Successfully activated LoRaWAN network via ABP");
|
||||||
|
printk("Device 0x%08X activated via ABP\n", dev_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_data_packet(char *data, uint8_t data_len)
|
void send_data_packet(char *data, uint8_t data_len)
|
||||||
{
|
{
|
||||||
LOG_INF("Sending data...");
|
LOG_INF("Sending %d bytes on port %d...", data_len, LORAWAN_PORT);
|
||||||
|
LOG_HEXDUMP_INF(data, data_len, "Payload: ");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int8_t ret = lorawan_send(LORAWAN_PORT, (uint8_t *)data, data_len, LORAWAN_MSG_UNCONFIRMED);
|
int8_t ret = lorawan_send(LORAWAN_PORT, (uint8_t *)data, data_len, LORAWAN_MSG_UNCONFIRMED);
|
||||||
|
|
||||||
if (ret == -EAGAIN)
|
if (ret == -EAGAIN)
|
||||||
{
|
{
|
||||||
LOG_ERR("lorawan_send failed: %d. Continuing...", ret);
|
LOG_WRN("LoRaWAN busy (duty cycle), retrying in 1s...");
|
||||||
k_sleep(RETRY_DELAY);
|
k_sleep(RETRY_DELAY);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
{
|
{
|
||||||
LOG_ERR("lorawan_send failed: %d", ret);
|
LOG_ERR("LoRaWAN send failed: %d", ret);
|
||||||
k_sleep(RETRY_DELAY);
|
k_sleep(RETRY_DELAY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_INF("Data sent!");
|
LOG_INF("✓ Data packet sent successfully!");
|
||||||
|
LOG_INF("DevAddr: 0x%08X, Port: %d, Length: %d bytes", dev_addr, LORAWAN_PORT, data_len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,16 @@
|
|||||||
|
|
||||||
#define LORAWAN_PORT 2
|
#define LORAWAN_PORT 2
|
||||||
|
|
||||||
/* Customize based on network configuration */
|
/* ABP Configuration */
|
||||||
|
#define LORAWAN_DEV_ADDR {0x01, 0x94, 0xC6, 0x5F}
|
||||||
|
#define LORAWAN_NWKS_KEY {0x26, 0x8F, 0xDA, 0x93, 0x3F, 0x4C, \
|
||||||
|
0xAE, 0xBF, 0x96, 0xA3, 0x0F, 0xE7, \
|
||||||
|
0x60, 0x27, 0xA4, 0x1E}
|
||||||
|
#define LORAWAN_APPS_KEY {0x40, 0x80, 0x09, 0xCA, 0x1D, 0x9F, \
|
||||||
|
0xE2, 0xB8, 0x22, 0xF4, 0x68, 0x4D, \
|
||||||
|
0x76, 0x33, 0x13, 0x00}
|
||||||
|
|
||||||
|
/* OTAA Configuration (backup) */
|
||||||
#define LORAWAN_APP_KEY {0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3, \
|
#define LORAWAN_APP_KEY {0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3, \
|
||||||
0x37, 0xA3, 0xC4, 0xF0, 0x78, 0xF9, \
|
0x37, 0xA3, 0xC4, 0xF0, 0x78, 0xF9, \
|
||||||
0x0F, 0x33, 0x07, 0x7D}
|
0x0F, 0x33, 0x07, 0x7D}
|
||||||
@ -16,6 +25,7 @@
|
|||||||
void init_lorawan();
|
void init_lorawan();
|
||||||
|
|
||||||
void join_network_otaa();
|
void join_network_otaa();
|
||||||
|
void join_network_abp();
|
||||||
|
|
||||||
void send_data_packet(char *data, uint8_t data_len);
|
void send_data_packet(char *data, uint8_t data_len);
|
||||||
|
|
||||||
|
|||||||
22
src/main.c
22
src/main.c
@ -14,17 +14,21 @@
|
|||||||
LOG_MODULE_REGISTER(g2h_heat_main);
|
LOG_MODULE_REGISTER(g2h_heat_main);
|
||||||
|
|
||||||
volatile bool relais_state = false;
|
volatile bool relais_state = false;
|
||||||
|
volatile bool relais_manual_override = false;
|
||||||
|
|
||||||
/* MAIN */
|
/* MAIN */
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
printk("=== Device starting ===\n");
|
||||||
|
LOG_INF("G2H Heat Control starting...");
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
init_gpio();
|
init_gpio();
|
||||||
init_mlx90614();
|
init_mlx90614();
|
||||||
init_sht4x();
|
init_sht4x();
|
||||||
init_lorawan();
|
init_lorawan();
|
||||||
join_network_otaa();
|
// join_network_otaa();
|
||||||
|
join_network_abp();
|
||||||
|
|
||||||
float humidity, temp, floor_temp;
|
float humidity, temp, floor_temp;
|
||||||
|
|
||||||
@ -33,16 +37,24 @@ int main(void)
|
|||||||
/* Get values from SHT4X */
|
/* Get values from SHT4X */
|
||||||
request_sensor_data_sht4x();
|
request_sensor_data_sht4x();
|
||||||
humidity = get_value_from_current_sample_sht4x(SENSOR_CHAN_HUMIDITY);
|
humidity = get_value_from_current_sample_sht4x(SENSOR_CHAN_HUMIDITY);
|
||||||
|
temp = get_value_from_current_sample_sht4x(SENSOR_CHAN_AMBIENT_TEMP);
|
||||||
printk("hum: %.2f%%\n", humidity);
|
printk("hum: %.2f%%\n", humidity);
|
||||||
|
|
||||||
/* Get values from MLX90614 */
|
|
||||||
request_sensor_data_mlx90614(MLX90614_INTERNAL_TEMP_ADDR);
|
|
||||||
temp = get_temp_from_raw_data_mlx90614();
|
|
||||||
printk("temp: %.2f °C\n", temp);
|
printk("temp: %.2f °C\n", temp);
|
||||||
request_sensor_data_mlx90614(MLX90614_IR_TEMP_ADDR);
|
request_sensor_data_mlx90614(MLX90614_IR_TEMP_ADDR);
|
||||||
floor_temp = get_temp_from_raw_data_mlx90614();
|
floor_temp = get_temp_from_raw_data_mlx90614();
|
||||||
printk("floor_temp: %.2f °C\n", floor_temp);
|
printk("floor_temp: %.2f °C\n", floor_temp);
|
||||||
|
|
||||||
|
/* Set relais based on temperature if not manually overridden */
|
||||||
|
if (!relais_manual_override) {
|
||||||
|
if (temp < 21.0) {
|
||||||
|
relais_state = 1; // Heat on below 21°C
|
||||||
|
} else {
|
||||||
|
relais_state = 0; // Heat off at/above 21°C
|
||||||
|
}
|
||||||
|
set_relais_state(relais_state);
|
||||||
|
}
|
||||||
|
printk("relais: %d (manual: %d)\n", relais_state, relais_manual_override);
|
||||||
|
|
||||||
/* Pack and send values */
|
/* Pack and send values */
|
||||||
char data[7];
|
char data[7];
|
||||||
create_data_package(data, temp, floor_temp, humidity, relais_state);
|
create_data_package(data, temp, floor_temp, humidity, relais_state);
|
||||||
|
|||||||
@ -155,15 +155,12 @@ stm32_lp_tick_source: &lptim1 {
|
|||||||
interrupts = <50 0>;
|
interrupts = <50 0>;
|
||||||
spi-max-frequency = <8000000>;
|
spi-max-frequency = <8000000>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
tx-enable-gpios = <&gpioc 4 GPIO_ACTIVE_LOW>; /* FE_CTRL1 */
|
/* Rev2 board: PC4/PC5 not connected - remove antenna switch control */
|
||||||
rx-enable-gpios = <&gpioc 5 GPIO_ACTIVE_LOW>; /* FE_CTRL2 */
|
/* tx-enable-gpios and rx-enable-gpios removed for Rev2 board */
|
||||||
dio3-tcxo-voltage = <SX126X_DIO3_TCXO_1V7>;
|
dio3-tcxo-voltage = <SX126X_DIO3_TCXO_1V7>;
|
||||||
tcxo-power-startup-delay-ms = <5>;
|
tcxo-power-startup-delay-ms = <5>;
|
||||||
/* High-power output is selected as a consequence of using
|
/* Use integrated STM32WL RF frontend without external switch */
|
||||||
* tx/rx-enable-gpio to control FE_CTRL1 and FE_CTRL2. Low-power
|
/* Maximize RF power for Rev 2.1 boards */
|
||||||
* output would require both FE_CTRL1 and FE_CTRL2 to be high,
|
|
||||||
* which is not currently supported by the driver.
|
|
||||||
*/
|
|
||||||
power-amplifier-output = "rfo-hp";
|
power-amplifier-output = "rfo-hp";
|
||||||
rfo-lp-max-power = <15>;
|
rfo-lp-max-power = <15>;
|
||||||
rfo-hp-max-power = <22>;
|
rfo-hp-max-power = <22>;
|
||||||
|
|||||||
104
zephyr/modules/loramac-node/CMakeLists.txt
Normal file
104
zephyr/modules/loramac-node/CMakeLists.txt
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
if(${CONFIG_HAS_SEMTECH_RADIO_DRIVERS})
|
||||||
|
|
||||||
|
set(ZEPHYR_CURRENT_LIBRARY loramac-node)
|
||||||
|
|
||||||
|
zephyr_library_include_directories(
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/boards
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/system
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources(
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/boards/mcu/utilities.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/system/systime.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/system/timer.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/system/delay.c
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_SX1272
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx1272/sx1272.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_SX1276
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx1276/sx1276.c
|
||||||
|
)
|
||||||
|
# Modified for STM32WL: Only include radio.c, not sx126x.c to avoid conflict with Zephyr native driver
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_SX126X
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio.c
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${CONFIG_HAS_SEMTECH_LORAMAC})
|
||||||
|
zephyr_library_include_directories(
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region
|
||||||
|
# required for FUOTA FragDecoder.h
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/apps/LoRaMac/common/LmHandler/packages
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
zephyr_library_compile_definitions_ifdef(CONFIG_HAS_SEMTECH_SOFT_SE SOFT_SE)
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_SOFT_SE
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/peripherals/soft-se/aes.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/peripherals/soft-se/cmac.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/peripherals/soft-se/soft-se.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/peripherals/soft-se/soft-se-hal.c
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_LORAMAC
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMac.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacAdr.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacClassB.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacCommands.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacConfirmQueue.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacCrypto.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacParser.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/LoRaMacSerializer.c
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAWAN_FRAG_TRANSPORT_DECODER_SEMTECH
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/apps/LoRaMac/common/LmHandler/packages/FragDecoder.c
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_LORAMAC
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/Region.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCommon.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_EU868
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionEU868.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_US915
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionBaseUS.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionUS915.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_CN779
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN779.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_EU433
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionEU433.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_AU915
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionBaseUS.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionAU915.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_AS923
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionAS923.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_CN470
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionBaseUS.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN470.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN470A20.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN470A26.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN470B20.c
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionCN470B26.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_KR920
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionKR920.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_IN865
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionIN865.c
|
||||||
|
)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_LORAMAC_REGION_RU864
|
||||||
|
${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/mac/region/RegionRU864.c
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
@ -15,4 +15,13 @@ CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
|
|||||||
CONFIG_LOG_DEFAULT_LEVEL=3
|
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||||
CONFIG_NEWLIB_LIBC=y
|
CONFIG_NEWLIB_LIBC=y
|
||||||
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
|
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
|
||||||
CONFIG_ENTROPY_GENERATOR=y
|
CONFIG_ENTROPY_GENERATOR=y
|
||||||
|
|
||||||
|
# Log buffer configuration to prevent dropped messages
|
||||||
|
CONFIG_LOG_BUFFER_SIZE=4096
|
||||||
|
CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=16
|
||||||
|
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
|
||||||
|
CONFIG_LOG_MODE_DEFERRED=y
|
||||||
|
|
||||||
|
# UART buffer size optimization
|
||||||
|
CONFIG_UART_CONSOLE_LOG_LEVEL_DBG=n
|
||||||
Loading…
Reference in New Issue
Block a user