P4 fixes
This commit is contained in:
1050
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_core.c
Normal file
1050
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_core.c
Normal file
File diff suppressed because it is too large
Load Diff
136
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_core.h
Normal file
136
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_core.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Espressif Systems Wireless LAN device driver
|
||||
*
|
||||
* Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __RPC_CORE_H
|
||||
#define __RPC_CORE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "rpc_slave_if.h"
|
||||
#include "os_wrapper.h"
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(n) (1UL << (n))
|
||||
#endif
|
||||
|
||||
#define MAX_SSID_LENGTH 32
|
||||
#define MIN_PWD_LENGTH 8
|
||||
#define MAX_PWD_LENGTH 64
|
||||
#define MIN_CHNL_NO 1
|
||||
#define MAX_CHNL_NO 11
|
||||
#define MIN_CONN_NO 1
|
||||
#define MAX_CONN_NO 10
|
||||
|
||||
#define CLEANUP_APP_MSG(app_msg) do { \
|
||||
if (app_msg) { \
|
||||
if (app_msg->app_free_buff_hdl) { \
|
||||
if (app_msg->app_free_buff_func) { \
|
||||
app_msg->app_free_buff_func(app_msg->app_free_buff_hdl); \
|
||||
app_msg->app_free_buff_hdl = NULL; \
|
||||
} \
|
||||
} \
|
||||
HOSTED_FREE(app_msg); \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define RPC_FAIL_ON_NULL_PRINT(msGparaM, prinTmsG) \
|
||||
if (!msGparaM) { \
|
||||
ESP_LOGE(TAG, prinTmsG"\n"); \
|
||||
goto fail_parse_rpc_msg; \
|
||||
}
|
||||
|
||||
#define RPC_FAIL_ON_NULL(msGparaM) \
|
||||
if (!rpc_msg->msGparaM) { \
|
||||
ESP_LOGE(TAG, "Failed to process rx data\n"); \
|
||||
goto fail_parse_rpc_msg; \
|
||||
}
|
||||
|
||||
|
||||
#define RPC_FREE_BUFFS() { \
|
||||
uint8_t idx = 0; \
|
||||
for (idx=0;idx<app_req->n_rpc_free_buff_hdls; idx++) \
|
||||
HOSTED_FREE(app_req->rpc_free_buff_hdls[idx]); \
|
||||
}
|
||||
|
||||
typedef struct q_element {
|
||||
void *buf;
|
||||
int buf_len;
|
||||
} esp_queue_elem_t;
|
||||
|
||||
//g_h.funcs->_h_memcpy(DsT.data, SrC, len_to_cp);
|
||||
|
||||
#if 0
|
||||
#define RPC_REQ_COPY_BYTES(DsT,SrC,SizE) { \
|
||||
if (SizE && SrC) { \
|
||||
DsT.data = (uint8_t *) g_h.funcs->_h_calloc(1, SizE); \
|
||||
if (!DsT.data) { \
|
||||
hosted_log("Failed to allocate memory for req.%s\n",#DsT); \
|
||||
failure_status = RPC_ERR_MEMORY_FAILURE; \
|
||||
goto fail_req; \
|
||||
} \
|
||||
buff_to_free[num_buff_to_free++] = (uint8_t*)DsT.data; \
|
||||
g_h.funcs->_h_memcpy(DsT.data, SrC, SizE); \
|
||||
DsT.len = SizE; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#define RPC_REQ_COPY_BYTES(DsT,SrC,SizE) { \
|
||||
if (SizE && SrC) { \
|
||||
DsT.data = SrC; \
|
||||
DsT.len = SizE; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define RPC_REQ_COPY_STR(DsT,SrC,MaxSizE) { \
|
||||
if (SrC) { \
|
||||
RPC_REQ_COPY_BYTES(DsT, SrC, min(strlen((char*)SrC)+1,MaxSizE)); \
|
||||
} \
|
||||
}
|
||||
|
||||
int rpc_core_init(void);
|
||||
int rpc_core_deinit(void);
|
||||
/*
|
||||
* Allows user app to create low level protobuf request
|
||||
* returns SUCCESS(0) or FAILURE(-1)
|
||||
*/
|
||||
int rpc_send_req(ctrl_cmd_t *app_req);
|
||||
|
||||
/* When request is sent without an async callback, this function will be called
|
||||
* It will wait for control response or timeout for control response
|
||||
* This is only used in synchrounous control path
|
||||
*
|
||||
* Input:
|
||||
* > req - control request from user
|
||||
*
|
||||
* Returns: control response or NULL in case of timeout
|
||||
*
|
||||
**/
|
||||
ctrl_cmd_t * rpc_wait_and_parse_sync_resp(ctrl_cmd_t *req);
|
||||
|
||||
|
||||
/* Checks if async control response callback is available
|
||||
* in argument passed of type control request
|
||||
*
|
||||
* Input:
|
||||
* > req - control request from user
|
||||
*
|
||||
* Returns:
|
||||
* > CALLBACK_AVAILABLE - if a non NULL asynchrounous control response
|
||||
* callback is available
|
||||
* In case of failures -
|
||||
* > MSG_ID_OUT_OF_ORDER - if request msg id is unsupported
|
||||
* > CALLBACK_NOT_REGISTERED - if aync callback is not available
|
||||
**/
|
||||
int compose_rpc_req(Rpc *req, ctrl_cmd_t *app_req, int32_t *failure_status);
|
||||
|
||||
int is_event_callback_registered(int event);
|
||||
|
||||
int rpc_parse_evt(Rpc *rpc_msg, ctrl_cmd_t *app_ntfy);
|
||||
|
||||
int rpc_parse_rsp(Rpc *rpc_msg, ctrl_cmd_t *app_resp);
|
||||
#endif /* __RPC_CORE_H */
|
||||
177
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_evt.c
Normal file
177
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_evt.c
Normal file
@@ -0,0 +1,177 @@
|
||||
// Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
|
||||
|
||||
#include "rpc_core.h"
|
||||
#include "rpc_slave_if.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_hosted_transport.h"
|
||||
|
||||
DEFINE_LOG_TAG(rpc_evt);
|
||||
|
||||
/* For new RPC event (from ESP to host), add up switch case for your message
|
||||
* In general, it is better to subscribe all events or notifications
|
||||
* at slave side & selective subscribe the events at host side.
|
||||
* This way, all the events reach at host and host will decide
|
||||
* if incoming event is expected to be entertained or dropped
|
||||
*
|
||||
* If you are concerned over battery usage, it is code further could be
|
||||
* optimized that only selective events are subscribed at slave and host both sides
|
||||
*
|
||||
* This function will copy rpc event from `Rpc` into
|
||||
* app structure `ctrl_cmd_t`
|
||||
* This function is called after
|
||||
* 1. Protobuf decoding is successful
|
||||
* 2. There is non NULL event callback is available
|
||||
**/
|
||||
int rpc_parse_evt(Rpc *rpc_msg, ctrl_cmd_t *app_ntfy)
|
||||
{
|
||||
if (!rpc_msg || !app_ntfy) {
|
||||
ESP_LOGE(TAG, "NULL rpc event or App struct\n");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
|
||||
app_ntfy->msg_type = RPC_TYPE__Event;
|
||||
app_ntfy->msg_id = rpc_msg->msg_id;
|
||||
app_ntfy->resp_event_status = SUCCESS;
|
||||
|
||||
switch (rpc_msg->msg_id) {
|
||||
|
||||
case RPC_ID__Event_ESPInit: {
|
||||
ESP_LOGI(TAG, "EVENT: ESP INIT\n");
|
||||
break;
|
||||
} case RPC_ID__Event_Heartbeat: {
|
||||
ESP_LOGD(TAG, "EVENT: Heartbeat\n");
|
||||
RPC_FAIL_ON_NULL(event_heartbeat);
|
||||
app_ntfy->u.e_heartbeat.hb_num = rpc_msg->event_heartbeat->hb_num;
|
||||
break;
|
||||
} case RPC_ID__Event_AP_StaConnected: {
|
||||
wifi_event_ap_staconnected_t * p_a = &(app_ntfy->u.e_wifi_ap_staconnected);
|
||||
RpcEventAPStaConnected * p_c = rpc_msg->event_ap_sta_connected;
|
||||
|
||||
RPC_FAIL_ON_NULL(event_ap_sta_connected);
|
||||
app_ntfy->resp_event_status = p_c->resp;
|
||||
|
||||
if(SUCCESS==app_ntfy->resp_event_status) {
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->mac.data, "NULL mac");
|
||||
g_h.funcs->_h_memcpy(p_a->mac, p_c->mac.data, p_c->mac.len);
|
||||
ESP_LOGI(TAG, "EVENT: AP -> sta connected mac[" MACSTR "] (len:%u)",
|
||||
MAC2STR(p_a->mac), p_c->mac.len);
|
||||
}
|
||||
p_a->aid = p_c->aid;
|
||||
p_a->is_mesh_child = p_c->is_mesh_child;
|
||||
|
||||
break;
|
||||
} case RPC_ID__Event_AP_StaDisconnected: {
|
||||
wifi_event_ap_stadisconnected_t * p_a = &(app_ntfy->u.e_wifi_ap_stadisconnected);
|
||||
RpcEventAPStaDisconnected * p_c = rpc_msg->event_ap_sta_disconnected;
|
||||
|
||||
ESP_LOGD(TAG, "EVENT: AP -> sta disconnected");
|
||||
RPC_FAIL_ON_NULL(event_ap_sta_disconnected);
|
||||
app_ntfy->resp_event_status = p_c->resp;
|
||||
|
||||
if(SUCCESS==app_ntfy->resp_event_status) {
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->mac.data, "NULL mac");
|
||||
g_h.funcs->_h_memcpy(p_a->mac, p_c->mac.data, p_c->mac.len);
|
||||
ESP_LOGI(TAG, "EVENT: AP -> sta DISconnected mac[" MACSTR "] (len:%u)",
|
||||
MAC2STR(p_a->mac), p_c->mac.len);
|
||||
}
|
||||
|
||||
p_a->aid = p_c->aid;
|
||||
p_a->is_mesh_child = p_c->is_mesh_child;
|
||||
p_a->reason = p_c->reason;
|
||||
|
||||
break;
|
||||
} case RPC_ID__Event_WifiEventNoArgs: {
|
||||
RPC_FAIL_ON_NULL(event_wifi_event_no_args);
|
||||
app_ntfy->resp_event_status = rpc_msg->event_wifi_event_no_args->resp;
|
||||
ESP_LOGI(TAG, "Event [0x%lx] received", rpc_msg->event_wifi_event_no_args->event_id);
|
||||
app_ntfy->u.e_wifi_simple.wifi_event_id = rpc_msg->event_wifi_event_no_args->event_id;
|
||||
|
||||
switch (rpc_msg->event_wifi_event_no_args->event_id) {
|
||||
/* basic events populated, not all */
|
||||
case WIFI_EVENT_WIFI_READY:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi Ready");
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_DONE:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi scan done");
|
||||
break;
|
||||
case WIFI_EVENT_STA_START:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi Start");
|
||||
break;
|
||||
case WIFI_EVENT_STA_STOP:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi Stop");
|
||||
break;
|
||||
case WIFI_EVENT_STA_CONNECTED:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi Connected");
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi Disconnected");
|
||||
break;
|
||||
case WIFI_EVENT_STA_AUTHMODE_CHANGE:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi AuthMode change");
|
||||
break;
|
||||
case WIFI_EVENT_AP_START:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi AP Start");
|
||||
break;
|
||||
case WIFI_EVENT_AP_STOP:
|
||||
ESP_LOGI(TAG, "EVT rcvd: Wi-Fi AP stop");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Event_StaScanDone: {
|
||||
RpcEventStaScanDone *p_c = rpc_msg->event_sta_scan_done;
|
||||
wifi_event_sta_scan_done_t *p_a = &app_ntfy->u.e_wifi_sta_scan_done;
|
||||
RPC_FAIL_ON_NULL(event_sta_scan_done);
|
||||
app_ntfy->resp_event_status = p_c->resp;
|
||||
ESP_LOGI(TAG, "Event Scan Done, %ld items", rpc_msg->event_sta_scan_done->scan_done->number);
|
||||
p_a->status = p_c->scan_done->status;
|
||||
p_a->number = p_c->scan_done->number;
|
||||
p_a->scan_id = p_c->scan_done->scan_id;
|
||||
break;
|
||||
} case RPC_ID__Event_StaConnected: {
|
||||
RPC_FAIL_ON_NULL(event_sta_connected);
|
||||
RPC_FAIL_ON_NULL(event_sta_connected->sta_connected);
|
||||
WifiEventStaConnected *p_c = rpc_msg->event_sta_connected->sta_connected;
|
||||
wifi_event_sta_connected_t *p_a = &app_ntfy->u.e_wifi_sta_connected;
|
||||
app_ntfy->resp_event_status = rpc_msg->event_sta_connected->resp;
|
||||
if (SUCCESS == app_ntfy->resp_event_status) {
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->ssid.data, "NULL SSID");
|
||||
g_h.funcs->_h_memcpy(p_a->ssid, p_c->ssid.data, p_c->ssid.len);
|
||||
p_a->ssid_len = p_c->ssid_len;
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->bssid.data, "NULL BSSID");
|
||||
g_h.funcs->_h_memcpy(p_a->bssid, p_c->bssid.data, p_c->bssid.len);
|
||||
p_a->channel = p_c->channel;
|
||||
p_a->authmode = p_c->authmode;
|
||||
p_a->aid = p_c->aid;
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Event_StaDisconnected: {
|
||||
RPC_FAIL_ON_NULL(event_sta_disconnected);
|
||||
RPC_FAIL_ON_NULL(event_sta_disconnected->sta_disconnected);
|
||||
WifiEventStaDisconnected *p_c = rpc_msg->event_sta_disconnected->sta_disconnected;
|
||||
wifi_event_sta_disconnected_t *p_a = &app_ntfy->u.e_wifi_sta_disconnected;
|
||||
app_ntfy->resp_event_status = rpc_msg->event_sta_connected->resp;
|
||||
if (SUCCESS == app_ntfy->resp_event_status) {
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->ssid.data, "NULL SSID");
|
||||
g_h.funcs->_h_memcpy(p_a->ssid, p_c->ssid.data, p_c->ssid.len);
|
||||
p_a->ssid_len = p_c->ssid_len;
|
||||
RPC_FAIL_ON_NULL_PRINT(p_c->bssid.data, "NULL BSSID");
|
||||
g_h.funcs->_h_memcpy(p_a->bssid, p_c->bssid.data, p_c->bssid.len);
|
||||
p_a->reason = p_c->reason;
|
||||
p_a->rssi = p_c->rssi;
|
||||
}
|
||||
break;
|
||||
} default: {
|
||||
ESP_LOGE(TAG, "Invalid/unsupported event[%u] received\n",rpc_msg->msg_id);
|
||||
goto fail_parse_rpc_msg;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
fail_parse_rpc_msg:
|
||||
app_ntfy->resp_event_status = FAILURE;
|
||||
return FAILURE;
|
||||
}
|
||||
510
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_req.c
Normal file
510
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_req.c
Normal file
@@ -0,0 +1,510 @@
|
||||
// Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
|
||||
|
||||
#include "rpc_core.h"
|
||||
#include "rpc_slave_if.h"
|
||||
#include "esp_hosted_rpc.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_hosted_wifi_config.h"
|
||||
#include "esp_hosted_transport.h"
|
||||
#include "esp_hosted_bitmasks.h"
|
||||
#include "esp_idf_version.h"
|
||||
|
||||
DEFINE_LOG_TAG(rpc_req);
|
||||
|
||||
#define ADD_RPC_BUFF_TO_FREE_LATER(BuFf) { \
|
||||
assert((app_req->n_rpc_free_buff_hdls+1)<=MAX_FREE_BUFF_HANDLES); \
|
||||
app_req->rpc_free_buff_hdls[app_req->n_rpc_free_buff_hdls++] = BuFf; \
|
||||
}
|
||||
|
||||
#define RPC_ALLOC_ASSIGN(TyPe,MsG_StRuCt,InItFuNc) \
|
||||
TyPe *req_payload = (TyPe *) \
|
||||
g_h.funcs->_h_calloc(1, sizeof(TyPe)); \
|
||||
if (!req_payload) { \
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for req->%s\n",#MsG_StRuCt); \
|
||||
*failure_status = RPC_ERR_MEMORY_FAILURE; \
|
||||
return FAILURE; \
|
||||
} \
|
||||
req->MsG_StRuCt = req_payload; \
|
||||
InItFuNc(req_payload); \
|
||||
ADD_RPC_BUFF_TO_FREE_LATER((uint8_t*)req_payload);
|
||||
|
||||
//TODO: How this is different in slave_control.c
|
||||
#define RPC_ALLOC_ELEMENT(TyPe,MsG_StRuCt,InIt_FuN) { \
|
||||
TyPe *NeW_AllocN = (TyPe *) g_h.funcs->_h_calloc(1, sizeof(TyPe)); \
|
||||
if (!NeW_AllocN) { \
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for req->%s\n",#MsG_StRuCt); \
|
||||
*failure_status = RPC_ERR_MEMORY_FAILURE; \
|
||||
return FAILURE; \
|
||||
} \
|
||||
ADD_RPC_BUFF_TO_FREE_LATER((uint8_t*)NeW_AllocN); \
|
||||
MsG_StRuCt = NeW_AllocN; \
|
||||
InIt_FuN(MsG_StRuCt); \
|
||||
}
|
||||
|
||||
/* RPC request is simple remote function invokation at slave from host
|
||||
*
|
||||
* For new RPC request, add up switch case for your message
|
||||
* If the RPC function to be invoked does not carry any arguments, just add
|
||||
* case in the top with intentional fall through
|
||||
* If any arguments are needed, you may have to add union for your message
|
||||
* in Ctrl_cmd_t in rpc_api.h and fill the request in new case
|
||||
*
|
||||
* For altogether new RPC function addition, please check
|
||||
* esp_hosted_fg/common/proto/esp_hosted_config.proto
|
||||
*/
|
||||
int compose_rpc_req(Rpc *req, ctrl_cmd_t *app_req, int32_t *failure_status)
|
||||
{
|
||||
switch(req->msg_id) {
|
||||
|
||||
case RPC_ID__Req_GetWifiMode:
|
||||
//case RPC_ID__Req_GetAPConfig:
|
||||
//case RPC_ID__Req_DisconnectAP:
|
||||
//case RPC_ID__Req_GetSoftAPConfig:
|
||||
//case RPC_ID__Req_GetSoftAPConnectedSTAList:
|
||||
//case RPC_ID__Req_StopSoftAP:
|
||||
case RPC_ID__Req_WifiGetPs:
|
||||
case RPC_ID__Req_OTABegin:
|
||||
case RPC_ID__Req_OTAEnd:
|
||||
case RPC_ID__Req_WifiDeinit:
|
||||
case RPC_ID__Req_WifiStart:
|
||||
case RPC_ID__Req_WifiStop:
|
||||
case RPC_ID__Req_WifiConnect:
|
||||
case RPC_ID__Req_WifiDisconnect:
|
||||
case RPC_ID__Req_WifiScanStop:
|
||||
case RPC_ID__Req_WifiScanGetApNum:
|
||||
case RPC_ID__Req_WifiClearApList:
|
||||
case RPC_ID__Req_WifiRestore:
|
||||
case RPC_ID__Req_WifiClearFastConnect:
|
||||
case RPC_ID__Req_WifiStaGetApInfo:
|
||||
case RPC_ID__Req_WifiGetMaxTxPower:
|
||||
case RPC_ID__Req_WifiGetChannel:
|
||||
case RPC_ID__Req_WifiGetCountryCode:
|
||||
case RPC_ID__Req_WifiGetCountry:
|
||||
case RPC_ID__Req_WifiApGetStaList:
|
||||
case RPC_ID__Req_WifiStaGetRssi:
|
||||
case RPC_ID__Req_WifiStaGetNegotiatedPhymode:
|
||||
case RPC_ID__Req_WifiStaGetAid:
|
||||
case RPC_ID__Req_WifiGetBand:
|
||||
case RPC_ID__Req_WifiGetBandMode:
|
||||
case RPC_ID__Req_WifiScanGetApRecord: {
|
||||
/* Intentional fallthrough & empty */
|
||||
break;
|
||||
} case RPC_ID__Req_GetMACAddress: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqGetMacAddress, req_get_mac_address,
|
||||
rpc__req__get_mac_address__init);
|
||||
|
||||
req_payload->mode = app_req->u.wifi_mac.mode;
|
||||
|
||||
break;
|
||||
} case RPC_ID__Req_SetMacAddress: {
|
||||
wifi_mac_t * p = &app_req->u.wifi_mac;
|
||||
RPC_ALLOC_ASSIGN(RpcReqSetMacAddress, req_set_mac_address,
|
||||
rpc__req__set_mac_address__init);
|
||||
|
||||
req_payload->mode = p->mode;
|
||||
RPC_REQ_COPY_BYTES(req_payload->mac, p->mac, BSSID_BYTES_SIZE);
|
||||
|
||||
break;
|
||||
} case RPC_ID__Req_SetWifiMode: {
|
||||
hosted_mode_t * p = &app_req->u.wifi_mode;
|
||||
RPC_ALLOC_ASSIGN(RpcReqSetMode, req_set_wifi_mode,
|
||||
rpc__req__set_mode__init);
|
||||
|
||||
if ((p->mode < WIFI_MODE_NULL) || (p->mode >= WIFI_MODE_MAX)) {
|
||||
ESP_LOGE(TAG, "Invalid wifi mode\n");
|
||||
*failure_status = RPC_ERR_INCORRECT_ARG;
|
||||
return FAILURE;
|
||||
}
|
||||
req_payload->mode = p->mode;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetPs: {
|
||||
wifi_power_save_t * p = &app_req->u.wifi_ps;
|
||||
RPC_ALLOC_ASSIGN(RpcReqSetPs, req_wifi_set_ps,
|
||||
rpc__req__set_ps__init);
|
||||
|
||||
req_payload->type = p->ps_mode;
|
||||
break;
|
||||
} case RPC_ID__Req_OTAWrite: {
|
||||
ota_write_t *p = & app_req->u.ota_write;
|
||||
RPC_ALLOC_ASSIGN(RpcReqOTAWrite, req_ota_write,
|
||||
rpc__req__otawrite__init);
|
||||
|
||||
if (!p->ota_data || (p->ota_data_len == 0)) {
|
||||
ESP_LOGE(TAG, "Invalid parameter\n");
|
||||
*failure_status = RPC_ERR_INCORRECT_ARG;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
req_payload->ota_data.data = p->ota_data;
|
||||
req_payload->ota_data.len = p->ota_data_len;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetMaxTxPower: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetMaxTxPower,
|
||||
req_set_wifi_max_tx_power,
|
||||
rpc__req__wifi_set_max_tx_power__init);
|
||||
req_payload->power = app_req->u.wifi_tx_power.power;
|
||||
break;
|
||||
} case RPC_ID__Req_ConfigHeartbeat: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqConfigHeartbeat, req_config_heartbeat,
|
||||
rpc__req__config_heartbeat__init);
|
||||
req_payload->enable = app_req->u.e_heartbeat.enable;
|
||||
req_payload->duration = app_req->u.e_heartbeat.duration;
|
||||
if (req_payload->enable) {
|
||||
ESP_LOGW(TAG, "Enable heartbeat with duration %ld\n", (long int)req_payload->duration);
|
||||
if (CALLBACK_AVAILABLE != is_event_callback_registered(RPC_ID__Event_Heartbeat))
|
||||
ESP_LOGW(TAG, "Note: ** Subscribe heartbeat event to get notification **\n");
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Disable Heartbeat\n");
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Req_WifiInit: {
|
||||
wifi_init_config_t * p_a = &app_req->u.wifi_init_config;
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiInit, req_wifi_init,
|
||||
rpc__req__wifi_init__init);
|
||||
RPC_ALLOC_ELEMENT(WifiInitConfig, req_payload->cfg, wifi_init_config__init);
|
||||
|
||||
req_payload->cfg->static_rx_buf_num = p_a->static_rx_buf_num ;
|
||||
req_payload->cfg->dynamic_rx_buf_num = p_a->dynamic_rx_buf_num ;
|
||||
req_payload->cfg->tx_buf_type = p_a->tx_buf_type ;
|
||||
req_payload->cfg->static_tx_buf_num = p_a->static_tx_buf_num ;
|
||||
req_payload->cfg->dynamic_tx_buf_num = p_a->dynamic_tx_buf_num ;
|
||||
req_payload->cfg->cache_tx_buf_num = p_a->cache_tx_buf_num ;
|
||||
req_payload->cfg->csi_enable = p_a->csi_enable ;
|
||||
req_payload->cfg->ampdu_rx_enable = p_a->ampdu_rx_enable ;
|
||||
req_payload->cfg->ampdu_tx_enable = p_a->ampdu_tx_enable ;
|
||||
req_payload->cfg->amsdu_tx_enable = p_a->amsdu_tx_enable ;
|
||||
req_payload->cfg->nvs_enable = p_a->nvs_enable ;
|
||||
req_payload->cfg->nano_enable = p_a->nano_enable ;
|
||||
req_payload->cfg->rx_ba_win = p_a->rx_ba_win ;
|
||||
req_payload->cfg->wifi_task_core_id = p_a->wifi_task_core_id ;
|
||||
req_payload->cfg->beacon_max_len = p_a->beacon_max_len ;
|
||||
req_payload->cfg->mgmt_sbuf_num = p_a->mgmt_sbuf_num ;
|
||||
req_payload->cfg->sta_disconnected_pm = p_a->sta_disconnected_pm ;
|
||||
req_payload->cfg->espnow_max_encrypt_num = p_a->espnow_max_encrypt_num ;
|
||||
req_payload->cfg->magic = p_a->magic ;
|
||||
|
||||
/* uint64 - TODO: portable? */
|
||||
req_payload->cfg->feature_caps = p_a->feature_caps ;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiGetConfig: {
|
||||
wifi_cfg_t * p_a = &app_req->u.wifi_config;
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiGetConfig, req_wifi_get_config,
|
||||
rpc__req__wifi_get_config__init);
|
||||
|
||||
req_payload->iface = p_a->iface;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetConfig: {
|
||||
wifi_cfg_t * p_a = &app_req->u.wifi_config;
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetConfig, req_wifi_set_config,
|
||||
rpc__req__wifi_set_config__init);
|
||||
|
||||
req_payload->iface = p_a->iface;
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiConfig, req_payload->cfg, wifi_config__init);
|
||||
|
||||
switch(req_payload->iface) {
|
||||
|
||||
case WIFI_IF_STA: {
|
||||
req_payload->cfg->u_case = WIFI_CONFIG__U_STA;
|
||||
|
||||
wifi_sta_config_t *p_a_sta = &p_a->u.sta;
|
||||
RPC_ALLOC_ELEMENT(WifiStaConfig, req_payload->cfg->sta, wifi_sta_config__init);
|
||||
WifiStaConfig *p_c_sta = req_payload->cfg->sta;
|
||||
RPC_REQ_COPY_STR(p_c_sta->ssid, p_a_sta->ssid, SSID_LENGTH);
|
||||
|
||||
RPC_REQ_COPY_STR(p_c_sta->password, p_a_sta->password, PASSWORD_LENGTH);
|
||||
|
||||
p_c_sta->scan_method = p_a_sta->scan_method;
|
||||
p_c_sta->bssid_set = p_a_sta->bssid_set;
|
||||
|
||||
if (p_a_sta->bssid_set)
|
||||
RPC_REQ_COPY_BYTES(p_c_sta->bssid, p_a_sta->bssid, BSSID_BYTES_SIZE);
|
||||
|
||||
p_c_sta->channel = p_a_sta->channel;
|
||||
p_c_sta->listen_interval = p_a_sta->listen_interval;
|
||||
p_c_sta->sort_method = p_a_sta->sort_method;
|
||||
RPC_ALLOC_ELEMENT(WifiScanThreshold, p_c_sta->threshold, wifi_scan_threshold__init);
|
||||
p_c_sta->threshold->rssi = p_a_sta->threshold.rssi;
|
||||
p_c_sta->threshold->authmode = p_a_sta->threshold.authmode;
|
||||
RPC_ALLOC_ELEMENT(WifiPmfConfig, p_c_sta->pmf_cfg, wifi_pmf_config__init);
|
||||
p_c_sta->pmf_cfg->capable = p_a_sta->pmf_cfg.capable;
|
||||
p_c_sta->pmf_cfg->required = p_a_sta->pmf_cfg.required;
|
||||
|
||||
if (p_a_sta->rm_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_rm_enabled, p_c_sta->bitmask);
|
||||
|
||||
if (p_a_sta->btm_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_btm_enabled, p_c_sta->bitmask);
|
||||
|
||||
if (p_a_sta->mbo_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_mbo_enabled, p_c_sta->bitmask);
|
||||
|
||||
if (p_a_sta->ft_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_ft_enabled, p_c_sta->bitmask);
|
||||
|
||||
if (p_a_sta->owe_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_owe_enabled, p_c_sta->bitmask);
|
||||
|
||||
if (p_a_sta->transition_disable)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_1_transition_disable, p_c_sta->bitmask);
|
||||
|
||||
#if H_WIFI_VHT_FIELDS_AVAILABLE
|
||||
if (p_a_sta->vht_su_beamformee_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_su_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->vht_mu_beamformee_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_mu_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->vht_mcs8_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_mcs8_enabled, p_c_sta->he_bitmask);
|
||||
#endif
|
||||
|
||||
#if H_DECODE_WIFI_RESERVED_FIELD
|
||||
#if H_WIFI_NEW_RESERVED_FIELD_NAMES
|
||||
WIFI_STA_CONFIG_2_SET_RESERVED_VAL(p_a_sta->reserved2, p_c_sta->he_bitmask);
|
||||
#else
|
||||
WIFI_STA_CONFIG_2_SET_RESERVED_VAL(p_a_sta->he_reserved, p_c_sta->he_bitmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
p_c_sta->sae_pwe_h2e = p_a_sta->sae_pwe_h2e;
|
||||
p_c_sta->failure_retry_cnt = p_a_sta->failure_retry_cnt;
|
||||
|
||||
if (p_a_sta->he_dcm_set)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_dcm_set_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
// WIFI_HE_STA_CONFIG_he_dcm_max_constellation_tx is two bits wide
|
||||
if (p_a_sta->he_dcm_max_constellation_tx)
|
||||
p_c_sta->he_bitmask |= ((p_a_sta->he_dcm_max_constellation_tx & 0x03) << WIFI_STA_CONFIG_2_he_dcm_max_constellation_tx_BITS);
|
||||
|
||||
// WIFI_HE_STA_CONFIG_he_dcm_max_constellation_rx is two bits wide
|
||||
if (p_a_sta->he_dcm_max_constellation_rx)
|
||||
p_c_sta->he_bitmask |= ((p_a_sta->he_dcm_max_constellation_rx & 0x03) << WIFI_STA_CONFIG_2_he_dcm_max_constellation_rx_BITS);
|
||||
|
||||
if (p_a_sta->he_mcs9_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_mcs9_enabled_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->he_su_beamformee_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_su_beamformee_disabled_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->he_trig_su_bmforming_feedback_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_trig_su_bmforming_feedback_disabled_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->he_trig_mu_bmforming_partial_feedback_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_trig_mu_bmforming_partial_feedback_disabled_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->he_trig_cqi_feedback_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_he_trig_cqi_feedback_disabled_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
#if H_WIFI_VHT_FIELDS_AVAILABLE
|
||||
if (p_a_sta->vht_su_beamformee_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_su_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->vht_mu_beamformee_disabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_mu_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
|
||||
if (p_a_sta->vht_mcs8_enabled)
|
||||
H_SET_BIT(WIFI_STA_CONFIG_2_vht_mcs8_enabled, p_c_sta->he_bitmask);
|
||||
#endif
|
||||
|
||||
#if H_DECODE_WIFI_RESERVED_FIELD
|
||||
#if H_WIFI_NEW_RESERVED_FIELD_NAMES
|
||||
WIFI_STA_CONFIG_2_SET_RESERVED_VAL(p_a_sta->reserved2, p_c_sta->he_bitmask);
|
||||
#else
|
||||
WIFI_STA_CONFIG_2_SET_RESERVED_VAL(p_a_sta->he_reserved, p_c_sta->he_bitmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
RPC_REQ_COPY_BYTES(p_c_sta->sae_h2e_identifier, p_a_sta->sae_h2e_identifier, SAE_H2E_IDENTIFIER_LEN);
|
||||
break;
|
||||
} case WIFI_IF_AP: {
|
||||
req_payload->cfg->u_case = WIFI_CONFIG__U_AP;
|
||||
|
||||
wifi_ap_config_t * p_a_ap = &p_a->u.ap;
|
||||
RPC_ALLOC_ELEMENT(WifiApConfig, req_payload->cfg->ap, wifi_ap_config__init);
|
||||
WifiApConfig * p_c_ap = req_payload->cfg->ap;
|
||||
|
||||
RPC_REQ_COPY_STR(p_c_ap->ssid, p_a_ap->ssid, SSID_LENGTH);
|
||||
RPC_REQ_COPY_STR(p_c_ap->password, p_a_ap->password, PASSWORD_LENGTH);
|
||||
p_c_ap->ssid_len = p_a_ap->ssid_len;
|
||||
p_c_ap->channel = p_a_ap->channel;
|
||||
p_c_ap->authmode = p_a_ap->authmode;
|
||||
p_c_ap->ssid_hidden = p_a_ap->ssid_hidden;
|
||||
p_c_ap->max_connection = p_a_ap->max_connection;
|
||||
p_c_ap->beacon_interval = p_a_ap->beacon_interval;
|
||||
p_c_ap->pairwise_cipher = p_a_ap->pairwise_cipher;
|
||||
p_c_ap->ftm_responder = p_a_ap->ftm_responder;
|
||||
RPC_ALLOC_ELEMENT(WifiPmfConfig, p_c_ap->pmf_cfg, wifi_pmf_config__init);
|
||||
p_c_ap->pmf_cfg->capable = p_a_ap->pmf_cfg.capable;
|
||||
p_c_ap->pmf_cfg->required = p_a_ap->pmf_cfg.required;
|
||||
break;
|
||||
} default: {
|
||||
ESP_LOGE(TAG, "unexpected wifi iface [%u]\n", p_a->iface);
|
||||
break;
|
||||
}
|
||||
|
||||
} /* switch */
|
||||
break;
|
||||
|
||||
} case RPC_ID__Req_WifiScanStart: {
|
||||
wifi_scan_config_t * p_a = &app_req->u.wifi_scan_config.cfg;
|
||||
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiScanStart, req_wifi_scan_start,
|
||||
rpc__req__wifi_scan_start__init);
|
||||
|
||||
req_payload->block = app_req->u.wifi_scan_config.block;
|
||||
if (app_req->u.wifi_scan_config.cfg_set) {
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiScanConfig, req_payload->config, wifi_scan_config__init);
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiScanTime , req_payload->config->scan_time, wifi_scan_time__init);
|
||||
RPC_ALLOC_ELEMENT(WifiActiveScanTime, req_payload->config->scan_time->active, wifi_active_scan_time__init);
|
||||
ESP_LOGD(TAG, "scan start4\n");
|
||||
|
||||
WifiScanConfig *p_c = req_payload->config;
|
||||
WifiScanTime *p_c_st = NULL;
|
||||
wifi_scan_time_t *p_a_st = &p_a->scan_time;
|
||||
|
||||
RPC_REQ_COPY_STR(p_c->ssid, p_a->ssid, SSID_LENGTH);
|
||||
RPC_REQ_COPY_STR(p_c->bssid, p_a->bssid, MAC_SIZE_BYTES);
|
||||
p_c->channel = p_a->channel;
|
||||
p_c->show_hidden = p_a->show_hidden;
|
||||
p_c->scan_type = p_a->scan_type;
|
||||
|
||||
p_c_st = p_c->scan_time;
|
||||
|
||||
p_c_st->passive = p_a_st->passive;
|
||||
p_c_st->active->min = p_a_st->active.min ;
|
||||
p_c_st->active->max = p_a_st->active.max ;
|
||||
|
||||
p_c->home_chan_dwell_time = p_a->home_chan_dwell_time;
|
||||
|
||||
req_payload->config_set = 1;
|
||||
}
|
||||
ESP_LOGI(TAG, "Scan start Req\n");
|
||||
|
||||
break;
|
||||
|
||||
} case RPC_ID__Req_WifiScanGetApRecords: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiScanGetApRecords, req_wifi_scan_get_ap_records,
|
||||
rpc__req__wifi_scan_get_ap_records__init);
|
||||
req_payload->number = app_req->u.wifi_scan_ap_list.number;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiDeauthSta: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiDeauthSta, req_wifi_deauth_sta,
|
||||
rpc__req__wifi_deauth_sta__init);
|
||||
req_payload->aid = app_req->u.wifi_deauth_sta.aid;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetStorage: {
|
||||
wifi_storage_t * p = &app_req->u.wifi_storage;
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetStorage, req_wifi_set_storage,
|
||||
rpc__req__wifi_set_storage__init);
|
||||
req_payload->storage = *p;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetBandwidth: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetBandwidth, req_wifi_set_bandwidth,
|
||||
rpc__req__wifi_set_bandwidth__init);
|
||||
req_payload->ifx = app_req->u.wifi_bandwidth.ifx;
|
||||
req_payload->bw = app_req->u.wifi_bandwidth.bw;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiGetBandwidth: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiGetBandwidth, req_wifi_get_bandwidth,
|
||||
rpc__req__wifi_get_bandwidth__init);
|
||||
req_payload->ifx = app_req->u.wifi_bandwidth.ifx;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetChannel: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetChannel, req_wifi_set_channel,
|
||||
rpc__req__wifi_set_channel__init);
|
||||
req_payload->primary = app_req->u.wifi_channel.primary;
|
||||
req_payload->second = app_req->u.wifi_channel.second;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetCountryCode: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetCountryCode, req_wifi_set_country_code,
|
||||
rpc__req__wifi_set_country_code__init);
|
||||
RPC_REQ_COPY_BYTES(req_payload->country, (uint8_t *)&app_req->u.wifi_country_code.cc[0], sizeof(app_req->u.wifi_country_code.cc));
|
||||
req_payload->ieee80211d_enabled = app_req->u.wifi_country_code.ieee80211d_enabled;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetCountry: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetCountry, req_wifi_set_country,
|
||||
rpc__req__wifi_set_country__init);
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiCountry, req_payload->country, wifi_country__init);
|
||||
RPC_REQ_COPY_BYTES(req_payload->country->cc, (uint8_t *)&app_req->u.wifi_country.cc[0], sizeof(app_req->u.wifi_country.cc));
|
||||
req_payload->country->schan = app_req->u.wifi_country.schan;
|
||||
req_payload->country->nchan = app_req->u.wifi_country.nchan;
|
||||
req_payload->country->max_tx_power = app_req->u.wifi_country.max_tx_power;
|
||||
req_payload->country->policy = app_req->u.wifi_country.policy;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiApGetStaAid: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiApGetStaAid, req_wifi_ap_get_sta_aid,
|
||||
rpc__req__wifi_ap_get_sta_aid__init);
|
||||
|
||||
uint8_t * p = &app_req->u.wifi_ap_get_sta_aid.mac[0];
|
||||
RPC_REQ_COPY_BYTES(req_payload->mac, p, MAC_SIZE_BYTES);
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetProtocol: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetProtocol, req_wifi_set_protocol,
|
||||
rpc__req__wifi_set_protocol__init);
|
||||
req_payload->ifx = app_req->u.wifi_protocol.ifx;
|
||||
req_payload->protocol_bitmap = app_req->u.wifi_protocol.protocol_bitmap;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiGetProtocol: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiGetProtocol, req_wifi_get_protocol,
|
||||
rpc__req__wifi_get_protocol__init);
|
||||
req_payload->ifx = app_req->u.wifi_protocol.ifx;
|
||||
break;
|
||||
} case RPC_ID__Req_GetCoprocessorFwVersion: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqGetCoprocessorFwVersion, req_get_coprocessor_fwversion,
|
||||
rpc__req__get_coprocessor_fw_version__init);
|
||||
break;
|
||||
#if H_WIFI_DUALBAND_SUPPORT
|
||||
} case RPC_ID__Req_WifiSetProtocols: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetProtocols, req_wifi_set_protocols,
|
||||
rpc__req__wifi_set_protocols__init);
|
||||
req_payload->ifx = app_req->u.wifi_protocols.ifx;
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiProtocols, req_payload->protocols, wifi_protocols__init);
|
||||
req_payload->protocols->ghz_2g = app_req->u.wifi_protocols.ghz_2g;
|
||||
req_payload->protocols->ghz_5g = app_req->u.wifi_protocols.ghz_5g;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiGetProtocols: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiGetProtocols, req_wifi_get_protocols,
|
||||
rpc__req__wifi_get_protocols__init);
|
||||
req_payload->ifx = app_req->u.wifi_protocols.ifx;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetBandwidths: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetBandwidths, req_wifi_set_bandwidths,
|
||||
rpc__req__wifi_set_bandwidths__init);
|
||||
req_payload->ifx = app_req->u.wifi_bandwidths.ifx;
|
||||
|
||||
RPC_ALLOC_ELEMENT(WifiBandwidths, req_payload->bandwidths, wifi_bandwidths__init);
|
||||
req_payload->bandwidths->ghz_2g = app_req->u.wifi_bandwidths.ghz_2g;
|
||||
req_payload->bandwidths->ghz_5g = app_req->u.wifi_bandwidths.ghz_5g;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiGetBandwidths: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiGetBandwidths, req_wifi_get_bandwidths,
|
||||
rpc__req__wifi_get_bandwidths__init);
|
||||
req_payload->ifx = app_req->u.wifi_bandwidths.ifx;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetBand: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetBand, req_wifi_set_band,
|
||||
rpc__req__wifi_set_band__init);
|
||||
req_payload->band = app_req->u.wifi_band;
|
||||
break;
|
||||
} case RPC_ID__Req_WifiSetBandMode: {
|
||||
RPC_ALLOC_ASSIGN(RpcReqWifiSetBandMode, req_wifi_set_bandmode,
|
||||
rpc__req__wifi_set_band_mode__init);
|
||||
req_payload->bandmode = app_req->u.wifi_band_mode;
|
||||
break;
|
||||
#endif
|
||||
} default: {
|
||||
*failure_status = RPC_ERR_UNSUPPORTED_MSG;
|
||||
ESP_LOGE(TAG, "Unsupported RPC Req[%u]",req->msg_id);
|
||||
return FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
} /* switch */
|
||||
return SUCCESS;
|
||||
}
|
||||
624
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_rsp.c
Normal file
624
resources/espressif__esp_hosted/host/drivers/rpc/core/rpc_rsp.c
Normal file
@@ -0,0 +1,624 @@
|
||||
// Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
|
||||
|
||||
#include "rpc_core.h"
|
||||
#include "rpc_slave_if.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_hosted_wifi_config.h"
|
||||
#include "esp_hosted_transport.h"
|
||||
#include "esp_hosted_bitmasks.h"
|
||||
#include "esp_idf_version.h"
|
||||
#include "esp_hosted_config.h"
|
||||
|
||||
DEFINE_LOG_TAG(rpc_rsp);
|
||||
|
||||
/* RPC response is result of remote function invokation at slave from host
|
||||
* The response will contain the return values of the RPC procedure
|
||||
* Return values typically will be simple integer return value of rpc call
|
||||
* for simple procedures. For function call with return value as a parameter,
|
||||
* RPC will contain full structure returned for that parameter and wrapper
|
||||
* level above will return these in expected pointer
|
||||
*
|
||||
* Responses will typically have two levels:
|
||||
* 1. protobuf level response received
|
||||
* 2. parse the response so that Ctrl_cmd_t app structure will be populated
|
||||
* or parsed from protobuf level response.
|
||||
*
|
||||
* For new RPC request, add up switch case for your message
|
||||
* For altogether new RPC function addition, please check
|
||||
* esp_hosted_fg/common/proto/esp_hosted_config.proto as a start point
|
||||
*/
|
||||
|
||||
#define RPC_ERR_IN_RESP(msGparaM) \
|
||||
if (rpc_msg->msGparaM->resp) { \
|
||||
app_resp->resp_event_status = rpc_msg->msGparaM->resp; \
|
||||
ESP_LOGW(TAG, "Hosted RPC_Resp [0x%"PRIx16"], uid [%"PRIu32"], resp code [%"PRIi32"]", \
|
||||
app_resp->msg_id, app_resp->uid, app_resp->resp_event_status); \
|
||||
goto fail_parse_rpc_msg; \
|
||||
}
|
||||
|
||||
|
||||
#define RPC_RSP_COPY_BYTES(dst,src) { \
|
||||
if (src.data && src.len) { \
|
||||
g_h.funcs->_h_memcpy(dst, src.data, src.len); \
|
||||
} \
|
||||
}
|
||||
|
||||
// copy the rpc record info to the wifi record info
|
||||
static int rpc_copy_ap_record(wifi_ap_record_t *ap_record, WifiApRecord *rpc_ap_record)
|
||||
{
|
||||
RPC_RSP_COPY_BYTES(ap_record->ssid, rpc_ap_record->ssid);
|
||||
RPC_RSP_COPY_BYTES(ap_record->bssid, rpc_ap_record->bssid);
|
||||
|
||||
ap_record->primary = rpc_ap_record->primary;
|
||||
ap_record->second = rpc_ap_record->second;
|
||||
ap_record->rssi = rpc_ap_record->rssi;
|
||||
ap_record->authmode = rpc_ap_record->authmode;
|
||||
ap_record->pairwise_cipher = rpc_ap_record->pairwise_cipher;
|
||||
ap_record->group_cipher = rpc_ap_record->group_cipher;
|
||||
ap_record->ant = rpc_ap_record->ant;
|
||||
|
||||
ap_record->phy_11b = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11b_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_11g = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11g_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_11n = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11n_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_lr = H_GET_BIT(WIFI_SCAN_AP_REC_phy_lr_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_11a = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11a_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_11ac = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11ac_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->phy_11ax = H_GET_BIT(WIFI_SCAN_AP_REC_phy_11ax_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->wps = H_GET_BIT(WIFI_SCAN_AP_REC_wps_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->ftm_responder = H_GET_BIT(WIFI_SCAN_AP_REC_ftm_responder_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->ftm_initiator = H_GET_BIT(WIFI_SCAN_AP_REC_ftm_initiator_BIT, rpc_ap_record->bitmask);
|
||||
ap_record->reserved = WIFI_SCAN_AP_GET_RESERVED_VAL(rpc_ap_record->bitmask);
|
||||
|
||||
RPC_RSP_COPY_BYTES(ap_record->country.cc, rpc_ap_record->country->cc);
|
||||
ap_record->country.schan = rpc_ap_record->country->schan;
|
||||
ap_record->country.nchan = rpc_ap_record->country->nchan;
|
||||
ap_record->country.max_tx_power = rpc_ap_record->country->max_tx_power;
|
||||
ap_record->country.policy = rpc_ap_record->country->policy;
|
||||
|
||||
ESP_LOGD(TAG, "SSID: %s BSSid: " MACSTR, ap_record->ssid, MAC2STR(ap_record->bssid));
|
||||
ESP_LOGD(TAG, "Primary: %u Second: %u RSSI: %d Authmode: %u",
|
||||
ap_record->primary, ap_record->second,
|
||||
ap_record->rssi, ap_record->authmode
|
||||
);
|
||||
ESP_LOGD(TAG, "PairwiseCipher: %u Groupcipher: %u Ant: %u",
|
||||
ap_record->pairwise_cipher, ap_record->group_cipher,
|
||||
ap_record->ant
|
||||
);
|
||||
ESP_LOGD(TAG, "Bitmask: 11b:%u g:%u n:%u ax: %u lr:%u wps:%u ftm_resp:%u ftm_ini:%u res: %u",
|
||||
ap_record->phy_11b, ap_record->phy_11g,
|
||||
ap_record->phy_11n, ap_record->phy_11ax, ap_record->phy_lr,
|
||||
ap_record->wps, ap_record->ftm_responder,
|
||||
ap_record->ftm_initiator, ap_record->reserved
|
||||
);
|
||||
ESP_LOGD(TAG, "Country cc:%c%c schan: %u nchan: %u max_tx_pow: %d policy: %u",
|
||||
ap_record->country.cc[0], ap_record->country.cc[1], ap_record->country.schan,
|
||||
ap_record->country.nchan, ap_record->country.max_tx_power,
|
||||
ap_record->country.policy);
|
||||
|
||||
WifiHeApInfo *p_c_he_ap = rpc_ap_record->he_ap;
|
||||
wifi_he_ap_info_t *p_a_he_ap = &ap_record->he_ap;
|
||||
// six bits
|
||||
p_a_he_ap->bss_color = p_c_he_ap->bitmask & 0x3F;
|
||||
p_a_he_ap->partial_bss_color = H_GET_BIT(WIFI_HE_AP_INFO_partial_bss_color_BIT, p_c_he_ap->bitmask);
|
||||
p_a_he_ap->bss_color_disabled = H_GET_BIT(WIFI_HE_AP_INFO_bss_color_disabled_BIT, p_c_he_ap->bitmask);
|
||||
|
||||
ESP_LOGD(TAG, "HE_AP: bss_color %d, partial_bss_color %d, bss_color_disabled %d",
|
||||
p_a_he_ap->bss_color, p_a_he_ap->bss_color_disabled, p_a_he_ap->bss_color_disabled);
|
||||
|
||||
ap_record->bandwidth = rpc_ap_record->bandwidth;
|
||||
ap_record->vht_ch_freq1 = rpc_ap_record->vht_ch_freq1;
|
||||
ap_record->vht_ch_freq2 = rpc_ap_record->vht_ch_freq2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This will copy rpc response from `Rpc` into
|
||||
* application structure `ctrl_cmd_t`
|
||||
* This function is called after protobuf decoding is successful
|
||||
**/
|
||||
int rpc_parse_rsp(Rpc *rpc_msg, ctrl_cmd_t *app_resp)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
|
||||
/* 1. Check non NULL */
|
||||
if (!rpc_msg || !app_resp) {
|
||||
ESP_LOGE(TAG, "NULL rpc resp or NULL App Resp");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
|
||||
/* 2. update basic fields */
|
||||
app_resp->msg_type = RPC_TYPE__Resp;
|
||||
app_resp->msg_id = rpc_msg->msg_id;
|
||||
app_resp->uid = rpc_msg->uid;
|
||||
ESP_LOGI(TAG, " --> RPC_Resp [0x%x], uid %ld", app_resp->msg_id, app_resp->uid);
|
||||
|
||||
/* 3. parse Rpc into ctrl_cmd_t */
|
||||
switch (rpc_msg->msg_id) {
|
||||
|
||||
case RPC_ID__Resp_GetMACAddress : {
|
||||
RPC_FAIL_ON_NULL(resp_get_mac_address);
|
||||
RPC_ERR_IN_RESP(resp_get_mac_address);
|
||||
RPC_FAIL_ON_NULL(resp_get_mac_address->mac.data);
|
||||
|
||||
RPC_RSP_COPY_BYTES(app_resp->u.wifi_mac.mac, rpc_msg->resp_get_mac_address->mac);
|
||||
ESP_LOGD(TAG, "Mac addr: "MACSTR, MAC2STR(app_resp->u.wifi_mac.mac));
|
||||
break;
|
||||
} case RPC_ID__Resp_SetMacAddress : {
|
||||
RPC_FAIL_ON_NULL(resp_set_mac_address);
|
||||
RPC_ERR_IN_RESP(resp_set_mac_address);
|
||||
break;
|
||||
} case RPC_ID__Resp_GetWifiMode : {
|
||||
RPC_FAIL_ON_NULL(resp_get_wifi_mode);
|
||||
RPC_ERR_IN_RESP(resp_get_wifi_mode);
|
||||
|
||||
app_resp->u.wifi_mode.mode = rpc_msg->resp_get_wifi_mode->mode;
|
||||
break;
|
||||
} case RPC_ID__Resp_SetWifiMode : {
|
||||
RPC_FAIL_ON_NULL(resp_set_wifi_mode);
|
||||
RPC_ERR_IN_RESP(resp_set_wifi_mode);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetPs: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_ps);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_ps);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetPs : {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_ps);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_ps);
|
||||
app_resp->u.wifi_ps.ps_mode = rpc_msg->resp_wifi_get_ps->type;
|
||||
break;
|
||||
} case RPC_ID__Resp_OTABegin : {
|
||||
RPC_FAIL_ON_NULL(resp_ota_begin);
|
||||
RPC_ERR_IN_RESP(resp_ota_begin);
|
||||
if (rpc_msg->resp_ota_begin->resp) {
|
||||
ESP_LOGE(TAG, "OTA Begin Failed");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Resp_OTAWrite : {
|
||||
RPC_FAIL_ON_NULL(resp_ota_write);
|
||||
RPC_ERR_IN_RESP(resp_ota_write);
|
||||
if (rpc_msg->resp_ota_write->resp) {
|
||||
ESP_LOGE(TAG, "OTA write failed");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Resp_OTAEnd: {
|
||||
RPC_FAIL_ON_NULL(resp_ota_end);
|
||||
if (rpc_msg->resp_ota_end->resp) {
|
||||
ESP_LOGE(TAG, "OTA write failed");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetMaxTxPower: {
|
||||
RPC_FAIL_ON_NULL(resp_set_wifi_max_tx_power);
|
||||
RPC_ERR_IN_RESP(resp_set_wifi_max_tx_power);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetMaxTxPower: {
|
||||
RPC_FAIL_ON_NULL(resp_get_wifi_max_tx_power);
|
||||
RPC_ERR_IN_RESP(resp_get_wifi_max_tx_power);
|
||||
app_resp->u.wifi_tx_power.power =
|
||||
rpc_msg->resp_get_wifi_max_tx_power->power;
|
||||
break;
|
||||
} case RPC_ID__Resp_ConfigHeartbeat: {
|
||||
RPC_FAIL_ON_NULL(resp_config_heartbeat);
|
||||
RPC_ERR_IN_RESP(resp_config_heartbeat);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiInit: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_init);
|
||||
RPC_ERR_IN_RESP(resp_wifi_init);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiDeinit: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_deinit);
|
||||
RPC_ERR_IN_RESP(resp_wifi_deinit);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStart: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_start);
|
||||
RPC_ERR_IN_RESP(resp_wifi_start);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStop: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_stop);
|
||||
RPC_ERR_IN_RESP(resp_wifi_stop);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiConnect: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_connect);
|
||||
RPC_ERR_IN_RESP(resp_wifi_connect);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiDisconnect: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_disconnect);
|
||||
RPC_ERR_IN_RESP(resp_wifi_disconnect);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetConfig: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_config);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_config);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetConfig: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_config);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_config);
|
||||
|
||||
app_resp->u.wifi_config.iface = rpc_msg->resp_wifi_get_config->iface;
|
||||
|
||||
switch (app_resp->u.wifi_config.iface) {
|
||||
|
||||
case WIFI_IF_STA: {
|
||||
wifi_sta_config_t * p_a_sta = &(app_resp->u.wifi_config.u.sta);
|
||||
WifiStaConfig * p_c_sta = rpc_msg->resp_wifi_get_config->cfg->sta;
|
||||
RPC_RSP_COPY_BYTES(p_a_sta->ssid, p_c_sta->ssid);
|
||||
RPC_RSP_COPY_BYTES(p_a_sta->password, p_c_sta->password);
|
||||
p_a_sta->scan_method = p_c_sta->scan_method;
|
||||
p_a_sta->bssid_set = p_c_sta->bssid_set;
|
||||
|
||||
if (p_a_sta->bssid_set)
|
||||
RPC_RSP_COPY_BYTES(p_a_sta->bssid, p_c_sta->bssid);
|
||||
|
||||
p_a_sta->channel = p_c_sta->channel;
|
||||
p_a_sta->listen_interval = p_c_sta->listen_interval;
|
||||
p_a_sta->sort_method = p_c_sta->sort_method;
|
||||
p_a_sta->threshold.rssi = p_c_sta->threshold->rssi;
|
||||
p_a_sta->threshold.authmode = p_c_sta->threshold->authmode;
|
||||
//p_a_sta->ssid_hidden = p_c_sta->ssid_hidden;
|
||||
//p_a_sta->max_connections = p_c_sta->max_connections;
|
||||
p_a_sta->pmf_cfg.capable = p_c_sta->pmf_cfg->capable;
|
||||
p_a_sta->pmf_cfg.required = p_c_sta->pmf_cfg->required;
|
||||
|
||||
p_a_sta->rm_enabled = H_GET_BIT(WIFI_STA_CONFIG_1_rm_enabled, p_c_sta->bitmask);
|
||||
p_a_sta->btm_enabled = H_GET_BIT(WIFI_STA_CONFIG_1_btm_enabled, p_c_sta->bitmask);
|
||||
p_a_sta->mbo_enabled = H_GET_BIT(WIFI_STA_CONFIG_1_mbo_enabled, p_c_sta->bitmask);
|
||||
p_a_sta->ft_enabled = H_GET_BIT(WIFI_STA_CONFIG_1_ft_enabled, p_c_sta->bitmask);
|
||||
p_a_sta->owe_enabled = H_GET_BIT(WIFI_STA_CONFIG_1_owe_enabled, p_c_sta->bitmask);
|
||||
p_a_sta->transition_disable = H_GET_BIT(WIFI_STA_CONFIG_1_transition_disable, p_c_sta->bitmask);
|
||||
|
||||
#if H_DECODE_WIFI_RESERVED_FIELD
|
||||
#if H_WIFI_NEW_RESERVED_FIELD_NAMES
|
||||
p_a_sta->reserved1 = WIFI_STA_CONFIG_1_GET_RESERVED_VAL(p_c_sta->bitmask);
|
||||
#else
|
||||
p_a_sta->reserved = WIFI_STA_CONFIG_1_GET_RESERVED_VAL(p_c_sta->bitmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
p_a_sta->sae_pwe_h2e = p_c_sta->sae_pwe_h2e;
|
||||
p_a_sta->failure_retry_cnt = p_c_sta->failure_retry_cnt;
|
||||
|
||||
p_a_sta->he_dcm_set = H_GET_BIT(WIFI_STA_CONFIG_2_he_dcm_set_BIT, p_c_sta->he_bitmask);
|
||||
|
||||
// WIFI_HE_STA_CONFIG_he_dcm_max_constellation_tx is two bits wide
|
||||
p_a_sta->he_dcm_max_constellation_tx = (p_c_sta->he_bitmask >> WIFI_STA_CONFIG_2_he_dcm_max_constellation_tx_BITS) & 0x03;
|
||||
// WIFI_HE_STA_CONFIG_he_dcm_max_constellation_rx is two bits wide
|
||||
p_a_sta->he_dcm_max_constellation_rx = (p_c_sta->he_bitmask >> WIFI_STA_CONFIG_2_he_dcm_max_constellation_rx_BITS) & 0x03;
|
||||
p_a_sta->he_mcs9_enabled = H_GET_BIT(WIFI_STA_CONFIG_2_he_mcs9_enabled_BIT, p_c_sta->he_bitmask);
|
||||
p_a_sta->he_su_beamformee_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_he_su_beamformee_disabled_BIT, p_c_sta->he_bitmask);
|
||||
p_a_sta->he_trig_su_bmforming_feedback_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_he_trig_su_bmforming_feedback_disabled_BIT, p_c_sta->bitmask);
|
||||
p_a_sta->he_trig_mu_bmforming_partial_feedback_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_he_trig_mu_bmforming_partial_feedback_disabled_BIT, p_c_sta->bitmask);
|
||||
p_a_sta->he_trig_cqi_feedback_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_he_trig_cqi_feedback_disabled_BIT, p_c_sta->bitmask);
|
||||
|
||||
#if H_WIFI_VHT_FIELDS_AVAILABLE
|
||||
p_a_sta->vht_su_beamformee_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_vht_su_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
p_a_sta->vht_mu_beamformee_disabled = H_GET_BIT(WIFI_STA_CONFIG_2_vht_mu_beamformee_disabled, p_c_sta->he_bitmask);
|
||||
p_a_sta->vht_mcs8_enabled = H_GET_BIT(WIFI_STA_CONFIG_2_vht_mcs8_enabled, p_c_sta->he_bitmask);
|
||||
#endif
|
||||
|
||||
#if H_DECODE_WIFI_RESERVED_FIELD
|
||||
#if H_WIFI_NEW_RESERVED_FIELD_NAMES
|
||||
p_a_sta->reserved2 = WIFI_STA_CONFIG_2_GET_RESERVED_VAL(p_c_sta->he_bitmask);
|
||||
#else
|
||||
p_a_sta->he_reserved = WIFI_STA_CONFIG_2_GET_RESERVED_VAL(p_c_sta->he_bitmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
case WIFI_IF_AP: {
|
||||
wifi_ap_config_t * p_a_ap = &(app_resp->u.wifi_config.u.ap);
|
||||
WifiApConfig * p_c_ap = rpc_msg->resp_wifi_get_config->cfg->ap;
|
||||
|
||||
RPC_RSP_COPY_BYTES(p_a_ap->ssid, p_c_ap->ssid);
|
||||
RPC_RSP_COPY_BYTES(p_a_ap->password, p_c_ap->password);
|
||||
p_a_ap->ssid_len = p_c_ap->ssid_len;
|
||||
p_a_ap->channel = p_c_ap->channel;
|
||||
p_a_ap->authmode = p_c_ap->authmode;
|
||||
p_a_ap->ssid_hidden = p_c_ap->ssid_hidden;
|
||||
p_a_ap->max_connection = p_c_ap->max_connection;
|
||||
p_a_ap->beacon_interval = p_c_ap->beacon_interval;
|
||||
p_a_ap->pairwise_cipher = p_c_ap->pairwise_cipher;
|
||||
p_a_ap->ftm_responder = p_c_ap->ftm_responder;
|
||||
p_a_ap->pmf_cfg.capable = p_c_ap->pmf_cfg->capable;
|
||||
p_a_ap->pmf_cfg.required = p_c_ap->pmf_cfg->required;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unsupported WiFi interface[%u]", app_resp->u.wifi_config.iface);
|
||||
} //switch
|
||||
|
||||
break;
|
||||
|
||||
} case RPC_ID__Resp_WifiScanStart: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_start);
|
||||
RPC_ERR_IN_RESP(resp_wifi_scan_start);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiScanStop: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_stop);
|
||||
RPC_ERR_IN_RESP(resp_wifi_scan_stop);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiScanGetApNum: {
|
||||
wifi_scan_ap_list_t *p_a = &(app_resp->u.wifi_scan_ap_list);
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_get_ap_num);
|
||||
RPC_ERR_IN_RESP(resp_wifi_scan_get_ap_num);
|
||||
|
||||
p_a->number = rpc_msg->resp_wifi_scan_get_ap_num->number;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiScanGetApRecord: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_get_ap_records);
|
||||
RPC_ERR_IN_RESP(resp_wifi_scan_get_ap_records);
|
||||
|
||||
rpc_copy_ap_record(&(app_resp->u.wifi_ap_record),
|
||||
rpc_msg->resp_wifi_scan_get_ap_record->ap_record);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiScanGetApRecords: {
|
||||
wifi_scan_ap_list_t *p_a = &(app_resp->u.wifi_scan_ap_list);
|
||||
wifi_ap_record_t *list = NULL;
|
||||
WifiApRecord **p_c_list = NULL;
|
||||
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_get_ap_records);
|
||||
RPC_ERR_IN_RESP(resp_wifi_scan_get_ap_records);
|
||||
p_c_list = rpc_msg->resp_wifi_scan_get_ap_records->ap_records;
|
||||
|
||||
p_a->number = rpc_msg->resp_wifi_scan_get_ap_records->number;
|
||||
|
||||
if (!p_a->number) {
|
||||
ESP_LOGI(TAG, "No AP found");
|
||||
goto fail_parse_rpc_msg;
|
||||
}
|
||||
ESP_LOGD(TAG, "Num AP records: %u",
|
||||
app_resp->u.wifi_scan_ap_list.number);
|
||||
|
||||
RPC_FAIL_ON_NULL(resp_wifi_scan_get_ap_records->ap_records);
|
||||
|
||||
list = (wifi_ap_record_t*)g_h.funcs->_h_calloc(p_a->number,
|
||||
sizeof(wifi_ap_record_t));
|
||||
p_a->out_list = list;
|
||||
|
||||
RPC_FAIL_ON_NULL_PRINT(list, "Malloc Failed");
|
||||
|
||||
app_resp->app_free_buff_func = g_h.funcs->_h_free;
|
||||
app_resp->app_free_buff_hdl = list;
|
||||
|
||||
ESP_LOGD(TAG, "Number of available APs is %d", p_a->number);
|
||||
for (i=0; i<p_a->number; i++) {
|
||||
rpc_copy_ap_record(&list[i], p_c_list[i]);
|
||||
}
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStaGetApInfo: {
|
||||
WifiApRecord *p_c = NULL;
|
||||
wifi_ap_record_t *ap_info = NULL;
|
||||
wifi_scan_ap_list_t *p_a = &(app_resp->u.wifi_scan_ap_list);
|
||||
|
||||
RPC_FAIL_ON_NULL(resp_wifi_sta_get_ap_info);
|
||||
RPC_ERR_IN_RESP(resp_wifi_sta_get_ap_info);
|
||||
p_c = rpc_msg->resp_wifi_sta_get_ap_info->ap_record;
|
||||
|
||||
p_a->number = 1;
|
||||
|
||||
RPC_FAIL_ON_NULL(resp_wifi_sta_get_ap_info->ap_record);
|
||||
|
||||
ap_info = (wifi_ap_record_t*)g_h.funcs->_h_calloc(p_a->number,
|
||||
sizeof(wifi_ap_record_t));
|
||||
p_a->out_list = ap_info;
|
||||
|
||||
RPC_FAIL_ON_NULL_PRINT(ap_info, "Malloc Failed");
|
||||
|
||||
app_resp->app_free_buff_func = g_h.funcs->_h_free;
|
||||
app_resp->app_free_buff_hdl = ap_info;
|
||||
|
||||
rpc_copy_ap_record(ap_info, p_c);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiClearApList: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_clear_ap_list);
|
||||
RPC_ERR_IN_RESP(resp_wifi_clear_ap_list);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiRestore: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_restore);
|
||||
RPC_ERR_IN_RESP(resp_wifi_restore);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiClearFastConnect: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_clear_fast_connect);
|
||||
RPC_ERR_IN_RESP(resp_wifi_clear_fast_connect);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiDeauthSta: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_deauth_sta);
|
||||
RPC_ERR_IN_RESP(resp_wifi_deauth_sta);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetStorage: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_storage);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_storage);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetBandwidth: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_bandwidth);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_bandwidth);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetBandwidth: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_bandwidth);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_bandwidth);
|
||||
app_resp->u.wifi_bandwidth.bw =
|
||||
rpc_msg->resp_wifi_get_bandwidth->bw;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetChannel: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_channel);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_channel);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetChannel: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_channel);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_channel);
|
||||
app_resp->u.wifi_channel.primary =
|
||||
rpc_msg->resp_wifi_get_channel->primary;
|
||||
app_resp->u.wifi_channel.second =
|
||||
rpc_msg->resp_wifi_get_channel->second;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetCountryCode: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_country_code);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_country_code);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetCountryCode: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_country_code);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_country_code);
|
||||
|
||||
RPC_RSP_COPY_BYTES(&app_resp->u.wifi_country_code.cc[0],
|
||||
rpc_msg->resp_wifi_get_country_code->country);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetCountry: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_country);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_country);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetCountry: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_country);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_country);
|
||||
|
||||
RPC_RSP_COPY_BYTES(&app_resp->u.wifi_country.cc[0],
|
||||
rpc_msg->resp_wifi_get_country->country->cc);
|
||||
app_resp->u.wifi_country.schan = rpc_msg->resp_wifi_get_country->country->schan;
|
||||
app_resp->u.wifi_country.nchan = rpc_msg->resp_wifi_get_country->country->nchan;
|
||||
app_resp->u.wifi_country.max_tx_power = rpc_msg->resp_wifi_get_country->country->max_tx_power;
|
||||
app_resp->u.wifi_country.policy = rpc_msg->resp_wifi_get_country->country->policy;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiApGetStaList: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_ap_get_sta_list);
|
||||
RPC_ERR_IN_RESP(resp_wifi_ap_get_sta_list);
|
||||
|
||||
// handle case where slave's num is bigger than our ESP_WIFI_MAX_CONN_NUM
|
||||
uint32_t num_stations = rpc_msg->resp_wifi_ap_get_sta_list->sta_list->num;
|
||||
if (num_stations > ESP_WIFI_MAX_CONN_NUM) {
|
||||
ESP_LOGW(TAG, "Slave returned %ld connected stations, but we can only accept %d items", num_stations, ESP_WIFI_MAX_CONN_NUM);
|
||||
num_stations = ESP_WIFI_MAX_CONN_NUM;
|
||||
}
|
||||
|
||||
WifiStaInfo ** p_c_sta_list = rpc_msg->resp_wifi_ap_get_sta_list->sta_list->sta;
|
||||
|
||||
for (int i = 0; i < num_stations; i++) {
|
||||
wifi_sta_info_t * p_a_sta = &app_resp->u.wifi_ap_sta_list.sta[i];
|
||||
|
||||
RPC_RSP_COPY_BYTES(p_a_sta->mac, p_c_sta_list[i]->mac);
|
||||
p_a_sta->rssi = p_c_sta_list[i]->rssi;
|
||||
|
||||
p_a_sta->phy_11b = H_GET_BIT(WIFI_STA_INFO_phy_11b_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->phy_11g = H_GET_BIT(WIFI_STA_INFO_phy_11g_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->phy_11n = H_GET_BIT(WIFI_STA_INFO_phy_11n_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->phy_lr = H_GET_BIT(WIFI_STA_INFO_phy_lr_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->phy_11ax = H_GET_BIT(WIFI_STA_INFO_phy_11ax_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->is_mesh_child = H_GET_BIT(WIFI_STA_INFO_is_mesh_child_BIT, p_c_sta_list[i]->bitmask);
|
||||
p_a_sta->reserved = WIFI_STA_INFO_GET_RESERVED_VAL(p_c_sta_list[i]->bitmask);
|
||||
}
|
||||
|
||||
app_resp->u.wifi_ap_sta_list.num = rpc_msg->resp_wifi_ap_get_sta_list->sta_list->num;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiApGetStaAid: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_ap_get_sta_aid);
|
||||
RPC_ERR_IN_RESP(resp_wifi_ap_get_sta_aid);
|
||||
|
||||
app_resp->u.wifi_ap_get_sta_aid.aid = rpc_msg->resp_wifi_ap_get_sta_aid->aid;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStaGetRssi: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_sta_get_rssi);
|
||||
RPC_ERR_IN_RESP(resp_wifi_sta_get_rssi);
|
||||
|
||||
app_resp->u.wifi_sta_get_rssi.rssi = rpc_msg->resp_wifi_sta_get_rssi->rssi;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetProtocol: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_protocol);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_protocol);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetProtocol: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_protocol);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_protocol);
|
||||
app_resp->u.wifi_protocol.protocol_bitmap =
|
||||
rpc_msg->resp_wifi_get_protocol->protocol_bitmap;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStaGetNegotiatedPhymode: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_sta_get_negotiated_phymode);
|
||||
RPC_ERR_IN_RESP(resp_wifi_sta_get_negotiated_phymode);
|
||||
app_resp->u.wifi_sta_get_negotiated_phymode.phymode =
|
||||
rpc_msg->resp_wifi_sta_get_negotiated_phymode->phymode;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiStaGetAid: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_sta_get_aid);
|
||||
RPC_ERR_IN_RESP(resp_wifi_sta_get_aid);
|
||||
app_resp->u.wifi_sta_get_aid.aid =
|
||||
rpc_msg->resp_wifi_sta_get_aid->aid;
|
||||
break;
|
||||
} case RPC_ID__Resp_GetCoprocessorFwVersion: {
|
||||
RPC_FAIL_ON_NULL(resp_get_coprocessor_fwversion);
|
||||
RPC_ERR_IN_RESP(resp_get_coprocessor_fwversion);
|
||||
app_resp->u.coprocessor_fwversion.major1 =
|
||||
rpc_msg->resp_get_coprocessor_fwversion->major1;
|
||||
app_resp->u.coprocessor_fwversion.minor1 =
|
||||
rpc_msg->resp_get_coprocessor_fwversion->minor1;
|
||||
app_resp->u.coprocessor_fwversion.patch1 =
|
||||
rpc_msg->resp_get_coprocessor_fwversion->patch1;
|
||||
break;
|
||||
#if H_WIFI_DUALBAND_SUPPORT
|
||||
} case RPC_ID__Resp_WifiSetProtocols: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_protocols);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_protocols);
|
||||
app_resp->u.wifi_protocols.ifx =
|
||||
rpc_msg->resp_wifi_set_protocols->ifx;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetProtocols: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_protocols);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_protocols);
|
||||
app_resp->u.wifi_protocols.ifx =
|
||||
rpc_msg->resp_wifi_get_protocols->ifx;
|
||||
app_resp->u.wifi_protocols.ghz_2g =
|
||||
rpc_msg->resp_wifi_get_protocols->protocols->ghz_2g;
|
||||
app_resp->u.wifi_protocols.ghz_5g =
|
||||
rpc_msg->resp_wifi_get_protocols->protocols->ghz_5g;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetBandwidths: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_bandwidths);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_bandwidths);
|
||||
app_resp->u.wifi_bandwidths.ifx =
|
||||
rpc_msg->resp_wifi_set_bandwidths->ifx;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetBandwidths: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_bandwidths);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_bandwidths);
|
||||
app_resp->u.wifi_bandwidths.ifx =
|
||||
rpc_msg->resp_wifi_get_bandwidths->ifx;
|
||||
app_resp->u.wifi_bandwidths.ghz_2g =
|
||||
rpc_msg->resp_wifi_get_bandwidths->bandwidths->ghz_2g;
|
||||
app_resp->u.wifi_bandwidths.ghz_5g =
|
||||
rpc_msg->resp_wifi_get_bandwidths->bandwidths->ghz_5g;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetBand: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_country_code);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_country_code);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetBand: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_band);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_band);
|
||||
app_resp->u.wifi_band =
|
||||
rpc_msg->resp_wifi_get_band->band;
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiSetBandMode: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_set_country_code);
|
||||
RPC_ERR_IN_RESP(resp_wifi_set_country_code);
|
||||
break;
|
||||
} case RPC_ID__Resp_WifiGetBandMode: {
|
||||
RPC_FAIL_ON_NULL(resp_wifi_get_bandmode);
|
||||
RPC_ERR_IN_RESP(resp_wifi_get_bandmode);
|
||||
app_resp->u.wifi_band_mode =
|
||||
rpc_msg->resp_wifi_get_bandmode->bandmode;
|
||||
break;
|
||||
#endif
|
||||
} default: {
|
||||
ESP_LOGE(TAG, "Unsupported rpc Resp[%u]", rpc_msg->msg_id);
|
||||
goto fail_parse_rpc_msg;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app_resp->resp_event_status = SUCCESS;
|
||||
return SUCCESS;
|
||||
|
||||
/* 5. Free up buffers in failure cases */
|
||||
fail_parse_rpc_msg:
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Espressif Systems Wireless LAN device driver
|
||||
*
|
||||
* Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
|
||||
*/
|
||||
#include "rpc_slave_if.h"
|
||||
#include "rpc_core.h"
|
||||
#include "esp_hosted_wifi_config.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
DEFINE_LOG_TAG(rpc_api);
|
||||
|
||||
#define RPC_SEND_REQ(msGiD) do { \
|
||||
assert(req); \
|
||||
req->msg_id = msGiD; \
|
||||
if(SUCCESS != rpc_send_req(req)) { \
|
||||
ESP_LOGE(TAG,"Failed to send control req 0x%x\n", req->msg_id); \
|
||||
return NULL; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define RPC_DECODE_RSP_IF_NOT_ASYNC() do { \
|
||||
if (req->rpc_rsp_cb) \
|
||||
return NULL; \
|
||||
return rpc_wait_and_parse_sync_resp(req); \
|
||||
} while(0);
|
||||
|
||||
|
||||
int rpc_slaveif_init(void)
|
||||
{
|
||||
ESP_LOGD(TAG, "%s", __func__);
|
||||
return rpc_core_init();
|
||||
}
|
||||
|
||||
int rpc_slaveif_deinit(void)
|
||||
{
|
||||
ESP_LOGD(TAG, "%s", __func__);
|
||||
return rpc_core_deinit();
|
||||
}
|
||||
|
||||
/** Control Req->Resp APIs **/
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_mac(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_GetMACAddress);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_mac(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_SetMacAddress);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_mode(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_GetWifiMode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_mode(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_SetWifiMode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_ps(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetPs);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_ps(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetPs);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_max_tx_power(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetMaxTxPower);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_max_tx_power(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetMaxTxPower);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_config_heartbeat(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_ConfigHeartbeat);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_ota_begin(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_OTABegin);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_ota_write(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_OTAWrite);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_ota_end(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_OTAEnd);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_init(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiInit);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_deinit(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiDeinit);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_start(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStart);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_stop(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStop);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_connect(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiConnect);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_disconnect(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiDisconnect);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_config(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetConfig);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_config(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetConfig);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_start(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiScanStart);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_stop(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiScanStop);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_num(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiScanGetApNum);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_record(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiScanGetApRecord);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_records(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiScanGetApRecords);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_clear_ap_list(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiClearApList);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_restore(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiRestore);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_clear_fast_connect(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiClearFastConnect);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_deauth_sta(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiDeauthSta);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_ap_info(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStaGetApInfo);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_storage(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetStorage);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_bandwidth(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetBandwidth);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_bandwidth(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetBandwidth);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_channel(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetChannel);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_channel(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetChannel);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_country_code(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetCountryCode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_country_code(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetCountryCode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_country(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetCountry);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_country(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetCountry);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_ap_get_sta_list(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiApGetStaList);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_ap_get_sta_aid(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiApGetStaAid);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_rssi(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStaGetRssi);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_protocol(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetProtocol);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_protocol(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetProtocol);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_negotiated_phymode(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStaGetNegotiatedPhymode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_aid(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiStaGetAid);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_protocols(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetProtocols);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_get_coprocessor_fwversion(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_GetCoprocessorFwVersion);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
#if H_WIFI_DUALBAND_SUPPORT
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_protocols(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetProtocols);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_bandwidths(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetBandwidths);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_bandwidths(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetBandwidths);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_band(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetBand);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_band(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetBand);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_band_mode(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiSetBandMode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_band_mode(ctrl_cmd_t *req)
|
||||
{
|
||||
RPC_SEND_REQ(RPC_ID__Req_WifiGetBandMode);
|
||||
RPC_DECODE_RSP_IF_NOT_ASYNC();
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,471 @@
|
||||
/*
|
||||
* Espressif Systems Wireless LAN device driver
|
||||
*
|
||||
* Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD
|
||||
* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
|
||||
*/
|
||||
|
||||
/** prevent recursive inclusion **/
|
||||
#ifndef __RPC_SLAVE_IF_H
|
||||
#define __RPC_SLAVE_IF_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_hosted_rpc.pb-c.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_hosted_wifi_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SSID_LENGTH 32
|
||||
#define BSSID_BYTES_SIZE 6
|
||||
#define PASSWORD_LENGTH 64
|
||||
#define STATUS_LENGTH 14
|
||||
#define VENDOR_OUI_BUF 3
|
||||
|
||||
/*
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1
|
||||
*/
|
||||
|
||||
#define CALLBACK_SET_SUCCESS 0
|
||||
#define CALLBACK_AVAILABLE 0
|
||||
#define CALLBACK_NOT_REGISTERED -1
|
||||
#define MSG_ID_OUT_OF_ORDER -2
|
||||
|
||||
#define MAX_FREE_BUFF_HANDLES 20
|
||||
|
||||
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
|
||||
/* If request is already being served and
|
||||
* another request is pending, time period for
|
||||
* which new request will wait in seconds
|
||||
* */
|
||||
//#define WAIT_TIME_B2B_RPC_REQ 5
|
||||
#define DEFAULT_RPC_RSP_TIMEOUT 5
|
||||
#define DEFAULT_RPC_RSP_SCAN_TIMEOUT 30
|
||||
|
||||
#define SUCCESS_STR "success"
|
||||
#define FAILURE_STR "failure"
|
||||
#define NOT_CONNECTED_STR "not_connected"
|
||||
|
||||
#define RPC_RX_QUEUE_SIZE 3
|
||||
#define RPC_TX_QUEUE_SIZE 5
|
||||
|
||||
/*---- Control structures ----*/
|
||||
|
||||
typedef struct {
|
||||
int mode;
|
||||
uint8_t mac[BSSID_BYTES_SIZE];
|
||||
} wifi_mac_t;
|
||||
|
||||
typedef struct {
|
||||
int mode;
|
||||
} hosted_mode_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t iface;
|
||||
wifi_config_t u;
|
||||
} wifi_cfg_t;
|
||||
|
||||
|
||||
/** @brief Parameters for an SSID scan. */
|
||||
typedef struct {
|
||||
bool block;
|
||||
wifi_scan_config_t cfg;
|
||||
uint8_t cfg_set;
|
||||
} wifi_scan_cfg_t;
|
||||
|
||||
typedef struct {
|
||||
//int count;
|
||||
int number;
|
||||
/* dynamic size */
|
||||
//wifi_scanlist_t *out_list;
|
||||
wifi_ap_record_t *out_list;
|
||||
} wifi_scan_ap_list_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t aid;
|
||||
} wifi_deauth_sta_t;
|
||||
|
||||
typedef struct {
|
||||
int ps_mode;
|
||||
} wifi_power_save_t;
|
||||
|
||||
typedef struct {
|
||||
bool enable;
|
||||
wifi_vendor_ie_type_t type;
|
||||
wifi_vendor_ie_id_t idx;
|
||||
vendor_ie_data_t vnd_ie;
|
||||
} wifi_softap_vendor_ie_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *ota_data;
|
||||
uint32_t ota_data_len;
|
||||
} ota_write_t;
|
||||
|
||||
typedef struct {
|
||||
int power;
|
||||
} wifi_tx_power_t;
|
||||
|
||||
typedef struct {
|
||||
wifi_interface_t ifx;
|
||||
wifi_bandwidth_t bw;
|
||||
} rpc_wifi_bandwidth_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t primary;
|
||||
wifi_second_chan_t second;
|
||||
} rpc_wifi_channel_t;
|
||||
|
||||
typedef struct {
|
||||
char cc[3];
|
||||
bool ieee80211d_enabled;
|
||||
} rpc_wifi_country_code;
|
||||
|
||||
typedef struct {
|
||||
wifi_interface_t ifx;
|
||||
uint8_t protocol_bitmap;
|
||||
} rpc_wifi_protocol;
|
||||
|
||||
typedef struct {
|
||||
uint8_t mac[6];
|
||||
uint16_t aid;
|
||||
} rpc_wifi_ap_get_sta_aid_t;
|
||||
|
||||
typedef struct {
|
||||
int rssi;
|
||||
} rpc_wifi_sta_get_rssi_t;
|
||||
|
||||
typedef struct {
|
||||
wifi_phy_mode_t phymode;
|
||||
} rpc_wifi_sta_get_negotiated_phymode_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t aid;
|
||||
} rpc_wifi_sta_get_aid_t;
|
||||
|
||||
typedef struct {
|
||||
wifi_interface_t ifx;
|
||||
uint16_t ghz_2g;
|
||||
uint16_t ghz_5g;
|
||||
} rpc_wifi_protocols_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t major1;
|
||||
uint32_t minor1;
|
||||
uint32_t patch1;
|
||||
} rpc_coprocessor_fwversion_t;
|
||||
|
||||
typedef struct {
|
||||
wifi_interface_t ifx;
|
||||
wifi_bandwidth_t ghz_2g;
|
||||
wifi_bandwidth_t ghz_5g;
|
||||
} rpc_wifi_bandwidths_t;
|
||||
|
||||
typedef struct {
|
||||
/* event */
|
||||
uint32_t hb_num;
|
||||
/* Req */
|
||||
uint8_t enable;
|
||||
uint32_t duration;
|
||||
} event_heartbeat_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t wifi_event_id;
|
||||
} event_wifi_simple_t;
|
||||
|
||||
typedef struct Ctrl_cmd_t {
|
||||
/* msg type could be 1. req 2. resp 3. notification */
|
||||
uint8_t msg_type;
|
||||
|
||||
/* control path protobuf msg number */
|
||||
uint16_t msg_id;
|
||||
|
||||
/* uid of request / response */
|
||||
uint32_t uid;
|
||||
|
||||
/* statusof response or notification */
|
||||
int32_t resp_event_status;
|
||||
|
||||
void * rx_sem;
|
||||
|
||||
union {
|
||||
wifi_init_config_t wifi_init_config;
|
||||
wifi_cfg_t wifi_config;
|
||||
wifi_mac_t wifi_mac;
|
||||
hosted_mode_t wifi_mode;
|
||||
|
||||
wifi_softap_vendor_ie_t wifi_softap_vendor_ie;
|
||||
//wifi_softap_conn_sta_list_t wifi_softap_con_sta;
|
||||
|
||||
wifi_power_save_t wifi_ps;
|
||||
|
||||
ota_write_t ota_write;
|
||||
|
||||
wifi_tx_power_t wifi_tx_power;
|
||||
|
||||
wifi_scan_cfg_t wifi_scan_config;
|
||||
|
||||
wifi_ap_record_t wifi_ap_record;
|
||||
|
||||
wifi_scan_ap_list_t wifi_scan_ap_list;
|
||||
|
||||
wifi_deauth_sta_t wifi_deauth_sta;
|
||||
|
||||
wifi_storage_t wifi_storage;
|
||||
|
||||
rpc_wifi_bandwidth_t wifi_bandwidth;
|
||||
|
||||
rpc_wifi_channel_t wifi_channel;
|
||||
|
||||
rpc_wifi_country_code wifi_country_code;
|
||||
|
||||
wifi_country_t wifi_country;
|
||||
|
||||
wifi_sta_list_t wifi_ap_sta_list;
|
||||
|
||||
rpc_wifi_ap_get_sta_aid_t wifi_ap_get_sta_aid;
|
||||
|
||||
rpc_wifi_sta_get_rssi_t wifi_sta_get_rssi;
|
||||
|
||||
rpc_wifi_protocol wifi_protocol;
|
||||
|
||||
rpc_wifi_sta_get_negotiated_phymode_t wifi_sta_get_negotiated_phymode;
|
||||
rpc_wifi_sta_get_aid_t wifi_sta_get_aid;
|
||||
|
||||
rpc_coprocessor_fwversion_t coprocessor_fwversion;
|
||||
|
||||
#if H_WIFI_DUALBAND_SUPPORT
|
||||
rpc_wifi_protocols_t wifi_protocols;
|
||||
|
||||
rpc_wifi_bandwidths_t wifi_bandwidths;
|
||||
|
||||
wifi_band_t wifi_band;
|
||||
|
||||
wifi_band_mode_t wifi_band_mode;
|
||||
#endif
|
||||
|
||||
event_heartbeat_t e_heartbeat;
|
||||
|
||||
event_wifi_simple_t e_wifi_simple;
|
||||
|
||||
wifi_event_ap_staconnected_t e_wifi_ap_staconnected;
|
||||
|
||||
wifi_event_ap_stadisconnected_t e_wifi_ap_stadisconnected;
|
||||
|
||||
wifi_event_sta_scan_done_t e_wifi_sta_scan_done;
|
||||
|
||||
wifi_event_sta_connected_t e_wifi_sta_connected;
|
||||
|
||||
wifi_event_sta_disconnected_t e_wifi_sta_disconnected;
|
||||
}u;
|
||||
|
||||
/* By default this callback is set to NULL.
|
||||
* When this callback is set by app while triggering request,
|
||||
* it will be automatically called asynchronously
|
||||
* by hosted control lib on receiving control response
|
||||
* in this case app will not be waiting for response.
|
||||
*
|
||||
* Whereas, when this is not set i.e. is NULL, it is understood
|
||||
* as synchronous response, and app after sending request,
|
||||
* will wait till getting a response
|
||||
*/
|
||||
int (*rpc_rsp_cb)(struct Ctrl_cmd_t *data);
|
||||
|
||||
/* Wait for timeout duration, if response not received,
|
||||
* it will send timeout response.
|
||||
* Default value for this time out is DEFAULT_RPC_RESP_TIMEOUT */
|
||||
int rsp_timeout_sec;
|
||||
|
||||
/* rpc takes only one request at a time.
|
||||
* If new request comes before previous command execution,
|
||||
* wait for previous command execution for these many seconds, else return failure.
|
||||
* Default: WAIT_TIME_B2B_RPC_REQ */
|
||||
int wait_prev_cmd_completion;
|
||||
|
||||
/* assign the data pointer to free by lower layer.
|
||||
* Ignored if assigned as NULL */
|
||||
void *app_free_buff_hdl;
|
||||
|
||||
/* free handle to be registered
|
||||
* Ignored if assigned as NULL */
|
||||
void (*app_free_buff_func)(void *app_free_buff_hdl);
|
||||
|
||||
void *rpc_free_buff_hdls[MAX_FREE_BUFF_HANDLES];
|
||||
uint8_t n_rpc_free_buff_hdls;
|
||||
} ctrl_cmd_t;
|
||||
|
||||
|
||||
/* resp callback */
|
||||
typedef int (*rpc_rsp_cb_t) (ctrl_cmd_t * resp);
|
||||
|
||||
/* event callback */
|
||||
typedef int (*rpc_evt_cb_t) (ctrl_cmd_t * event);
|
||||
|
||||
|
||||
/*---- Control API Function ----*/
|
||||
|
||||
|
||||
/* This file contains hosted control library exposed APIs.
|
||||
* For detailed documentation, Please refer `../../../docs/common/ctrl_apis.md`
|
||||
*
|
||||
* As important note, application using these APIs, should clean
|
||||
* 1. allocated buffer within library are saved in `app_resp->app_free_buff_hdl`
|
||||
* Please use `app_resp->app_free_buff_func` for freeing them.
|
||||
* 2. Response `ctrl_cmd_t *app_resp` is also allocated from library,
|
||||
* need to free using g_h.funcs->_h_free() function.
|
||||
**/
|
||||
|
||||
/* Set control event callback
|
||||
*
|
||||
* when user sets event callback, user provided function pointer
|
||||
* will be registered with user function
|
||||
* If user does not register event callback,
|
||||
* events received from ESP32 will be dropped
|
||||
*
|
||||
* Inputs:
|
||||
* > event - Control Event ID
|
||||
* > event_cb - NULL - resets event callback
|
||||
* Function pointer - Registers event callback
|
||||
* Returns:
|
||||
* > MSG_ID_OUT_OF_ORDER - If event is not registered with hosted control lib
|
||||
* > CALLBACK_SET_SUCCESS - Callback is set successful
|
||||
**/
|
||||
int set_event_callback(int event, rpc_rsp_cb_t event_cb);
|
||||
|
||||
/* Reset control event callback
|
||||
*
|
||||
* when user sets event callback, user provided function pointer
|
||||
* will be registered with user function
|
||||
* If user does not register event callback,
|
||||
* events received from ESP32 will be dropped
|
||||
*
|
||||
* Inputs:
|
||||
* > event - Control Event ID
|
||||
*
|
||||
* Returns:
|
||||
* > MSG_ID_OUT_OF_ORDER - If event is not registered with hosted control lib
|
||||
* > CALLBACK_SET_SUCCESS - Callback is set successful
|
||||
**/
|
||||
int reset_event_callback(int event);
|
||||
|
||||
|
||||
/* Initialize hosted control library
|
||||
*
|
||||
* This is first step for application while using control path
|
||||
* This will allocate and instantiate hosted control library
|
||||
*
|
||||
* Returns:
|
||||
* > SUCCESS - 0
|
||||
* > FAILURE - -1
|
||||
**/
|
||||
int rpc_slaveif_init(void);
|
||||
|
||||
/* De-initialize hosted control library
|
||||
*
|
||||
* This is last step for application while using control path
|
||||
* This will deallocate and cleanup hosted control library
|
||||
*
|
||||
* Returns:
|
||||
* > SUCCESS - 0
|
||||
* > FAILURE - -1
|
||||
**/
|
||||
int rpc_slaveif_deinit(void);
|
||||
|
||||
/* Get the MAC address of station or softAP interface of ESP32 */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_mac(ctrl_cmd_t *req);
|
||||
|
||||
/* Set MAC address of ESP32 interface for given wifi mode */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_mac(ctrl_cmd_t *req);
|
||||
|
||||
/* Get Wi-Fi mode of ESP32 */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_mode(ctrl_cmd_t *req);
|
||||
|
||||
/* Set the Wi-Fi mode of ESP32 */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_mode(ctrl_cmd_t *req);
|
||||
|
||||
/* Sets maximum WiFi transmitting power at ESP32 */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_max_tx_power(ctrl_cmd_t *req);
|
||||
|
||||
/* Gets maximum WiFi transmiting power at ESP32 */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_max_tx_power(ctrl_cmd_t *req);
|
||||
|
||||
/* Configure heartbeat event. Be default heartbeat is not enabled.
|
||||
* To enable heartbeats, user need to use this API in addition
|
||||
* to setting event callback for heartbeat event */
|
||||
ctrl_cmd_t * rpc_slaveif_config_heartbeat(ctrl_cmd_t *req);
|
||||
|
||||
/* Performs an OTA begin operation for ESP32 which erases and
|
||||
* prepares existing flash partition for new flash writing */
|
||||
ctrl_cmd_t * rpc_slaveif_ota_begin(ctrl_cmd_t *req);
|
||||
|
||||
/* Performs an OTA write operation for ESP32, It writes bytes from `ota_data`
|
||||
* buffer with `ota_data_len` number of bytes to OTA partition in flash. Number
|
||||
* of bytes can be small than size of complete binary to be flashed. In that
|
||||
* case, this caller is expected to repeatedly call this function till
|
||||
* total size written equals size of complete binary */
|
||||
ctrl_cmd_t * rpc_slaveif_ota_write(ctrl_cmd_t *req);
|
||||
|
||||
/* Performs an OTA end operation for ESP32, It validates written OTA image,
|
||||
* sets newly written OTA partition as boot partition for next boot,
|
||||
* Creates timer which reset ESP32 after 5 sec */
|
||||
ctrl_cmd_t * rpc_slaveif_ota_end(ctrl_cmd_t *req);
|
||||
|
||||
/* Gets the co-processor FW Version */
|
||||
ctrl_cmd_t * rpc_slaveif_get_coprocessor_fwversion(ctrl_cmd_t *req);
|
||||
|
||||
/* TODO: add descriptions */
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_init(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_deinit(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_start(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_stop(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_connect(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_disconnect(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_config(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_config(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_start(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_stop(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_num(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_record(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_scan_get_ap_records(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_clear_ap_list(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_restore(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_clear_fast_connect(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_deauth_sta(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_ap_info(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_ps(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_ps(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_storage(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_bandwidth(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_bandwidth(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_channel(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_channel(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_country_code(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_country_code(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_country(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_country(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_ap_get_sta_list(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_ap_get_sta_aid(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_rssi(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_protocol(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_protocol(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_negotiated_phymode(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_sta_get_aid(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_protocols(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_protocols(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_bandwidths(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_bandwidths(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_band(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_band(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_set_band_mode(ctrl_cmd_t *req);
|
||||
ctrl_cmd_t * rpc_slaveif_wifi_get_band_mode(ctrl_cmd_t *req);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1363
resources/espressif__esp_hosted/host/drivers/rpc/wrap/rpc_wrap.c
Normal file
1363
resources/espressif__esp_hosted/host/drivers/rpc/wrap/rpc_wrap.c
Normal file
File diff suppressed because it is too large
Load Diff
106
resources/espressif__esp_hosted/host/drivers/rpc/wrap/rpc_wrap.h
Normal file
106
resources/espressif__esp_hosted/host/drivers/rpc/wrap/rpc_wrap.h
Normal file
@@ -0,0 +1,106 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** prevent recursive inclusion **/
|
||||
#ifndef __RPC_WRAP_H__
|
||||
#define __RPC_WRAP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Includes **/
|
||||
#include "common.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_hosted_wifi_config.h"
|
||||
#include "esp_hosted_api_types.h"
|
||||
#include "esp_hosted_ota.h"
|
||||
|
||||
/** Exported variables **/
|
||||
|
||||
/** Inline functions **/
|
||||
|
||||
/** Exported Functions **/
|
||||
esp_err_t rpc_init(void);
|
||||
esp_err_t rpc_deinit(void);
|
||||
esp_err_t rpc_unregister_event_callbacks(void);
|
||||
esp_err_t rpc_register_event_callbacks(void);
|
||||
|
||||
esp_err_t rpc_wifi_init(const wifi_init_config_t *arg);
|
||||
esp_err_t rpc_wifi_deinit(void);
|
||||
esp_err_t rpc_wifi_set_mode(wifi_mode_t mode);
|
||||
esp_err_t rpc_wifi_get_mode(wifi_mode_t* mode);
|
||||
esp_err_t rpc_wifi_start(void);
|
||||
esp_err_t rpc_wifi_stop(void);
|
||||
esp_err_t rpc_wifi_connect(void);
|
||||
esp_err_t rpc_wifi_disconnect(void);
|
||||
esp_err_t rpc_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf);
|
||||
esp_err_t rpc_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf);
|
||||
esp_err_t rpc_wifi_get_mac(wifi_interface_t mode, uint8_t mac[6]);
|
||||
esp_err_t rpc_wifi_set_mac(wifi_interface_t mode, const uint8_t mac[6]);
|
||||
|
||||
esp_err_t rpc_wifi_scan_start(const wifi_scan_config_t *config, bool block);
|
||||
esp_err_t rpc_wifi_scan_stop(void);
|
||||
esp_err_t rpc_wifi_scan_get_ap_num(uint16_t *number);
|
||||
esp_err_t rpc_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record);
|
||||
esp_err_t rpc_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
|
||||
esp_err_t rpc_wifi_clear_ap_list(void);
|
||||
esp_err_t rpc_wifi_restore(void);
|
||||
esp_err_t rpc_wifi_clear_fast_connect(void);
|
||||
esp_err_t rpc_wifi_deauth_sta(uint16_t aid);
|
||||
esp_err_t rpc_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
|
||||
esp_err_t rpc_wifi_set_ps(wifi_ps_type_t type);
|
||||
esp_err_t rpc_wifi_get_ps(wifi_ps_type_t *type);
|
||||
esp_err_t rpc_wifi_set_storage(wifi_storage_t storage);
|
||||
esp_err_t rpc_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
|
||||
esp_err_t rpc_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
|
||||
esp_err_t rpc_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
|
||||
esp_err_t rpc_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
||||
esp_err_t rpc_wifi_set_country_code(const char *country, bool ieee80211d_enabled);
|
||||
esp_err_t rpc_wifi_get_country_code(char *country);
|
||||
esp_err_t rpc_wifi_set_country(const wifi_country_t *country);
|
||||
esp_err_t rpc_wifi_get_country(wifi_country_t *country);
|
||||
esp_err_t rpc_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
|
||||
esp_err_t rpc_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid);
|
||||
esp_err_t rpc_wifi_sta_get_rssi(int *rssi);
|
||||
esp_err_t rpc_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
|
||||
esp_err_t rpc_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
|
||||
esp_err_t rpc_wifi_set_max_tx_power(int8_t power);
|
||||
esp_err_t rpc_wifi_get_max_tx_power(int8_t *power);
|
||||
esp_err_t rpc_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode);
|
||||
esp_err_t rpc_wifi_sta_get_aid(uint16_t *aid);
|
||||
|
||||
esp_err_t rpc_get_coprocessor_fwversion(esp_hosted_coprocessor_fwver_t *ver_info);
|
||||
|
||||
esp_err_t rpc_ota_begin(void);
|
||||
esp_err_t rpc_ota_write(uint8_t* ota_data, uint32_t ota_data_len);
|
||||
esp_err_t rpc_ota_end(void);
|
||||
|
||||
#if H_WIFI_DUALBAND_SUPPORT
|
||||
esp_err_t rpc_wifi_set_band(wifi_band_t band);
|
||||
esp_err_t rpc_wifi_get_band(wifi_band_t *band);
|
||||
esp_err_t rpc_wifi_set_band_mode(wifi_band_mode_t band_mode);
|
||||
esp_err_t rpc_wifi_get_band_mode(wifi_band_mode_t *band_mode);
|
||||
esp_err_t rpc_wifi_set_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols);
|
||||
esp_err_t rpc_wifi_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols);
|
||||
esp_err_t rpc_wifi_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw);
|
||||
esp_err_t rpc_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user