File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
components/esp_websocket_client Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -1278,6 +1278,43 @@ esp_err_t esp_websocket_client_set_ping_interval_sec(esp_websocket_client_handle
1278
1278
return ESP_OK ;
1279
1279
}
1280
1280
1281
+ int esp_websocket_client_get_reconnect_timeout (esp_websocket_client_handle_t client )
1282
+ {
1283
+ if (client == NULL ) {
1284
+ ESP_LOGW (TAG , "Client was not initialized" );
1285
+ return -1 ;
1286
+ }
1287
+
1288
+ if (!client -> config -> auto_reconnect ) {
1289
+ ESP_LOGW (TAG , "Automatic reconnect is disabled" );
1290
+ return -1 ;
1291
+ }
1292
+
1293
+ return client -> wait_timeout_ms ;
1294
+ }
1295
+
1296
+ esp_err_t esp_websocket_client_set_reconnect_timeout (esp_websocket_client_handle_t client , int reconnect_timeout_ms )
1297
+ {
1298
+ if (client == NULL ) {
1299
+ ESP_LOGW (TAG , "Client was not initialized" );
1300
+ return ESP_ERR_INVALID_ARG ;
1301
+ }
1302
+
1303
+ if (reconnect_timeout_ms <= 0 ) {
1304
+ ESP_LOGW (TAG , "Invalid reconnect timeout" );
1305
+ return ESP_ERR_INVALID_ARG ;
1306
+ }
1307
+
1308
+ if (!client -> config -> auto_reconnect ) {
1309
+ ESP_LOGW (TAG , "Automatic reconnect is disabled" );
1310
+ return ESP_ERR_INVALID_STATE ;
1311
+ }
1312
+
1313
+ client -> wait_timeout_ms = reconnect_timeout_ms ;
1314
+
1315
+ return ESP_OK ;
1316
+ }
1317
+
1281
1318
esp_err_t esp_websocket_register_events (esp_websocket_client_handle_t client ,
1282
1319
esp_websocket_event_id_t event ,
1283
1320
esp_event_handler_t event_handler ,
Original file line number Diff line number Diff line change @@ -416,6 +416,29 @@ size_t esp_websocket_client_get_ping_interval_sec(esp_websocket_client_handle_t
416
416
*/
417
417
esp_err_t esp_websocket_client_set_ping_interval_sec (esp_websocket_client_handle_t client , size_t ping_interval_sec );
418
418
419
+ /**
420
+ * @brief Get the next reconnect timeout for client. Returns -1 when client is not initialized or automatic reconnect is disabled.
421
+ *
422
+ * @param[in] client The client
423
+ *
424
+ * @return Reconnect timeout in msec
425
+ */
426
+ int esp_websocket_client_get_reconnect_timeout (esp_websocket_client_handle_t client );
427
+
428
+ /**
429
+ * @brief Set next reconnect timeout for client.
430
+ *
431
+ * Notes:
432
+ * - Changing this value when reconnection delay is already active does not immediately affect the active delay and may have unexpected result.
433
+ * - Good place to change this value is when handling WEBSOCKET_EVENT_DISCONNECTED or WEBSOCKET_EVENT_ERROR events.
434
+ *
435
+ * @param[in] client The client
436
+ * @param[in] reconnect_timeout_ms The new timeout
437
+ *
438
+ * @return esp_err_t
439
+ */
440
+ esp_err_t esp_websocket_client_set_reconnect_timeout (esp_websocket_client_handle_t client , int reconnect_timeout_ms );
441
+
419
442
/**
420
443
* @brief Register the Websocket Events
421
444
*
You can’t perform that action at this time.
0 commit comments