RPC: Implement storage_stat_request (#800)

* RPC: Update protobuf sources
* RPC: Implement storage_stat_request
* RPC: Test storage_stat_request
* FuriRecord: fix use after free in destroy method.
* Furi: refactor PubSub and it's usage. Fix allocation in RPC.
* FuriCore: fix memory leak in pubsub
* FuriCore: update unsubscribe method signature in pubsub, make subscription structure lighter.
* FuriCore: remove dead code

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Anna Prosvetova
2021-11-01 23:35:54 +03:00
committed by GitHub
parent b397442d89
commit e9e76e144c
37 changed files with 350 additions and 214 deletions

View File

@@ -28,11 +28,11 @@ void input_press_timer_callback(void* arg) {
input_pin->press_counter++;
if(input_pin->press_counter == INPUT_LONG_PRESS_COUNTS) {
event.type = InputTypeLong;
notify_pubsub(&input->event_pubsub, &event);
furi_pubsub_publish(input->event_pubsub, &event);
} else if(input_pin->press_counter > INPUT_LONG_PRESS_COUNTS) {
input_pin->press_counter--;
event.type = InputTypeRepeat;
notify_pubsub(&input->event_pubsub, &event);
furi_pubsub_publish(input->event_pubsub, &event);
}
}
@@ -89,7 +89,7 @@ void input_cli_send(Cli* cli, string_t args, void* context) {
return;
}
// Publish input event
notify_pubsub(&input->event_pubsub, &event);
furi_pubsub_publish(input->event_pubsub, &event);
}
const char* input_get_key_name(InputKey key) {
@@ -120,8 +120,8 @@ const char* input_get_type_name(InputType type) {
int32_t input_srv() {
input = furi_alloc(sizeof(Input));
input->thread = osThreadGetId();
init_pubsub(&input->event_pubsub);
furi_record_create("input_events", &input->event_pubsub);
input->event_pubsub = furi_pubsub_alloc();
furi_record_create("input_events", input->event_pubsub);
input->cli = furi_record_open("cli");
if(input->cli) {
@@ -168,14 +168,14 @@ int32_t input_srv() {
input_timer_stop(input->pin_states[i].press_timer);
if(input->pin_states[i].press_counter < INPUT_LONG_PRESS_COUNTS) {
event.type = InputTypeShort;
notify_pubsub(&input->event_pubsub, &event);
furi_pubsub_publish(input->event_pubsub, &event);
}
input->pin_states[i].press_counter = 0;
}
// Send Press/Release event
event.type = input->pin_states[i].state ? InputTypePress : InputTypeRelease;
notify_pubsub(&input->event_pubsub, &event);
furi_pubsub_publish(input->event_pubsub, &event);
}
}

View File

@@ -18,7 +18,7 @@ typedef enum {
InputTypeRepeat, /**< Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */
} InputType;
/** Input Event, dispatches with PubSub */
/** Input Event, dispatches with FuriPubSub */
typedef struct {
uint32_t sequence;
InputKey key;

View File

@@ -6,8 +6,6 @@
#pragma once
#include "input.h"
#include <FreeRTOS.h>
#include <timers.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -35,7 +33,7 @@ typedef struct {
/** Input state */
typedef struct {
osThreadId_t thread;
PubSub event_pubsub;
FuriPubSub* event_pubsub;
InputPinState* pin_states;
Cli* cli;
volatile uint32_t counter;