fixes for esp32 and sx1276

This commit is contained in:
Rastislav Vysoky
2026-04-07 20:58:55 +02:00
parent da22b127c3
commit a72dc3e4d9
2 changed files with 45 additions and 0 deletions
@@ -98,6 +98,19 @@ static void wifi_event_handler(struct net_mgmt_event_callback *cb,
if (success) {
LOG_INF("WiFi link up (SSID: %s)", s_creds ? s_creds->wifi_ssid : "?");
s_wifi_link_up = true;
/* Disable power save — WIFI_PS_MIN_MODEM (default) sleeps between
* DTIM beacons, which delays ACKs and causes the MQTT broker's TCP
* stack to retransmit and eventually RST the connection (-ECONNRESET
* in the poll loop). WIFI_PS_DISABLED keeps the radio always awake. */
struct wifi_ps_params ps = {
.enabled = WIFI_PS_DISABLED,
.type = WIFI_PS_PARAM_STATE,
};
if (net_mgmt(NET_REQUEST_WIFI_PS, iface, &ps, sizeof(ps)) < 0) {
LOG_WRN("Failed to disable WiFi power save");
} else {
LOG_INF("WiFi power save disabled");
}
/* DHCP will fire ipv4_event_handler when lease is obtained */
} else {
LOG_WRN("WiFi connect failed (reason=%d) — retry in 10s", reason);
@@ -0,0 +1,32 @@
diff --git a/drivers/lora/loramac-node/sx12xx_common.c b/drivers/lora/loramac-node/sx12xx_common.c
index 17689720dd2..09982dc2e70 100644
--- a/drivers/lora/loramac-node/sx12xx_common.c
+++ b/drivers/lora/loramac-node/sx12xx_common.c
@@ -195,8 +195,15 @@ static void sx12xx_ev_rx_error(void)
/**
* @brief Convert Zephyr bandwidth enum to loramac-node bandwidth index
*
- * The loramac-node library expects bandwidth as an index (0, 1, 2) into its
- * internal Bandwidths[] array, not the actual kHz value.
+ * The loramac-node library expects bandwidth as an index into its internal
+ * Bandwidths[] array (not the actual kHz value). The SX127x hardware
+ * supports sub-125 kHz LoRa bandwidths; index 3 maps to 62.5 kHz (reg BW=6).
+ *
+ * Index mapping (kept in sync with sx1276.c / sx1272.c):
+ * 0 → 125 kHz (reg BW 7)
+ * 1 → 250 kHz (reg BW 8)
+ * 2 → 500 kHz (reg BW 9)
+ * 3 → 62.5 kHz (reg BW 6) — SX127x only
*
* @param bandwidth Zephyr lora_signal_bandwidth enum value
* @param bw_idx Pointer to store the resulting bandwidth index
@@ -215,6 +222,9 @@ static int sx12xx_get_bandwidth_idx(enum lora_signal_bandwidth bandwidth,
case BW_500_KHZ:
*bw_idx = 2;
break;
+ case BW_62_KHZ:
+ *bw_idx = 3;
+ break;
default:
return -EINVAL;
}