Add protobuf versioning (#954)
* Add protobuf versioning * Add protobuf version unit test * Change pb version providing * Remove redundant 'call'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <furi.h>
|
||||
#include <loader/loader.h>
|
||||
|
||||
void rpc_system_app_start_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_app_start_process(const PB_Main* request, void* context) {
|
||||
Rpc* rpc = context;
|
||||
furi_assert(rpc);
|
||||
furi_assert(request);
|
||||
@@ -36,7 +36,7 @@ void rpc_system_app_start_process(const PB_Main* request, void* context) {
|
||||
rpc_send_and_release_empty(rpc, request->command_id, result);
|
||||
}
|
||||
|
||||
void rpc_system_app_lock_status_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_app_lock_status_process(const PB_Main* request, void* context) {
|
||||
Rpc* rpc = context;
|
||||
furi_assert(rpc);
|
||||
furi_assert(request);
|
||||
|
@@ -13,7 +13,8 @@ typedef struct {
|
||||
bool virtual_display_not_empty;
|
||||
} RpcGuiSystem;
|
||||
|
||||
void rpc_system_gui_screen_stream_frame_callback(uint8_t* data, size_t size, void* context) {
|
||||
static void
|
||||
rpc_system_gui_screen_stream_frame_callback(uint8_t* data, size_t size, void* context) {
|
||||
furi_assert(data);
|
||||
furi_assert(size == 1024);
|
||||
furi_assert(context);
|
||||
@@ -35,7 +36,7 @@ void rpc_system_gui_screen_stream_frame_callback(uint8_t* data, size_t size, voi
|
||||
free(frame);
|
||||
}
|
||||
|
||||
void rpc_system_gui_start_screen_stream_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_gui_start_screen_stream_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(context);
|
||||
RpcGuiSystem* rpc_gui = context;
|
||||
@@ -46,7 +47,7 @@ void rpc_system_gui_start_screen_stream_process(const PB_Main* request, void* co
|
||||
rpc_gui->gui, rpc_system_gui_screen_stream_frame_callback, context);
|
||||
}
|
||||
|
||||
void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(context);
|
||||
RpcGuiSystem* rpc_gui = context;
|
||||
@@ -56,7 +57,8 @@ void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* con
|
||||
rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
void rpc_system_gui_send_input_event_request_process(const PB_Main* request, void* context) {
|
||||
static void
|
||||
rpc_system_gui_send_input_event_request_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_gui_send_input_event_request_tag);
|
||||
furi_assert(context);
|
||||
@@ -141,7 +143,7 @@ static void rpc_system_gui_virtual_display_render_callback(Canvas* canvas, void*
|
||||
canvas_draw_xbm(canvas, 0, 0, canvas->width, canvas->height, rpc_gui->virtual_display_buffer);
|
||||
}
|
||||
|
||||
void rpc_system_gui_start_virtual_display_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_gui_start_virtual_display_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(context);
|
||||
RpcGuiSystem* rpc_gui = context;
|
||||
@@ -179,7 +181,7 @@ void rpc_system_gui_start_virtual_display_process(const PB_Main* request, void*
|
||||
rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
void rpc_system_gui_stop_virtual_display_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_gui_stop_virtual_display_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(context);
|
||||
RpcGuiSystem* rpc_gui = context;
|
||||
@@ -199,7 +201,7 @@ void rpc_system_gui_stop_virtual_display_process(const PB_Main* request, void* c
|
||||
rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
void rpc_system_gui_virtual_display_frame_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_gui_virtual_display_frame_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(context);
|
||||
RpcGuiSystem* rpc_gui = context;
|
||||
@@ -268,4 +270,4 @@ void rpc_system_gui_free(void* ctx) {
|
||||
gui_set_framebuffer_callback(rpc_gui->gui, NULL, NULL);
|
||||
furi_record_close("gui");
|
||||
free(rpc_gui);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
#include "flipper.pb.h"
|
||||
#include "rpc_i.h"
|
||||
|
||||
#include <flipper.pb.h>
|
||||
#include <furi_hal.h>
|
||||
#include <power/power_service/power.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <protobuf_version.h>
|
||||
|
||||
void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
||||
#include "rpc_i.h"
|
||||
|
||||
static void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
||||
furi_assert(msg_request);
|
||||
furi_assert(msg_request->which_content == PB_Main_system_ping_request_tag);
|
||||
furi_assert(context);
|
||||
@@ -34,7 +35,7 @@ void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) {
|
||||
rpc_send_and_release(rpc, &msg_response);
|
||||
}
|
||||
|
||||
void rpc_system_system_reboot_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_system_reboot_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_reboot_request_tag);
|
||||
furi_assert(context);
|
||||
@@ -57,7 +58,7 @@ typedef struct {
|
||||
PB_Main* response;
|
||||
} RpcSystemSystemDeviceInfoContext;
|
||||
|
||||
void rpc_system_system_device_info_callback(
|
||||
static void rpc_system_system_device_info_callback(
|
||||
const char* key,
|
||||
const char* value,
|
||||
bool last,
|
||||
@@ -77,7 +78,7 @@ void rpc_system_system_device_info_callback(
|
||||
rpc_send_and_release(ctx->rpc, ctx->response);
|
||||
}
|
||||
|
||||
void rpc_system_system_device_info_process(const PB_Main* request, void* context) {
|
||||
static void rpc_system_system_device_info_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_device_info_request_tag);
|
||||
furi_assert(context);
|
||||
@@ -98,7 +99,7 @@ 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) {
|
||||
static 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);
|
||||
@@ -121,9 +122,10 @@ void rpc_system_system_get_datetime_process(const PB_Main* request, void* contex
|
||||
response->content.system_get_datetime_response.datetime.weekday = datetime.weekday;
|
||||
|
||||
rpc_send_and_release(rpc, response);
|
||||
free(response);
|
||||
}
|
||||
|
||||
void rpc_system_system_set_datetime_process(const PB_Main* request, void* context) {
|
||||
static 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);
|
||||
@@ -148,7 +150,7 @@ void rpc_system_system_set_datetime_process(const PB_Main* request, void* contex
|
||||
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) {
|
||||
static 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);
|
||||
@@ -157,7 +159,8 @@ void rpc_system_system_factory_reset_process(const PB_Main* request, void* conte
|
||||
power_reboot(PowerBootModeNormal);
|
||||
}
|
||||
|
||||
void rpc_system_system_play_audiovisual_alert_process(const PB_Main* request, void* context) {
|
||||
static void
|
||||
rpc_system_system_play_audiovisual_alert_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_play_audiovisual_alert_request_tag);
|
||||
furi_assert(context);
|
||||
@@ -170,6 +173,27 @@ void rpc_system_system_play_audiovisual_alert_process(const PB_Main* request, vo
|
||||
rpc_send_and_release_empty(rpc, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
static void rpc_system_system_protobuf_version_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_protobuf_version_request_tag);
|
||||
furi_assert(context);
|
||||
|
||||
Rpc* rpc = context;
|
||||
|
||||
PB_Main* response = furi_alloc(sizeof(PB_Main));
|
||||
response->command_id = request->command_id;
|
||||
response->has_next = false;
|
||||
response->command_status = PB_CommandStatus_OK;
|
||||
response->which_content = PB_Main_system_protobuf_version_response_tag;
|
||||
/* build error here means something wrong with tags in
|
||||
* local repo https://github.com/flipperdevices/flipperzero-protobuf */
|
||||
response->content.system_protobuf_version_response.major = PROTOBUF_MAJOR_VERSION;
|
||||
response->content.system_protobuf_version_response.minor = PROTOBUF_MINOR_VERSION;
|
||||
|
||||
rpc_send_and_release(rpc, response);
|
||||
free(response);
|
||||
}
|
||||
|
||||
void* rpc_system_system_alloc(Rpc* rpc) {
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
@@ -198,5 +222,8 @@ void* rpc_system_system_alloc(Rpc* rpc) {
|
||||
rpc_handler.message_handler = rpc_system_system_play_audiovisual_alert_process;
|
||||
rpc_add_handler(rpc, PB_Main_system_play_audiovisual_alert_request_tag, &rpc_handler);
|
||||
|
||||
rpc_handler.message_handler = rpc_system_system_protobuf_version_process;
|
||||
rpc_add_handler(rpc, PB_Main_system_protobuf_version_request_tag, &rpc_handler);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user