Rpc: implement SystemGetDateTime, SystemSetDateTime, update GuiStartVirtualDisplay (#908)

* Rpc: update protobuf sources
* Rpc: implement SystemGetDateTime, SystemSetDateTime
* Rpc: add first frame parameter to GuiStartVirtualDisplay
This commit is contained in:
Anna Prosvetova 2021-12-16 18:41:55 +03:00 committed by GitHub
parent acb2c98663
commit 4013da5b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 188 additions and 12 deletions

View File

@ -159,6 +159,16 @@ void rpc_system_gui_start_virtual_display_process(const PB_Main* request, void*
// Glad they both are 1024 for now
size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas);
rpc_gui->virtual_display_buffer = furi_alloc(buffer_size);
if(request->content.gui_start_virtual_display_request.has_first_frame) {
size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas);
memcpy(
rpc_gui->virtual_display_buffer,
request->content.gui_start_virtual_display_request.first_frame.data->bytes,
buffer_size);
rpc_gui->virtual_display_not_empty = true;
}
rpc_gui->virtual_display_view_port = view_port_alloc();
view_port_draw_callback_set(
rpc_gui->virtual_display_view_port,

View File

@ -98,6 +98,56 @@ void rpc_system_system_device_info_process(const PB_Main* request, void* context
free(response);
}
void rpc_system_system_get_datetime_process(const PB_Main* request, void* context) {
furi_assert(request);
furi_assert(request->which_content == PB_Main_system_get_datetime_request_tag);
furi_assert(context);
Rpc* rpc = context;
FuriHalRtcDateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
PB_Main* response = furi_alloc(sizeof(PB_Main));
response->command_id = request->command_id;
response->which_content = PB_Main_system_get_datetime_response_tag;
response->command_status = PB_CommandStatus_OK;
response->content.system_get_datetime_response.has_datetime = true;
response->content.system_get_datetime_response.datetime.hour = datetime.hour;
response->content.system_get_datetime_response.datetime.minute = datetime.minute;
response->content.system_get_datetime_response.datetime.second = datetime.second;
response->content.system_get_datetime_response.datetime.day = datetime.day;
response->content.system_get_datetime_response.datetime.month = datetime.month;
response->content.system_get_datetime_response.datetime.year = datetime.year;
response->content.system_get_datetime_response.datetime.weekday = datetime.weekday;
rpc_send_and_release(rpc, response);
}
void rpc_system_system_set_datetime_process(const PB_Main* request, void* context) {
furi_assert(request);
furi_assert(request->which_content == PB_Main_system_set_datetime_request_tag);
furi_assert(context);
Rpc* rpc = context;
if(!request->content.system_set_datetime_request.has_datetime) {
rpc_send_and_release_empty(
rpc, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS);
return;
}
FuriHalRtcDateTime datetime;
datetime.hour = request->content.system_set_datetime_request.datetime.hour;
datetime.minute = request->content.system_set_datetime_request.datetime.minute;
datetime.second = request->content.system_set_datetime_request.datetime.second;
datetime.day = request->content.system_set_datetime_request.datetime.day;
datetime.month = request->content.system_set_datetime_request.datetime.month;
datetime.year = request->content.system_set_datetime_request.datetime.year;
datetime.weekday = request->content.system_set_datetime_request.datetime.weekday;
furi_hal_rtc_set_datetime(&datetime);
rpc_send_and_release_empty(rpc, request->command_id, PB_CommandStatus_OK);
}
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);
@ -126,5 +176,11 @@ void* rpc_system_system_alloc(Rpc* rpc) {
rpc_handler.message_handler = rpc_system_system_factory_reset_process;
rpc_add_handler(rpc, PB_Main_system_factory_reset_request_tag, &rpc_handler);
rpc_handler.message_handler = rpc_system_system_get_datetime_process;
rpc_add_handler(rpc, PB_Main_system_get_datetime_request_tag, &rpc_handler);
rpc_handler.message_handler = rpc_system_system_set_datetime_process;
rpc_add_handler(rpc, PB_Main_system_set_datetime_request_tag, &rpc_handler);
return NULL;
}

View File

@ -92,6 +92,9 @@ typedef struct _PB_Main {
PB_System_DeviceInfoRequest system_device_info_request;
PB_System_DeviceInfoResponse system_device_info_response;
PB_System_FactoryResetRequest system_factory_reset_request;
PB_System_GetDateTimeRequest system_get_datetime_request;
PB_System_GetDateTimeResponse system_get_datetime_response;
PB_System_SetDateTimeRequest system_set_datetime_request;
} content;
} PB_Main;
@ -149,6 +152,9 @@ extern "C" {
#define PB_Main_system_device_info_request_tag 32
#define PB_Main_system_device_info_response_tag 33
#define PB_Main_system_factory_reset_request_tag 34
#define PB_Main_system_get_datetime_request_tag 35
#define PB_Main_system_get_datetime_response_tag 36
#define PB_Main_system_set_datetime_request_tag 37
/* Struct field encoding specification for nanopb */
#define PB_Empty_FIELDLIST(X, a) \
@ -195,7 +201,10 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_rename_request,content.stora
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_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)
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_factory_reset_request,content.system_factory_reset_request), 34) \
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_get_datetime_request,content.system_get_datetime_request), 35) \
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_get_datetime_response,content.system_get_datetime_response), 36) \
X(a, STATIC, ONEOF, MSG_W_CB, (content,system_set_datetime_request,content.system_set_datetime_request), 37)
#define PB_Main_CALLBACK NULL
#define PB_Main_DEFAULT NULL
#define PB_Main_content_empty_MSGTYPE PB_Empty
@ -229,6 +238,9 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,system_factory_reset_request,content
#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_factory_reset_request_MSGTYPE PB_System_FactoryResetRequest
#define PB_Main_content_system_get_datetime_request_MSGTYPE PB_System_GetDateTimeRequest
#define PB_Main_content_system_get_datetime_response_MSGTYPE PB_System_GetDateTimeResponse
#define PB_Main_content_system_set_datetime_request_MSGTYPE PB_System_SetDateTimeRequest
extern const pb_msgdesc_t PB_Empty_msg;
extern const pb_msgdesc_t PB_StopSession_msg;
@ -242,9 +254,9 @@ extern const pb_msgdesc_t PB_Main_msg;
/* Maximum encoded size of messages (where known) */
#define PB_Empty_size 0
#define PB_StopSession_size 0
#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size)
#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Gui_StartVirtualDisplayRequest_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size)
#define PB_Main_size (10 + sizeof(union PB_Main_content_size_union))
union PB_Main_content_size_union {char f5[(6 + PB_System_PingRequest_size)]; char f6[(6 + PB_System_PingResponse_size)]; char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f28[(7 + PB_Storage_InfoRequest_size)]; char f30[(7 + PB_Storage_RenameRequest_size)]; char f33[(7 + PB_System_DeviceInfoResponse_size)]; char f0[36];};
union PB_Main_content_size_union {char f5[(6 + PB_System_PingRequest_size)]; char f6[(6 + PB_System_PingResponse_size)]; char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f26[(7 + PB_Gui_StartVirtualDisplayRequest_size)]; char f28[(7 + PB_Storage_InfoRequest_size)]; char f30[(7 + PB_Storage_RenameRequest_size)]; char f33[(7 + PB_System_DeviceInfoResponse_size)]; char f0[36];};
#endif
#ifdef __cplusplus

View File

@ -36,10 +36,6 @@ typedef struct _PB_Gui_StartScreenStreamRequest {
char dummy_field;
} PB_Gui_StartScreenStreamRequest;
typedef struct _PB_Gui_StartVirtualDisplayRequest {
char dummy_field;
} PB_Gui_StartVirtualDisplayRequest;
typedef struct _PB_Gui_StopScreenStreamRequest {
char dummy_field;
} PB_Gui_StopScreenStreamRequest;
@ -53,6 +49,11 @@ typedef struct _PB_Gui_SendInputEventRequest {
PB_Gui_InputType type;
} PB_Gui_SendInputEventRequest;
typedef struct _PB_Gui_StartVirtualDisplayRequest {
bool has_first_frame;
PB_Gui_ScreenFrame first_frame; /* optional */
} PB_Gui_StartVirtualDisplayRequest;
/* Helper constants for enums */
#define _PB_Gui_InputKey_MIN PB_Gui_InputKey_UP
@ -73,19 +74,20 @@ extern "C" {
#define PB_Gui_StartScreenStreamRequest_init_default {0}
#define PB_Gui_StopScreenStreamRequest_init_default {0}
#define PB_Gui_SendInputEventRequest_init_default {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN}
#define PB_Gui_StartVirtualDisplayRequest_init_default {0}
#define PB_Gui_StartVirtualDisplayRequest_init_default {false, PB_Gui_ScreenFrame_init_default}
#define PB_Gui_StopVirtualDisplayRequest_init_default {0}
#define PB_Gui_ScreenFrame_init_zero {NULL}
#define PB_Gui_StartScreenStreamRequest_init_zero {0}
#define PB_Gui_StopScreenStreamRequest_init_zero {0}
#define PB_Gui_SendInputEventRequest_init_zero {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN}
#define PB_Gui_StartVirtualDisplayRequest_init_zero {0}
#define PB_Gui_StartVirtualDisplayRequest_init_zero {false, PB_Gui_ScreenFrame_init_zero}
#define PB_Gui_StopVirtualDisplayRequest_init_zero {0}
/* Field tags (for use in manual encoding/decoding) */
#define PB_Gui_ScreenFrame_data_tag 1
#define PB_Gui_SendInputEventRequest_key_tag 1
#define PB_Gui_SendInputEventRequest_type_tag 2
#define PB_Gui_StartVirtualDisplayRequest_first_frame_tag 1
/* Struct field encoding specification for nanopb */
#define PB_Gui_ScreenFrame_FIELDLIST(X, a) \
@ -110,9 +112,10 @@ X(a, STATIC, SINGULAR, UENUM, type, 2)
#define PB_Gui_SendInputEventRequest_DEFAULT NULL
#define PB_Gui_StartVirtualDisplayRequest_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, first_frame, 1)
#define PB_Gui_StartVirtualDisplayRequest_CALLBACK NULL
#define PB_Gui_StartVirtualDisplayRequest_DEFAULT NULL
#define PB_Gui_StartVirtualDisplayRequest_first_frame_MSGTYPE PB_Gui_ScreenFrame
#define PB_Gui_StopVirtualDisplayRequest_FIELDLIST(X, a) \
@ -136,9 +139,9 @@ extern const pb_msgdesc_t PB_Gui_StopVirtualDisplayRequest_msg;
/* Maximum encoded size of messages (where known) */
/* PB_Gui_ScreenFrame_size depends on runtime parameters */
/* PB_Gui_StartVirtualDisplayRequest_size depends on runtime parameters */
#define PB_Gui_SendInputEventRequest_size 4
#define PB_Gui_StartScreenStreamRequest_size 0
#define PB_Gui_StartVirtualDisplayRequest_size 0
#define PB_Gui_StopScreenStreamRequest_size 0
#define PB_Gui_StopVirtualDisplayRequest_size 0

View File

@ -24,5 +24,17 @@ PB_BIND(PB_System_DeviceInfoResponse, PB_System_DeviceInfoResponse, AUTO)
PB_BIND(PB_System_FactoryResetRequest, PB_System_FactoryResetRequest, AUTO)
PB_BIND(PB_System_GetDateTimeRequest, PB_System_GetDateTimeRequest, AUTO)
PB_BIND(PB_System_GetDateTimeResponse, PB_System_GetDateTimeResponse, AUTO)
PB_BIND(PB_System_SetDateTimeRequest, PB_System_SetDateTimeRequest, AUTO)
PB_BIND(PB_System_DateTime, PB_System_DateTime, AUTO)

View File

@ -29,6 +29,10 @@ typedef struct _PB_System_FactoryResetRequest {
char dummy_field;
} PB_System_FactoryResetRequest;
typedef struct _PB_System_GetDateTimeRequest {
char dummy_field;
} PB_System_GetDateTimeRequest;
typedef struct _PB_System_PingRequest {
pb_bytes_array_t *data;
} PB_System_PingRequest;
@ -37,10 +41,32 @@ typedef struct _PB_System_PingResponse {
pb_bytes_array_t *data;
} PB_System_PingResponse;
typedef struct _PB_System_DateTime {
/* Time */
uint8_t hour; /* *< Hour in 24H format: 0-23 */
uint8_t minute; /* *< Minute: 0-59 */
uint8_t second; /* *< Second: 0-59 */
/* Date */
uint8_t day; /* *< Current day: 1-31 */
uint8_t month; /* *< Current month: 1-12 */
uint16_t year; /* *< Current year: 2000-2099 */
uint8_t weekday; /* *< Current weekday: 1-7 */
} PB_System_DateTime;
typedef struct _PB_System_RebootRequest {
PB_System_RebootRequest_RebootMode mode;
} PB_System_RebootRequest;
typedef struct _PB_System_GetDateTimeResponse {
bool has_datetime;
PB_System_DateTime datetime;
} PB_System_GetDateTimeResponse;
typedef struct _PB_System_SetDateTimeRequest {
bool has_datetime;
PB_System_DateTime datetime;
} PB_System_SetDateTimeRequest;
/* Helper constants for enums */
#define _PB_System_RebootRequest_RebootMode_MIN PB_System_RebootRequest_RebootMode_OS
@ -59,19 +85,36 @@ extern "C" {
#define PB_System_DeviceInfoRequest_init_default {0}
#define PB_System_DeviceInfoResponse_init_default {NULL, NULL}
#define PB_System_FactoryResetRequest_init_default {0}
#define PB_System_GetDateTimeRequest_init_default {0}
#define PB_System_GetDateTimeResponse_init_default {false, PB_System_DateTime_init_default}
#define PB_System_SetDateTimeRequest_init_default {false, PB_System_DateTime_init_default}
#define PB_System_DateTime_init_default {0, 0, 0, 0, 0, 0, 0}
#define PB_System_PingRequest_init_zero {NULL}
#define PB_System_PingResponse_init_zero {NULL}
#define PB_System_RebootRequest_init_zero {_PB_System_RebootRequest_RebootMode_MIN}
#define PB_System_DeviceInfoRequest_init_zero {0}
#define PB_System_DeviceInfoResponse_init_zero {NULL, NULL}
#define PB_System_FactoryResetRequest_init_zero {0}
#define PB_System_GetDateTimeRequest_init_zero {0}
#define PB_System_GetDateTimeResponse_init_zero {false, PB_System_DateTime_init_zero}
#define PB_System_SetDateTimeRequest_init_zero {false, PB_System_DateTime_init_zero}
#define PB_System_DateTime_init_zero {0, 0, 0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */
#define PB_System_DeviceInfoResponse_key_tag 1
#define PB_System_DeviceInfoResponse_value_tag 2
#define PB_System_PingRequest_data_tag 1
#define PB_System_PingResponse_data_tag 1
#define PB_System_DateTime_hour_tag 1
#define PB_System_DateTime_minute_tag 2
#define PB_System_DateTime_second_tag 3
#define PB_System_DateTime_day_tag 4
#define PB_System_DateTime_month_tag 5
#define PB_System_DateTime_year_tag 6
#define PB_System_DateTime_weekday_tag 7
#define PB_System_RebootRequest_mode_tag 1
#define PB_System_GetDateTimeResponse_datetime_tag 1
#define PB_System_SetDateTimeRequest_datetime_tag 1
/* Struct field encoding specification for nanopb */
#define PB_System_PingRequest_FIELDLIST(X, a) \
@ -105,12 +148,44 @@ X(a, POINTER, SINGULAR, STRING, value, 2)
#define PB_System_FactoryResetRequest_CALLBACK NULL
#define PB_System_FactoryResetRequest_DEFAULT NULL
#define PB_System_GetDateTimeRequest_FIELDLIST(X, a) \
#define PB_System_GetDateTimeRequest_CALLBACK NULL
#define PB_System_GetDateTimeRequest_DEFAULT NULL
#define PB_System_GetDateTimeResponse_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, datetime, 1)
#define PB_System_GetDateTimeResponse_CALLBACK NULL
#define PB_System_GetDateTimeResponse_DEFAULT NULL
#define PB_System_GetDateTimeResponse_datetime_MSGTYPE PB_System_DateTime
#define PB_System_SetDateTimeRequest_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, datetime, 1)
#define PB_System_SetDateTimeRequest_CALLBACK NULL
#define PB_System_SetDateTimeRequest_DEFAULT NULL
#define PB_System_SetDateTimeRequest_datetime_MSGTYPE PB_System_DateTime
#define PB_System_DateTime_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, hour, 1) \
X(a, STATIC, SINGULAR, UINT32, minute, 2) \
X(a, STATIC, SINGULAR, UINT32, second, 3) \
X(a, STATIC, SINGULAR, UINT32, day, 4) \
X(a, STATIC, SINGULAR, UINT32, month, 5) \
X(a, STATIC, SINGULAR, UINT32, year, 6) \
X(a, STATIC, SINGULAR, UINT32, weekday, 7)
#define PB_System_DateTime_CALLBACK NULL
#define PB_System_DateTime_DEFAULT NULL
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_RebootRequest_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_FactoryResetRequest_msg;
extern const pb_msgdesc_t PB_System_GetDateTimeRequest_msg;
extern const pb_msgdesc_t PB_System_GetDateTimeResponse_msg;
extern const pb_msgdesc_t PB_System_SetDateTimeRequest_msg;
extern const pb_msgdesc_t PB_System_DateTime_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define PB_System_PingRequest_fields &PB_System_PingRequest_msg
@ -119,14 +194,22 @@ extern const pb_msgdesc_t PB_System_FactoryResetRequest_msg;
#define PB_System_DeviceInfoRequest_fields &PB_System_DeviceInfoRequest_msg
#define PB_System_DeviceInfoResponse_fields &PB_System_DeviceInfoResponse_msg
#define PB_System_FactoryResetRequest_fields &PB_System_FactoryResetRequest_msg
#define PB_System_GetDateTimeRequest_fields &PB_System_GetDateTimeRequest_msg
#define PB_System_GetDateTimeResponse_fields &PB_System_GetDateTimeResponse_msg
#define PB_System_SetDateTimeRequest_fields &PB_System_SetDateTimeRequest_msg
#define PB_System_DateTime_fields &PB_System_DateTime_msg
/* Maximum encoded size of messages (where known) */
/* PB_System_PingRequest_size depends on runtime parameters */
/* PB_System_PingResponse_size depends on runtime parameters */
/* PB_System_DeviceInfoResponse_size depends on runtime parameters */
#define PB_System_DateTime_size 22
#define PB_System_DeviceInfoRequest_size 0
#define PB_System_FactoryResetRequest_size 0
#define PB_System_GetDateTimeRequest_size 0
#define PB_System_GetDateTimeResponse_size 24
#define PB_System_RebootRequest_size 2
#define PB_System_SetDateTimeRequest_size 24
#ifdef __cplusplus
} /* extern "C" */

@ -1 +1 @@
Subproject commit f6fdc10e6d111b289188e88ac1d432698bb739cf
Subproject commit f5365c36aa458eb344280560440d6e27232a5667