Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ add_custom_command (
POST_BUILD
COMMAND cmake -E remove_directory "${CMAKE_SOURCE_DIR}/frontend/build"
)
set(PROJECT_VER "2.2.1 (stable)")
set(PROJECT_VER "2.3.0 (stable)")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(db_esp32)
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ These boards are very affordable, have everything you need, and are also very co

**[You can find more info on how to get the official boards here!](https://dronebridge.gitbook.io/docs/dronebridge-for-esp32/hardware-and-wiring#officially-supported-boards)**

<img src="https://github.com/user-attachments/assets/efd2b305-8046-4431-a4a0-ec8de07fd264" alt="Official Boadrd DroneBridge for ESP32 featuring the ESP32C3" width="350">

**[Order the PCB yourself using the KiCAD PCB Project & Production files with private and commercial use options! Easy solder version now available!](https://buymeacoffee.com/seeul8er/extras)**
![Official Board DroneBridge for ESP32 featuring the ESP32C6](wiki/officialboard.webp)

[For further info please check the wiki!](https://dronebridge.gitbook.io/docs/dronebridge-for-esp32/hardware-and-wiring)

Expand Down Expand Up @@ -108,10 +106,7 @@ In any other case, there are multiple ways how to flash the firmware.
- **In case of a UDP connection the GCS must send at least one packet (e.g. MAVLink heart beat etc.) to the UDP port of the ESP32 to register as an endpoint. Add ESP32 as an UDP target in the GCS**
- Manually add a UDP target using the web interface

## Further Support & Donations

**If you benefited from this project please consider a donation:**
- [PayPal](https://www.paypal.com/donate/?hosted_button_id=SG97392AJN73J)
## Further Support

For questions or general chatting regarding DroneBridge for ESP32 please visit the Discord channel
<div>
Expand Down
1 change: 1 addition & 0 deletions config_defaults/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_IDF_EXPERIMENTAL_FEATURES=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
1 change: 1 addition & 0 deletions config_defaults/sdkconfig.defaults.USBSerial
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
4 changes: 2 additions & 2 deletions config_defaults/sdkconfig.defaults.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_DB_SKYBRUSH_SUPPORT=y
CONFIG_DB_GENERIC_BOARD=y
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
Expand All @@ -35,4 +34,5 @@ CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=n
CONFIG_ESP_WIFI_RX_IRAM_OPT=n
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH=y
CONFIG_SPI_MASTER_ISR_IN_IRAM=n
CONFIG_SPI_MASTER_ISR_IN_IRAM=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
1 change: 1 addition & 0 deletions config_defaults/sdkconfig.defaults.noUARTConsole
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=n
CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=n
CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
1 change: 1 addition & 0 deletions config_defaults/sdkconfig.defaults.official.esp32c3
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=n
CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=n
CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
1 change: 1 addition & 0 deletions config_defaults/sdkconfig.defaults.official.esp32c6
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_MQTT_PROTOCOL_311=n
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_BUTTON_SHORT_PRESS_TIME_MS=350
43 changes: 43 additions & 0 deletions frontend/dronebridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function change_ap_ip_visibility() {
wifi_en_gn_div: document.getElementById("wifi_en_gn_div"),
static_ip_config_div: document.getElementById("static_ip_config_div"),
pass_div: document.getElementById("pass_div"),
espnow_secret_div: document.getElementById("espnow_secret_div"),
espnow_rotate_secret_button: document.getElementById("espnow_rotate_secret_button"),
};

if (esp32Mode === "2") {
Expand Down Expand Up @@ -70,8 +72,12 @@ function change_ap_ip_visibility() {
if (esp32Mode > "3" && esp32Mode < "6") {
elements.ap_ip_div.style.display = "none";
elements.wifi_ssid_div.style.visibility = "hidden";
elements.espnow_secret_div.style.display = "block";
elements.espnow_rotate_secret_button.style.display = esp32Mode === "5" ? "inline-block" : "none";
} else {
elements.wifi_ssid_div.style.visibility = "visible";
elements.espnow_secret_div.style.display = "none";
elements.espnow_rotate_secret_button.style.display = "none";
}
change_radio_dis_arm_visibility();
}
Expand Down Expand Up @@ -187,6 +193,22 @@ async function get_json(api_path) {
}
}

/**
* Rotates the ESP-NOW group secret after warning that every AIR unit must be rebound.
*/
async function rotate_espnow_secret() {
if (!confirm("Rotate the ESP-NOW link secret? All currently bound AIR units will disconnect and must be rebound.")) {
return;
}
try {
const response = await send_json("api/settings/espnow-secret/rotate");
document.getElementById("espnow_secret").value = response.espnow_secret;
show_toast(response.msg);
} catch (error) {
show_toast(error.message);
}
}

/**
* Create a response with JSON data attached
* @param api_path API URL path
Expand Down Expand Up @@ -281,6 +303,7 @@ function refresh_static_data() {
const refresh_succeeded = results.every(result => result === true);
if (refresh_succeeded) {
static_data_ready = true;
check_for_issues();
}
return refresh_succeeded;
})
Expand Down Expand Up @@ -444,6 +467,7 @@ async function get_settings() {
set_telem_proto = document.getElementById("proto").value;
change_ap_ip_visibility();
change_msp_ltm_visibility();
check_for_issues();
return true;
} catch (error) {
console.error("Failed to load or display settings:", error);
Expand Down Expand Up @@ -532,16 +556,35 @@ function check_validity() {
show_toast("Error: 8<(password length)<64");
valid = false;
}
let espnow_secret = document.getElementById("espnow_secret")
if (!espnow_secret.checkValidity()) {
show_toast("Error: ESP-NOW link secret must be 43 Base64URL characters");
valid = false;
}
return valid;
}

/**
* Update the frontend information boxes based on current serial and MAVLink state.
*/
function check_for_issues() {
let issue_div = document.getElementById("issue_div");
if (set_telem_proto === "4" && serial_dec_mav_msgs === 0 && recv_ser_bytes !== 0) {
issue_div.style.display = "block";
} else {
issue_div.style.display = "none";
}

let uart_pins_info_div = document.getElementById("uart_pins_info_div");
let gpio_tx = document.getElementById("gpio_tx");
let gpio_rx = document.getElementById("gpio_rx");
let uart_pins_not_configured = static_data_ready && serial_via_JTAG === 0 &&
gpio_tx.value !== "" && gpio_rx.value !== "" && gpio_tx.value === gpio_rx.value;
if (uart_pins_not_configured) {
uart_pins_info_div.style.display = "block";
} else {
uart_pins_info_div.style.display = "none";
}
}

function save_settings() {
Expand Down
17 changes: 15 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<div class="container">
<form id="settings_form">
<div>
<div class="info note" id="uart_pins_info_div" style="display: none;">
<h4>Attention:</h4>
UART TX and RX pins are not configured. Set the correct GPIO pins for UART TX and RX before DroneBridge can forward data.
</div>
<div class="info issue" id="issue_div">
There might be an issue with your baud rate configuration.<br>Match the UART baud rates on the flight controller and the ESP32.<br>The ESP32 is receiving serial bytes but fails to decode the MAVLink messages.
</div>
Expand Down Expand Up @@ -88,14 +92,22 @@ <h3>Wi-Fi</h3>
</div>
<div class="row">
<div class="six columns" id="wifi_ssid_div">
<label for="ssid">SSID</label>
<label for="ssid">Wi-Fi SSID</label>
<input type="text" name="ssid" value="" id="ssid" maxlength="31">
</div>
<div class="six columns" id="pass_div">
<label for="wifi_pass">Password</label>
<label for="wifi_pass">Wi-Fi Password</label>
<input type="text" name="wifi_pass" value="" id="wifi_pass" minlength="8" maxlength="63" required>
</div>
</div>
<div class="row" id="espnow_secret_div">
<div class="twelve columns">
<label for="espnow_secret">ESP-NOW link secret</label>
<input type="text" name="espnow_secret" value="" id="espnow_secret" minlength="43" maxlength="43" pattern="[A-Za-z0-9_-]{43}">
<button class="button-primary" type="button" id="espnow_rotate_secret_button" onclick="rotate_espnow_secret()">Rotate</button>
<div class="info note">Binding creates the ESP-NOW link secret automatically. Rotating it disconnects all currently bound AIR units; they need to be re-bound.<br>Leave it empty only to use the legacy Wi-Fi password for ESP-NOW.<br>AIR and GND must have matching secrets.</div>
</div>
</div>
<div class="row">
<div id="ap_channel_div" class="six columns">
<label for="wifi_chan">Channel</label>
Expand Down Expand Up @@ -254,6 +266,7 @@ <h3 style="margin-top: 2rem">Serial</h3>
<option value="128">128</option>
<option value="160">160</option>
<option value="192">192</option>
<option value="215">215</option>
<option value="224">224</option>
<option value="256">256</option>
<option value="288">288</option>
Expand Down
1 change: 1 addition & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SRCS
db_esp32_control.c
db_crc.c
db_esp_now.c
db_espnow_binding.c
db_serial.c
db_mavlink_msgs.c
db_parameters.c
Expand Down
10 changes: 3 additions & 7 deletions main/db_esp_now.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,8 @@ void db_espnow_broadcast_peers_list_destroy(db_esp_now_clients_list_t *esp_now_c
*/
int init_gcm_encryption_module(uint8_t *aes_key) {
mbedtls_gcm_init(&aes);
generate_pkcs5_key(DB_PARAM_PASS, aes_key, AES_256_KEY_BYTES);
ESP_LOGI(TAG, "Derived AES Key:");
for (int i = 0; i < AES_256_KEY_BYTES; ++i) {
printf("%02x", aes_key[i]);
}
printf("\n");
const char *espnow_secret = strlen(DB_PARAM_ESPNOW_LINK_SECRET) > 0 ? DB_PARAM_ESPNOW_LINK_SECRET : DB_PARAM_PASS;
generate_pkcs5_key(espnow_secret, aes_key, AES_256_KEY_BYTES);
int ret = mbedtls_gcm_setkey(&aes, MBEDTLS_CIPHER_ID_AES, aes_key, DB_ESPNOW_AES_KEY_LEN);
return ret;
}
Expand Down Expand Up @@ -691,4 +687,4 @@ _Noreturn void process_espnow_data() {
*/
void db_start_espnow_module() {
xTaskCreate(&process_espnow_data, "db_espnow", 40960, NULL, 5, NULL);
}
}
Loading
Loading