Remove old debug code, move dev eui to lorawan.h

This commit is contained in:
Jochen Gojowsky 2026-02-19 13:28:57 +01:00
parent f1108e678a
commit aefdc7b05c
2 changed files with 10 additions and 49 deletions

View File

@ -18,7 +18,7 @@ extern uint8_t floor_temp_threshold;
extern uint32_t send_interval_minutes; extern uint32_t send_interval_minutes;
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[] = LORAWAN_DEV_EUI;
/* OTAA keys */ /* OTAA keys */
static uint8_t app_key[] = LORAWAN_APP_KEY; static uint8_t app_key[] = LORAWAN_APP_KEY;
@ -142,46 +142,6 @@ static void print_lorawan_ids(void)
void init_lorawan() void init_lorawan()
{ {
/* set dev eui from MCU-ID (UID) of STM32WL */
uint32_t uid_l = HAL_GetUIDw0();
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[1] = (uid_h >> 16) & 0xFF;
dev_eui[2] = (uid_h >> 8) & 0xFF;
dev_eui[3] = (uid_h) & 0xFF;
dev_eui[4] = (uid_l >> 24) & 0xFF;
dev_eui[5] = (uid_l >> 16) & 0xFF;
dev_eui[6] = (uid_l >> 8) & 0xFF;
dev_eui[7] = (uid_l) & 0xFF;
*/
int err; int err;
lora_dev = DEVICE_DT_GET(DT_ALIAS(lora0)); lora_dev = DEVICE_DT_GET(DT_ALIAS(lora0));

View File

@ -4,13 +4,14 @@
#define LORAWAN_PORT 2 #define LORAWAN_PORT 2
/* ABP Configuration */ /* ABP Configuration */
#define LORAWAN_DEV_ADDR {0x01, 0x9D, 0x28, 0xDF} #define LORAWAN_DEV_EUI {0xCF, 0x05, 0x28, 0x64, 0x13, 0xAF, 0xC0, 0xF9}
#define LORAWAN_NWKS_KEY {0x4C, 0xF3, 0xD2, 0xF5, 0x6C, 0x5C, \ #define LORAWAN_DEV_ADDR {0x00, 0x7B, 0x31, 0x7E}
0x45, 0xA6, 0x78, 0x81, 0xD7, 0xBA, \ #define LORAWAN_NWKS_KEY {0xA2, 0xFC, 0xDA, 0xC5, 0x3A, 0xF7, \
0x91, 0x61, 0x65, 0x11} 0xBD, 0x0C, 0xE3, 0x53, 0x28, 0xD1, \
#define LORAWAN_APPS_KEY {0x41, 0x5F, 0x07, 0xCF, 0x5B, 0xA6, \ 0xC5, 0x0A, 0x27, 0x94}
0xE6, 0x30, 0xC4, 0xC3, 0xEB, 0x9C, \ #define LORAWAN_APPS_KEY {0x3B, 0x9F, 0xD6, 0x6B, 0xE4, 0x5B, \
0x7E, 0x71, 0x8C, 0x5D} 0x92, 0xDA, 0x5A, 0xAA, 0xBD, 0xDE, \
0x68, 0x9B, 0xE7, 0x98}
/* OTAA Configuration (backup) */ /* OTAA Configuration (backup) */
#define LORAWAN_APP_KEY {0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3, \ #define LORAWAN_APP_KEY {0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3, \
@ -28,4 +29,4 @@ void join_network_abp();
void send_data_packet(char *data, uint8_t data_len); void send_data_packet(char *data, uint8_t data_len);
void create_data_package(char *package, float temp_room_mlx, float temp_floor, float humidity, uint8_t relais_state); void create_data_package(char *package, float temp_room_mlx, float temp_floor, float humidity, uint8_t relais_state);