Skip to content

Commit

Permalink
Added more baud rate options, added config for official board
Browse files Browse the repository at this point in the history
  • Loading branch information
seeul8er committed Dec 9, 2024
1 parent e87214f commit 6380f1b
Show file tree
Hide file tree
Showing 6 changed files with 2,168 additions and 34 deletions.
3 changes: 3 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ <h3>Serial</h3>
<label for="baud">UART baud</label>
<select name="baud" id="baud" form="settings_form">
<option value="5000000">5000000</option>
<option value="1500000">3000000</option>
<option value="1500000">2000000</option>
<option value="1500000">1500000</option>
<option value="1000000">1000000</option>
<option value="500000">500000</option>
<option value="921600">921600</option>
<option value="576000">576000</option>
<option value="460800">500800</option>
<option value="460800">460800</option>
<option value="230400">230400</option>
<option value="115200">115200</option>
Expand Down
18 changes: 18 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
menu "DroneBridge for ESP32 Configuration"

choice
prompt "ESP32 board type"
default DB_GENERIC_BOARD
help
Select the DroneBridge ESP32 board type.
Depending on the chosen option the UART pins will be pre-configured (official boards) or not (generic boards)
config DB_GENERIC_BOARD
bool "Generic ESP32 board (no pre-configuration)"
help
For all types of ESP32 boards. UART pins must be set in the web interface.
If in doubt choose this option.
config DB_OFFICIAL_BOARD_1_X
bool "Official DroneBridge for ESP32 HWv1.x board"
help
The correct UART pins are set as defaults. No need to configure them manually.
Choose this if you have the official DroneBridge for ESP32 HWv1.x board.
endchoice

choice
prompt "Serial interface for data."
default DB_SERIAL_OPTION_UART
Expand Down
68 changes: 45 additions & 23 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@

#define NVS_NAMESPACE "settings"

/* used to reset ESP to defaults and force restart or to reset the mode to access point mode */
#ifdef CONFIG_IDF_TARGET_ESP32C3
#define DB_RESET_PIN GPIO_NUM_9
#elif CONFIG_IDF_TARGET_ESP32S2
#define DB_RESET_PIN GPIO_NUM_0
#elif CONFIG_IDF_TARGET_ESP32S3
#define DB_RESET_PIN GPIO_NUM_0
#elif CONFIG_IDF_TARGET_ESP32
#define DB_RESET_PIN GPIO_NUM_0
#else
#define DB_RESET_PIN GPIO_NUM_0
#endif

#ifdef CONFIG_DB_OFFICIAL_BOARD_1_X
#define DB_DEFAULT_UART_TX_PIN GPIO_NUM_5
#define DB_DEFAULT_UART_RX_PIN GPIO_NUM_4
#define DB_DEFAULT_UART_RTS_PIN GPIO_NUM_6
#define DB_DEFAULT_UART_CTS_PIN GPIO_NUM_7
#define DB_DEFAULT_UART_BAUD_RATE 115200
#elif CONFIG_DB_GENERIC_BOARD
// initially set pins to 0 to allow the start of the system on all boards. User has to set the correct pins
#define DB_DEFAULT_UART_TX_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_RX_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_RTS_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_CTS_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_BAUD_RATE 57600
#else
// someone fucked up the config - fallback to generic config
#define DB_DEFAULT_UART_TX_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_RX_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_RTS_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_CTS_PIN GPIO_NUM_0
#define DB_DEFAULT_UART_BAUD_RATE 57600
#endif

static const char *TAG = "DB_ESP32";

uint8_t DB_WIFI_MODE = DB_WIFI_MODE_AP;
Expand All @@ -60,27 +95,13 @@ char CURRENT_CLIENT_IP[IP4ADDR_STRLEN_MAX] = "192.168.2.1";
uint8_t DB_WIFI_CHANNEL = 6;
uint8_t DB_SERIAL_PROTOCOL = DB_SERIAL_PROTOCOL_MAVLINK;

// initially set pins to 0 to allow the start of the system on all boards. User has to set the correct pins
uint8_t DB_UART_PIN_TX = GPIO_NUM_0;
uint8_t DB_UART_PIN_RX = GPIO_NUM_0;
uint8_t DB_UART_PIN_RTS = GPIO_NUM_0;
uint8_t DB_UART_PIN_CTS = GPIO_NUM_0;
uint8_t DB_UART_PIN_TX = DB_DEFAULT_UART_TX_PIN;
uint8_t DB_UART_PIN_RX = DB_DEFAULT_UART_RX_PIN;
uint8_t DB_UART_PIN_RTS = DB_DEFAULT_UART_RTS_PIN;
uint8_t DB_UART_PIN_CTS = DB_DEFAULT_UART_CTS_PIN;
uint8_t DB_UART_RTS_THRESH = 64;
int32_t DB_UART_BAUD_RATE = DB_DEFAULT_UART_BAUD_RATE;

/* used to reset ESP to defaults and force restart or to reset the mode to access point mode */
#ifdef CONFIG_IDF_TARGET_ESP32C3
#define DB_RESET_PIN GPIO_NUM_9
#elif CONFIG_IDF_TARGET_ESP32S2
#define DB_RESET_PIN GPIO_NUM_0
#elif CONFIG_IDF_TARGET_ESP32S3
#define DB_RESET_PIN GPIO_NUM_0
#elif CONFIG_IDF_TARGET_ESP32
#define DB_RESET_PIN GPIO_NUM_0
#else
#define DB_RESET_PIN GPIO_NUM_0
#endif

int32_t DB_UART_BAUD_RATE = 57600;
uint16_t DB_TRANS_BUF_SIZE = 128;
uint8_t DB_LTM_FRAME_NUM_BUFFER = 2;
db_esp_signal_quality_t db_esp_signal_quality = {.air_rssi = -127, .air_noise_floor = -1, .gnd_rssi= -127, .gnd_noise_floor = -1};
Expand Down Expand Up @@ -618,10 +639,11 @@ void long_press_callback(void *arg,void *usr_data) {
memset(DB_STATIC_STA_IP_GW, 0, strlen(DB_STATIC_STA_IP_GW));
memset(DB_STATIC_STA_IP_NETMASK, 0, strlen(DB_STATIC_STA_IP_NETMASK));
DB_WIFI_CHANNEL = 6;
DB_UART_PIN_TX = GPIO_NUM_0;
DB_UART_PIN_RX = GPIO_NUM_0;
DB_UART_PIN_CTS = GPIO_NUM_0;
DB_UART_PIN_RTS = GPIO_NUM_0;
DB_UART_PIN_TX = DB_DEFAULT_UART_TX_PIN;
DB_UART_PIN_RX = DB_DEFAULT_UART_RX_PIN;
DB_UART_PIN_CTS = DB_DEFAULT_UART_CTS_PIN;
DB_UART_PIN_RTS = DB_DEFAULT_UART_RTS_PIN; //
DB_UART_BAUD_RATE = DB_DEFAULT_UART_BAUD_RATE;
DB_SERIAL_PROTOCOL = DB_SERIAL_PROTOCOL_MAVLINK;
DB_TRANS_BUF_SIZE = 128;
DB_UART_RTS_THRESH = 64;
Expand Down
23 changes: 12 additions & 11 deletions sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ CONFIG_PARTITION_TABLE_MD5=y
#
# DroneBridge for ESP32 Configuration
#
# CONFIG_DB_GENERIC_BOARD is not set
CONFIG_DB_OFFICIAL_BOARD_1_X=y
CONFIG_DB_SERIAL_OPTION_UART=y
CONFIG_DB_SKYBRUSH_SUPPORT=y
# CONFIG_WEB_DEPLOY_SEMIHOST is not set
Expand Down Expand Up @@ -1003,7 +1005,7 @@ CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
# CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y
# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set
CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0
Expand All @@ -1017,7 +1019,7 @@ CONFIG_ESP_WIFI_NVS_ENABLED=y
CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752
CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32
CONFIG_ESP_WIFI_IRAM_OPT=y
# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
CONFIG_ESP_WIFI_ENABLE_SAE_PK=y
Expand All @@ -1030,16 +1032,18 @@ CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15
# CONFIG_ESP_WIFI_FTM_ENABLE is not set
# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set
# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set
# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set
CONFIG_ESP_WIFI_GMAC_SUPPORT=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y
# CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=1
CONFIG_ESP_WIFI_MBEDTLS_CRYPTO=y
CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y
# CONFIG_ESP_WIFI_EAP_TLS1_3 is not set
# CONFIG_ESP_WIFI_WAPI_PSK is not set
# CONFIG_ESP_WIFI_SUITE_B_192 is not set
# CONFIG_ESP_WIFI_11KV_SUPPORT is not set
# CONFIG_ESP_WIFI_MBO_SUPPORT is not set
# CONFIG_ESP_WIFI_ENABLE_ROAMING_APP is not set
# CONFIG_ESP_WIFI_DPP_SUPPORT is not set
# CONFIG_ESP_WIFI_11R_SUPPORT is not set
# CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR is not set
Expand Down Expand Up @@ -1227,7 +1231,7 @@ CONFIG_LWIP_TCPIP_TASK_PRIO=18
# CONFIG_LWIP_CHECK_THREAD_SAFETY is not set
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
# CONFIG_LWIP_L2_TO_L3_COPY is not set
# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set
CONFIG_LWIP_TIMERS_ONDEMAND=y
CONFIG_LWIP_ND6=y
Expand Down Expand Up @@ -1527,7 +1531,6 @@ CONFIG_MBEDTLS_ERROR_STRINGS=y
# CONFIG_MQTT_PROTOCOL_311 is not set
# CONFIG_MQTT_PROTOCOL_5 is not set
# CONFIG_MQTT_TRANSPORT_SSL is not set
# CONFIG_MQTT_TRANSPORT_WEBSOCKET is not set
# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
Expand Down Expand Up @@ -1720,9 +1723,7 @@ CONFIG_SPIFFS_USE_MTIME=y
#
# Websocket
#
CONFIG_WS_TRANSPORT=y
CONFIG_WS_BUFFER_SIZE=1024
# CONFIG_WS_DYNAMIC_BUFFER is not set
# CONFIG_WS_TRANSPORT is not set
# end of Websocket
# end of TCP Transport

Expand Down Expand Up @@ -1906,7 +1907,7 @@ CONFIG_MDNS_PREDEF_NETIF_AP=y
# end of mDNS
# end of Component config

# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set
CONFIG_IDF_EXPERIMENTAL_FEATURES=y

# Deprecated options for backward compatibility
# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set
Expand Down Expand Up @@ -2014,7 +2015,7 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=64
# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP32_WIFI_TX_BA_WIN=6
Expand Down
1 change: 1 addition & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_WS_TRANSPORT=n
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_DB_SKYBRUSH_SUPPORT=y
CONFIG_DB_GENERIC_BOARD=y
Loading

0 comments on commit 6380f1b

Please sign in to comment.