wifi_provisioning: added wifi-ctrl reprov endpoint

This commit is contained in:
harshal.patil 2022-10-20 15:56:00 +05:30
parent dacf44dd1d
commit b7de443aaa
9 changed files with 341 additions and 17 deletions

View File

@ -155,6 +155,7 @@ exclude =
components/protocomm/python/sec1_pb2.py,
components/protocomm/python/sec2_pb2.py,
components/protocomm/python/session_pb2.py,
components/wifi_provisioning/python/wifi_ctrl_pb2.py,
components/wifi_provisioning/python/wifi_scan_pb2.py,
components/wifi_provisioning/python/wifi_config_pb2.py,
components/wifi_provisioning/python/wifi_constants_pb2.py,

View File

@ -97,6 +97,96 @@ void resp_ctrl_reset__free_unpacked
assert(message->base.descriptor == &resp_ctrl_reset__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void cmd_ctrl_reprov__init
(CmdCtrlReprov *message)
{
static const CmdCtrlReprov init_value = CMD_CTRL_REPROV__INIT;
*message = init_value;
}
size_t cmd_ctrl_reprov__get_packed_size
(const CmdCtrlReprov *message)
{
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t cmd_ctrl_reprov__pack
(const CmdCtrlReprov *message,
uint8_t *out)
{
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t cmd_ctrl_reprov__pack_to_buffer
(const CmdCtrlReprov *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
CmdCtrlReprov *
cmd_ctrl_reprov__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (CmdCtrlReprov *)
protobuf_c_message_unpack (&cmd_ctrl_reprov__descriptor,
allocator, len, data);
}
void cmd_ctrl_reprov__free_unpacked
(CmdCtrlReprov *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &cmd_ctrl_reprov__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void resp_ctrl_reprov__init
(RespCtrlReprov *message)
{
static const RespCtrlReprov init_value = RESP_CTRL_REPROV__INIT;
*message = init_value;
}
size_t resp_ctrl_reprov__get_packed_size
(const RespCtrlReprov *message)
{
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t resp_ctrl_reprov__pack
(const RespCtrlReprov *message,
uint8_t *out)
{
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t resp_ctrl_reprov__pack_to_buffer
(const RespCtrlReprov *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
RespCtrlReprov *
resp_ctrl_reprov__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (RespCtrlReprov *)
protobuf_c_message_unpack (&resp_ctrl_reprov__descriptor,
allocator, len, data);
}
void resp_ctrl_reprov__free_unpacked
(RespCtrlReprov *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &resp_ctrl_reprov__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void wi_fi_ctrl_payload__init
(WiFiCtrlPayload *message)
{
@ -178,7 +268,43 @@ const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor =
(ProtobufCMessageInit) resp_ctrl_reset__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor wi_fi_ctrl_payload__field_descriptors[4] =
#define cmd_ctrl_reprov__field_descriptors NULL
#define cmd_ctrl_reprov__field_indices_by_name NULL
#define cmd_ctrl_reprov__number_ranges NULL
const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"CmdCtrlReprov",
"CmdCtrlReprov",
"CmdCtrlReprov",
"",
sizeof(CmdCtrlReprov),
0,
cmd_ctrl_reprov__field_descriptors,
cmd_ctrl_reprov__field_indices_by_name,
0, cmd_ctrl_reprov__number_ranges,
(ProtobufCMessageInit) cmd_ctrl_reprov__init,
NULL,NULL,NULL /* reserved[123] */
};
#define resp_ctrl_reprov__field_descriptors NULL
#define resp_ctrl_reprov__field_indices_by_name NULL
#define resp_ctrl_reprov__number_ranges NULL
const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"RespCtrlReprov",
"RespCtrlReprov",
"RespCtrlReprov",
"",
sizeof(RespCtrlReprov),
0,
resp_ctrl_reprov__field_descriptors,
resp_ctrl_reprov__field_indices_by_name,
0, resp_ctrl_reprov__number_ranges,
(ProtobufCMessageInit) resp_ctrl_reprov__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor wi_fi_ctrl_payload__field_descriptors[6] =
{
{
"msg",
@ -228,10 +354,36 @@ static const ProtobufCFieldDescriptor wi_fi_ctrl_payload__field_descriptors[4] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"cmd_ctrl_reprov",
13,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(WiFiCtrlPayload, payload_case),
offsetof(WiFiCtrlPayload, cmd_ctrl_reprov),
&cmd_ctrl_reprov__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"resp_ctrl_reprov",
14,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(WiFiCtrlPayload, payload_case),
offsetof(WiFiCtrlPayload, resp_ctrl_reprov),
&resp_ctrl_reprov__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned wi_fi_ctrl_payload__field_indices_by_name[] = {
4, /* field[4] = cmd_ctrl_reprov */
2, /* field[2] = cmd_ctrl_reset */
0, /* field[0] = msg */
5, /* field[5] = resp_ctrl_reprov */
3, /* field[3] = resp_ctrl_reset */
1, /* field[1] = status */
};
@ -239,7 +391,7 @@ static const ProtobufCIntRange wi_fi_ctrl_payload__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 11, 2 },
{ 0, 4 }
{ 0, 6 }
};
const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor =
{
@ -249,26 +401,30 @@ const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor =
"WiFiCtrlPayload",
"",
sizeof(WiFiCtrlPayload),
4,
6,
wi_fi_ctrl_payload__field_descriptors,
wi_fi_ctrl_payload__field_indices_by_name,
2, wi_fi_ctrl_payload__number_ranges,
(ProtobufCMessageInit) wi_fi_ctrl_payload__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue wi_fi_ctrl_msg_type__enum_values_by_number[3] =
static const ProtobufCEnumValue wi_fi_ctrl_msg_type__enum_values_by_number[5] =
{
{ "TypeCtrlReserved", "WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved", 0 },
{ "TypeCmdCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset", 1 },
{ "TypeRespCtrlReset", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset", 2 },
{ "TypeCmdCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov", 3 },
{ "TypeRespCtrlReprov", "WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov", 4 },
};
static const ProtobufCIntRange wi_fi_ctrl_msg_type__value_ranges[] = {
{0, 0},{0, 3}
{0, 0},{0, 5}
};
static const ProtobufCEnumValueIndex wi_fi_ctrl_msg_type__enum_values_by_name[3] =
static const ProtobufCEnumValueIndex wi_fi_ctrl_msg_type__enum_values_by_name[5] =
{
{ "TypeCmdCtrlReprov", 3 },
{ "TypeCmdCtrlReset", 1 },
{ "TypeCtrlReserved", 0 },
{ "TypeRespCtrlReprov", 4 },
{ "TypeRespCtrlReset", 2 },
};
const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor =
@ -278,9 +434,9 @@ const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor =
"WiFiCtrlMsgType",
"WiFiCtrlMsgType",
"",
3,
5,
wi_fi_ctrl_msg_type__enum_values_by_number,
3,
5,
wi_fi_ctrl_msg_type__enum_values_by_name,
1,
wi_fi_ctrl_msg_type__value_ranges,

View File

@ -18,6 +18,8 @@ PROTOBUF_C__BEGIN_DECLS
typedef struct CmdCtrlReset CmdCtrlReset;
typedef struct RespCtrlReset RespCtrlReset;
typedef struct CmdCtrlReprov CmdCtrlReprov;
typedef struct RespCtrlReprov RespCtrlReprov;
typedef struct WiFiCtrlPayload WiFiCtrlPayload;
@ -26,7 +28,9 @@ typedef struct WiFiCtrlPayload WiFiCtrlPayload;
typedef enum _WiFiCtrlMsgType {
WI_FI_CTRL_MSG_TYPE__TypeCtrlReserved = 0,
WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset = 1,
WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset = 2
WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReset = 2,
WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov = 3,
WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov = 4
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_MSG_TYPE)
} WiFiCtrlMsgType;
@ -50,10 +54,30 @@ struct RespCtrlReset
}
struct CmdCtrlReprov
{
ProtobufCMessage base;
};
#define CMD_CTRL_REPROV__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&cmd_ctrl_reprov__descriptor) \
}
struct RespCtrlReprov
{
ProtobufCMessage base;
};
#define RESP_CTRL_REPROV__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&resp_ctrl_reprov__descriptor) \
}
typedef enum {
WI_FI_CTRL_PAYLOAD__PAYLOAD__NOT_SET = 0,
WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_RESET = 11,
WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET = 12
WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_RESET = 12,
WI_FI_CTRL_PAYLOAD__PAYLOAD_CMD_CTRL_REPROV = 13,
WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV = 14
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CTRL_PAYLOAD__PAYLOAD__CASE)
} WiFiCtrlPayload__PayloadCase;
@ -66,6 +90,8 @@ struct WiFiCtrlPayload
union {
CmdCtrlReset *cmd_ctrl_reset;
RespCtrlReset *resp_ctrl_reset;
CmdCtrlReprov *cmd_ctrl_reprov;
RespCtrlReprov *resp_ctrl_reprov;
};
};
#define WI_FI_CTRL_PAYLOAD__INIT \
@ -111,6 +137,44 @@ RespCtrlReset *
void resp_ctrl_reset__free_unpacked
(RespCtrlReset *message,
ProtobufCAllocator *allocator);
/* CmdCtrlReprov methods */
void cmd_ctrl_reprov__init
(CmdCtrlReprov *message);
size_t cmd_ctrl_reprov__get_packed_size
(const CmdCtrlReprov *message);
size_t cmd_ctrl_reprov__pack
(const CmdCtrlReprov *message,
uint8_t *out);
size_t cmd_ctrl_reprov__pack_to_buffer
(const CmdCtrlReprov *message,
ProtobufCBuffer *buffer);
CmdCtrlReprov *
cmd_ctrl_reprov__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void cmd_ctrl_reprov__free_unpacked
(CmdCtrlReprov *message,
ProtobufCAllocator *allocator);
/* RespCtrlReprov methods */
void resp_ctrl_reprov__init
(RespCtrlReprov *message);
size_t resp_ctrl_reprov__get_packed_size
(const RespCtrlReprov *message);
size_t resp_ctrl_reprov__pack
(const RespCtrlReprov *message,
uint8_t *out);
size_t resp_ctrl_reprov__pack_to_buffer
(const RespCtrlReprov *message,
ProtobufCBuffer *buffer);
RespCtrlReprov *
resp_ctrl_reprov__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void resp_ctrl_reprov__free_unpacked
(RespCtrlReprov *message,
ProtobufCAllocator *allocator);
/* WiFiCtrlPayload methods */
void wi_fi_ctrl_payload__init
(WiFiCtrlPayload *message);
@ -138,6 +202,12 @@ typedef void (*CmdCtrlReset_Closure)
typedef void (*RespCtrlReset_Closure)
(const RespCtrlReset *message,
void *closure_data);
typedef void (*CmdCtrlReprov_Closure)
(const CmdCtrlReprov *message,
void *closure_data);
typedef void (*RespCtrlReprov_Closure)
(const RespCtrlReprov *message,
void *closure_data);
typedef void (*WiFiCtrlPayload_Closure)
(const WiFiCtrlPayload *message,
void *closure_data);
@ -150,6 +220,8 @@ typedef void (*WiFiCtrlPayload_Closure)
extern const ProtobufCEnumDescriptor wi_fi_ctrl_msg_type__descriptor;
extern const ProtobufCMessageDescriptor cmd_ctrl_reset__descriptor;
extern const ProtobufCMessageDescriptor resp_ctrl_reset__descriptor;
extern const ProtobufCMessageDescriptor cmd_ctrl_reprov__descriptor;
extern const ProtobufCMessageDescriptor resp_ctrl_reprov__descriptor;
extern const ProtobufCMessageDescriptor wi_fi_ctrl_payload__descriptor;
PROTOBUF_C__END_DECLS

View File

@ -10,10 +10,20 @@ message RespCtrlReset {
}
message CmdCtrlReprov {
}
message RespCtrlReprov{
}
enum WiFiCtrlMsgType {
TypeCtrlReserved = 0;
TypeCmdCtrlReset = 1;
TypeRespCtrlReset = 2;
TypeCmdCtrlReprov = 3;
TypeRespCtrlReprov = 4;
}
message WiFiCtrlPayload {
@ -22,5 +32,7 @@ message WiFiCtrlPayload {
oneof payload {
CmdCtrlReset cmd_ctrl_reset = 11;
RespCtrlReset resp_ctrl_reset = 12;
CmdCtrlReprov cmd_ctrl_reprov = 13;
RespCtrlReprov resp_ctrl_reprov = 14;
}
}

View File

@ -14,19 +14,23 @@ _sym_db = _symbol_database.Default()
import constants_pb2 as constants__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_ctrl.proto\x1a\x0f\x63onstants.proto\"\x0e\n\x0c\x43mdCtrlReset\"\x0f\n\rRespCtrlReset\"\xa8\x01\n\x0fWiFiCtrlPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiCtrlMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_ctrl_reset\x18\x0b \x01(\x0b\x32\r.CmdCtrlResetH\x00\x12)\n\x0fresp_ctrl_reset\x18\x0c \x01(\x0b\x32\x0e.RespCtrlResetH\x00\x42\t\n\x07payload*T\n\x0fWiFiCtrlMsgType\x12\x14\n\x10TypeCtrlReserved\x10\x00\x12\x14\n\x10TypeCmdCtrlReset\x10\x01\x12\x15\n\x11TypeRespCtrlReset\x10\x02\x62\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fwifi_ctrl.proto\x1a\x0f\x63onstants.proto\"\x0e\n\x0c\x43mdCtrlReset\"\x0f\n\rRespCtrlReset\"\x0f\n\rCmdCtrlReprov\"\x10\n\x0eRespCtrlReprov\"\x80\x02\n\x0fWiFiCtrlPayload\x12\x1d\n\x03msg\x18\x01 \x01(\x0e\x32\x10.WiFiCtrlMsgType\x12\x17\n\x06status\x18\x02 \x01(\x0e\x32\x07.Status\x12\'\n\x0e\x63md_ctrl_reset\x18\x0b \x01(\x0b\x32\r.CmdCtrlResetH\x00\x12)\n\x0fresp_ctrl_reset\x18\x0c \x01(\x0b\x32\x0e.RespCtrlResetH\x00\x12)\n\x0f\x63md_ctrl_reprov\x18\r \x01(\x0b\x32\x0e.CmdCtrlReprovH\x00\x12+\n\x10resp_ctrl_reprov\x18\x0e \x01(\x0b\x32\x0f.RespCtrlReprovH\x00\x42\t\n\x07payload*\x83\x01\n\x0fWiFiCtrlMsgType\x12\x14\n\x10TypeCtrlReserved\x10\x00\x12\x14\n\x10TypeCmdCtrlReset\x10\x01\x12\x15\n\x11TypeRespCtrlReset\x10\x02\x12\x15\n\x11TypeCmdCtrlReprov\x10\x03\x12\x16\n\x12TypeRespCtrlReprov\x10\x04\x62\x06proto3')
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'wifi_ctrl_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_WIFICTRLMSGTYPE._serialized_start=240
_WIFICTRLMSGTYPE._serialized_end=324
_WIFICTRLMSGTYPE._serialized_start=364
_WIFICTRLMSGTYPE._serialized_end=495
_CMDCTRLRESET._serialized_start=36
_CMDCTRLRESET._serialized_end=50
_RESPCTRLRESET._serialized_start=52
_RESPCTRLRESET._serialized_end=67
_WIFICTRLPAYLOAD._serialized_start=70
_WIFICTRLPAYLOAD._serialized_end=238
_CMDCTRLREPROV._serialized_start=69
_CMDCTRLREPROV._serialized_end=84
_RESPCTRLREPROV._serialized_start=86
_RESPCTRLREPROV._serialized_end=102
_WIFICTRLPAYLOAD._serialized_start=105
_WIFICTRLPAYLOAD._serialized_end=361
# @@protoc_insertion_point(module_scope)

View File

@ -203,11 +203,17 @@ static esp_err_t ctrl_reset(void)
return wifi_prov_mgr_reset_sm_state_on_failure();
}
static esp_err_t ctrl_reprov(void)
{
return wifi_prov_mgr_reset_sm_state_for_reprovision();
}
esp_err_t get_wifi_ctrl_handlers(wifi_ctrl_handlers_t *ptr)
{
if (!ptr) {
return ESP_ERR_INVALID_ARG;
}
ptr->ctrl_reset = ctrl_reset;
ptr->ctrl_reprov = ctrl_reprov;
return ESP_OK;
}

View File

@ -25,11 +25,19 @@ static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req,
WiFiCtrlPayload *resp,
void *priv_data);
static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req,
WiFiCtrlPayload *resp,
void *priv_data);
static wifi_ctrl_cmd_t cmd_table[] = {
{
.cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReset,
.command_handler = cmd_ctrl_reset_handler
},
{
.cmd_id = WI_FI_CTRL_MSG_TYPE__TypeCmdCtrlReprov,
.command_handler = cmd_ctrl_reprov_handler
},
};
static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req,
@ -55,6 +63,29 @@ static esp_err_t cmd_ctrl_reset_handler(WiFiCtrlPayload *req,
return ESP_OK;
}
static esp_err_t cmd_ctrl_reprov_handler(WiFiCtrlPayload *req,
WiFiCtrlPayload *resp, void *priv_data)
{
wifi_ctrl_handlers_t *h = (wifi_ctrl_handlers_t *) priv_data;
if (!h) {
ESP_LOGE(TAG, "Command invoked without handlers");
return ESP_ERR_INVALID_STATE;
}
RespCtrlReprov *resp_payload = (RespCtrlReprov *) malloc(sizeof(RespCtrlReprov));
if (!resp_payload) {
ESP_LOGE(TAG, "Error allocating memory");
return ESP_ERR_NO_MEM;
}
resp_ctrl_reprov__init(resp_payload);
resp->status = (h->ctrl_reprov() == ESP_OK ?
STATUS__Success : STATUS__InternalError);
resp->payload_case = WI_FI_CTRL_PAYLOAD__PAYLOAD_RESP_CTRL_REPROV;
resp->resp_ctrl_reprov = resp_payload;
return ESP_OK;
}
static int lookup_cmd_handler(int cmd_id)
{
for (size_t i = 0; i < sizeof(cmd_table)/sizeof(wifi_ctrl_cmd_t); i++) {
@ -74,6 +105,11 @@ static void wifi_ctrl_cmd_cleanup(WiFiCtrlPayload *resp, void *priv_data)
free(resp->resp_ctrl_reset);
}
break;
case WI_FI_CTRL_MSG_TYPE__TypeRespCtrlReprov:
{
free(resp->resp_ctrl_reprov);
}
break;
default:
ESP_LOGE(TAG, "Unsupported response type in cleanup_handler");
break;

View File

@ -290,7 +290,7 @@ async def wait_wifi_connected(tp, sec):
return False
async def reset_wifi(sel_transport, tp, sec):
async def reset_wifi(tp, sec):
try:
message = prov.ctrl_reset_request(sec)
response = await tp.send_data('prov-ctrl', message)
@ -301,6 +301,17 @@ async def reset_wifi(sel_transport, tp, sec):
return None
async def reprov_wifi(tp, sec):
try:
message = prov.ctrl_reprov_request(sec)
response = await tp.send_data('prov-ctrl', message)
prov.ctrl_reprov_response(sec, response)
except RuntimeError as e:
on_except(e)
return None
def desc_format(*args):
desc = ''
for arg in args:
@ -385,6 +396,8 @@ async def main():
parser.add_argument('--reset', help='Reset WiFi', action='store_true')
parser.add_argument('--reprov', help='Reprovision WiFi', action='store_true')
parser.add_argument('-v','--verbose', help='Increase output verbosity', action='store_true')
args = parser.parse_args()
@ -447,7 +460,12 @@ async def main():
if args.reset:
print('==== Reseting WiFi====')
await reset_wifi(args.mode.lower(), obj_transport, obj_security)
await reset_wifi(obj_transport, obj_security)
sys.exit()
if args.reprov:
print('==== Reprovisioning WiFi====')
await reprov_wifi(obj_transport, obj_security)
sys.exit()
if args.custom_data != '':

View File

@ -30,3 +30,22 @@ def ctrl_reset_response(security_ctx, response_data):
print_verbose(security_ctx, f'CtrlReset status: 0x{str(resp.status)}')
if resp.status != 0:
raise RuntimeError
def ctrl_reprov_request(security_ctx):
# Form protobuf request packet for CtrlReprov command
cmd = proto.wifi_ctrl_pb2.WiFiCtrlPayload()
cmd.msg = proto.wifi_ctrl_pb2.TypeCmdCtrlReprov
enc_cmd = security_ctx.encrypt_data(cmd.SerializeToString())
print_verbose(security_ctx, f'Client -> Device (Encrypted CmdCtrlReset): 0x{enc_cmd.hex()}')
return enc_cmd.decode('latin-1')
def ctrl_reprov_response(security_ctx, response_data):
# Interpret protobuf response packet from CtrlReprov command
dec_resp = security_ctx.decrypt_data(str_to_bytes(response_data))
resp = proto.wifi_ctrl_pb2.WiFiCtrlPayload()
resp.ParseFromString(dec_resp)
print_verbose(security_ctx, f'CtrlReset status: 0x{str(resp.status)}')
if resp.status != 0:
raise RuntimeError