[FL-2163] CLI: Separate session from CLI service (#1130)

* CLI: session refactoring
* Added forgotten define
* Desktop lock state save
* Dolphin: use proper type for value returned by dolphin_state_xp_to_levelup

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov
2022-04-29 15:02:17 +03:00
committed by GitHub
parent 76221021ec
commit 0eac917f91
20 changed files with 348 additions and 243 deletions

View File

@@ -12,6 +12,8 @@ struct SubGhzChatWorker {
volatile bool worker_stoping;
osMessageQueueId_t event_queue;
uint32_t last_time_rx_data;
Cli* cli;
};
/** Worker thread
@@ -27,7 +29,7 @@ static int32_t subghz_chat_worker_thread(void* context) {
event.event = SubGhzChatEventUserEntrance;
osMessageQueuePut(instance->event_queue, &event, 0, 0);
while(instance->worker_running) {
if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 1000) == 1) {
if(cli_read_timeout(instance->cli, (uint8_t*)&c, 1, 1000) == 1) {
event.event = SubGhzChatEventInputData;
event.c = c;
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
@@ -52,9 +54,11 @@ static void subghz_chat_worker_update_rx_event_chat(void* context) {
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
}
SubGhzChatWorker* subghz_chat_worker_alloc() {
SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli) {
SubGhzChatWorker* instance = malloc(sizeof(SubGhzChatWorker));
instance->cli = cli;
instance->thread = furi_thread_alloc();
furi_thread_set_name(instance->thread, "SubGhzChat");
furi_thread_set_stack_size(instance->thread, 2048);

View File

@@ -1,5 +1,6 @@
#pragma once
#include "../subghz_i.h"
#include <cli/cli.h>
typedef struct SubGhzChatWorker SubGhzChatWorker;
@@ -17,7 +18,7 @@ typedef struct {
char c;
} SubGhzChatEvent;
SubGhzChatWorker* subghz_chat_worker_alloc();
SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli);
void subghz_chat_worker_free(SubGhzChatWorker* instance);
bool subghz_chat_worker_start(SubGhzChatWorker* instance, uint32_t frequency);
void subghz_chat_worker_stop(SubGhzChatWorker* instance);