From 9b47fdee8532fce5cfe110579324513ef560ecc8 Mon Sep 17 00:00:00 2001 From: Wolfgang <24637325+seeul8er@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:03:40 +0100 Subject: [PATCH] Added settings to output --- main/db_esp32_comm.c | 7 +++++++ main/db_esp32_control.c | 2 +- main/main.c | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/main/db_esp32_comm.c b/main/db_esp32_comm.c index 9392b55..123f330 100644 --- a/main/db_esp32_comm.c +++ b/main/db_esp32_comm.c @@ -34,6 +34,13 @@ uint8_t tcp_comm_buffer[TCP_COMM_BUF_SIZE]; uint8_t comm_resp_buf[TCP_COMM_BUF_SIZE]; +/** + * The communication protocol is a DroneBridge specific protocol that allows settings changes via JSON. It is not + * implemented for DroneBridge for ESP32. This is just an implementation to respond with an error. + * + * @param client_socket + * @param new_json_bytes + */ void parse_comm_protocol(int client_socket, char *new_json_bytes) { cJSON *json_pointer = cJSON_Parse(new_json_bytes); int dest = cJSON_GetObjectItem(json_pointer, DB_COMM_KEY_DEST)->valueint; diff --git a/main/db_esp32_control.c b/main/db_esp32_control.c index d6516ce..58100b6 100644 --- a/main/db_esp32_control.c +++ b/main/db_esp32_control.c @@ -397,7 +397,7 @@ void control_module_udp_tcp() { parse_transparent(tcp_clients, udp_conn_list, serial_buffer, &read_transparent); break; } - if (delay_timer_cnt == 10000) { + if (delay_timer_cnt == 5000) { // all actions are non-blocking so allow some delay so that the IDLE task of FreeRTOS and the watchdog can run // read: https://esp32developer.com/programming-in-c-c/tasks/tasks-vs-co-routines for reference vTaskDelay(10/portTICK_PERIOD_MS); diff --git a/main/main.c b/main/main.c index de0eae4..b514a69 100644 --- a/main/main.c +++ b/main/main.c @@ -328,11 +328,14 @@ int init_wifi_clientmode() { return 0; } +/** + * Write settings to non-volatile storage + */ void write_settings_to_nvs() { ESP_LOGI(TAG, - "Trying to save: ssid %s\nwifi_pass %s\nwifi_chan %i\nbaud %liu\ngpio_tx %i\ngpio_rx %i\ngpio_cts %i\ngpio_rts %i\nrts_thresh %i\nproto %i\n" + "Trying to save:\nWifi Mode: %i\nssid %s\nwifi_pass %s\nwifi_chan %i\nbaud %liu\ngpio_tx %i\ngpio_rx %i\ngpio_cts %i\ngpio_rts %i\nrts_thresh %i\nproto %i\n" "trans_pack_size %i\nltm_per_packet %i\nmsp_ltm %i\nap_ip %s", - DEFAULT_SSID, DEFAULT_PWD, DEFAULT_CHANNEL, DB_UART_BAUD_RATE, DB_UART_PIN_TX, DB_UART_PIN_RX, + DB_WIFI_MODE, DEFAULT_SSID, DEFAULT_PWD, DEFAULT_CHANNEL, DB_UART_BAUD_RATE, DB_UART_PIN_TX, DB_UART_PIN_RX, DB_UART_PIN_CTS, DB_UART_PIN_RTS, DB_UART_RTS_THRESH, SERIAL_PROTOCOL, TRANSPARENT_BUF_SIZE, LTM_FRAME_NUM_BUFFER, MSP_LTM_SAMEPORT, DEFAULT_AP_IP); ESP_LOGI(TAG, "Saving to NVS %s", NVS_NAMESPACE); @@ -357,7 +360,9 @@ void write_settings_to_nvs() { nvs_close(my_handle); } - +/** + * Read stored settings from internal storage + */ void read_settings_nvs() { nvs_handle my_handle; if (nvs_open(NVS_NAMESPACE, NVS_READONLY, &my_handle) != ESP_OK) { @@ -401,6 +406,12 @@ void read_settings_nvs() { free(wifi_pass); free(ssid); free(ap_ip); + ESP_LOGI(TAG, + "Stored settings:\nWifi Mode: %i\nssid %s\nwifi_pass %s\nwifi_chan %i\nbaud %liu\ngpio_tx %i\ngpio_rx %i\ngpio_cts %i\n" + "gpio_rts %i\nrts_thresh %i\nproto %i\ntrans_pack_size %i\nltm_per_packet %i\nmsp_ltm %i\nap_ip %s", + DB_WIFI_MODE, DEFAULT_SSID, DEFAULT_PWD, DEFAULT_CHANNEL, DB_UART_BAUD_RATE, DB_UART_PIN_TX, DB_UART_PIN_RX, + DB_UART_PIN_CTS, DB_UART_PIN_RTS, DB_UART_RTS_THRESH, SERIAL_PROTOCOL, TRANSPARENT_BUF_SIZE, + LTM_FRAME_NUM_BUFFER, MSP_LTM_SAMEPORT, DEFAULT_AP_IP); } }