Skip to content

Commit

Permalink
Added settings to output
Browse files Browse the repository at this point in the history
  • Loading branch information
seeul8er committed Mar 7, 2024
1 parent ca6aa5b commit 9b47fde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions main/db_esp32_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion main/db_esp32_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 14 additions & 3 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 9b47fde

Please sign in to comment.