Skip to content

Commit

Permalink
Added MAVLink Parameter Protocol, Ping Protocol and simple Command Pr…
Browse files Browse the repository at this point in the history
…otocol support

Fixed build system by supplying default sdkconfig file
  • Loading branch information
seeul8er committed Jun 30, 2024
1 parent bcc1b3b commit 7b00245
Show file tree
Hide file tree
Showing 22 changed files with 927 additions and 4,001 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ add_custom_command (
POST_BUILD
COMMAND cmake -E remove_directory "${CMAKE_SOURCE_DIR}/frontend/build"
)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(db_esp32)
project(db_esp32)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ For questions or general chatting regarding DroneBridge for ESP32 please visit t
### Compile
You will need the Espressif SDK: esp-idf + toolchain. Check out their website for more info and on how to set it up.
The code is written in pure C using the esp-idf (no Arduino libs).
Compile using esp-idf v5.1:
Compile using esp-idf v5.1.2
- ESP32 `idf.py set-target esp32 build`
- ESP32S2 `idf.py set-target esp32s2 build`
- ESP32S3 `idf.py set-target esp32s3 build`
- ESP32C3 `idf.py set-target esp32c3 build`

Or compile all at once with release configuration running the release scripts for bash or powershell `create_release_zip.sh` or `create_release_zip.ps1`

**This project supports the v5.1.2 of ESP-IDF**
Compile and flash by running: `idf.py build`, `idf.py flash`

Expand Down
20 changes: 16 additions & 4 deletions create_release_zip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ $release_foldername = "DroneBridge_ESP32_vXX"
$release_name_zip = "DroneBridge_ESP32_vXX.zip"

mkdir $release_foldername
mkdir build
cp .\flashing_instructions.txt $release_foldername

rm -Recurse .\build
idf.py set-target esp32
idf.py fullclean
cp .\sdkconfig_esp32 .\sdkconfig
idf.py build
mkdir $release_foldername\esp32
Expand All @@ -19,7 +20,7 @@ cp .\build\www.bin $release_foldername\esp32
cp .\build\partition_table\partition-table.bin $release_foldername\esp32

rm -Recurse .\build
idf.py set-target esp32s2
idf.py fullclean
cp .\sdkconfig_s2 .\sdkconfig
idf.py build
mkdir $release_foldername\esp32s2
Expand All @@ -30,7 +31,7 @@ cp .\build\www.bin $release_foldername\esp32s2
cp .\build\partition_table\partition-table.bin $release_foldername\esp32s2

rm -Recurse .\build
idf.py set-target esp32s3
idf.py fullclean
cp .\sdkconfig_s3 .\sdkconfig
idf.py build
mkdir $release_foldername\esp32s3
Expand All @@ -41,7 +42,7 @@ cp .\build\www.bin $release_foldername\esp32s3
cp .\build\partition_table\partition-table.bin $release_foldername\esp32s3

rm -Recurse .\build
idf.py set-target esp32c3
idf.py fullclean
cp .\sdkconfig_c3 .\sdkconfig
idf.py build
mkdir $release_foldername\esp32c3
Expand All @@ -51,6 +52,17 @@ cp .\build\bootloader\bootloader.bin $release_foldername\esp32c3
cp .\build\www.bin $release_foldername\esp32c3
cp .\build\partition_table\partition-table.bin $release_foldername\esp32c3

rm -Recurse .\build
idf.py fullclean
cp .\sdkconfig_c3_serial_via_JTAG .\sdkconfig
idf.py build
mkdir $release_foldername\esp32c3_USBSerial
cp .\build\flash_args $release_foldername\esp32c3_USBSerial\flash_args.txt
cp .\build\db_esp32.bin $release_foldername\esp32c3_USBSerial
cp .\build\bootloader\bootloader.bin $release_foldername\esp32c3_USBSerial
cp .\build\www.bin $release_foldername\esp32c3_USBSerial
cp .\build\partition_table\partition-table.bin $release_foldername\esp32c3_USBSerial

if (Test-Path $release_name_zip) {
Remove-Item $release_name_zip -verbose
}
Expand Down
70 changes: 70 additions & 0 deletions create_release_zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

release_foldername="DroneBridge_ESP32_vXX"
release_name_zip="DroneBridge_ESP32_vXX.zip"

mkdir "$release_foldername"
mkdir build
cp flashing_instructions.txt "$release_foldername"

rm -rf build
idf.py fullclean
cp sdkconfig_esp32 sdkconfig
idf.py build
mkdir "$release_foldername/esp32"
cp build/flash_args "$release_foldername/esp32/flash_args.txt"
cp build/db_esp32.bin "$release_foldername/esp32"
cp build/bootloader/bootloader.bin "$release_foldername/esp32"
cp build/www.bin "$release_foldername/esp32"
cp build/partition_table/partition-table.bin "$release_foldername/esp32"

rm -rf build
idf.py fullclean
cp sdkconfig_s2 sdkconfig
idf.py build
mkdir "$release_foldername/esp32s2"
cp build/flash_args "$release_foldername/esp32s2/flash_args.txt"
cp build/db_esp32.bin "$release_foldername/esp32s2"
cp build/bootloader/bootloader.bin "$release_foldername/esp32s2"
cp build/www.bin "$release_foldername/esp32s2"
cp build/partition_table/partition-table.bin "$release_foldername/esp32s2"

rm -rf build
idf.py fullclean
cp sdkconfig_s3 sdkconfig
idf.py build
mkdir "$release_foldername/esp32s3"
cp build/flash_args "$release_foldername/esp32s3/flash_args.txt"
cp build/db_esp32.bin "$release_foldername/esp32s3"
cp build/bootloader/bootloader.bin "$release_foldername/esp32s3"
cp build/www.bin "$release_foldername/esp32s3"
cp build/partition_table/partition-table.bin "$release_foldername/esp32s3"

rm -rf build
idf.py fullclean
cp sdkconfig_c3 sdkconfig
idf.py build
mkdir "$release_foldername/esp32c3"
cp build/flash_args "$release_foldername/esp32c3/flash_args.txt"
cp build/db_esp32.bin "$release_foldername/esp32c3"
cp build/bootloader/bootloader.bin "$release_foldername/esp32c3"
cp build/www.bin "$release_foldername/esp32c3"
cp build/partition_table/partition-table.bin "$release_foldername/esp32c3"

rm -rf build
idf.py fullclean
cp sdkconfig_c3_serial_via_JTAG sdkconfig
idf.py build
mkdir "$release_foldername/esp32c3_USBSerial"
cp build/flash_args "$release_foldername/esp32c3_USBSerial/flash_args.txt"
cp build/db_esp32.bin "$release_foldername/esp32c3_USBSerial"
cp build/bootloader/bootloader.bin "$release_foldername/esp32c3_USBSerial"
cp build/www.bin "$release_foldername/esp32c3_USBSerial"
cp build/partition_table/partition-table.bin "$release_foldername/esp32c3_USBSerial"

if [ -f "$release_name_zip" ]; then
rm "$release_name_zip"
fi
zip -r "$release_name_zip" "$release_foldername"

rm -rf "$release_foldername"
4 changes: 2 additions & 2 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
idf_component_register(SRCS main.c db_esp32_control.c msp_ltm_serial.c http_server.c
db_esp32_comm.c db_comm.c db_crc.c tcp_server.c db_esp_now.c db_serial.c
db_esp32_comm.c db_comm.c db_crc.c tcp_server.c db_esp_now.c db_serial.c db_mavlink_msgs.c
INCLUDE_DIRS ".")

if(CONFIG_WEB_DEPLOY_SF)
set(WEB_SRC_DIR "${CMAKE_BINARY_DIR}/frontend")
spiffs_create_partition_image(www ${WEB_SRC_DIR} FLASH_IN_PROJECT DEPENDS frontend)
endif()
endif()
16 changes: 13 additions & 3 deletions main/db_esp32_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,16 @@ bool remove_from_known_udp_clients(udp_conn_list_t *n_udp_conn_list, struct db_u
void read_process_uart(int *tcp_clients, uint *transparent_buff_pos, uint *msp_ltm_buff_pos, uint8_t *msp_message_buffer,
uint8_t *serial_buffer, msp_ltm_port_t *db_msp_ltm_port) {
switch (DB_SERIAL_PROTOCOL) {
case 1:
case 0:
case 2:
case DB_SERIAL_PROTOCOL_MSPLTM:
db_parse_msp_ltm(tcp_clients, udp_conn_list, msp_message_buffer, msp_ltm_buff_pos, db_msp_ltm_port);
break;
case 3:
case 4:
case DB_SERIAL_PROTOCOL_MAVLINK:
db_read_serial_parse_mavlink(tcp_clients, udp_conn_list, msp_message_buffer, transparent_buff_pos);
break;
case 5:
case DB_SERIAL_PROTOCOL_TRANSPARENT:
default:
db_read_serial_parse_transparent(tcp_clients, udp_conn_list, serial_buffer, transparent_buff_pos);
break;
Expand Down Expand Up @@ -363,6 +364,9 @@ _Noreturn void control_module_esp_now(){
&db_msp_ltm_port);
if (db_uart_write_queue != NULL && xQueueReceive(db_uart_write_queue, &db_espnow_uart_evt, 0) == pdTRUE) {
write_to_serial(db_espnow_uart_evt.data, db_espnow_uart_evt.data_len);
if (DB_SERIAL_PROTOCOL == DB_SERIAL_PROTOCOL_MAVLINK) {
db_parse_mavlink_from_radio(NULL, NULL, db_espnow_uart_evt.data, db_espnow_uart_evt.data_len);
} // only parse in mavlink mode
free(db_espnow_uart_evt.data);
} else {
if (db_uart_write_queue == NULL) ESP_LOGE(TAG, "db_uart_write_queue is NULL!");
Expand Down Expand Up @@ -521,6 +525,9 @@ _Noreturn void control_module_udp_tcp() {
ssize_t recv_length = recv(tcp_clients[i], tcp_client_buffer, TCP_BUFF_SIZ, 0);
if (recv_length > 0) {
write_to_serial(tcp_client_buffer, recv_length);
if (DB_SERIAL_PROTOCOL == DB_SERIAL_PROTOCOL_MAVLINK) {
db_parse_mavlink_from_radio(tcp_clients, udp_conn_list, tcp_client_buffer, recv_length);
}
} else if (recv_length == 0) {
shutdown(tcp_clients[i], 0);
close(tcp_clients[i]);
Expand All @@ -547,6 +554,9 @@ _Noreturn void control_module_udp_tcp() {
// determine if the client is still existing. This will blow up the list connected devices.
// In AP-Mode the devices can be removed based on the IP/MAC address
add_to_known_udp_clients(udp_conn_list, new_db_udp_client);
if (DB_SERIAL_PROTOCOL == DB_SERIAL_PROTOCOL_MAVLINK) {
db_parse_mavlink_from_radio(tcp_clients, udp_conn_list, udp_buffer, recv_length);
} // no parsing with any other protocol
}

if (DB_WIFI_MODE == DB_WIFI_MODE_STA) {
Expand Down
Loading

0 comments on commit 7b00245

Please sign in to comment.