Skip to content

Commit 93256d1

Browse files
committed
fix(wifi_remote): Added misc wifi API in eppp impl
Adds missing implementation of: * esp_wifi_deinit() * esp_wifi_disconnect() * esp_wifi_set_storage()
1 parent 3a48c06 commit 93256d1

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,24 @@ extern "C" esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode)
295295
ESP_RETURN_ON_ERROR(instance.send(api_id::SET_MODE, &mode), TAG, "Failed to send request");
296296
return instance.get_resp<esp_err_t>(api_id::SET_MODE);
297297
}
298+
299+
extern "C" esp_err_t esp_wifi_remote_deinit(void)
300+
{
301+
std::lock_guard<Sync> lock(instance.sync);
302+
ESP_RETURN_ON_ERROR(instance.send(api_id::DEINIT), TAG, "Failed to send request");
303+
return instance.get_resp<esp_err_t>(api_id::DEINIT);
304+
}
305+
306+
extern "C" esp_err_t esp_wifi_remote_disconnect(void)
307+
{
308+
std::lock_guard<Sync> lock(instance.sync);
309+
ESP_RETURN_ON_ERROR(instance.send(api_id::DISCONNECT), TAG, "Failed to send request");
310+
return instance.get_resp<esp_err_t>(api_id::DISCONNECT);
311+
}
312+
313+
extern "C" esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage)
314+
{
315+
std::lock_guard<Sync> lock(instance.sync);
316+
ESP_RETURN_ON_ERROR(instance.send(api_id::SET_STORAGE, &storage), TAG, "Failed to send request");
317+
return instance.get_resp<esp_err_t>(api_id::SET_STORAGE);
318+
}

components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ enum class api_id : uint32_t {
1818
ERROR,
1919
UNDEF,
2020
INIT,
21+
DEINIT,
2122
SET_MODE,
2223
SET_CONFIG,
2324
START,
2425
STOP,
2526
CONNECT,
27+
DISCONNECT,
2628
GET_MAC,
29+
SET_STORAGE,
2730
WIFI_EVENT,
2831
IP_EVENT,
2932
};

components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,36 @@ class RpcInstance {
164164
}
165165
break;
166166
}
167+
case api_id::DISCONNECT: {
168+
if (header.size != 0) {
169+
return ESP_FAIL;
170+
}
171+
172+
auto ret = esp_wifi_disconnect();
173+
if (rpc.send(api_id::DISCONNECT, &ret) != ESP_OK) {
174+
return ESP_FAIL;
175+
}
176+
break;
177+
}
178+
case api_id::DEINIT: {
179+
if (header.size != 0) {
180+
return ESP_FAIL;
181+
}
182+
183+
auto ret = esp_wifi_deinit();
184+
if (rpc.send(api_id::DEINIT, &ret) != ESP_OK) {
185+
return ESP_FAIL;
186+
}
187+
break;
188+
}
189+
case api_id::SET_STORAGE: {
190+
auto req = rpc.get_payload<wifi_storage_t>(api_id::SET_STORAGE, header);
191+
auto ret = esp_wifi_set_storage(req);
192+
if (rpc.send(api_id::SET_STORAGE, &ret) != ESP_OK) {
193+
return ESP_FAIL;
194+
}
195+
break;
196+
}
167197
case api_id::GET_MAC: {
168198
auto req = rpc.get_payload<wifi_interface_t>(api_id::GET_MAC, header);
169199
esp_wifi_remote_mac_t resp = {};

0 commit comments

Comments
 (0)