[FL-2297, FL-2289] Power info command, Validator fixes (#1097)
* Power info command, validator fixes * strdup in validator, fix memory leak * furi_hal_crypto fixed again * FuriHal: limit ARR and CC in speaker hal * FuriHal: LL_TIM_DisableAllOutputs in speaker stop * Rpc: fix memory leak in screen streaming * Get rid of crypto_enable/crypto_disable Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <furi_hal.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#define TAG "RpcCli"
|
||||
|
||||
typedef struct {
|
||||
Cli* cli;
|
||||
bool session_close_request;
|
||||
@@ -38,6 +40,9 @@ static void rpc_session_terminated_callback(void* context) {
|
||||
void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) {
|
||||
Rpc* rpc = context;
|
||||
|
||||
uint32_t mem_before = memmgr_get_free_heap();
|
||||
FURI_LOG_D(TAG, "Free memory %d", mem_before);
|
||||
|
||||
furi_hal_usb_lock();
|
||||
RpcSession* rpc_session = rpc_session_open(rpc);
|
||||
if(rpc_session == NULL) {
|
||||
|
@@ -346,8 +346,19 @@ void rpc_system_gui_free(void* context) {
|
||||
}
|
||||
|
||||
if(rpc_gui->is_streaming) {
|
||||
rpc_gui->is_streaming = false;
|
||||
// Remove GUI framebuffer callback
|
||||
gui_remove_framebuffer_callback(
|
||||
rpc_gui->gui, rpc_system_gui_screen_stream_frame_callback, context);
|
||||
// Stop and release worker thread
|
||||
osThreadFlagsSet(
|
||||
furi_thread_get_thread_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagExit);
|
||||
furi_thread_join(rpc_gui->transmit_thread);
|
||||
furi_thread_free(rpc_gui->transmit_thread);
|
||||
// Release frame
|
||||
pb_release(&PB_Main_msg, rpc_gui->transmit_frame);
|
||||
free(rpc_gui->transmit_frame);
|
||||
rpc_gui->transmit_frame = NULL;
|
||||
}
|
||||
furi_record_close("gui");
|
||||
free(rpc_gui);
|
||||
|
@@ -6,6 +6,11 @@
|
||||
|
||||
#include "rpc_i.h"
|
||||
|
||||
typedef struct {
|
||||
RpcSession* session;
|
||||
PB_Main* response;
|
||||
} RpcSystemContext;
|
||||
|
||||
static void rpc_system_system_ping_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_ping_request_tag);
|
||||
@@ -55,11 +60,6 @@ static void rpc_system_system_reboot_process(const PB_Main* request, void* conte
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
RpcSession* session;
|
||||
PB_Main* response;
|
||||
} RpcSystemSystemDeviceInfoContext;
|
||||
|
||||
static void rpc_system_system_device_info_callback(
|
||||
const char* key,
|
||||
const char* value,
|
||||
@@ -67,7 +67,7 @@ static void rpc_system_system_device_info_callback(
|
||||
void* context) {
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
RpcSystemSystemDeviceInfoContext* ctx = context;
|
||||
RpcSystemContext* ctx = context;
|
||||
|
||||
char* str_key = strdup(key);
|
||||
char* str_value = strdup(value);
|
||||
@@ -91,7 +91,7 @@ static void rpc_system_system_device_info_process(const PB_Main* request, void*
|
||||
response->which_content = PB_Main_system_device_info_response_tag;
|
||||
response->command_status = PB_CommandStatus_OK;
|
||||
|
||||
RpcSystemSystemDeviceInfoContext device_info_context = {
|
||||
RpcSystemContext device_info_context = {
|
||||
.session = session,
|
||||
.response = response,
|
||||
};
|
||||
@@ -202,6 +202,46 @@ static void rpc_system_system_protobuf_version_process(const PB_Main* request, v
|
||||
free(response);
|
||||
}
|
||||
|
||||
static void rpc_system_system_power_info_callback(
|
||||
const char* key,
|
||||
const char* value,
|
||||
bool last,
|
||||
void* context) {
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
RpcSystemContext* ctx = context;
|
||||
|
||||
char* str_key = strdup(key);
|
||||
char* str_value = strdup(value);
|
||||
|
||||
ctx->response->has_next = !last;
|
||||
ctx->response->content.system_device_info_response.key = str_key;
|
||||
ctx->response->content.system_device_info_response.value = str_value;
|
||||
|
||||
rpc_send_and_release(ctx->session, ctx->response);
|
||||
}
|
||||
|
||||
static void rpc_system_system_get_power_info_process(const PB_Main* request, void* context) {
|
||||
furi_assert(request);
|
||||
furi_assert(request->which_content == PB_Main_system_power_info_request_tag);
|
||||
|
||||
RpcSession* session = (RpcSession*)context;
|
||||
furi_assert(session);
|
||||
|
||||
PB_Main* response = malloc(sizeof(PB_Main));
|
||||
response->command_id = request->command_id;
|
||||
response->which_content = PB_Main_system_power_info_response_tag;
|
||||
response->command_status = PB_CommandStatus_OK;
|
||||
|
||||
RpcSystemContext power_info_context = {
|
||||
.session = session,
|
||||
.response = response,
|
||||
};
|
||||
furi_hal_power_info_get(rpc_system_system_power_info_callback, &power_info_context);
|
||||
|
||||
free(response);
|
||||
}
|
||||
|
||||
void* rpc_system_system_alloc(RpcSession* session) {
|
||||
RpcHandler rpc_handler = {
|
||||
.message_handler = NULL,
|
||||
@@ -233,5 +273,8 @@ void* rpc_system_system_alloc(RpcSession* session) {
|
||||
rpc_handler.message_handler = rpc_system_system_protobuf_version_process;
|
||||
rpc_add_handler(session, PB_Main_system_protobuf_version_request_tag, &rpc_handler);
|
||||
|
||||
rpc_handler.message_handler = rpc_system_system_get_power_info_process;
|
||||
rpc_add_handler(session, PB_Main_system_power_info_request_tag, &rpc_handler);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user