Removed nanopb, use protobuf-c for nested decoding.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
624150181c
commit
59d47eb342
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,3 +1,3 @@
|
|||
[submodule "lib/nanopb"]
|
||||
path = lib/nanopb
|
||||
url = https://github.com/nanopb/nanopb.git
|
||||
[submodule "lib/protobuf-c"]
|
||||
path = lib/protobuf-c
|
||||
url = https://github.com/protobuf-c/protobuf-c.git
|
||||
|
|
|
@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.10)
|
|||
project(esp_nano_hosted)
|
||||
|
||||
set(NH_SOURCES
|
||||
"proto/esp_hosted_config.pb.c"
|
||||
"lib/protobuf-c/protobuf-c/protobuf-c.c"
|
||||
"proto/esp_hosted_config.pb-c.c"
|
||||
"src/nh_ctrl_api.c"
|
||||
"src/nh_helper_event.c"
|
||||
"src/nh_helper_serial.c"
|
||||
|
@ -12,15 +13,13 @@ set(NH_SOURCES
|
|||
|
||||
set(NH_INCLUDES
|
||||
"include"
|
||||
"lib/protobuf-c"
|
||||
"proto"
|
||||
)
|
||||
|
||||
set(NH_LIBS
|
||||
"protobuf-nanopb-static"
|
||||
)
|
||||
|
||||
add_subdirectory(lib/nanopb)
|
||||
|
||||
add_library(${PROJECT_NAME} ${NH_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${NH_INCLUDES})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${NH_LIBS})
|
|
@ -1 +0,0 @@
|
|||
Subproject commit b97aa657a706d3ba4a9a6ccca7043c9d6fe41cba
|
1
lib/protobuf-c
Submodule
1
lib/protobuf-c
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit abc67a11c6db271bedbb9f58be85d6f4e2ea8389
|
5087
proto/esp_hosted_config.pb-c.c
Normal file
5087
proto/esp_hosted_config.pb-c.c
Normal file
File diff suppressed because it is too large
Load Diff
1849
proto/esp_hosted_config.pb-c.h
Normal file
1849
proto/esp_hosted_config.pb-c.h
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,150 +0,0 @@
|
|||
/* Automatically generated nanopb constant definitions */
|
||||
/* Generated by nanopb-0.4.7 */
|
||||
|
||||
#include "esp_hosted_config.pb.h"
|
||||
#if PB_PROTO_HEADER_VERSION != 40
|
||||
#error Regenerate this file with the current version of nanopb generator.
|
||||
#endif
|
||||
|
||||
PB_BIND(ScanResult, ScanResult, AUTO)
|
||||
|
||||
|
||||
PB_BIND(ConnectedSTAList, ConnectedSTAList, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetMacAddress, CtrlMsg_Req_GetMacAddress, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetMacAddress, CtrlMsg_Resp_GetMacAddress, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetMode, CtrlMsg_Req_GetMode, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetMode, CtrlMsg_Resp_GetMode, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_SetMode, CtrlMsg_Req_SetMode, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_SetMode, CtrlMsg_Resp_SetMode, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetStatus, CtrlMsg_Req_GetStatus, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetStatus, CtrlMsg_Resp_GetStatus, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_SetMacAddress, CtrlMsg_Req_SetMacAddress, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_SetMacAddress, CtrlMsg_Resp_SetMacAddress, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetAPConfig, CtrlMsg_Req_GetAPConfig, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetAPConfig, CtrlMsg_Resp_GetAPConfig, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_ConnectAP, CtrlMsg_Req_ConnectAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_ConnectAP, CtrlMsg_Resp_ConnectAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetSoftAPConfig, CtrlMsg_Req_GetSoftAPConfig, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetSoftAPConfig, CtrlMsg_Resp_GetSoftAPConfig, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_StartSoftAP, CtrlMsg_Req_StartSoftAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_StartSoftAP, CtrlMsg_Resp_StartSoftAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_ScanResult, CtrlMsg_Req_ScanResult, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_ScanResult, CtrlMsg_Resp_ScanResult, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_SoftAPConnectedSTA, CtrlMsg_Req_SoftAPConnectedSTA, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_SoftAPConnectedSTA, CtrlMsg_Resp_SoftAPConnectedSTA, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_OTABegin, CtrlMsg_Req_OTABegin, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_OTABegin, CtrlMsg_Resp_OTABegin, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_OTAWrite, CtrlMsg_Req_OTAWrite, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_OTAWrite, CtrlMsg_Resp_OTAWrite, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_OTAEnd, CtrlMsg_Req_OTAEnd, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_OTAEnd, CtrlMsg_Resp_OTAEnd, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_VendorIEData, CtrlMsg_Req_VendorIEData, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_SetSoftAPVendorSpecificIE, CtrlMsg_Req_SetSoftAPVendorSpecificIE, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_SetSoftAPVendorSpecificIE, CtrlMsg_Resp_SetSoftAPVendorSpecificIE, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_SetWifiMaxTxPower, CtrlMsg_Req_SetWifiMaxTxPower, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_SetWifiMaxTxPower, CtrlMsg_Resp_SetWifiMaxTxPower, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_GetWifiCurrTxPower, CtrlMsg_Req_GetWifiCurrTxPower, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_GetWifiCurrTxPower, CtrlMsg_Resp_GetWifiCurrTxPower, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Req_ConfigHeartbeat, CtrlMsg_Req_ConfigHeartbeat, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Resp_ConfigHeartbeat, CtrlMsg_Resp_ConfigHeartbeat, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Event_ESPInit, CtrlMsg_Event_ESPInit, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Event_Heartbeat, CtrlMsg_Event_Heartbeat, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Event_StationDisconnectFromAP, CtrlMsg_Event_StationDisconnectFromAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg_Event_StationDisconnectFromESPSoftAP, CtrlMsg_Event_StationDisconnectFromESPSoftAP, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CtrlMsg, CtrlMsg, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,5 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import 'nanopb.proto';
|
||||
|
||||
/* Enums similar to ESP IDF */
|
||||
enum Ctrl_VendorIEType {
|
||||
Beacon = 0;
|
||||
|
@ -362,8 +360,6 @@ message CtrlMsg_Event_StationDisconnectFromESPSoftAP {
|
|||
}
|
||||
|
||||
message CtrlMsg {
|
||||
option (nanopb_msgopt).submsg_callback = true;
|
||||
|
||||
/* msg_type could be req, resp or Event */
|
||||
CtrlMsgType msg_type = 1;
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/* Private */
|
||||
#include "nh_ctrl_api.h"
|
||||
|
||||
/* Nano-PB */
|
||||
#include "pb_decode.h"
|
||||
#include "pb_encode.h"
|
||||
#include "protobuf-c/protobuf-c.h"
|
||||
|
||||
/* PB config */
|
||||
#include "esp_hosted_config.pb.h"
|
||||
#include "esp_hosted_config.pb-c.h"
|
||||
|
||||
#define NH_COMMAND_TIMEOUT_MSEC 30000
|
||||
#define NH_COMMAND_REQ_MEM_SIZE 256
|
||||
|
@ -55,21 +53,14 @@ nh_ret_t nh_ctrl_api_get_mac_address(nh_ctrl_api_t *api, uint8_t *mac_addr) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
CtrlMsg tx_msg = CtrlMsg_init_zero;
|
||||
|
||||
tx_msg.msg_type = CtrlMsgType_Req;
|
||||
tx_msg.msg_id = CtrlMsgId_Req_GetMACAddress;
|
||||
tx_msg.which_payload = CtrlMsg_req_get_mac_address_tag;
|
||||
tx_msg.payload.req_get_mac_address.mode = Ctrl_WifiMode_STA;
|
||||
CtrlMsg tx_msg;
|
||||
|
||||
ret = nh_ctrl_api_general_request(api, &tx_msg);
|
||||
if (ret != NH_RET_SUCCESS) {
|
||||
goto give_sem_exit;
|
||||
}
|
||||
|
||||
CtrlMsg rx_msg = CtrlMsg_init_zero;
|
||||
|
||||
rx_msg.cb_payload.arg = mac_addr;
|
||||
CtrlMsg rx_msg;
|
||||
|
||||
ret = nh_ctrl_api_general_response(api, &rx_msg);
|
||||
if (ret != NH_RET_SUCCESS) {
|
||||
|
@ -132,7 +123,7 @@ static nh_ret_t nh_ctrl_api_parse_event(nh_ctrl_api_t *api, CtrlMsgId *event_id,
|
|||
|
||||
static void nh_ctrl_api_dispatch_event(nh_ctrl_api_t *api, CtrlMsgId event_id) {
|
||||
switch (event_id) {
|
||||
case CtrlMsgId_Event_ESPInit: {
|
||||
case CTRL_MSG_ID__Event_ESPInit: {
|
||||
if (api->cb.init) {
|
||||
api->cb.init(api->user_data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user