Skip to content

Commit

Permalink
Added checks for max packet size
Browse files Browse the repository at this point in the history
  • Loading branch information
seeul8er committed Oct 22, 2024
1 parent bc75ad7 commit 0cd5ab8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main/db_esp_now.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions main/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 0cd5ab8

Please sign in to comment.