diff --git a/main/db_esp_now.c b/main/db_esp_now.c index 128d56c..af7b7dc 100644 --- a/main/db_esp_now.c +++ b/main/db_esp_now.c @@ -544,7 +544,7 @@ esp_err_t db_espnow_init() { if (!esp_now_is_peer_exist(BROADCAST_MAC)) ESP_ERROR_CHECK(esp_now_add_peer(&peer)); /* Limit payload size to the max we can do */ - if (DB_TRANS_BUF_SIZE > DB_ESPNOW_PAYLOAD_MAXSIZE) { + if (DB_TRANS_BUF_SIZE > DB_ESPNOW_PAYLOAD_MAXSIZE || DB_TRANS_BUF_SIZE < 1) { DB_TRANS_BUF_SIZE = DB_ESPNOW_PAYLOAD_MAXSIZE; } else { // all good diff --git a/main/http_server.c b/main/http_server.c index ae72389..3f296d9 100644 --- a/main/http_server.c +++ b/main/http_server.c @@ -183,9 +183,18 @@ static esp_err_t settings_post_handler(httpd_req_t *req) { } json = cJSON_GetObjectItem(root, "trans_pack_size"); - if (json) DB_TRANS_BUF_SIZE = json->valueint; + if (json && json->valueint > 0 && json->valueint < 1024) { + DB_TRANS_BUF_SIZE = json->valueint; + } else { + ESP_LOGE(REST_TAG, "Settings change: trans_pack_size is out of range (1-1024): %i", json->valueint); + } + json = cJSON_GetObjectItem(root, "serial_timeout"); - if (json) DB_SERIAL_READ_TIMEOUT_MS = json->valueint; + if (json && json->valueint > 0) { + DB_SERIAL_READ_TIMEOUT_MS = json->valueint; + } else { + ESP_LOGE(REST_TAG,"Serial read timeout must be >0 - ignoring"); + } json = cJSON_GetObjectItem(root, "tx_pin"); if (json) DB_UART_PIN_TX = json->valueint; json = cJSON_GetObjectItem(root, "rx_pin");