diff --git a/components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp b/components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp index c287cc167..f2de628f8 100644 --- a/components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp +++ b/components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp @@ -295,3 +295,24 @@ extern "C" esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode) ESP_RETURN_ON_ERROR(instance.send(api_id::SET_MODE, &mode), TAG, "Failed to send request"); return instance.get_resp(api_id::SET_MODE); } + +extern "C" esp_err_t esp_wifi_remote_deinit(void) +{ + std::lock_guard lock(instance.sync); + ESP_RETURN_ON_ERROR(instance.send(api_id::DEINIT), TAG, "Failed to send request"); + return instance.get_resp(api_id::DEINIT); +} + +extern "C" esp_err_t esp_wifi_remote_disconnect(void) +{ + std::lock_guard lock(instance.sync); + ESP_RETURN_ON_ERROR(instance.send(api_id::DISCONNECT), TAG, "Failed to send request"); + return instance.get_resp(api_id::DISCONNECT); +} + +extern "C" esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage) +{ + std::lock_guard lock(instance.sync); + ESP_RETURN_ON_ERROR(instance.send(api_id::SET_STORAGE, &storage), TAG, "Failed to send request"); + return instance.get_resp(api_id::SET_STORAGE); +} diff --git a/components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp b/components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp index 30a0104db..2b8d6d271 100644 --- a/components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp +++ b/components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp @@ -18,12 +18,15 @@ enum class api_id : uint32_t { ERROR, UNDEF, INIT, + DEINIT, SET_MODE, SET_CONFIG, START, STOP, CONNECT, + DISCONNECT, GET_MAC, + SET_STORAGE, WIFI_EVENT, IP_EVENT, }; diff --git a/components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp b/components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp index 0a8645d95..9665e5cc3 100644 --- a/components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp +++ b/components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp @@ -164,6 +164,36 @@ private: } break; } + case api_id::DISCONNECT: { + if (header.size != 0) { + return ESP_FAIL; + } + + auto ret = esp_wifi_disconnect(); + if (rpc.send(api_id::DISCONNECT, &ret) != ESP_OK) { + return ESP_FAIL; + } + break; + } + case api_id::DEINIT: { + if (header.size != 0) { + return ESP_FAIL; + } + + auto ret = esp_wifi_deinit(); + if (rpc.send(api_id::DEINIT, &ret) != ESP_OK) { + return ESP_FAIL; + } + break; + } + case api_id::SET_STORAGE: { + auto req = rpc.get_payload(api_id::SET_STORAGE, header); + auto ret = esp_wifi_set_storage(req); + if (rpc.send(api_id::SET_STORAGE, &ret) != ESP_OK) { + return ESP_FAIL; + } + break; + } case api_id::GET_MAC: { auto req = rpc.get_payload(api_id::GET_MAC, header); esp_wifi_remote_mac_t resp = {};