[FL-2957] Unified Info API, App Error, Data Xchange (#1998)
* Update protobuf definitions * Add Property subsystem entry point function * Key-based system info and power info function stubs * Remove unneeded functions * Working power info * Working system info * Replace #defines with string literals * Remove unneeded field * Simplify system info formatting * Refactor output callback handling * Handle the last info element correctly * Optimise power info, rename methods * Add comments * Add power debug * Remove unneeded definitions * Rename some files and functions * Update protobuf definitions * Implement App GetError and DataExchange APIs * Send GetErrorReply with correct command_id * Add RPC debug app stub * Add more scenes * Add warning, increase stack size * Add receive data exchange scene * Improve data exchange * Add notifications * Update application requirements * Bump format version for property-based infos * Correctly reset error text * RCP: sync protobuf repo to latest release tag Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
10
applications/debug/rpc_debug_app/application.fam
Normal file
10
applications/debug/rpc_debug_app/application.fam
Normal file
@@ -0,0 +1,10 @@
|
||||
App(
|
||||
appid="rpc_debug",
|
||||
name="RPC Debug",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="rpc_debug_app",
|
||||
requires=["gui", "rpc_start", "notification"],
|
||||
stack_size=2 * 1024,
|
||||
order=10,
|
||||
fap_category="Debug",
|
||||
)
|
138
applications/debug/rpc_debug_app/rpc_debug_app.c
Normal file
138
applications/debug/rpc_debug_app/rpc_debug_app.c
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "rpc_debug_app.h"
|
||||
#include <core/log.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static bool rpc_debug_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
RpcDebugApp* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool rpc_debug_app_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
RpcDebugApp* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void rpc_debug_app_tick_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
RpcDebugApp* app = context;
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void rpc_debug_app_rpc_command_callback(RpcAppSystemEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
RpcDebugApp* app = context;
|
||||
furi_assert(app->rpc);
|
||||
|
||||
if(event == RpcAppEventSessionClose) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
rpc_system_app_set_callback(app->rpc, NULL, NULL);
|
||||
app->rpc = NULL;
|
||||
} else if(event == RpcAppEventAppExit) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
rpc_system_app_confirm(app->rpc, RpcAppEventAppExit, true);
|
||||
} else {
|
||||
rpc_system_app_confirm(app->rpc, event, false);
|
||||
}
|
||||
}
|
||||
|
||||
static bool rpc_debug_app_rpc_init_rpc(RpcDebugApp* app, const char* args) {
|
||||
bool ret = false;
|
||||
if(args && strlen(args)) {
|
||||
uint32_t rpc = 0;
|
||||
if(sscanf(args, "RPC %lX", &rpc) == 1) {
|
||||
app->rpc = (RpcAppSystem*)rpc;
|
||||
rpc_system_app_set_callback(app->rpc, rpc_debug_app_rpc_command_callback, app);
|
||||
rpc_system_app_send_started(app->rpc);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static RpcDebugApp* rpc_debug_app_alloc() {
|
||||
RpcDebugApp* app = malloc(sizeof(RpcDebugApp));
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
app->scene_manager = scene_manager_alloc(&rpc_debug_app_scene_handlers, app);
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
app->view_dispatcher, rpc_debug_app_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
app->view_dispatcher, rpc_debug_app_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(
|
||||
app->view_dispatcher, rpc_debug_app_tick_event_callback, 100);
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
|
||||
app->widget = widget_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, RpcDebugAppViewWidget, widget_get_view(app->widget));
|
||||
app->submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, RpcDebugAppViewSubmenu, submenu_get_view(app->submenu));
|
||||
app->text_box = text_box_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, RpcDebugAppViewTextBox, text_box_get_view(app->text_box));
|
||||
app->text_input = text_input_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, RpcDebugAppViewTextInput, text_input_get_view(app->text_input));
|
||||
app->byte_input = byte_input_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, RpcDebugAppViewByteInput, byte_input_get_view(app->byte_input));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void rpc_debug_app_free(RpcDebugApp* app) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, RpcDebugAppViewByteInput);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, RpcDebugAppViewTextInput);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, RpcDebugAppViewTextBox);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, RpcDebugAppViewSubmenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, RpcDebugAppViewWidget);
|
||||
|
||||
free(app->byte_input);
|
||||
free(app->text_input);
|
||||
free(app->text_box);
|
||||
free(app->submenu);
|
||||
free(app->widget);
|
||||
|
||||
free(app->scene_manager);
|
||||
free(app->view_dispatcher);
|
||||
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
app->notifications = NULL;
|
||||
furi_record_close(RECORD_GUI);
|
||||
app->gui = NULL;
|
||||
|
||||
if(app->rpc) {
|
||||
rpc_system_app_set_callback(app->rpc, NULL, NULL);
|
||||
rpc_system_app_send_exited(app->rpc);
|
||||
app->rpc = NULL;
|
||||
}
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t rpc_debug_app(void* args) {
|
||||
RpcDebugApp* app = rpc_debug_app_alloc();
|
||||
|
||||
if(rpc_debug_app_rpc_init_rpc(app, args)) {
|
||||
notification_message(app->notifications, &sequence_display_backlight_on);
|
||||
scene_manager_next_scene(app->scene_manager, RpcDebugAppSceneStart);
|
||||
} else {
|
||||
scene_manager_next_scene(app->scene_manager, RpcDebugAppSceneStartDummy);
|
||||
}
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
rpc_debug_app_free(app);
|
||||
return 0;
|
||||
}
|
54
applications/debug/rpc_debug_app/rpc_debug_app.h
Normal file
54
applications/debug/rpc_debug_app/rpc_debug_app.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#include <gui/modules/widget.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/text_box.h>
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/modules/byte_input.h>
|
||||
|
||||
#include <rpc/rpc_app.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#include "scenes/rpc_debug_app_scene.h"
|
||||
|
||||
#define DATA_STORE_SIZE 64U
|
||||
#define TEXT_STORE_SIZE 64U
|
||||
|
||||
typedef struct {
|
||||
Gui* gui;
|
||||
RpcAppSystem* rpc;
|
||||
SceneManager* scene_manager;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
NotificationApp* notifications;
|
||||
|
||||
Widget* widget;
|
||||
Submenu* submenu;
|
||||
TextBox* text_box;
|
||||
TextInput* text_input;
|
||||
ByteInput* byte_input;
|
||||
|
||||
char text_store[TEXT_STORE_SIZE];
|
||||
uint8_t data_store[DATA_STORE_SIZE];
|
||||
} RpcDebugApp;
|
||||
|
||||
typedef enum {
|
||||
RpcDebugAppViewWidget,
|
||||
RpcDebugAppViewSubmenu,
|
||||
RpcDebugAppViewTextBox,
|
||||
RpcDebugAppViewTextInput,
|
||||
RpcDebugAppViewByteInput,
|
||||
} RpcDebugAppView;
|
||||
|
||||
typedef enum {
|
||||
// Reserve first 100 events for button types and indexes, starting from 0
|
||||
RpcDebugAppCustomEventInputErrorCode = 100,
|
||||
RpcDebugAppCustomEventInputErrorText,
|
||||
RpcDebugAppCustomEventInputDataExchange,
|
||||
RpcDebugAppCustomEventRpcDataExchange,
|
||||
} RpcDebugAppCustomEvent;
|
@@ -0,0 +1,30 @@
|
||||
#include "rpc_debug_app_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const rpc_debug_app_on_enter_handlers[])(void*) = {
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const rpc_debug_app_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const rpc_debug_app_on_exit_handlers[])(void* context) = {
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers rpc_debug_app_scene_handlers = {
|
||||
.on_enter_handlers = rpc_debug_app_on_enter_handlers,
|
||||
.on_event_handlers = rpc_debug_app_on_event_handlers,
|
||||
.on_exit_handlers = rpc_debug_app_on_exit_handlers,
|
||||
.scene_num = RpcDebugAppSceneNum,
|
||||
};
|
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) RpcDebugAppScene##id,
|
||||
typedef enum {
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
RpcDebugAppSceneNum,
|
||||
} RpcDebugAppScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers rpc_debug_app_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "rpc_debug_app_scene_config.h"
|
||||
#undef ADD_SCENE
|
@@ -0,0 +1,8 @@
|
||||
ADD_SCENE(rpc_debug_app, start, Start)
|
||||
ADD_SCENE(rpc_debug_app, start_dummy, StartDummy)
|
||||
ADD_SCENE(rpc_debug_app, test_app_error, TestAppError)
|
||||
ADD_SCENE(rpc_debug_app, test_data_exchange, TestDataExchange)
|
||||
ADD_SCENE(rpc_debug_app, input_error_code, InputErrorCode)
|
||||
ADD_SCENE(rpc_debug_app, input_error_text, InputErrorText)
|
||||
ADD_SCENE(rpc_debug_app, input_data_exchange, InputDataExchange)
|
||||
ADD_SCENE(rpc_debug_app, receive_data_exchange, ReceiveDataExchange)
|
@@ -0,0 +1,40 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
static void rpc_debug_app_scene_input_data_exchange_result_callback(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, RpcDebugAppCustomEventInputDataExchange);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_data_exchange_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
byte_input_set_header_text(app->byte_input, "Enter data to exchange");
|
||||
byte_input_set_result_callback(
|
||||
app->byte_input,
|
||||
rpc_debug_app_scene_input_data_exchange_result_callback,
|
||||
NULL,
|
||||
app,
|
||||
app->data_store,
|
||||
DATA_STORE_SIZE);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewByteInput);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_input_data_exchange_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == RpcDebugAppCustomEventInputDataExchange) {
|
||||
rpc_system_app_exchange_data(app->rpc, app->data_store, DATA_STORE_SIZE);
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_data_exchange_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
UNUSED(app);
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
static bool rpc_debug_app_scene_input_error_code_validator_callback(
|
||||
const char* text,
|
||||
FuriString* error,
|
||||
void* context) {
|
||||
UNUSED(context);
|
||||
|
||||
for(; *text; ++text) {
|
||||
const char c = *text;
|
||||
if(c < '0' || c > '9') {
|
||||
furi_string_printf(error, "%s", "Please enter\na number!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void rpc_debug_app_scene_input_error_code_result_callback(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, RpcDebugAppCustomEventInputErrorCode);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_error_code_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
strncpy(app->text_store, "666", TEXT_STORE_SIZE);
|
||||
text_input_set_header_text(app->text_input, "Enter error code");
|
||||
text_input_set_validator(
|
||||
app->text_input, rpc_debug_app_scene_input_error_code_validator_callback, NULL);
|
||||
text_input_set_result_callback(
|
||||
app->text_input,
|
||||
rpc_debug_app_scene_input_error_code_result_callback,
|
||||
app,
|
||||
app->text_store,
|
||||
TEXT_STORE_SIZE,
|
||||
true);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewTextInput);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_input_error_code_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == RpcDebugAppCustomEventInputErrorCode) {
|
||||
rpc_system_app_set_error_code(app->rpc, (uint32_t)atol(app->text_store));
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_error_code_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
text_input_set_validator(app->text_input, NULL, NULL);
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
static void rpc_debug_app_scene_input_error_text_result_callback(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, RpcDebugAppCustomEventInputErrorText);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_error_text_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
strncpy(app->text_store, "I'm a scary error message!", TEXT_STORE_SIZE);
|
||||
text_input_set_header_text(app->text_input, "Enter error text");
|
||||
text_input_set_result_callback(
|
||||
app->text_input,
|
||||
rpc_debug_app_scene_input_error_text_result_callback,
|
||||
app,
|
||||
app->text_store,
|
||||
TEXT_STORE_SIZE,
|
||||
true);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewTextInput);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_input_error_text_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == RpcDebugAppCustomEventInputErrorText) {
|
||||
rpc_system_app_set_error_text(app->rpc, app->text_store);
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_input_error_text_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
static void rpc_debug_app_scene_start_format_hex(
|
||||
const uint8_t* data,
|
||||
size_t data_size,
|
||||
char* buf,
|
||||
size_t buf_size) {
|
||||
furi_assert(data);
|
||||
furi_assert(buf);
|
||||
|
||||
const size_t byte_width = 3;
|
||||
const size_t line_width = 7;
|
||||
|
||||
data_size = MIN(data_size, buf_size / (byte_width + 1));
|
||||
|
||||
for(size_t i = 0; i < data_size; ++i) {
|
||||
char* p = buf + (i * byte_width);
|
||||
char sep = !((i + 1) % line_width) ? '\n' : ' ';
|
||||
snprintf(p, byte_width + 1, "%02X%c", data[i], sep);
|
||||
}
|
||||
|
||||
buf[buf_size - 1] = '\0';
|
||||
}
|
||||
|
||||
static void rpc_debug_app_scene_receive_data_exchange_callback(
|
||||
const uint8_t* data,
|
||||
size_t data_size,
|
||||
void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
if(data) {
|
||||
rpc_debug_app_scene_start_format_hex(data, data_size, app->text_store, TEXT_STORE_SIZE);
|
||||
} else {
|
||||
strncpy(app->text_store, "<Data empty>", TEXT_STORE_SIZE);
|
||||
}
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, RpcDebugAppCustomEventRpcDataExchange);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_receive_data_exchange_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
strncpy(app->text_store, "Received data will appear here...", TEXT_STORE_SIZE);
|
||||
|
||||
text_box_set_text(app->text_box, app->text_store);
|
||||
text_box_set_font(app->text_box, TextBoxFontHex);
|
||||
|
||||
rpc_system_app_set_data_exchange_callback(
|
||||
app->rpc, rpc_debug_app_scene_receive_data_exchange_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewTextBox);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_receive_data_exchange_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == RpcDebugAppCustomEventRpcDataExchange) {
|
||||
notification_message(app->notifications, &sequence_blink_cyan_100);
|
||||
notification_message(app->notifications, &sequence_display_backlight_on);
|
||||
text_box_set_text(app->text_box, app->text_store);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_receive_data_exchange_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
text_box_reset(app->text_box);
|
||||
rpc_system_app_set_data_exchange_callback(app->rpc, NULL, NULL);
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexTestAppError,
|
||||
SubmenuIndexTestDataExchange,
|
||||
};
|
||||
|
||||
static void rpc_debug_app_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_start_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Test App Error",
|
||||
SubmenuIndexTestAppError,
|
||||
rpc_debug_app_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Test Data Exchange",
|
||||
SubmenuIndexTestDataExchange,
|
||||
rpc_debug_app_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(submenu, SubmenuIndexTestAppError);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewSubmenu);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
SceneManager* scene_manager = app->scene_manager;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
const uint32_t submenu_index = event.event;
|
||||
if(submenu_index == SubmenuIndexTestAppError) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneTestAppError);
|
||||
consumed = true;
|
||||
} else if(submenu_index == SubmenuIndexTestDataExchange) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneTestDataExchange);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_start_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
void rpc_debug_app_scene_start_dummy_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
64,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
"This application\nis meant to be run\nin \e#RPC\e# mode.",
|
||||
false);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewWidget);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_start_dummy_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
bool consumed = false;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_start_dummy_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexSetErrorCode,
|
||||
SubmenuIndexSetErrorText,
|
||||
} SubmenuIndex;
|
||||
|
||||
static void rpc_debug_app_scene_test_app_error_submenu_callback(void* context, uint32_t index) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_test_app_error_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Set Error Code",
|
||||
SubmenuIndexSetErrorCode,
|
||||
rpc_debug_app_scene_test_app_error_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Set Error Text",
|
||||
SubmenuIndexSetErrorText,
|
||||
rpc_debug_app_scene_test_app_error_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(submenu, SubmenuIndexSetErrorCode);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewSubmenu);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_test_app_error_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
SceneManager* scene_manager = app->scene_manager;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
const uint32_t submenu_index = event.event;
|
||||
if(submenu_index == SubmenuIndexSetErrorCode) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneInputErrorCode);
|
||||
consumed = true;
|
||||
} else if(submenu_index == SubmenuIndexSetErrorText) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneInputErrorText);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_test_app_error_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
#include "../rpc_debug_app.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexSendData,
|
||||
SubmenuIndexReceiveData,
|
||||
} SubmenuIndex;
|
||||
|
||||
static void
|
||||
rpc_debug_app_scene_test_data_exchange_submenu_callback(void* context, uint32_t index) {
|
||||
RpcDebugApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_test_data_exchange_on_enter(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Send Data",
|
||||
SubmenuIndexSendData,
|
||||
rpc_debug_app_scene_test_data_exchange_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Receive Data",
|
||||
SubmenuIndexReceiveData,
|
||||
rpc_debug_app_scene_test_data_exchange_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(submenu, SubmenuIndexSendData);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, RpcDebugAppViewSubmenu);
|
||||
}
|
||||
|
||||
bool rpc_debug_app_scene_test_data_exchange_on_event(void* context, SceneManagerEvent event) {
|
||||
RpcDebugApp* app = context;
|
||||
SceneManager* scene_manager = app->scene_manager;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
const uint32_t submenu_index = event.event;
|
||||
if(submenu_index == SubmenuIndexSendData) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneInputDataExchange);
|
||||
consumed = true;
|
||||
} else if(submenu_index == SubmenuIndexReceiveData) {
|
||||
scene_manager_next_scene(scene_manager, RpcDebugAppSceneReceiveDataExchange);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void rpc_debug_app_scene_test_data_exchange_on_exit(void* context) {
|
||||
RpcDebugApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
@@ -25,7 +25,7 @@ void cli_command_device_info_callback(const char* key, const char* value, bool l
|
||||
void cli_command_device_info(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(cli);
|
||||
UNUSED(args);
|
||||
furi_hal_info_get(cli_command_device_info_callback, context);
|
||||
furi_hal_info_get(cli_command_device_info_callback, '_', context);
|
||||
}
|
||||
|
||||
void cli_command_help(Cli* cli, FuriString* args, void* context) {
|
||||
|
@@ -26,7 +26,7 @@ void power_cli_reboot2dfu(Cli* cli, FuriString* args) {
|
||||
power_reboot(PowerBootModeDfu);
|
||||
}
|
||||
|
||||
static void power_cli_info_callback(const char* key, const char* value, bool last, void* context) {
|
||||
static void power_cli_callback(const char* key, const char* value, bool last, void* context) {
|
||||
UNUSED(last);
|
||||
UNUSED(context);
|
||||
printf("%-24s: %s\r\n", key, value);
|
||||
@@ -35,13 +35,13 @@ static void power_cli_info_callback(const char* key, const char* value, bool las
|
||||
void power_cli_info(Cli* cli, FuriString* args) {
|
||||
UNUSED(cli);
|
||||
UNUSED(args);
|
||||
furi_hal_power_info_get(power_cli_info_callback, NULL);
|
||||
furi_hal_power_info_get(power_cli_callback, '_', NULL);
|
||||
}
|
||||
|
||||
void power_cli_debug(Cli* cli, FuriString* args) {
|
||||
UNUSED(cli);
|
||||
UNUSED(args);
|
||||
furi_hal_power_dump_state();
|
||||
furi_hal_power_debug_get(power_cli_callback, NULL);
|
||||
}
|
||||
|
||||
void power_cli_5v(Cli* cli, FuriString* args) {
|
||||
|
@@ -52,7 +52,12 @@ static RpcSystemCallbacks rpc_systems[] = {
|
||||
{
|
||||
.alloc = rpc_system_gpio_alloc,
|
||||
.free = NULL,
|
||||
}};
|
||||
},
|
||||
{
|
||||
.alloc = rpc_system_property_alloc,
|
||||
.free = NULL,
|
||||
},
|
||||
};
|
||||
|
||||
struct RpcSession {
|
||||
Rpc* rpc;
|
||||
|
@@ -9,9 +9,15 @@
|
||||
|
||||
struct RpcAppSystem {
|
||||
RpcSession* session;
|
||||
|
||||
RpcAppSystemCallback app_callback;
|
||||
void* app_context;
|
||||
|
||||
RpcAppSystemDataExchangeCallback data_exchange_callback;
|
||||
void* data_exchange_context;
|
||||
|
||||
PB_Main* state_msg;
|
||||
PB_Main* error_msg;
|
||||
|
||||
uint32_t last_id;
|
||||
char* last_data;
|
||||
@@ -195,6 +201,50 @@ static void rpc_system_app_button_release(const PB_Main* request, void* context)
|
||||
}
|
||||
}
|
||||
|
||||
static void rpc_system_app_get_error_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_app_get_error_request_tag);
|
||||
furi_assert(context);
|
||||
|
||||
RpcAppSystem* rpc_app = context;
|
||||
RpcSession* session = rpc_app->session;
|
||||
furi_assert(session);
|
||||
|
||||
rpc_app->error_msg->command_id = request->command_id;
|
||||
|
||||
FURI_LOG_D(TAG, "GetError");
|
||||
rpc_send(session, rpc_app->error_msg);
|
||||
}
|
||||
|
||||
static void rpc_system_app_data_exchange_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_app_data_exchange_request_tag);
|
||||
furi_assert(context);
|
||||
|
||||
RpcAppSystem* rpc_app = context;
|
||||
RpcSession* session = rpc_app->session;
|
||||
furi_assert(session);
|
||||
|
||||
PB_CommandStatus command_status;
|
||||
pb_bytes_array_t* data = request->content.app_data_exchange_request.data;
|
||||
|
||||
if(rpc_app->data_exchange_callback) {
|
||||
uint8_t* data_bytes = NULL;
|
||||
size_t data_size = 0;
|
||||
if(data) {
|
||||
data_bytes = data->bytes;
|
||||
data_size = data->size;
|
||||
}
|
||||
rpc_app->data_exchange_callback(data_bytes, data_size, rpc_app->data_exchange_context);
|
||||
command_status = PB_CommandStatus_OK;
|
||||
} else {
|
||||
command_status = PB_CommandStatus_ERROR_APP_CMD_ERROR;
|
||||
}
|
||||
|
||||
FURI_LOG_D(TAG, "DataExchange");
|
||||
rpc_send_and_release_empty(session, request->command_id, command_status);
|
||||
}
|
||||
|
||||
void rpc_system_app_send_started(RpcAppSystem* rpc_app) {
|
||||
furi_assert(rpc_app);
|
||||
RpcSession* session = rpc_app->session;
|
||||
@@ -259,6 +309,58 @@ void rpc_system_app_set_callback(RpcAppSystem* rpc_app, RpcAppSystemCallback cal
|
||||
rpc_app->app_context = ctx;
|
||||
}
|
||||
|
||||
void rpc_system_app_set_error_code(RpcAppSystem* rpc_app, uint32_t error_code) {
|
||||
furi_assert(rpc_app);
|
||||
PB_App_GetErrorResponse* content = &rpc_app->error_msg->content.app_get_error_response;
|
||||
content->code = error_code;
|
||||
}
|
||||
|
||||
void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text) {
|
||||
furi_assert(rpc_app);
|
||||
PB_App_GetErrorResponse* content = &rpc_app->error_msg->content.app_get_error_response;
|
||||
|
||||
if(content->text) {
|
||||
free(content->text);
|
||||
}
|
||||
|
||||
content->text = error_text ? strdup(error_text) : NULL;
|
||||
}
|
||||
|
||||
void rpc_system_app_set_data_exchange_callback(
|
||||
RpcAppSystem* rpc_app,
|
||||
RpcAppSystemDataExchangeCallback callback,
|
||||
void* ctx) {
|
||||
furi_assert(rpc_app);
|
||||
|
||||
rpc_app->data_exchange_callback = callback;
|
||||
rpc_app->data_exchange_context = ctx;
|
||||
}
|
||||
|
||||
void rpc_system_app_exchange_data(RpcAppSystem* rpc_app, const uint8_t* data, size_t data_size) {
|
||||
furi_assert(rpc_app);
|
||||
RpcSession* session = rpc_app->session;
|
||||
furi_assert(session);
|
||||
|
||||
PB_Main message = {
|
||||
.command_id = 0,
|
||||
.command_status = PB_CommandStatus_OK,
|
||||
.has_next = false,
|
||||
.which_content = PB_Main_app_data_exchange_request_tag,
|
||||
};
|
||||
|
||||
PB_App_DataExchangeRequest* content = &message.content.app_data_exchange_request;
|
||||
|
||||
if(data && data_size) {
|
||||
content->data = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data_size));
|
||||
content->data->size = data_size;
|
||||
memcpy(content->data->bytes, data, data_size);
|
||||
} else {
|
||||
content->data = NULL;
|
||||
}
|
||||
|
||||
rpc_send_and_release(session, &message);
|
||||
}
|
||||
|
||||
void* rpc_system_app_alloc(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
|
||||
@@ -270,6 +372,13 @@ void* rpc_system_app_alloc(RpcSession* session) {
|
||||
rpc_app->state_msg->which_content = PB_Main_app_state_response_tag;
|
||||
rpc_app->state_msg->command_status = PB_CommandStatus_OK;
|
||||
|
||||
// App error message
|
||||
rpc_app->error_msg = malloc(sizeof(PB_Main));
|
||||
rpc_app->error_msg->which_content = PB_Main_app_get_error_response_tag;
|
||||
rpc_app->error_msg->command_status = PB_CommandStatus_OK;
|
||||
rpc_app->error_msg->content.app_get_error_response.code = 0;
|
||||
rpc_app->error_msg->content.app_get_error_response.text = NULL;
|
||||
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
.decode_submessage = NULL,
|
||||
@@ -294,6 +403,12 @@ void* rpc_system_app_alloc(RpcSession* session) {
|
||||
rpc_handler.message_handler = rpc_system_app_button_release;
|
||||
rpc_add_handler(session, PB_Main_app_button_release_request_tag, &rpc_handler);
|
||||
|
||||
rpc_handler.message_handler = rpc_system_app_get_error_process;
|
||||
rpc_add_handler(session, PB_Main_app_get_error_request_tag, &rpc_handler);
|
||||
|
||||
rpc_handler.message_handler = rpc_system_app_data_exchange_process;
|
||||
rpc_add_handler(session, PB_Main_app_data_exchange_request_tag, &rpc_handler);
|
||||
|
||||
return rpc_app;
|
||||
}
|
||||
|
||||
@@ -311,8 +426,13 @@ void rpc_system_app_free(void* context) {
|
||||
furi_delay_tick(1);
|
||||
}
|
||||
|
||||
furi_assert(!rpc_app->data_exchange_callback);
|
||||
|
||||
if(rpc_app->last_data) free(rpc_app->last_data);
|
||||
|
||||
pb_release(&PB_Main_msg, rpc_app->error_msg);
|
||||
|
||||
free(rpc_app->error_msg);
|
||||
free(rpc_app->state_msg);
|
||||
free(rpc_app);
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ typedef enum {
|
||||
} RpcAppSystemEvent;
|
||||
|
||||
typedef void (*RpcAppSystemCallback)(RpcAppSystemEvent event, void* context);
|
||||
typedef void (
|
||||
*RpcAppSystemDataExchangeCallback)(const uint8_t* data, size_t data_size, void* context);
|
||||
|
||||
typedef struct RpcAppSystem RpcAppSystem;
|
||||
|
||||
@@ -27,6 +29,17 @@ const char* rpc_system_app_get_data(RpcAppSystem* rpc_app);
|
||||
|
||||
void rpc_system_app_confirm(RpcAppSystem* rpc_app, RpcAppSystemEvent event, bool result);
|
||||
|
||||
void rpc_system_app_set_error_code(RpcAppSystem* rpc_app, uint32_t error_code);
|
||||
|
||||
void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text);
|
||||
|
||||
void rpc_system_app_set_data_exchange_callback(
|
||||
RpcAppSystem* rpc_app,
|
||||
RpcAppSystemDataExchangeCallback callback,
|
||||
void* ctx);
|
||||
|
||||
void rpc_system_app_exchange_data(RpcAppSystem* rpc_app, const uint8_t* data, size_t data_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -34,6 +34,7 @@ void* rpc_system_gui_alloc(RpcSession* session);
|
||||
void rpc_system_gui_free(void* ctx);
|
||||
void* rpc_system_gpio_alloc(RpcSession* session);
|
||||
void rpc_system_gpio_free(void* ctx);
|
||||
void* rpc_system_property_alloc(RpcSession* session);
|
||||
|
||||
void rpc_debug_print_message(const PB_Main* message);
|
||||
void rpc_debug_print_data(const char* prefix, uint8_t* buffer, size_t size);
|
||||
|
107
applications/services/rpc/rpc_property.c
Normal file
107
applications/services/rpc/rpc_property.c
Normal file
@@ -0,0 +1,107 @@
|
||||
#include <flipper.pb.h>
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_info.h>
|
||||
#include <furi_hal_power.h>
|
||||
#include <core/core_defines.h>
|
||||
|
||||
#include "rpc_i.h"
|
||||
|
||||
#define TAG "RpcProperty"
|
||||
|
||||
#define PROPERTY_CATEGORY_DEVICE_INFO "devinfo"
|
||||
#define PROPERTY_CATEGORY_POWER_INFO "pwrinfo"
|
||||
#define PROPERTY_CATEGORY_POWER_DEBUG "pwrdebug"
|
||||
|
||||
typedef struct {
|
||||
RpcSession* session;
|
||||
PB_Main* response;
|
||||
FuriString* subkey;
|
||||
} RpcPropertyContext;
|
||||
|
||||
static void
|
||||
rpc_system_property_get_callback(const char* key, const char* value, bool last, void* context) {
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
furi_assert(context);
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
|
||||
RpcPropertyContext* ctx = context;
|
||||
RpcSession* session = ctx->session;
|
||||
PB_Main* response = ctx->response;
|
||||
|
||||
if(!strncmp(key, furi_string_get_cstr(ctx->subkey), furi_string_size(ctx->subkey))) {
|
||||
response->content.system_device_info_response.key = strdup(key);
|
||||
response->content.system_device_info_response.value = strdup(value);
|
||||
rpc_send_and_release(session, response);
|
||||
}
|
||||
|
||||
if(last) {
|
||||
rpc_send_and_release_empty(session, response->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
}
|
||||
|
||||
static void rpc_system_property_get_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_property_get_request_tag);
|
||||
|
||||
FURI_LOG_D(TAG, "GetProperty");
|
||||
|
||||
RpcSession* session = (RpcSession*)context;
|
||||
furi_assert(session);
|
||||
|
||||
FuriString* topkey = furi_string_alloc();
|
||||
FuriString* subkey = furi_string_alloc_set_str(request->content.property_get_request.key);
|
||||
|
||||
const size_t sep_idx = furi_string_search_char(subkey, '.');
|
||||
|
||||
if(sep_idx == FURI_STRING_FAILURE) {
|
||||
furi_string_swap(topkey, subkey);
|
||||
} else {
|
||||
furi_string_set_n(topkey, subkey, 0, sep_idx);
|
||||
furi_string_right(subkey, sep_idx + 1);
|
||||
}
|
||||
|
||||
PB_Main* response = malloc(sizeof(PB_Main));
|
||||
|
||||
response->command_id = request->command_id;
|
||||
response->command_status = PB_CommandStatus_OK;
|
||||
response->has_next = true;
|
||||
response->which_content = PB_Main_property_get_response_tag;
|
||||
|
||||
RpcPropertyContext property_context = {
|
||||
.session = session,
|
||||
.response = response,
|
||||
.subkey = subkey,
|
||||
};
|
||||
|
||||
if(!furi_string_cmp(topkey, PROPERTY_CATEGORY_DEVICE_INFO)) {
|
||||
furi_hal_info_get(rpc_system_property_get_callback, '.', &property_context);
|
||||
} else if(!furi_string_cmp(topkey, PROPERTY_CATEGORY_POWER_INFO)) {
|
||||
furi_hal_power_info_get(rpc_system_property_get_callback, '.', &property_context);
|
||||
} else if(!furi_string_cmp(topkey, PROPERTY_CATEGORY_POWER_DEBUG)) {
|
||||
furi_hal_power_debug_get(rpc_system_property_get_callback, &property_context);
|
||||
} else {
|
||||
rpc_send_and_release_empty(
|
||||
session, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS);
|
||||
}
|
||||
|
||||
furi_string_free(subkey);
|
||||
furi_string_free(topkey);
|
||||
|
||||
free(response);
|
||||
}
|
||||
|
||||
void* rpc_system_property_alloc(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
.decode_submessage = NULL,
|
||||
.context = session,
|
||||
};
|
||||
|
||||
rpc_handler.message_handler = rpc_system_property_get_process;
|
||||
rpc_add_handler(session, PB_Main_property_get_request_tag, &rpc_handler);
|
||||
return NULL;
|
||||
}
|
@@ -109,7 +109,7 @@ static void rpc_system_system_device_info_process(const PB_Main* request, void*
|
||||
.session = session,
|
||||
.response = response,
|
||||
};
|
||||
furi_hal_info_get(rpc_system_system_device_info_callback, &device_info_context);
|
||||
furi_hal_info_get(rpc_system_system_device_info_callback, '_', &device_info_context);
|
||||
|
||||
free(response);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ static void rpc_system_system_get_power_info_process(const PB_Main* request, voi
|
||||
.session = session,
|
||||
.response = response,
|
||||
};
|
||||
furi_hal_power_info_get(rpc_system_system_power_info_callback, &power_info_context);
|
||||
furi_hal_power_info_get(rpc_system_system_power_info_callback, '_', &power_info_context);
|
||||
|
||||
free(response);
|
||||
}
|
||||
|
Reference in New Issue
Block a user