[FL-2230] SubGhz: protocol API refactoring (#969)

* SubGhz: protocols library refactoring
* SubGhz: new architecture and refactoring
* SubGhz: simplify protocol structure, remove unused types
* SubGhz: rename Subghz to SubGhz
* SubGhz: add environment concept

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
Skorpionm
2022-03-03 13:48:56 +04:00
committed by GitHub
parent 052237f8c9
commit 3164184bbc
173 changed files with 9836 additions and 8486 deletions
+12 -12
View File
@@ -23,12 +23,12 @@ static int32_t subghz_chat_worker_thread(void* context) {
SubGhzChatWorker* instance = context;
FURI_LOG_I(TAG, "Worker start");
char c;
SubghzChatEvent event;
event.event = SubghzChatEventUserEntrance;
SubGhzChatEvent event;
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) {
event.event = SubghzChatEventInputData;
event.event = SubGhzChatEventInputData;
event.c = c;
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
}
@@ -41,13 +41,13 @@ static int32_t subghz_chat_worker_thread(void* context) {
static void subghz_chat_worker_update_rx_event_chat(void* context) {
furi_assert(context);
SubGhzChatWorker* instance = context;
SubghzChatEvent event;
SubGhzChatEvent event;
if((millis() - instance->last_time_rx_data) > SUBGHZ_CHAT_WORKER_TIMEOUT_BETWEEN_MESSAGES) {
event.event = SubghzChatEventNewMessage;
event.event = SubGhzChatEventNewMessage;
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
}
instance->last_time_rx_data = millis();
event.event = SubghzChatEventRXData;
event.event = SubGhzChatEventRXData;
osMessageQueuePut(instance->event_queue, &event, 0, osWaitForever);
}
@@ -55,12 +55,12 @@ SubGhzChatWorker* subghz_chat_worker_alloc() {
SubGhzChatWorker* instance = malloc(sizeof(SubGhzChatWorker));
instance->thread = furi_thread_alloc();
furi_thread_set_name(instance->thread, "SubghzChat");
furi_thread_set_name(instance->thread, "SubGhzChat");
furi_thread_set_stack_size(instance->thread, 2048);
furi_thread_set_context(instance->thread, instance);
furi_thread_set_callback(instance->thread, subghz_chat_worker_thread);
instance->subghz_txrx = subghz_tx_rx_worker_alloc();
instance->event_queue = osMessageQueueNew(80, sizeof(SubghzChatEvent), NULL);
instance->event_queue = osMessageQueueNew(80, sizeof(SubGhzChatEvent), NULL);
return instance;
}
@@ -109,18 +109,18 @@ bool subghz_chat_worker_is_running(SubGhzChatWorker* instance) {
return instance->worker_running;
}
SubghzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance) {
SubGhzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance) {
furi_assert(instance);
SubghzChatEvent event;
SubGhzChatEvent event;
if(osMessageQueueGet(instance->event_queue, &event, NULL, osWaitForever) == osOK) {
return event;
} else {
event.event = SubghzChatEventNoEvent;
event.event = SubGhzChatEventNoEvent;
return event;
}
}
void subghz_chat_worker_put_event_chat(SubGhzChatWorker* instance, SubghzChatEvent* event) {
void subghz_chat_worker_put_event_chat(SubGhzChatWorker* instance, SubGhzChatEvent* event) {
furi_assert(instance);
osMessageQueuePut(instance->event_queue, event, 0, osWaitForever);
}