Rpc: implement SystemFactoryReset (#890)
* Rpc: update protobuf sources * Rpc: implement SystemFactoryReset
This commit is contained in:
parent
d6f080f7d0
commit
195f422bb9
@ -3,6 +3,7 @@
|
|||||||
#include "status.pb.h"
|
#include "status.pb.h"
|
||||||
|
|
||||||
#include <furi-hal-info.h>
|
#include <furi-hal-info.h>
|
||||||
|
#include <furi-hal-bootloader.h>
|
||||||
#include <power/power_service/power.h>
|
#include <power/power_service/power.h>
|
||||||
|
|
||||||
void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
||||||
@ -98,6 +99,15 @@ void rpc_system_system_device_info_process(const PB_Main* request, void* context
|
|||||||
free(response);
|
free(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rpc_system_system_factory_reset_process(const PB_Main* request, void* context) {
|
||||||
|
furi_assert(request);
|
||||||
|
furi_assert(request->which_content == PB_Main_system_factory_reset_request_tag);
|
||||||
|
furi_assert(context);
|
||||||
|
|
||||||
|
furi_hal_bootloader_set_flags(FuriHalBootloaderFlagFactoryReset);
|
||||||
|
power_reboot(PowerBootModeNormal);
|
||||||
|
}
|
||||||
|
|
||||||
void* rpc_system_system_alloc(Rpc* rpc) {
|
void* rpc_system_system_alloc(Rpc* rpc) {
|
||||||
RpcHandler rpc_handler = {
|
RpcHandler rpc_handler = {
|
||||||
.message_handler = NULL,
|
.message_handler = NULL,
|
||||||
@ -114,5 +124,8 @@ void* rpc_system_system_alloc(Rpc* rpc) {
|
|||||||
rpc_handler.message_handler = rpc_system_system_device_info_process;
|
rpc_handler.message_handler = rpc_system_system_device_info_process;
|
||||||
rpc_add_handler(rpc, PB_Main_system_device_info_request_tag, &rpc_handler);
|
rpc_add_handler(rpc, PB_Main_system_device_info_request_tag, &rpc_handler);
|
||||||
|
|
||||||
|
rpc_handler.message_handler = rpc_system_system_factory_reset_process;
|
||||||
|
rpc_add_handler(rpc, PB_Main_system_factory_reset_request_tag, &rpc_handler);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ typedef struct _PB_Main {
|
|||||||
PB_System_RebootRequest system_reboot_request;
|
PB_System_RebootRequest system_reboot_request;
|
||||||
PB_System_DeviceInfoRequest system_device_info_request;
|
PB_System_DeviceInfoRequest system_device_info_request;
|
||||||
PB_System_DeviceInfoResponse system_device_info_response;
|
PB_System_DeviceInfoResponse system_device_info_response;
|
||||||
|
PB_System_FactoryResetRequest system_factory_reset_request;
|
||||||
} content;
|
} content;
|
||||||
} PB_Main;
|
} PB_Main;
|
||||||
|
|
||||||
@ -147,6 +148,7 @@ extern "C" {
|
|||||||
#define PB_Main_system_reboot_request_tag 31
|
#define PB_Main_system_reboot_request_tag 31
|
||||||
#define PB_Main_system_device_info_request_tag 32
|
#define PB_Main_system_device_info_request_tag 32
|
||||||
#define PB_Main_system_device_info_response_tag 33
|
#define PB_Main_system_device_info_response_tag 33
|
||||||
|
#define PB_Main_system_factory_reset_request_tag 34
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
#define PB_Empty_FIELDLIST(X, a) \
|
#define PB_Empty_FIELDLIST(X, a) \
|
||||||
@ -192,7 +194,8 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_info_response,content.storag
|
|||||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_rename_request,content.storage_rename_request), 30) \
|
X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_rename_request,content.storage_rename_request), 30) \
|
||||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_reboot_request,content.system_reboot_request), 31) \
|
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_reboot_request,content.system_reboot_request), 31) \
|
||||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_request,content.system_device_info_request), 32) \
|
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_request,content.system_device_info_request), 32) \
|
||||||
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_response,content.system_device_info_response), 33)
|
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_response,content.system_device_info_response), 33) \
|
||||||
|
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_factory_reset_request,content.system_factory_reset_request), 34)
|
||||||
#define PB_Main_CALLBACK NULL
|
#define PB_Main_CALLBACK NULL
|
||||||
#define PB_Main_DEFAULT NULL
|
#define PB_Main_DEFAULT NULL
|
||||||
#define PB_Main_content_empty_MSGTYPE PB_Empty
|
#define PB_Main_content_empty_MSGTYPE PB_Empty
|
||||||
@ -225,6 +228,7 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,system_device_info_response,content.
|
|||||||
#define PB_Main_content_system_reboot_request_MSGTYPE PB_System_RebootRequest
|
#define PB_Main_content_system_reboot_request_MSGTYPE PB_System_RebootRequest
|
||||||
#define PB_Main_content_system_device_info_request_MSGTYPE PB_System_DeviceInfoRequest
|
#define PB_Main_content_system_device_info_request_MSGTYPE PB_System_DeviceInfoRequest
|
||||||
#define PB_Main_content_system_device_info_response_MSGTYPE PB_System_DeviceInfoResponse
|
#define PB_Main_content_system_device_info_response_MSGTYPE PB_System_DeviceInfoResponse
|
||||||
|
#define PB_Main_content_system_factory_reset_request_MSGTYPE PB_System_FactoryResetRequest
|
||||||
|
|
||||||
extern const pb_msgdesc_t PB_Empty_msg;
|
extern const pb_msgdesc_t PB_Empty_msg;
|
||||||
extern const pb_msgdesc_t PB_StopSession_msg;
|
extern const pb_msgdesc_t PB_StopSession_msg;
|
||||||
|
@ -21,5 +21,8 @@ PB_BIND(PB_System_DeviceInfoRequest, PB_System_DeviceInfoRequest, AUTO)
|
|||||||
PB_BIND(PB_System_DeviceInfoResponse, PB_System_DeviceInfoResponse, AUTO)
|
PB_BIND(PB_System_DeviceInfoResponse, PB_System_DeviceInfoResponse, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(PB_System_FactoryResetRequest, PB_System_FactoryResetRequest, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@ typedef struct _PB_System_DeviceInfoResponse {
|
|||||||
char *value;
|
char *value;
|
||||||
} PB_System_DeviceInfoResponse;
|
} PB_System_DeviceInfoResponse;
|
||||||
|
|
||||||
|
typedef struct _PB_System_FactoryResetRequest {
|
||||||
|
char dummy_field;
|
||||||
|
} PB_System_FactoryResetRequest;
|
||||||
|
|
||||||
typedef struct _PB_System_PingRequest {
|
typedef struct _PB_System_PingRequest {
|
||||||
pb_bytes_array_t *data;
|
pb_bytes_array_t *data;
|
||||||
} PB_System_PingRequest;
|
} PB_System_PingRequest;
|
||||||
@ -54,11 +58,13 @@ extern "C" {
|
|||||||
#define PB_System_RebootRequest_init_default {_PB_System_RebootRequest_RebootMode_MIN}
|
#define PB_System_RebootRequest_init_default {_PB_System_RebootRequest_RebootMode_MIN}
|
||||||
#define PB_System_DeviceInfoRequest_init_default {0}
|
#define PB_System_DeviceInfoRequest_init_default {0}
|
||||||
#define PB_System_DeviceInfoResponse_init_default {NULL, NULL}
|
#define PB_System_DeviceInfoResponse_init_default {NULL, NULL}
|
||||||
|
#define PB_System_FactoryResetRequest_init_default {0}
|
||||||
#define PB_System_PingRequest_init_zero {NULL}
|
#define PB_System_PingRequest_init_zero {NULL}
|
||||||
#define PB_System_PingResponse_init_zero {NULL}
|
#define PB_System_PingResponse_init_zero {NULL}
|
||||||
#define PB_System_RebootRequest_init_zero {_PB_System_RebootRequest_RebootMode_MIN}
|
#define PB_System_RebootRequest_init_zero {_PB_System_RebootRequest_RebootMode_MIN}
|
||||||
#define PB_System_DeviceInfoRequest_init_zero {0}
|
#define PB_System_DeviceInfoRequest_init_zero {0}
|
||||||
#define PB_System_DeviceInfoResponse_init_zero {NULL, NULL}
|
#define PB_System_DeviceInfoResponse_init_zero {NULL, NULL}
|
||||||
|
#define PB_System_FactoryResetRequest_init_zero {0}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define PB_System_DeviceInfoResponse_key_tag 1
|
#define PB_System_DeviceInfoResponse_key_tag 1
|
||||||
@ -94,11 +100,17 @@ X(a, POINTER, SINGULAR, STRING, value, 2)
|
|||||||
#define PB_System_DeviceInfoResponse_CALLBACK NULL
|
#define PB_System_DeviceInfoResponse_CALLBACK NULL
|
||||||
#define PB_System_DeviceInfoResponse_DEFAULT NULL
|
#define PB_System_DeviceInfoResponse_DEFAULT NULL
|
||||||
|
|
||||||
|
#define PB_System_FactoryResetRequest_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define PB_System_FactoryResetRequest_CALLBACK NULL
|
||||||
|
#define PB_System_FactoryResetRequest_DEFAULT NULL
|
||||||
|
|
||||||
extern const pb_msgdesc_t PB_System_PingRequest_msg;
|
extern const pb_msgdesc_t PB_System_PingRequest_msg;
|
||||||
extern const pb_msgdesc_t PB_System_PingResponse_msg;
|
extern const pb_msgdesc_t PB_System_PingResponse_msg;
|
||||||
extern const pb_msgdesc_t PB_System_RebootRequest_msg;
|
extern const pb_msgdesc_t PB_System_RebootRequest_msg;
|
||||||
extern const pb_msgdesc_t PB_System_DeviceInfoRequest_msg;
|
extern const pb_msgdesc_t PB_System_DeviceInfoRequest_msg;
|
||||||
extern const pb_msgdesc_t PB_System_DeviceInfoResponse_msg;
|
extern const pb_msgdesc_t PB_System_DeviceInfoResponse_msg;
|
||||||
|
extern const pb_msgdesc_t PB_System_FactoryResetRequest_msg;
|
||||||
|
|
||||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
#define PB_System_PingRequest_fields &PB_System_PingRequest_msg
|
#define PB_System_PingRequest_fields &PB_System_PingRequest_msg
|
||||||
@ -106,12 +118,14 @@ extern const pb_msgdesc_t PB_System_DeviceInfoResponse_msg;
|
|||||||
#define PB_System_RebootRequest_fields &PB_System_RebootRequest_msg
|
#define PB_System_RebootRequest_fields &PB_System_RebootRequest_msg
|
||||||
#define PB_System_DeviceInfoRequest_fields &PB_System_DeviceInfoRequest_msg
|
#define PB_System_DeviceInfoRequest_fields &PB_System_DeviceInfoRequest_msg
|
||||||
#define PB_System_DeviceInfoResponse_fields &PB_System_DeviceInfoResponse_msg
|
#define PB_System_DeviceInfoResponse_fields &PB_System_DeviceInfoResponse_msg
|
||||||
|
#define PB_System_FactoryResetRequest_fields &PB_System_FactoryResetRequest_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
/* PB_System_PingRequest_size depends on runtime parameters */
|
/* PB_System_PingRequest_size depends on runtime parameters */
|
||||||
/* PB_System_PingResponse_size depends on runtime parameters */
|
/* PB_System_PingResponse_size depends on runtime parameters */
|
||||||
/* PB_System_DeviceInfoResponse_size depends on runtime parameters */
|
/* PB_System_DeviceInfoResponse_size depends on runtime parameters */
|
||||||
#define PB_System_DeviceInfoRequest_size 0
|
#define PB_System_DeviceInfoRequest_size 0
|
||||||
|
#define PB_System_FactoryResetRequest_size 0
|
||||||
#define PB_System_RebootRequest_size 2
|
#define PB_System_RebootRequest_size 2
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 5761a23786b4729303bfa49142effea51870e549
|
Subproject commit f6fdc10e6d111b289188e88ac1d432698bb739cf
|
Loading…
Reference in New Issue
Block a user