RPC: Add Virtual Display & Unify log tags (#814)
* RPC: Update protobuf sources * RPC: Add Virtual Display * Unify log tags * RPC: Virtual Display placeholder * Rpc: clear frame buffer callback before confirm. * Firmware: full assert for hal, move fatfs initialization to furi hal. * FuriHal: VCP optimizations, thread safe console. Rpc: adjust buffer sizes. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
		
							parent
							
								
									b564e8eb38
								
							
						
					
					
						commit
						558fa5670b
					
				| @ -231,6 +231,10 @@ endif | |||||||
| SRV_RPC ?= 0 | SRV_RPC ?= 0 | ||||||
| ifeq ($(SRV_RPC), 1) | ifeq ($(SRV_RPC), 1) | ||||||
| CFLAGS		+= -DSRV_RPC | CFLAGS		+= -DSRV_RPC | ||||||
|  | ifeq ($(SRV_RPC_DEBUG), 1) | ||||||
|  | CFLAGS		+= -DSRV_RPC_DEBUG | ||||||
|  | endif | ||||||
|  | SRV_CLI		= 1 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| SRV_LOADER ?= 0 | SRV_LOADER ?= 0 | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include "archive_files.h" | #include "archive_files.h" | ||||||
| #include "archive_browser.h" | #include "archive_browser.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Archive" | ||||||
|  | 
 | ||||||
| bool filter_by_extension(FileInfo* file_info, const char* tab_ext, const char* name) { | bool filter_by_extension(FileInfo* file_info, const char* tab_ext, const char* name) { | ||||||
|     furi_assert(file_info); |     furi_assert(file_info); | ||||||
|     furi_assert(tab_ext); |     furi_assert(tab_ext); | ||||||
| @ -147,11 +149,11 @@ void archive_file_append(const char* path, const char* format, ...) { | |||||||
|     FileWorker* file_worker = file_worker_alloc(false); |     FileWorker* file_worker = file_worker_alloc(false); | ||||||
| 
 | 
 | ||||||
|     if(!file_worker_open(file_worker, path, FSAM_WRITE, FSOM_OPEN_APPEND)) { |     if(!file_worker_open(file_worker, path, FSAM_WRITE, FSOM_OPEN_APPEND)) { | ||||||
|         FURI_LOG_E("Archive", "Append open error"); |         FURI_LOG_E(TAG, "Append open error"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(!file_worker_write(file_worker, string_get_cstr(string), string_size(string))) { |     if(!file_worker_write(file_worker, string_get_cstr(string), string_size(string))) { | ||||||
|         FURI_LOG_E("Archive", "Append write error"); |         FURI_LOG_E(TAG, "Append write error"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     file_worker_close(file_worker); |     file_worker_close(file_worker); | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| #include "battery_service.h" | #include "battery_service.h" | ||||||
| #include "bt_keys_storage.h" | #include "bt_keys_storage.h" | ||||||
| 
 | 
 | ||||||
| #define BT_SERVICE_TAG "BT" | #define TAG "BtSrv" | ||||||
| 
 | 
 | ||||||
| static void bt_draw_statusbar_callback(Canvas* canvas, void* context) { | static void bt_draw_statusbar_callback(Canvas* canvas, void* context) { | ||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
| @ -87,7 +87,7 @@ static uint16_t bt_on_data_received_callback(uint8_t* data, uint16_t size, void* | |||||||
| 
 | 
 | ||||||
|     size_t bytes_processed = rpc_session_feed(bt->rpc_session, data, size, 1000); |     size_t bytes_processed = rpc_session_feed(bt->rpc_session, data, size, 1000); | ||||||
|     if(bytes_processed != size) { |     if(bytes_processed != size) { | ||||||
|         FURI_LOG_E(BT_SERVICE_TAG, "Only %d of %d bytes processed by RPC", bytes_processed, size); |         FURI_LOG_E(TAG, "Only %d of %d bytes processed by RPC", bytes_processed, size); | ||||||
|     } |     } | ||||||
|     return rpc_session_get_available_size(bt->rpc_session); |     return rpc_session_get_available_size(bt->rpc_session); | ||||||
| } | } | ||||||
| @ -135,7 +135,7 @@ static void bt_on_gap_event_callback(BleEvent event, void* context) { | |||||||
|         BtMessage message = {.type = BtMessageTypeUpdateStatusbar}; |         BtMessage message = {.type = BtMessageTypeUpdateStatusbar}; | ||||||
|         furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); |         furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); | ||||||
|         // Open RPC session
 |         // Open RPC session
 | ||||||
|         FURI_LOG_I(BT_SERVICE_TAG, "Open RPC connection"); |         FURI_LOG_I(TAG, "Open RPC connection"); | ||||||
|         bt->rpc_session = rpc_session_open(bt->rpc); |         bt->rpc_session = rpc_session_open(bt->rpc); | ||||||
|         rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback); |         rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback); | ||||||
|         rpc_session_set_buffer_is_empty_callback(bt->rpc_session, bt_rpc_buffer_is_empty_callback); |         rpc_session_set_buffer_is_empty_callback(bt->rpc_session, bt_rpc_buffer_is_empty_callback); | ||||||
| @ -149,7 +149,7 @@ static void bt_on_gap_event_callback(BleEvent event, void* context) { | |||||||
|         message.data.battery_level = info.charge; |         message.data.battery_level = info.charge; | ||||||
|         furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); |         furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); | ||||||
|     } else if(event.type == BleEventTypeDisconnected) { |     } else if(event.type == BleEventTypeDisconnected) { | ||||||
|         FURI_LOG_I(BT_SERVICE_TAG, "Close RPC connection"); |         FURI_LOG_I(TAG, "Close RPC connection"); | ||||||
|         if(bt->rpc_session) { |         if(bt->rpc_session) { | ||||||
|             rpc_session_close(bt->rpc_session); |             rpc_session_close(bt->rpc_session); | ||||||
|             bt->rpc_session = NULL; |             bt->rpc_session = NULL; | ||||||
| @ -172,7 +172,7 @@ static void bt_on_gap_event_callback(BleEvent event, void* context) { | |||||||
| static void bt_on_key_storage_change_callback(uint8_t* addr, uint16_t size, void* context) { | static void bt_on_key_storage_change_callback(uint8_t* addr, uint16_t size, void* context) { | ||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
|     Bt* bt = context; |     Bt* bt = context; | ||||||
|     FURI_LOG_I(BT_SERVICE_TAG, "Changed addr start: %08lX, size changed: %d", addr, size); |     FURI_LOG_I(TAG, "Changed addr start: %08lX, size changed: %d", addr, size); | ||||||
|     BtMessage message = {.type = BtMessageTypeKeysStorageUpdated}; |     BtMessage message = {.type = BtMessageTypeKeysStorageUpdated}; | ||||||
|     furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); |     furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); | ||||||
| } | } | ||||||
| @ -195,20 +195,20 @@ int32_t bt_srv() { | |||||||
| 
 | 
 | ||||||
|     // Read keys
 |     // Read keys
 | ||||||
|     if(!bt_load_key_storage(bt)) { |     if(!bt_load_key_storage(bt)) { | ||||||
|         FURI_LOG_W(BT_SERVICE_TAG, "Failed to load saved bonding keys"); |         FURI_LOG_W(TAG, "Failed to load saved bonding keys"); | ||||||
|     } |     } | ||||||
|     // Start 2nd core
 |     // Start 2nd core
 | ||||||
|     if(!furi_hal_bt_start_core2()) { |     if(!furi_hal_bt_start_core2()) { | ||||||
|         FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); |         FURI_LOG_E(TAG, "Core2 startup failed"); | ||||||
|     } else { |     } else { | ||||||
|         view_port_enabled_set(bt->statusbar_view_port, true); |         view_port_enabled_set(bt->statusbar_view_port, true); | ||||||
|         if(furi_hal_bt_init_app(bt_on_gap_event_callback, bt)) { |         if(furi_hal_bt_init_app(bt_on_gap_event_callback, bt)) { | ||||||
|             FURI_LOG_I(BT_SERVICE_TAG, "BLE stack started"); |             FURI_LOG_I(TAG, "BLE stack started"); | ||||||
|             if(bt->bt_settings.enabled) { |             if(bt->bt_settings.enabled) { | ||||||
|                 furi_hal_bt_start_advertising(); |                 furi_hal_bt_start_advertising(); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed"); |             FURI_LOG_E(TAG, "BT App start failed"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     furi_hal_bt_set_key_storage_change_callback(bt_on_key_storage_change_callback, bt); |     furi_hal_bt_set_key_storage_change_callback(bt_on_key_storage_change_callback, bt); | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <file-worker.h> | #include <file-worker.h> | ||||||
| 
 | 
 | ||||||
| #define BT_SETTINGS_TAG "bt settings" | #define TAG "BtSettings" | ||||||
| #define BT_SETTINGS_PATH "/int/bt.settings" | #define BT_SETTINGS_PATH "/int/bt.settings" | ||||||
| 
 | 
 | ||||||
| bool bt_settings_load(BtSettings* bt_settings) { | bool bt_settings_load(BtSettings* bt_settings) { | ||||||
| @ -10,7 +10,7 @@ bool bt_settings_load(BtSettings* bt_settings) { | |||||||
|     bool file_loaded = false; |     bool file_loaded = false; | ||||||
|     BtSettings settings = {}; |     BtSettings settings = {}; | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I(BT_SETTINGS_TAG, "Loading settings from \"%s\"", BT_SETTINGS_PATH); |     FURI_LOG_I(TAG, "Loading settings from \"%s\"", BT_SETTINGS_PATH); | ||||||
|     FileWorker* file_worker = file_worker_alloc(true); |     FileWorker* file_worker = file_worker_alloc(true); | ||||||
|     if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { |     if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { | ||||||
|         if(file_worker_read(file_worker, &settings, sizeof(settings))) { |         if(file_worker_read(file_worker, &settings, sizeof(settings))) { | ||||||
| @ -20,16 +20,16 @@ bool bt_settings_load(BtSettings* bt_settings) { | |||||||
|     file_worker_free(file_worker); |     file_worker_free(file_worker); | ||||||
| 
 | 
 | ||||||
|     if(file_loaded) { |     if(file_loaded) { | ||||||
|         FURI_LOG_I(BT_SETTINGS_TAG, "Settings load success"); |         FURI_LOG_I(TAG, "Settings load success"); | ||||||
|         if(settings.version != BT_SETTINGS_VERSION) { |         if(settings.version != BT_SETTINGS_VERSION) { | ||||||
|             FURI_LOG_E(BT_SETTINGS_TAG, "Settings version mismatch"); |             FURI_LOG_E(TAG, "Settings version mismatch"); | ||||||
|         } else { |         } else { | ||||||
|             osKernelLock(); |             osKernelLock(); | ||||||
|             *bt_settings = settings; |             *bt_settings = settings; | ||||||
|             osKernelUnlock(); |             osKernelUnlock(); | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E(BT_SETTINGS_TAG, "Settings load failed"); |         FURI_LOG_E(TAG, "Settings load failed"); | ||||||
|     } |     } | ||||||
|     return file_loaded; |     return file_loaded; | ||||||
| } | } | ||||||
| @ -41,7 +41,7 @@ bool bt_settings_save(BtSettings* bt_settings) { | |||||||
|     FileWorker* file_worker = file_worker_alloc(true); |     FileWorker* file_worker = file_worker_alloc(true); | ||||||
|     if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS)) { |     if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS)) { | ||||||
|         if(file_worker_write(file_worker, bt_settings, sizeof(BtSettings))) { |         if(file_worker_write(file_worker, bt_settings, sizeof(BtSettings))) { | ||||||
|             FURI_LOG_I(BT_SETTINGS_TAG, "Settings saved to \"%s\"", BT_SETTINGS_PATH); |             FURI_LOG_I(TAG, "Settings saved to \"%s\"", BT_SETTINGS_PATH); | ||||||
|             result = true; |             result = true; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -6,6 +6,9 @@ | |||||||
| #include <furi-hal-usb-hid.h> | #include <furi-hal-usb-hid.h> | ||||||
| #include <storage/storage.h> | #include <storage/storage.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "BadUsb" | ||||||
|  | #define WORKER_TAG TAG "Worker" | ||||||
|  | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     EventTypeInput, |     EventTypeInput, | ||||||
|     EventTypeWorkerState, |     EventTypeWorkerState, | ||||||
| @ -191,7 +194,7 @@ static bool ducky_parse_line(string_t line, BadUsbParams* app) { | |||||||
| 
 | 
 | ||||||
| static void badusb_worker(void* context) { | static void badusb_worker(void* context) { | ||||||
|     BadUsbParams* app = context; |     BadUsbParams* app = context; | ||||||
|     FURI_LOG_I("BadUSB worker", "Init"); |     FURI_LOG_I(WORKER_TAG, "Init"); | ||||||
|     File* script_file = storage_file_alloc(furi_record_open("storage")); |     File* script_file = storage_file_alloc(furi_record_open("storage")); | ||||||
|     BadUsbEvent evt; |     BadUsbEvent evt; | ||||||
|     string_t line; |     string_t line; | ||||||
| @ -203,7 +206,7 @@ static void badusb_worker(void* context) { | |||||||
|         uint32_t flags = |         uint32_t flags = | ||||||
|             osThreadFlagsWait(WorkerCmdStart | WorkerCmdStop, osFlagsWaitAny, osWaitForever); |             osThreadFlagsWait(WorkerCmdStart | WorkerCmdStop, osFlagsWaitAny, osWaitForever); | ||||||
|         if(flags & WorkerCmdStart) { |         if(flags & WorkerCmdStart) { | ||||||
|             FURI_LOG_I("BadUSB worker", "Start"); |             FURI_LOG_I(WORKER_TAG, "Start"); | ||||||
|             do { |             do { | ||||||
|                 ret = storage_file_read(script_file, buffer, 16); |                 ret = storage_file_read(script_file, buffer, 16); | ||||||
|                 for(uint16_t i = 0; i < ret; i++) { |                 for(uint16_t i = 0; i < ret; i++) { | ||||||
| @ -211,7 +214,7 @@ static void badusb_worker(void* context) { | |||||||
|                         line_cnt++; |                         line_cnt++; | ||||||
|                         if(ducky_parse_line(line, app) == false) { |                         if(ducky_parse_line(line, app) == false) { | ||||||
|                             ret = 0; |                             ret = 0; | ||||||
|                             FURI_LOG_E("BadUSB worker", "Unknown command at line %lu", line_cnt); |                             FURI_LOG_E(WORKER_TAG, "Unknown command at line %lu", line_cnt); | ||||||
|                             evt.type = EventTypeWorkerState; |                             evt.type = EventTypeWorkerState; | ||||||
|                             evt.worker.state = WorkerStateScriptError; |                             evt.worker.state = WorkerStateScriptError; | ||||||
|                             evt.worker.line = line_cnt; |                             evt.worker.line = line_cnt; | ||||||
| @ -231,7 +234,7 @@ static void badusb_worker(void* context) { | |||||||
|             } while(ret > 0); |             } while(ret > 0); | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E("BadUSB worker", "Script file open error"); |         FURI_LOG_E(WORKER_TAG, "Script file open error"); | ||||||
|         evt.type = EventTypeWorkerState; |         evt.type = EventTypeWorkerState; | ||||||
|         evt.worker.state = WorkerStateNoFile; |         evt.worker.state = WorkerStateNoFile; | ||||||
|         osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); |         osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); | ||||||
| @ -243,7 +246,7 @@ static void badusb_worker(void* context) { | |||||||
|     storage_file_close(script_file); |     storage_file_close(script_file); | ||||||
|     storage_file_free(script_file); |     storage_file_free(script_file); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("BadUSB worker", "End"); |     FURI_LOG_I(WORKER_TAG, "End"); | ||||||
|     evt.type = EventTypeWorkerState; |     evt.type = EventTypeWorkerState; | ||||||
|     evt.worker.state = WorkerStateDone; |     evt.worker.state = WorkerStateDone; | ||||||
|     osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); |     osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever); | ||||||
| @ -324,7 +327,7 @@ int32_t bad_usb_app(void* p) { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else if(event.type == EventTypeWorkerState) { |             } else if(event.type == EventTypeWorkerState) { | ||||||
|                 FURI_LOG_I("BadUSB app", "ev: %d", event.worker.state); |                 FURI_LOG_I(TAG, "ev: %d", event.worker.state); | ||||||
|                 if(event.worker.state == WorkerStateDone) { |                 if(event.worker.state == WorkerStateDone) { | ||||||
|                     worker_running = false; |                     worker_running = false; | ||||||
|                     if(app_state == AppStateExit) |                     if(app_state == AppStateExit) | ||||||
|  | |||||||
| @ -14,6 +14,8 @@ | |||||||
| 
 | 
 | ||||||
| #include "view_display_test.h" | #include "view_display_test.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "DisplayTest" | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     Gui* gui; |     Gui* gui; | ||||||
|     ViewDispatcher* view_dispatcher; |     ViewDispatcher* view_dispatcher; | ||||||
| @ -77,7 +79,7 @@ static uint32_t display_test_exit_callback(void* context) { | |||||||
| 
 | 
 | ||||||
| static void display_test_reload_config(DisplayTest* instance) { | static void display_test_reload_config(DisplayTest* instance) { | ||||||
|     FURI_LOG_I( |     FURI_LOG_I( | ||||||
|         "DisplayTest", |         TAG, | ||||||
|         "contrast: %d, regulation_ratio: %d, bias: %d", |         "contrast: %d, regulation_ratio: %d, bias: %d", | ||||||
|         instance->config_contrast, |         instance->config_contrast, | ||||||
|         instance->config_regulation_ratio, |         instance->config_regulation_ratio, | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ | |||||||
| #include <gui/gui.h> | #include <gui/gui.h> | ||||||
| #include <input/input.h> | #include <input/input.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "KeypadTest" | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     bool press[5]; |     bool press[5]; | ||||||
|     uint16_t up; |     uint16_t up; | ||||||
| @ -80,7 +82,7 @@ int32_t keypad_test_app(void* p) { | |||||||
| 
 | 
 | ||||||
|     ValueMutex state_mutex; |     ValueMutex state_mutex; | ||||||
|     if(!init_mutex(&state_mutex, &_state, sizeof(KeypadTestState))) { |     if(!init_mutex(&state_mutex, &_state, sizeof(KeypadTestState))) { | ||||||
|         FURI_LOG_E("KeypadTest", "cannot create mutex"); |         FURI_LOG_E(TAG, "cannot create mutex"); | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -101,7 +103,7 @@ int32_t keypad_test_app(void* p) { | |||||||
|         if(event_status == osOK) { |         if(event_status == osOK) { | ||||||
|             if(event.type == EventTypeInput) { |             if(event.type == EventTypeInput) { | ||||||
|                 FURI_LOG_I( |                 FURI_LOG_I( | ||||||
|                     "KeypadTest", |                     TAG, | ||||||
|                     "key: %s type: %s", |                     "key: %s type: %s", | ||||||
|                     input_get_key_name(event.input.key), |                     input_get_key_name(event.input.key), | ||||||
|                     input_get_type_name(event.input.type)); |                     input_get_type_name(event.input.type)); | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| #include "desktop_animation.h" | #include "desktop_animation.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "DesktopAnimation" | ||||||
|  | 
 | ||||||
| static const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64}; | static const Icon* idle_scenes[] = {&A_Wink_128x64, &A_WatchingTV_128x64}; | ||||||
| 
 | 
 | ||||||
| const Icon* desktop_get_icon() { | const Icon* desktop_get_icon() { | ||||||
| @ -12,10 +14,10 @@ const Icon* desktop_get_icon() { | |||||||
|     DolphinStats stats = dolphin_stats(dolphin); |     DolphinStats stats = dolphin_stats(dolphin); | ||||||
|     float timediff = fabs(difftime(stats.timestamp, dolphin_state_timestamp())); |     float timediff = fabs(difftime(stats.timestamp, dolphin_state_timestamp())); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("desktop-animation", "background change"); |     FURI_LOG_I(TAG, "background change"); | ||||||
|     FURI_LOG_I("desktop-animation", "icounter: %d", stats.icounter); |     FURI_LOG_I(TAG, "icounter: %d", stats.icounter); | ||||||
|     FURI_LOG_I("desktop-animation", "butthurt: %d", stats.butthurt); |     FURI_LOG_I(TAG, "butthurt: %d", stats.butthurt); | ||||||
|     FURI_LOG_I("desktop-animation", "time since deeed: %.0f", timediff); |     FURI_LOG_I(TAG, "time since deeed: %.0f", timediff); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     if((random() % 100) > 50) { // temp rnd selection
 |     if((random() % 100) > 50) { // temp rnd selection
 | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include "view-holder.h" | #include "view-holder.h" | ||||||
| #include <gui/view_i.h> | #include <gui/view_i.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "ViewHolder" | ||||||
|  | 
 | ||||||
| struct ViewHolder { | struct ViewHolder { | ||||||
|     View* view; |     View* view; | ||||||
|     ViewPort* view_port; |     ViewPort* view_port; | ||||||
| @ -125,7 +127,7 @@ static void view_holder_input_callback(InputEvent* event, void* context) { | |||||||
|         view_holder->ongoing_input &= ~key_bit; |         view_holder->ongoing_input &= ~key_bit; | ||||||
|     } else if(!(view_holder->ongoing_input & key_bit)) { |     } else if(!(view_holder->ongoing_input & key_bit)) { | ||||||
|         FURI_LOG_W( |         FURI_LOG_W( | ||||||
|             "ViewHolder", |             TAG, | ||||||
|             "non-complementary input, discarding key: %s, type: %s", |             "non-complementary input, discarding key: %s, type: %s", | ||||||
|             input_get_key_name(event->key), |             input_get_key_name(event->key), | ||||||
|             input_get_type_name(event->type)); |             input_get_type_name(event->type)); | ||||||
|  | |||||||
| @ -82,7 +82,7 @@ static void dolphin_check_butthurt(DolphinState* state) { | |||||||
|     float diff_time = difftime(dolphin_state_get_timestamp(state), dolphin_state_timestamp()); |     float diff_time = difftime(dolphin_state_get_timestamp(state), dolphin_state_timestamp()); | ||||||
| 
 | 
 | ||||||
|     if((fabs(diff_time)) > DOLPHIN_TIMEGATE) { |     if((fabs(diff_time)) > DOLPHIN_TIMEGATE) { | ||||||
|         FURI_LOG_I("dolphin-state", "Increasing butthurt"); |         FURI_LOG_I("DolphinState", "Increasing butthurt"); | ||||||
|         dolphin_state_butthurted(state); |         dolphin_state_butthurted(state); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| #include <math.h> | #include <math.h> | ||||||
| #include <toolbox/saved_struct.h> | #include <toolbox/saved_struct.h> | ||||||
| 
 | 
 | ||||||
| #define DOLPHIN_STATE_TAG "DolphinState" | #define TAG "DolphinState" | ||||||
| #define DOLPHIN_STATE_PATH "/int/dolphin.state" | #define DOLPHIN_STATE_PATH "/int/dolphin.state" | ||||||
| #define DOLPHIN_STATE_HEADER_MAGIC 0xD0 | #define DOLPHIN_STATE_HEADER_MAGIC 0xD0 | ||||||
| #define DOLPHIN_STATE_HEADER_VERSION 0x01 | #define DOLPHIN_STATE_HEADER_VERSION 0x01 | ||||||
| @ -48,10 +48,10 @@ bool dolphin_state_save(DolphinState* dolphin_state) { | |||||||
|         DOLPHIN_STATE_HEADER_VERSION); |         DOLPHIN_STATE_HEADER_VERSION); | ||||||
| 
 | 
 | ||||||
|     if(result) { |     if(result) { | ||||||
|         FURI_LOG_I(DOLPHIN_STATE_TAG, "State saved"); |         FURI_LOG_I(TAG, "State saved"); | ||||||
|         dolphin_state->dirty = false; |         dolphin_state->dirty = false; | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E(DOLPHIN_STATE_TAG, "Failed to save state"); |         FURI_LOG_E(TAG, "Failed to save state"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return result; |     return result; | ||||||
| @ -66,7 +66,7 @@ bool dolphin_state_load(DolphinState* dolphin_state) { | |||||||
|         DOLPHIN_STATE_HEADER_VERSION); |         DOLPHIN_STATE_HEADER_VERSION); | ||||||
| 
 | 
 | ||||||
|     if(!loaded) { |     if(!loaded) { | ||||||
|         FURI_LOG_W(DOLPHIN_STATE_TAG, "Reset dolphin-state"); |         FURI_LOG_W(TAG, "Reset dolphin-state"); | ||||||
|         memset(dolphin_state, 0, sizeof(*dolphin_state)); |         memset(dolphin_state, 0, sizeof(*dolphin_state)); | ||||||
|         dolphin_state->dirty = true; |         dolphin_state->dirty = true; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| #include "gui_i.h" | #include "gui_i.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "GuiSrv" | ||||||
|  | 
 | ||||||
| ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) { | ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) { | ||||||
|     // Iterating backward
 |     // Iterating backward
 | ||||||
|     ViewPortArray_it_t it; |     ViewPortArray_it_t it; | ||||||
| @ -190,7 +192,7 @@ void gui_input(Gui* gui, InputEvent* input_event) { | |||||||
|         gui->ongoing_input |= key_bit; |         gui->ongoing_input |= key_bit; | ||||||
|     } else if(!(gui->ongoing_input & key_bit)) { |     } else if(!(gui->ongoing_input & key_bit)) { | ||||||
|         FURI_LOG_D( |         FURI_LOG_D( | ||||||
|             "Gui", |             TAG, | ||||||
|             "non-complementary input, discarding key: %s type: %s, sequence: %p", |             "non-complementary input, discarding key: %s type: %s, sequence: %p", | ||||||
|             input_get_key_name(input_event->key), |             input_get_key_name(input_event->key), | ||||||
|             input_get_type_name(input_event->type), |             input_get_type_name(input_event->type), | ||||||
| @ -212,7 +214,7 @@ void gui_input(Gui* gui, InputEvent* input_event) { | |||||||
|         view_port_input(view_port, input_event); |         view_port_input(view_port, input_event); | ||||||
|     } else if(gui->ongoing_input_view_port && input_event->type == InputTypeRelease) { |     } else if(gui->ongoing_input_view_port && input_event->type == InputTypeRelease) { | ||||||
|         FURI_LOG_D( |         FURI_LOG_D( | ||||||
|             "Gui", |             TAG, | ||||||
|             "ViewPort changed while key press %p -> %p. Sending key: %s, type: %s, sequence: %p to previous view port", |             "ViewPort changed while key press %p -> %p. Sending key: %s, type: %s, sequence: %p to previous view port", | ||||||
|             gui->ongoing_input_view_port, |             gui->ongoing_input_view_port, | ||||||
|             view_port, |             view_port, | ||||||
| @ -222,7 +224,7 @@ void gui_input(Gui* gui, InputEvent* input_event) { | |||||||
|         view_port_input(gui->ongoing_input_view_port, input_event); |         view_port_input(gui->ongoing_input_view_port, input_event); | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_D( |         FURI_LOG_D( | ||||||
|             "Gui", |             TAG, | ||||||
|             "ViewPort changed while key press %p -> %p. Discarding key: %s, type: %s, sequence: %p", |             "ViewPort changed while key press %p -> %p. Discarding key: %s, type: %s, sequence: %p", | ||||||
|             gui->ongoing_input_view_port, |             gui->ongoing_input_view_port, | ||||||
|             view_port, |             view_port, | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| #include "view_dispatcher_i.h" | #include "view_dispatcher_i.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "ViewDispatcher" | ||||||
|  | 
 | ||||||
| ViewDispatcher* view_dispatcher_alloc() { | ViewDispatcher* view_dispatcher_alloc() { | ||||||
|     ViewDispatcher* view_dispatcher = furi_alloc(sizeof(ViewDispatcher)); |     ViewDispatcher* view_dispatcher = furi_alloc(sizeof(ViewDispatcher)); | ||||||
| 
 | 
 | ||||||
| @ -237,7 +239,7 @@ void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* e | |||||||
|         view_dispatcher->ongoing_input &= ~key_bit; |         view_dispatcher->ongoing_input &= ~key_bit; | ||||||
|     } else if(!(view_dispatcher->ongoing_input & key_bit)) { |     } else if(!(view_dispatcher->ongoing_input & key_bit)) { | ||||||
|         FURI_LOG_D( |         FURI_LOG_D( | ||||||
|             "ViewDispatcher", |             TAG, | ||||||
|             "non-complementary input, discarding key: %s, type: %s, sequence: %p", |             "non-complementary input, discarding key: %s, type: %s, sequence: %p", | ||||||
|             input_get_key_name(event->key), |             input_get_key_name(event->key), | ||||||
|             input_get_type_name(event->type), |             input_get_type_name(event->type), | ||||||
| @ -276,7 +278,7 @@ void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* e | |||||||
|         } |         } | ||||||
|     } else if(view_dispatcher->ongoing_input_view && event->type == InputTypeRelease) { |     } else if(view_dispatcher->ongoing_input_view && event->type == InputTypeRelease) { | ||||||
|         FURI_LOG_D( |         FURI_LOG_D( | ||||||
|             "ViewDispatcher", |             TAG, | ||||||
|             "View changed while key press %p -> %p. Sending key: %s, type: %s, sequence: %p to previous view port", |             "View changed while key press %p -> %p. Sending key: %s, type: %s, sequence: %p to previous view port", | ||||||
|             view_dispatcher->ongoing_input_view, |             view_dispatcher->ongoing_input_view, | ||||||
|             view_dispatcher->current_view, |             view_dispatcher->current_view, | ||||||
|  | |||||||
| @ -11,6 +11,8 @@ | |||||||
| #include <furi-hal-irda.h> | #include <furi-hal-irda.h> | ||||||
| #include <file-worker-cpp.h> | #include <file-worker-cpp.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "IrdaFileParser" | ||||||
|  | 
 | ||||||
| bool IrdaAppFileParser::open_irda_file_read(const char* name) { | bool IrdaAppFileParser::open_irda_file_read(const char* name) { | ||||||
|     std::string full_filename; |     std::string full_filename; | ||||||
|     if(name[0] != '/') |     if(name[0] != '/') | ||||||
| @ -154,11 +156,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if(!irda_is_protocol_valid((IrdaProtocol)protocol)) { |     if(!irda_is_protocol_valid((IrdaProtocol)protocol)) { | ||||||
|         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); |         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); | ||||||
|         FURI_LOG_E( |         FURI_LOG_E( | ||||||
|             "IrdaFileParser", |             TAG, "Unknown protocol(\'%.*s...\'): \'%s\'", end_of_str, str.c_str(), protocol_name); | ||||||
|             "Unknown protocol(\'%.*s...\'): \'%s\'", |  | ||||||
|             end_of_str, |  | ||||||
|             str.c_str(), |  | ||||||
|             protocol_name); |  | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -167,7 +165,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if(address != (address & address_mask)) { |     if(address != (address & address_mask)) { | ||||||
|         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); |         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); | ||||||
|         FURI_LOG_E( |         FURI_LOG_E( | ||||||
|             "IrdaFileParser", |             TAG, | ||||||
|             "Signal(\'%.*s...\'): address is too long (mask for this protocol is 0x%08X): 0x%X", |             "Signal(\'%.*s...\'): address is too long (mask for this protocol is 0x%08X): 0x%X", | ||||||
|             end_of_str, |             end_of_str, | ||||||
|             str.c_str(), |             str.c_str(), | ||||||
| @ -181,7 +179,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if(command != (command & command_mask)) { |     if(command != (command & command_mask)) { | ||||||
|         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); |         size_t end_of_str = MIN(str.find_last_not_of(" \t\r\n") + 1, (size_t)30); | ||||||
|         FURI_LOG_E( |         FURI_LOG_E( | ||||||
|             "IrdaFileParser", |             TAG, | ||||||
|             "Signal(\'%.*s...\'): command is too long (mask for this protocol is 0x%08X): 0x%X", |             "Signal(\'%.*s...\'): command is too long (mask for this protocol is 0x%08X): 0x%X", | ||||||
|             end_of_str, |             end_of_str, | ||||||
|             str.c_str(), |             str.c_str(), | ||||||
| @ -256,7 +254,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if((frequency < IRDA_MIN_FREQUENCY) || (frequency > IRDA_MAX_FREQUENCY)) { |     if((frequency < IRDA_MIN_FREQUENCY) || (frequency > IRDA_MAX_FREQUENCY)) { | ||||||
|         size_t end_of_str = MIN(string.find_last_not_of(" \t\r\n") + 1, (size_t)30); |         size_t end_of_str = MIN(string.find_last_not_of(" \t\r\n") + 1, (size_t)30); | ||||||
|         FURI_LOG_E( |         FURI_LOG_E( | ||||||
|             "IrdaFileParser", |             TAG, | ||||||
|             "RAW signal(\'%.*s...\'): frequency is out of bounds (%ld-%ld): %ld", |             "RAW signal(\'%.*s...\'): frequency is out of bounds (%ld-%ld): %ld", | ||||||
|             end_of_str, |             end_of_str, | ||||||
|             string.c_str(), |             string.c_str(), | ||||||
| @ -269,7 +267,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if((duty_cycle == 0) || (duty_cycle > 100)) { |     if((duty_cycle == 0) || (duty_cycle > 100)) { | ||||||
|         size_t end_of_str = MIN(string.find_last_not_of(" \t\r\n") + 1, (size_t)30); |         size_t end_of_str = MIN(string.find_last_not_of(" \t\r\n") + 1, (size_t)30); | ||||||
|         FURI_LOG_E( |         FURI_LOG_E( | ||||||
|             "IrdaFileParser", |             TAG, | ||||||
|             "RAW signal(\'%.*s...\'): duty cycle is out of bounds (0-100): %ld", |             "RAW signal(\'%.*s...\'): duty cycle is out of bounds (0-100): %ld", | ||||||
|             end_of_str, |             end_of_str, | ||||||
|             string.c_str(), |             string.c_str(), | ||||||
| @ -283,8 +281,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|     if(last_valid_ch != std::string_view::npos) { |     if(last_valid_ch != std::string_view::npos) { | ||||||
|         str.remove_suffix(str.size() - last_valid_ch - 1); |         str.remove_suffix(str.size() - last_valid_ch - 1); | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E( |         FURI_LOG_E(TAG, "RAW signal(\'%.*s\'): no timings", header_len, string.c_str()); | ||||||
|             "IrdaFileParser", "RAW signal(\'%.*s\'): no timings", header_len, string.c_str()); |  | ||||||
|         return nullptr; |         return nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -303,7 +300,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|         parsed = std::sscanf(str.data(), "%9s", buf); |         parsed = std::sscanf(str.data(), "%9s", buf); | ||||||
|         if(parsed != 1) { |         if(parsed != 1) { | ||||||
|             FURI_LOG_E( |             FURI_LOG_E( | ||||||
|                 "IrdaFileParser", |                 TAG, | ||||||
|                 "RAW signal(\'%.*s...\'): failed on timing[%ld] \'%*s\'", |                 "RAW signal(\'%.*s...\'): failed on timing[%ld] \'%*s\'", | ||||||
|                 header_len, |                 header_len, | ||||||
|                 string.c_str(), |                 string.c_str(), | ||||||
| @ -318,7 +315,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
|         int value = atoi(buf); |         int value = atoi(buf); | ||||||
|         if(value <= 0) { |         if(value <= 0) { | ||||||
|             FURI_LOG_E( |             FURI_LOG_E( | ||||||
|                 "IrdaFileParser", |                 TAG, | ||||||
|                 "RAW signal(\'%.*s...\'): failed on timing[%ld] \'%s\'", |                 "RAW signal(\'%.*s...\'): failed on timing[%ld] \'%s\'", | ||||||
|                 header_len, |                 header_len, | ||||||
|                 string.c_str(), |                 string.c_str(), | ||||||
| @ -330,7 +327,7 @@ std::unique_ptr<IrdaAppFileParser::IrdaFileSignal> | |||||||
| 
 | 
 | ||||||
|         if(raw_signal.timings_cnt >= max_raw_timings_in_signal) { |         if(raw_signal.timings_cnt >= max_raw_timings_in_signal) { | ||||||
|             FURI_LOG_E( |             FURI_LOG_E( | ||||||
|                 "IrdaFileParser", |                 TAG, | ||||||
|                 "RAW signal(\'%.*s...\'): too much timings (max %ld)", |                 "RAW signal(\'%.*s...\'): too much timings (max %ld)", | ||||||
|                 header_len, |                 header_len, | ||||||
|                 string.c_str(), |                 string.c_str(), | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include "loader/loader.h" | #include "loader/loader.h" | ||||||
| #include "loader_i.h" | #include "loader_i.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "LoaderSrv" | ||||||
|  | 
 | ||||||
| #define LOADER_THREAD_FLAG_SHOW_MENU (1 << 0) | #define LOADER_THREAD_FLAG_SHOW_MENU (1 << 0) | ||||||
| #define LOADER_THREAD_FLAG_ALL (LOADER_THREAD_FLAG_SHOW_MENU) | #define LOADER_THREAD_FLAG_ALL (LOADER_THREAD_FLAG_SHOW_MENU) | ||||||
| 
 | 
 | ||||||
| @ -15,15 +17,13 @@ static void loader_menu_callback(void* _ctx, uint32_t index) { | |||||||
|     if(!loader_lock(loader_instance)) return; |     if(!loader_lock(loader_instance)) return; | ||||||
| 
 | 
 | ||||||
|     if(furi_thread_get_state(loader_instance->thread) != FuriThreadStateStopped) { |     if(furi_thread_get_state(loader_instance->thread) != FuriThreadStateStopped) { | ||||||
|         FURI_LOG_E( |         FURI_LOG_E(TAG, "Can't start app. %s is running", loader_instance->current_app->name); | ||||||
|             LOADER_LOG_TAG, "Can't start app. %s is running", loader_instance->current_app->name); |  | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     furi_hal_power_insomnia_enter(); |     furi_hal_power_insomnia_enter(); | ||||||
|     loader_instance->current_app = flipper_app; |     loader_instance->current_app = flipper_app; | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I( |     FURI_LOG_I(TAG, "Starting furi application: %s", loader_instance->current_app->name); | ||||||
|         LOADER_LOG_TAG, "Starting furi application: %s", loader_instance->current_app->name); |  | ||||||
|     furi_thread_set_name(loader_instance->thread, flipper_app->name); |     furi_thread_set_name(loader_instance->thread, flipper_app->name); | ||||||
|     furi_thread_set_stack_size(loader_instance->thread, flipper_app->stack_size); |     furi_thread_set_stack_size(loader_instance->thread, flipper_app->stack_size); | ||||||
|     furi_thread_set_context(loader_instance->thread, NULL); |     furi_thread_set_context(loader_instance->thread, NULL); | ||||||
| @ -79,14 +79,14 @@ LoaderStatus loader_start(Loader* instance, const char* name, const char* args) | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(!flipper_app) { |     if(!flipper_app) { | ||||||
|         FURI_LOG_E(LOADER_LOG_TAG, "Can't find application with name %s", name); |         FURI_LOG_E(TAG, "Can't find application with name %s", name); | ||||||
|         return LoaderStatusErrorUnknownApp; |         return LoaderStatusErrorUnknownApp; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     bool locked = loader_lock(instance); |     bool locked = loader_lock(instance); | ||||||
| 
 | 
 | ||||||
|     if(!locked || (furi_thread_get_state(instance->thread) != FuriThreadStateStopped)) { |     if(!locked || (furi_thread_get_state(instance->thread) != FuriThreadStateStopped)) { | ||||||
|         FURI_LOG_E(LOADER_LOG_TAG, "Can't start app. %s is running", instance->current_app->name); |         FURI_LOG_E(TAG, "Can't start app. %s is running", instance->current_app->name); | ||||||
|         /* no need to call loader_unlock() - it is called as soon as application stops */ |         /* no need to call loader_unlock() - it is called as soon as application stops */ | ||||||
|         return LoaderStatusErrorAppStarted; |         return LoaderStatusErrorAppStarted; | ||||||
|     } |     } | ||||||
| @ -97,10 +97,10 @@ LoaderStatus loader_start(Loader* instance, const char* name, const char* args) | |||||||
|         string_set_str(instance->args, args); |         string_set_str(instance->args, args); | ||||||
|         string_strim(instance->args); |         string_strim(instance->args); | ||||||
|         thread_args = (void*)string_get_cstr(instance->args); |         thread_args = (void*)string_get_cstr(instance->args); | ||||||
|         FURI_LOG_I(LOADER_LOG_TAG, "Start %s app with args: %s", name, args); |         FURI_LOG_I(TAG, "Start %s app with args: %s", name, args); | ||||||
|     } else { |     } else { | ||||||
|         string_clean(instance->args); |         string_clean(instance->args); | ||||||
|         FURI_LOG_I(LOADER_LOG_TAG, "Start %s app with no args", name); |         FURI_LOG_I(TAG, "Start %s app with no args", name); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     furi_thread_set_name(instance->thread, flipper_app->name); |     furi_thread_set_name(instance->thread, flipper_app->name); | ||||||
| @ -155,7 +155,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con | |||||||
|         delay(20); |         delay(20); | ||||||
|         int heap_diff = instance->free_heap_size - memmgr_get_free_heap(); |         int heap_diff = instance->free_heap_size - memmgr_get_free_heap(); | ||||||
|         FURI_LOG_I( |         FURI_LOG_I( | ||||||
|             LOADER_LOG_TAG, |             TAG, | ||||||
|             "Application thread stopped. Heap allocation balance: %d. Thread allocation balance: %d.", |             "Application thread stopped. Heap allocation balance: %d. Thread allocation balance: %d.", | ||||||
|             heap_diff, |             heap_diff, | ||||||
|             furi_thread_get_heap_size(instance->thread)); |             furi_thread_get_heap_size(instance->thread)); | ||||||
| @ -266,7 +266,7 @@ static void loader_add_cli_command(FlipperApplication* app) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void loader_build_menu() { | static void loader_build_menu() { | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Building main menu"); |     FURI_LOG_I(TAG, "Building main menu"); | ||||||
|     size_t i; |     size_t i; | ||||||
|     for(i = 0; i < FLIPPER_APPS_COUNT; i++) { |     for(i = 0; i < FLIPPER_APPS_COUNT; i++) { | ||||||
|         loader_add_cli_command((FlipperApplication*)&FLIPPER_APPS[i]); |         loader_add_cli_command((FlipperApplication*)&FLIPPER_APPS[i]); | ||||||
| @ -300,7 +300,7 @@ static void loader_build_menu() { | |||||||
|         loader_submenu_callback, |         loader_submenu_callback, | ||||||
|         (void*)LoaderMenuViewSettings); |         (void*)LoaderMenuViewSettings); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Building plugins menu"); |     FURI_LOG_I(TAG, "Building plugins menu"); | ||||||
|     for(i = 0; i < FLIPPER_PLUGINS_COUNT; i++) { |     for(i = 0; i < FLIPPER_PLUGINS_COUNT; i++) { | ||||||
|         loader_add_cli_command((FlipperApplication*)&FLIPPER_PLUGINS[i]); |         loader_add_cli_command((FlipperApplication*)&FLIPPER_PLUGINS[i]); | ||||||
|         submenu_add_item( |         submenu_add_item( | ||||||
| @ -311,7 +311,7 @@ static void loader_build_menu() { | |||||||
|             (void*)&FLIPPER_PLUGINS[i]); |             (void*)&FLIPPER_PLUGINS[i]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Building debug menu"); |     FURI_LOG_I(TAG, "Building debug menu"); | ||||||
|     for(i = 0; i < FLIPPER_DEBUG_APPS_COUNT; i++) { |     for(i = 0; i < FLIPPER_DEBUG_APPS_COUNT; i++) { | ||||||
|         loader_add_cli_command((FlipperApplication*)&FLIPPER_DEBUG_APPS[i]); |         loader_add_cli_command((FlipperApplication*)&FLIPPER_DEBUG_APPS[i]); | ||||||
|         submenu_add_item( |         submenu_add_item( | ||||||
| @ -322,7 +322,7 @@ static void loader_build_menu() { | |||||||
|             (void*)&FLIPPER_DEBUG_APPS[i]); |             (void*)&FLIPPER_DEBUG_APPS[i]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Building settings menu"); |     FURI_LOG_I(TAG, "Building settings menu"); | ||||||
|     for(i = 0; i < FLIPPER_SETTINGS_APPS_COUNT; i++) { |     for(i = 0; i < FLIPPER_SETTINGS_APPS_COUNT; i++) { | ||||||
|         submenu_add_item( |         submenu_add_item( | ||||||
|             loader_instance->settings_menu, |             loader_instance->settings_menu, | ||||||
| @ -339,7 +339,7 @@ void loader_show_menu() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t loader_srv(void* p) { | int32_t loader_srv(void* p) { | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Starting"); |     FURI_LOG_I(TAG, "Starting"); | ||||||
| 
 | 
 | ||||||
|     loader_instance = loader_alloc(); |     loader_instance = loader_alloc(); | ||||||
| 
 | 
 | ||||||
| @ -350,7 +350,7 @@ int32_t loader_srv(void* p) { | |||||||
|         FLIPPER_ON_SYSTEM_START[i](); |         FLIPPER_ON_SYSTEM_START[i](); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I(LOADER_LOG_TAG, "Started"); |     FURI_LOG_I(TAG, "Started"); | ||||||
| 
 | 
 | ||||||
|     furi_record_create("loader", loader_instance); |     furi_record_create("loader", loader_instance); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,8 +12,6 @@ | |||||||
| #include <applications.h> | #include <applications.h> | ||||||
| #include <assets_icons.h> | #include <assets_icons.h> | ||||||
| 
 | 
 | ||||||
| #define LOADER_LOG_TAG "loader" |  | ||||||
| 
 |  | ||||||
| struct Loader { | struct Loader { | ||||||
|     osThreadId_t loader_thread; |     osThreadId_t loader_thread; | ||||||
|     FuriThread* thread; |     FuriThread* thread; | ||||||
|  | |||||||
							
								
								
									
										141
									
								
								applications/nfc/nfc_worker.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										141
									
								
								applications/nfc/nfc_worker.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @ -3,7 +3,7 @@ | |||||||
| #include "nfc_protocols/emv_decoder.h" | #include "nfc_protocols/emv_decoder.h" | ||||||
| #include "nfc_protocols/mifare_ultralight.h" | #include "nfc_protocols/mifare_ultralight.h" | ||||||
| 
 | 
 | ||||||
| #define NFC_WORKER_TAG "nfc worker" | #define TAG "NfcWorker" | ||||||
| 
 | 
 | ||||||
| /***************************** NFC Worker API *******************************/ | /***************************** NFC Worker API *******************************/ | ||||||
| 
 | 
 | ||||||
| @ -144,7 +144,7 @@ void nfc_worker_emulate(NfcWorker* nfc_worker) { | |||||||
|     NfcDeviceCommonData* data = &nfc_worker->dev_data->nfc_data; |     NfcDeviceCommonData* data = &nfc_worker->dev_data->nfc_data; | ||||||
|     while(nfc_worker->state == NfcWorkerStateEmulate) { |     while(nfc_worker->state == NfcWorkerStateEmulate) { | ||||||
|         if(furi_hal_nfc_listen(data->uid, data->uid_len, data->atqa, data->sak, false, 100)) { |         if(furi_hal_nfc_listen(data->uid, data->uid_len, data->atqa, data->sak, false, 100)) { | ||||||
|             FURI_LOG_I(NFC_WORKER_TAG, "Reader detected"); |             FURI_LOG_I(TAG, "Reader detected"); | ||||||
|         } |         } | ||||||
|         osDelay(10); |         osDelay(10); | ||||||
|     } |     } | ||||||
| @ -174,18 +174,17 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) { | |||||||
|                     result->nfc_data.uid, dev_list[0].dev.nfca.nfcId1, result->nfc_data.uid_len); |                     result->nfc_data.uid, dev_list[0].dev.nfca.nfcId1, result->nfc_data.uid_len); | ||||||
|                 result->nfc_data.protocol = NfcDeviceProtocolEMV; |                 result->nfc_data.protocol = NfcDeviceProtocolEMV; | ||||||
| 
 | 
 | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Send select PPSE command"); |                 FURI_LOG_I(TAG, "Send select PPSE command"); | ||||||
|                 tx_len = emv_prepare_select_ppse(tx_buff); |                 tx_len = emv_prepare_select_ppse(tx_buff); | ||||||
|                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err != ERR_NONE) { |                 if(err != ERR_NONE) { | ||||||
|                     FURI_LOG_E(NFC_WORKER_TAG, "Error during selection PPSE request: %d", err); |                     FURI_LOG_E(TAG, "Error during selection PPSE request: %d", err); | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 FURI_LOG_I( |                 FURI_LOG_I(TAG, "Select PPSE response received. Start parsing response"); | ||||||
|                     NFC_WORKER_TAG, "Select PPSE response received. Start parsing response"); |  | ||||||
|                 if(emv_decode_ppse_response(rx_buff, *rx_len, &emv_app)) { |                 if(emv_decode_ppse_response(rx_buff, *rx_len, &emv_app)) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Select PPSE responce parced"); |                     FURI_LOG_I(TAG, "Select PPSE responce parced"); | ||||||
|                     // Notify caller and exit
 |                     // Notify caller and exit
 | ||||||
|                     result->emv_data.aid_len = emv_app.aid_len; |                     result->emv_data.aid_len = emv_app.aid_len; | ||||||
|                     memcpy(result->emv_data.aid, emv_app.aid, emv_app.aid_len); |                     memcpy(result->emv_data.aid, emv_app.aid, emv_app.aid_len); | ||||||
| @ -194,18 +193,18 @@ void nfc_worker_read_emv_app(NfcWorker* nfc_worker) { | |||||||
|                     } |                     } | ||||||
|                     break; |                     break; | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_E(NFC_WORKER_TAG, "Can't find pay application"); |                     FURI_LOG_E(TAG, "Can't find pay application"); | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 // Can't find EMV card
 |                 // Can't find EMV card
 | ||||||
|                 FURI_LOG_W(NFC_WORKER_TAG, "Card doesn't support EMV"); |                 FURI_LOG_W(TAG, "Card doesn't support EMV"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             // Can't find EMV card
 |             // Can't find EMV card
 | ||||||
|             FURI_LOG_W(NFC_WORKER_TAG, "Can't find any cards"); |             FURI_LOG_W(TAG, "Can't find any cards"); | ||||||
|             furi_hal_nfc_deactivate(); |             furi_hal_nfc_deactivate(); | ||||||
|         } |         } | ||||||
|         osDelay(20); |         osDelay(20); | ||||||
| @ -236,58 +235,53 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { | |||||||
|                     result->nfc_data.uid, dev_list[0].dev.nfca.nfcId1, result->nfc_data.uid_len); |                     result->nfc_data.uid, dev_list[0].dev.nfca.nfcId1, result->nfc_data.uid_len); | ||||||
|                 result->nfc_data.protocol = NfcDeviceProtocolEMV; |                 result->nfc_data.protocol = NfcDeviceProtocolEMV; | ||||||
| 
 | 
 | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Send select PPSE command"); |                 FURI_LOG_I(TAG, "Send select PPSE command"); | ||||||
|                 tx_len = emv_prepare_select_ppse(tx_buff); |                 tx_len = emv_prepare_select_ppse(tx_buff); | ||||||
|                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err != ERR_NONE) { |                 if(err != ERR_NONE) { | ||||||
|                     FURI_LOG_E(NFC_WORKER_TAG, "Error during selection PPSE request: %d", err); |                     FURI_LOG_E(TAG, "Error during selection PPSE request: %d", err); | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 FURI_LOG_I( |                 FURI_LOG_I(TAG, "Select PPSE response received. Start parsing response"); | ||||||
|                     NFC_WORKER_TAG, "Select PPSE response received. Start parsing response"); |  | ||||||
|                 if(emv_decode_ppse_response(rx_buff, *rx_len, &emv_app)) { |                 if(emv_decode_ppse_response(rx_buff, *rx_len, &emv_app)) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Select PPSE responce parced"); |                     FURI_LOG_I(TAG, "Select PPSE responce parced"); | ||||||
|                     result->emv_data.aid_len = emv_app.aid_len; |                     result->emv_data.aid_len = emv_app.aid_len; | ||||||
|                     memcpy(result->emv_data.aid, emv_app.aid, emv_app.aid_len); |                     memcpy(result->emv_data.aid, emv_app.aid, emv_app.aid_len); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_E(NFC_WORKER_TAG, "Can't find pay application"); |                     FURI_LOG_E(TAG, "Can't find pay application"); | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Starting application ..."); |                 FURI_LOG_I(TAG, "Starting application ..."); | ||||||
|                 tx_len = emv_prepare_select_app(tx_buff, &emv_app); |                 tx_len = emv_prepare_select_app(tx_buff, &emv_app); | ||||||
|                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err != ERR_NONE) { |                 if(err != ERR_NONE) { | ||||||
|                     FURI_LOG_E( |                     FURI_LOG_E(TAG, "Error during application selection request: %d", err); | ||||||
|                         NFC_WORKER_TAG, "Error during application selection request: %d", err); |  | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 FURI_LOG_I( |                 FURI_LOG_I(TAG, "Select application response received. Start parsing response"); | ||||||
|                     NFC_WORKER_TAG, |  | ||||||
|                     "Select application response received. Start parsing response"); |  | ||||||
|                 if(emv_decode_select_app_response(rx_buff, *rx_len, &emv_app)) { |                 if(emv_decode_select_app_response(rx_buff, *rx_len, &emv_app)) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Card name: %s", emv_app.name); |                     FURI_LOG_I(TAG, "Card name: %s", emv_app.name); | ||||||
|                     memcpy(result->emv_data.name, emv_app.name, sizeof(emv_app.name)); |                     memcpy(result->emv_data.name, emv_app.name, sizeof(emv_app.name)); | ||||||
|                 } else if(emv_app.pdol.size > 0) { |                 } else if(emv_app.pdol.size > 0) { | ||||||
|                     FURI_LOG_W(NFC_WORKER_TAG, "Can't find card name, but PDOL is present."); |                     FURI_LOG_W(TAG, "Can't find card name, but PDOL is present."); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_E(NFC_WORKER_TAG, "Can't find card name or PDOL"); |                     FURI_LOG_E(TAG, "Can't find card name or PDOL"); | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Starting Get Processing Options command ..."); |                 FURI_LOG_I(TAG, "Starting Get Processing Options command ..."); | ||||||
|                 tx_len = emv_prepare_get_proc_opt(tx_buff, &emv_app); |                 tx_len = emv_prepare_get_proc_opt(tx_buff, &emv_app); | ||||||
|                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err != ERR_NONE) { |                 if(err != ERR_NONE) { | ||||||
|                     FURI_LOG_E( |                     FURI_LOG_E(TAG, "Error during Get Processing Options command: %d", err); | ||||||
|                         NFC_WORKER_TAG, "Error during Get Processing Options command: %d", err); |  | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 if(emv_decode_get_proc_opt(rx_buff, *rx_len, &emv_app)) { |                 if(emv_decode_get_proc_opt(rx_buff, *rx_len, &emv_app)) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Card number parsed"); |                     FURI_LOG_I(TAG, "Card number parsed"); | ||||||
|                     result->emv_data.number_len = emv_app.card_number_len; |                     result->emv_data.number_len = emv_app.card_number_len; | ||||||
|                     memcpy(result->emv_data.number, emv_app.card_number, emv_app.card_number_len); |                     memcpy(result->emv_data.number, emv_app.card_number, emv_app.card_number_len); | ||||||
|                     // Notify caller and exit
 |                     // Notify caller and exit
 | ||||||
| @ -311,7 +305,7 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { | |||||||
|                                 tx_buff, tx_len, &rx_buff, &rx_len, false); |                                 tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                             if(err != ERR_NONE) { |                             if(err != ERR_NONE) { | ||||||
|                                 FURI_LOG_E( |                                 FURI_LOG_E( | ||||||
|                                     NFC_WORKER_TAG, |                                     TAG, | ||||||
|                                     "Error reading application sfi %d, record %d", |                                     "Error reading application sfi %d, record %d", | ||||||
|                                     sfi, |                                     sfi, | ||||||
|                                     record); |                                     record); | ||||||
| @ -323,7 +317,7 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     if(pan_found) { |                     if(pan_found) { | ||||||
|                         FURI_LOG_I(NFC_WORKER_TAG, "Card PAN found"); |                         FURI_LOG_I(TAG, "Card PAN found"); | ||||||
|                         result->emv_data.number_len = emv_app.card_number_len; |                         result->emv_data.number_len = emv_app.card_number_len; | ||||||
|                         memcpy( |                         memcpy( | ||||||
|                             result->emv_data.number, |                             result->emv_data.number, | ||||||
| @ -345,18 +339,18 @@ void nfc_worker_read_emv(NfcWorker* nfc_worker) { | |||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|                     } else { |                     } else { | ||||||
|                         FURI_LOG_E(NFC_WORKER_TAG, "Can't read card number"); |                         FURI_LOG_E(TAG, "Can't read card number"); | ||||||
|                     } |                     } | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 // Can't find EMV card
 |                 // Can't find EMV card
 | ||||||
|                 FURI_LOG_W(NFC_WORKER_TAG, "Card doesn't support EMV"); |                 FURI_LOG_W(TAG, "Card doesn't support EMV"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             // Can't find EMV card
 |             // Can't find EMV card
 | ||||||
|             FURI_LOG_W(NFC_WORKER_TAG, "Can't find any cards"); |             FURI_LOG_W(TAG, "Can't find any cards"); | ||||||
|             furi_hal_nfc_deactivate(); |             furi_hal_nfc_deactivate(); | ||||||
|         } |         } | ||||||
|         osDelay(20); |         osDelay(20); | ||||||
| @ -418,63 +412,63 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) { | |||||||
| 
 | 
 | ||||||
|     while(nfc_worker->state == NfcWorkerStateEmulateApdu) { |     while(nfc_worker->state == NfcWorkerStateEmulateApdu) { | ||||||
|         if(furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, false, 300)) { |         if(furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, false, 300)) { | ||||||
|             FURI_LOG_I(NFC_WORKER_TAG, "POS terminal detected"); |             FURI_LOG_I(TAG, "POS terminal detected"); | ||||||
|             // Read data from POS terminal
 |             // Read data from POS terminal
 | ||||||
|             err = furi_hal_nfc_data_exchange(NULL, 0, &rx_buff, &rx_len, false); |             err = furi_hal_nfc_data_exchange(NULL, 0, &rx_buff, &rx_len, false); | ||||||
|             if(err == ERR_NONE) { |             if(err == ERR_NONE) { | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Received Select PPSE"); |                 FURI_LOG_I(TAG, "Received Select PPSE"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E(NFC_WORKER_TAG, "Error in 1st data exchange: select PPSE"); |                 FURI_LOG_E(TAG, "Error in 1st data exchange: select PPSE"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             FURI_LOG_I(NFC_WORKER_TAG, "Transive SELECT PPSE ANS"); |             FURI_LOG_I(TAG, "Transive SELECT PPSE ANS"); | ||||||
|             tx_len = emv_select_ppse_ans(tx_buff); |             tx_len = emv_select_ppse_ans(tx_buff); | ||||||
|             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|             if(err == ERR_NONE) { |             if(err == ERR_NONE) { | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Received Select APP"); |                 FURI_LOG_I(TAG, "Received Select APP"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E(NFC_WORKER_TAG, "Error in 2nd data exchange: select APP"); |                 FURI_LOG_E(TAG, "Error in 2nd data exchange: select APP"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             FURI_LOG_I(NFC_WORKER_TAG, "Transive SELECT APP ANS"); |             FURI_LOG_I(TAG, "Transive SELECT APP ANS"); | ||||||
|             tx_len = emv_select_app_ans(tx_buff); |             tx_len = emv_select_app_ans(tx_buff); | ||||||
|             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|             if(err == ERR_NONE) { |             if(err == ERR_NONE) { | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Received PDOL"); |                 FURI_LOG_I(TAG, "Received PDOL"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E(NFC_WORKER_TAG, "Error in 3rd data exchange: receive PDOL"); |                 FURI_LOG_E(TAG, "Error in 3rd data exchange: receive PDOL"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             FURI_LOG_I(NFC_WORKER_TAG, "Transive PDOL ANS"); |             FURI_LOG_I(TAG, "Transive PDOL ANS"); | ||||||
|             tx_len = emv_get_proc_opt_ans(tx_buff); |             tx_len = emv_get_proc_opt_ans(tx_buff); | ||||||
|             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |             err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|             if(err == ERR_NONE) { |             if(err == ERR_NONE) { | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Transive PDOL ANS"); |                 FURI_LOG_I(TAG, "Transive PDOL ANS"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E(NFC_WORKER_TAG, "Error in 4rd data exchange: Transive PDOL ANS"); |                 FURI_LOG_E(TAG, "Error in 4rd data exchange: Transive PDOL ANS"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if(*rx_len != sizeof(debug_rx) || memcmp(rx_buff, debug_rx, sizeof(debug_rx))) { |             if(*rx_len != sizeof(debug_rx) || memcmp(rx_buff, debug_rx, sizeof(debug_rx))) { | ||||||
|                 FURI_LOG_E(NFC_WORKER_TAG, "Failed long message test"); |                 FURI_LOG_E(TAG, "Failed long message test"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Correct debug message received"); |                 FURI_LOG_I(TAG, "Correct debug message received"); | ||||||
|                 tx_len = sizeof(debug_tx); |                 tx_len = sizeof(debug_tx); | ||||||
|                 err = furi_hal_nfc_data_exchange( |                 err = furi_hal_nfc_data_exchange( | ||||||
|                     (uint8_t*)debug_tx, tx_len, &rx_buff, &rx_len, false); |                     (uint8_t*)debug_tx, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err == ERR_NONE) { |                 if(err == ERR_NONE) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Transive Debug message"); |                     FURI_LOG_I(TAG, "Transive Debug message"); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             furi_hal_nfc_deactivate(); |             furi_hal_nfc_deactivate(); | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_W(NFC_WORKER_TAG, "Can't find reader"); |             FURI_LOG_W(TAG, "Can't find reader"); | ||||||
|         } |         } | ||||||
|         osDelay(20); |         osDelay(20); | ||||||
|     } |     } | ||||||
| @ -501,71 +495,69 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                    dev_list[0].dev.nfca.sensRes.platformInfo, |                    dev_list[0].dev.nfca.sensRes.platformInfo, | ||||||
|                    dev_list[0].dev.nfca.selRes.sak)) { |                    dev_list[0].dev.nfca.selRes.sak)) { | ||||||
|                 // Get Mifare Ultralight version
 |                 // Get Mifare Ultralight version
 | ||||||
|                 FURI_LOG_I(NFC_WORKER_TAG, "Found Mifare Ultralight tag. Reading tag version"); |                 FURI_LOG_I(TAG, "Found Mifare Ultralight tag. Reading tag version"); | ||||||
|                 tx_len = mf_ul_prepare_get_version(tx_buff); |                 tx_len = mf_ul_prepare_get_version(tx_buff); | ||||||
|                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); |                 err = furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false); | ||||||
|                 if(err == ERR_NONE) { |                 if(err == ERR_NONE) { | ||||||
|                     mf_ul_parse_get_version_response(rx_buff, &mf_ul_read); |                     mf_ul_parse_get_version_response(rx_buff, &mf_ul_read); | ||||||
|                     FURI_LOG_I( |                     FURI_LOG_I( | ||||||
|                         NFC_WORKER_TAG, |                         TAG, | ||||||
|                         "Mifare Ultralight Type: %d, Pages: %d", |                         "Mifare Ultralight Type: %d, Pages: %d", | ||||||
|                         mf_ul_read.type, |                         mf_ul_read.type, | ||||||
|                         mf_ul_read.pages_to_read); |                         mf_ul_read.pages_to_read); | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Reading signature ..."); |                     FURI_LOG_I(TAG, "Reading signature ..."); | ||||||
|                     tx_len = mf_ul_prepare_read_signature(tx_buff); |                     tx_len = mf_ul_prepare_read_signature(tx_buff); | ||||||
|                     if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { |                     if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { | ||||||
|                         FURI_LOG_W(NFC_WORKER_TAG, "Failed reading signature"); |                         FURI_LOG_W(TAG, "Failed reading signature"); | ||||||
|                         memset(mf_ul_read.data.signature, 0, sizeof(mf_ul_read.data.signature)); |                         memset(mf_ul_read.data.signature, 0, sizeof(mf_ul_read.data.signature)); | ||||||
|                     } else { |                     } else { | ||||||
|                         mf_ul_parse_read_signature_response(rx_buff, &mf_ul_read); |                         mf_ul_parse_read_signature_response(rx_buff, &mf_ul_read); | ||||||
|                     } |                     } | ||||||
|                 } else if(err == ERR_TIMEOUT) { |                 } else if(err == ERR_TIMEOUT) { | ||||||
|                     FURI_LOG_W( |                     FURI_LOG_W( | ||||||
|                         NFC_WORKER_TAG, |                         TAG, | ||||||
|                         "Card doesn't respond to GET VERSION command. Setting default read parameters"); |                         "Card doesn't respond to GET VERSION command. Setting default read parameters"); | ||||||
|                     err = ERR_NONE; |                     err = ERR_NONE; | ||||||
|                     mf_ul_set_default_version(&mf_ul_read); |                     mf_ul_set_default_version(&mf_ul_read); | ||||||
|                     // Reinit device
 |                     // Reinit device
 | ||||||
|                     furi_hal_nfc_deactivate(); |                     furi_hal_nfc_deactivate(); | ||||||
|                     if(!furi_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { |                     if(!furi_hal_nfc_detect(&dev_list, &dev_cnt, 300, false)) { | ||||||
|                         FURI_LOG_E(NFC_WORKER_TAG, "Lost connection. Restarting search"); |                         FURI_LOG_E(TAG, "Lost connection. Restarting search"); | ||||||
|                         continue; |                         continue; | ||||||
|                     } |                     } | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_E( |                     FURI_LOG_E( | ||||||
|                         NFC_WORKER_TAG, |                         TAG, "Error getting Mifare Ultralight version. Error code: %d", err); | ||||||
|                         "Error getting Mifare Ultralight version. Error code: %d", |  | ||||||
|                         err); |  | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if(mf_ul_read.support_fast_read) { |                 if(mf_ul_read.support_fast_read) { | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Reading pages ..."); |                     FURI_LOG_I(TAG, "Reading pages ..."); | ||||||
|                     tx_len = mf_ul_prepare_fast_read(tx_buff, 0x00, mf_ul_read.pages_to_read - 1); |                     tx_len = mf_ul_prepare_fast_read(tx_buff, 0x00, mf_ul_read.pages_to_read - 1); | ||||||
|                     if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { |                     if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { | ||||||
|                         FURI_LOG_E(NFC_WORKER_TAG, "Failed reading pages"); |                         FURI_LOG_E(TAG, "Failed reading pages"); | ||||||
|                         continue; |                         continue; | ||||||
|                     } else { |                     } else { | ||||||
|                         mf_ul_parse_fast_read_response( |                         mf_ul_parse_fast_read_response( | ||||||
|                             rx_buff, 0x00, mf_ul_read.pages_to_read - 1, &mf_ul_read); |                             rx_buff, 0x00, mf_ul_read.pages_to_read - 1, &mf_ul_read); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Reading 3 counters ..."); |                     FURI_LOG_I(TAG, "Reading 3 counters ..."); | ||||||
|                     for(uint8_t i = 0; i < 3; i++) { |                     for(uint8_t i = 0; i < 3; i++) { | ||||||
|                         tx_len = mf_ul_prepare_read_cnt(tx_buff, i); |                         tx_len = mf_ul_prepare_read_cnt(tx_buff, i); | ||||||
|                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { |                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { | ||||||
|                             FURI_LOG_W(NFC_WORKER_TAG, "Failed reading Counter %d", i); |                             FURI_LOG_W(TAG, "Failed reading Counter %d", i); | ||||||
|                             mf_ul_read.data.counter[i] = 0; |                             mf_ul_read.data.counter[i] = 0; | ||||||
|                         } else { |                         } else { | ||||||
|                             mf_ul_parse_read_cnt_response(rx_buff, i, &mf_ul_read); |                             mf_ul_parse_read_cnt_response(rx_buff, i, &mf_ul_read); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     FURI_LOG_I(NFC_WORKER_TAG, "Checking tearing flags ..."); |                     FURI_LOG_I(TAG, "Checking tearing flags ..."); | ||||||
|                     for(uint8_t i = 0; i < 3; i++) { |                     for(uint8_t i = 0; i < 3; i++) { | ||||||
|                         tx_len = mf_ul_prepare_check_tearing(tx_buff, i); |                         tx_len = mf_ul_prepare_check_tearing(tx_buff, i); | ||||||
|                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { |                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { | ||||||
|                             FURI_LOG_E(NFC_WORKER_TAG, "Error checking tearing flag %d", i); |                             FURI_LOG_E(TAG, "Error checking tearing flag %d", i); | ||||||
|                             mf_ul_read.data.tearing[i] = MF_UL_TEARING_FLAG_DEFAULT; |                             mf_ul_read.data.tearing[i] = MF_UL_TEARING_FLAG_DEFAULT; | ||||||
|                         } else { |                         } else { | ||||||
|                             mf_ul_parse_check_tearing_response(rx_buff, i, &mf_ul_read); |                             mf_ul_parse_check_tearing_response(rx_buff, i, &mf_ul_read); | ||||||
| @ -574,11 +566,10 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                 } else { |                 } else { | ||||||
|                     // READ card with READ command (4 pages at a time)
 |                     // READ card with READ command (4 pages at a time)
 | ||||||
|                     for(uint8_t page = 0; page < mf_ul_read.pages_to_read; page += 4) { |                     for(uint8_t page = 0; page < mf_ul_read.pages_to_read; page += 4) { | ||||||
|                         FURI_LOG_I(NFC_WORKER_TAG, "Reading pages %d - %d ...", page, page + 3); |                         FURI_LOG_I(TAG, "Reading pages %d - %d ...", page, page + 3); | ||||||
|                         tx_len = mf_ul_prepare_read(tx_buff, page); |                         tx_len = mf_ul_prepare_read(tx_buff, page); | ||||||
|                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { |                         if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) { | ||||||
|                             FURI_LOG_E( |                             FURI_LOG_E(TAG, "Read pages %d - %d failed", page, page + 3); | ||||||
|                                 NFC_WORKER_TAG, "Read pages %d - %d failed", page, page + 3); |  | ||||||
|                             continue; |                             continue; | ||||||
|                         } else { |                         } else { | ||||||
|                             mf_ul_parse_read_response(rx_buff, page, &mf_ul_read); |                             mf_ul_parse_read_response(rx_buff, page, &mf_ul_read); | ||||||
| @ -602,10 +593,10 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_W(NFC_WORKER_TAG, "Tag does not support Mifare Ultralight"); |                 FURI_LOG_W(TAG, "Tag does not support Mifare Ultralight"); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_W(NFC_WORKER_TAG, "Can't find any tags"); |             FURI_LOG_W(TAG, "Can't find any tags"); | ||||||
|         } |         } | ||||||
|         osDelay(100); |         osDelay(100); | ||||||
|     } |     } | ||||||
| @ -629,7 +620,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                data->nfc_data.sak, |                data->nfc_data.sak, | ||||||
|                true, |                true, | ||||||
|                200)) { |                200)) { | ||||||
|             FURI_LOG_D(NFC_WORKER_TAG, "Anticollision passed"); |             FURI_LOG_D(TAG, "Anticollision passed"); | ||||||
|             if(furi_hal_nfc_get_first_frame(&rx_buff, &rx_len)) { |             if(furi_hal_nfc_get_first_frame(&rx_buff, &rx_len)) { | ||||||
|                 // Data exchange loop
 |                 // Data exchange loop
 | ||||||
|                 while(nfc_worker->state == NfcWorkerStateEmulateMifareUl) { |                 while(nfc_worker->state == NfcWorkerStateEmulateMifareUl) { | ||||||
| @ -641,17 +632,17 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                         if(err == ERR_NONE) { |                         if(err == ERR_NONE) { | ||||||
|                             continue; |                             continue; | ||||||
|                         } else { |                         } else { | ||||||
|                             FURI_LOG_E(NFC_WORKER_TAG, "Communication error: %d", err); |                             FURI_LOG_E(TAG, "Communication error: %d", err); | ||||||
|                             break; |                             break; | ||||||
|                         } |                         } | ||||||
|                     } else { |                     } else { | ||||||
|                         FURI_LOG_W(NFC_WORKER_TAG, "Not valid command: %02X", rx_buff[0]); |                         FURI_LOG_W(TAG, "Not valid command: %02X", rx_buff[0]); | ||||||
|                         furi_hal_nfc_deactivate(); |                         furi_hal_nfc_deactivate(); | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_W(NFC_WORKER_TAG, "Error in 1st data exchange"); |                 FURI_LOG_W(TAG, "Error in 1st data exchange"); | ||||||
|                 furi_hal_nfc_deactivate(); |                 furi_hal_nfc_deactivate(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -662,7 +653,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) { | |||||||
|                 nfc_worker->callback(nfc_worker->context); |                 nfc_worker->callback(nfc_worker->context); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         FURI_LOG_W(NFC_WORKER_TAG, "Can't find reader"); |         FURI_LOG_W(TAG, "Can't find reader"); | ||||||
|         osThreadYield(); |         osThreadYield(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,6 +5,8 @@ | |||||||
| #include "notification-messages.h" | #include "notification-messages.h" | ||||||
| #include "notification-app.h" | #include "notification-app.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "NotificationSrv" | ||||||
|  | 
 | ||||||
| static const uint8_t minimal_delay = 100; | static const uint8_t minimal_delay = 100; | ||||||
| static const uint8_t led_off_values[NOTIFICATION_LED_COUNT] = {0x00, 0x00, 0x00}; | static const uint8_t led_off_values[NOTIFICATION_LED_COUNT] = {0x00, 0x00, 0x00}; | ||||||
| 
 | 
 | ||||||
| @ -314,7 +316,7 @@ static bool notification_load_settings(NotificationApp* app) { | |||||||
|     File* file = storage_file_alloc(furi_record_open("storage")); |     File* file = storage_file_alloc(furi_record_open("storage")); | ||||||
|     const size_t settings_size = sizeof(NotificationSettings); |     const size_t settings_size = sizeof(NotificationSettings); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("notification", "loading settings from \"%s\"", NOTIFICATION_SETTINGS_PATH); |     FURI_LOG_I(TAG, "loading settings from \"%s\"", NOTIFICATION_SETTINGS_PATH); | ||||||
|     bool fs_result = |     bool fs_result = | ||||||
|         storage_file_open(file, NOTIFICATION_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING); |         storage_file_open(file, NOTIFICATION_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING); | ||||||
| 
 | 
 | ||||||
| @ -327,21 +329,18 @@ static bool notification_load_settings(NotificationApp* app) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(fs_result) { |     if(fs_result) { | ||||||
|         FURI_LOG_I("notification", "load success"); |         FURI_LOG_I(TAG, "load success"); | ||||||
| 
 | 
 | ||||||
|         if(settings.version != NOTIFICATION_SETTINGS_VERSION) { |         if(settings.version != NOTIFICATION_SETTINGS_VERSION) { | ||||||
|             FURI_LOG_E( |             FURI_LOG_E( | ||||||
|                 "notification", |                 TAG, "version(%d != %d) mismatch", settings.version, NOTIFICATION_SETTINGS_VERSION); | ||||||
|                 "version(%d != %d) mismatch", |  | ||||||
|                 settings.version, |  | ||||||
|                 NOTIFICATION_SETTINGS_VERSION); |  | ||||||
|         } else { |         } else { | ||||||
|             osKernelLock(); |             osKernelLock(); | ||||||
|             memcpy(&app->settings, &settings, settings_size); |             memcpy(&app->settings, &settings, settings_size); | ||||||
|             osKernelUnlock(); |             osKernelUnlock(); | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E("notification", "load failed, %s", storage_file_get_error_desc(file)); |         FURI_LOG_E(TAG, "load failed, %s", storage_file_get_error_desc(file)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     storage_file_close(file); |     storage_file_close(file); | ||||||
| @ -356,7 +355,7 @@ static bool notification_save_settings(NotificationApp* app) { | |||||||
|     File* file = storage_file_alloc(furi_record_open("storage")); |     File* file = storage_file_alloc(furi_record_open("storage")); | ||||||
|     const size_t settings_size = sizeof(NotificationSettings); |     const size_t settings_size = sizeof(NotificationSettings); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("notification", "saving settings to \"%s\"", NOTIFICATION_SETTINGS_PATH); |     FURI_LOG_I(TAG, "saving settings to \"%s\"", NOTIFICATION_SETTINGS_PATH); | ||||||
| 
 | 
 | ||||||
|     osKernelLock(); |     osKernelLock(); | ||||||
|     memcpy(&settings, &app->settings, settings_size); |     memcpy(&settings, &app->settings, settings_size); | ||||||
| @ -374,9 +373,9 @@ static bool notification_save_settings(NotificationApp* app) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(fs_result) { |     if(fs_result) { | ||||||
|         FURI_LOG_I("notification", "save success"); |         FURI_LOG_I(TAG, "save success"); | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E("notification", "save failed, %s", storage_file_get_error_desc(file)); |         FURI_LOG_E(TAG, "save failed, %s", storage_file_get_error_desc(file)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     storage_file_close(file); |     storage_file_close(file); | ||||||
|  | |||||||
							
								
								
									
										39
									
								
								applications/rpc/rpc.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										39
									
								
								applications/rpc/rpc.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @ -9,6 +9,7 @@ | |||||||
| #include <cmsis_os2.h> | #include <cmsis_os2.h> | ||||||
| #include <portmacro.h> | #include <portmacro.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
|  | 
 | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| @ -16,14 +17,12 @@ | |||||||
| #include <m-string.h> | #include <m-string.h> | ||||||
| #include <m-dict.h> | #include <m-dict.h> | ||||||
| 
 | 
 | ||||||
| #define RPC_TAG "RPC" | #define TAG "RpcSrv" | ||||||
| 
 | 
 | ||||||
| #define RPC_EVENT_NEW_DATA (1 << 0) | #define RPC_EVENT_NEW_DATA (1 << 0) | ||||||
| #define RPC_EVENT_DISCONNECT (1 << 1) | #define RPC_EVENT_DISCONNECT (1 << 1) | ||||||
| #define RPC_EVENTS_ALL (RPC_EVENT_DISCONNECT | RPC_EVENT_NEW_DATA) | #define RPC_EVENTS_ALL (RPC_EVENT_DISCONNECT | RPC_EVENT_NEW_DATA) | ||||||
| 
 | 
 | ||||||
| #define DEBUG_PRINT 0 |  | ||||||
| 
 |  | ||||||
| DICT_DEF2(RpcHandlerDict, pb_size_t, M_DEFAULT_OPLIST, RpcHandler, M_POD_OPLIST) | DICT_DEF2(RpcHandlerDict, pb_size_t, M_DEFAULT_OPLIST, RpcHandler, M_POD_OPLIST) | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
| @ -264,6 +263,7 @@ void rpc_print_message(const PB_Main* message) { | |||||||
|         size_t msg_file_count = message->content.storage_list_response.file_count; |         size_t msg_file_count = message->content.storage_list_response.file_count; | ||||||
|         string_cat_printf(str, "\tlist_response {\r\n"); |         string_cat_printf(str, "\tlist_response {\r\n"); | ||||||
|         rpc_sprintf_msg_file(str, "\t\t", msg_file, msg_file_count); |         rpc_sprintf_msg_file(str, "\t\t", msg_file, msg_file_count); | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|     case PB_Main_gui_start_screen_stream_request_tag: |     case PB_Main_gui_start_screen_stream_request_tag: | ||||||
|         string_cat_printf(str, "\tstart_screen_stream {\r\n"); |         string_cat_printf(str, "\tstart_screen_stream {\r\n"); | ||||||
| @ -271,8 +271,8 @@ void rpc_print_message(const PB_Main* message) { | |||||||
|     case PB_Main_gui_stop_screen_stream_request_tag: |     case PB_Main_gui_stop_screen_stream_request_tag: | ||||||
|         string_cat_printf(str, "\tstop_screen_stream {\r\n"); |         string_cat_printf(str, "\tstop_screen_stream {\r\n"); | ||||||
|         break; |         break; | ||||||
|     case PB_Main_gui_screen_stream_frame_tag: |     case PB_Main_gui_screen_frame_tag: | ||||||
|         string_cat_printf(str, "\tscreen_stream_frame {\r\n"); |         string_cat_printf(str, "\tscreen_frame {\r\n"); | ||||||
|         break; |         break; | ||||||
|     case PB_Main_gui_send_input_event_request_tag: |     case PB_Main_gui_send_input_event_request_tag: | ||||||
|         string_cat_printf(str, "\tsend_input_event {\r\n"); |         string_cat_printf(str, "\tsend_input_event {\r\n"); | ||||||
| @ -281,6 +281,12 @@ void rpc_print_message(const PB_Main* message) { | |||||||
|         string_cat_printf( |         string_cat_printf( | ||||||
|             str, "\t\type: %d\r\n", message->content.gui_send_input_event_request.type); |             str, "\t\type: %d\r\n", message->content.gui_send_input_event_request.type); | ||||||
|         break; |         break; | ||||||
|  |     case PB_Main_gui_start_virtual_display_request_tag: | ||||||
|  |         string_cat_printf(str, "\tstart_virtual_display {\r\n"); | ||||||
|  |         break; | ||||||
|  |     case PB_Main_gui_stop_virtual_display_request_tag: | ||||||
|  |         string_cat_printf(str, "\tstop_virtual_display {\r\n"); | ||||||
|  |         break; | ||||||
|     } |     } | ||||||
|     string_cat_printf(str, "\t}\r\n}\r\n"); |     string_cat_printf(str, "\t}\r\n}\r\n"); | ||||||
|     printf("%s", string_get_cstr(str)); |     printf("%s", string_get_cstr(str)); | ||||||
| @ -335,7 +341,7 @@ RpcSession* rpc_session_open(Rpc* rpc) { | |||||||
|         }; |         }; | ||||||
|         rpc_add_handler(rpc, PB_Main_stop_session_tag, &rpc_handler); |         rpc_add_handler(rpc, PB_Main_stop_session_tag, &rpc_handler); | ||||||
| 
 | 
 | ||||||
|         FURI_LOG_D(RPC_TAG, "Session started\r\n"); |         FURI_LOG_D(TAG, "Session started\r\n"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return result ? &rpc->session : NULL; /* support 1 open session for now */ |     return result ? &rpc->session : NULL; /* support 1 open session for now */ | ||||||
| @ -468,7 +474,7 @@ bool rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| #if DEBUG_PRINT | #if SRV_RPC_DEBUG | ||||||
|     rpc_print_data("INPUT", buf, bytes_received); |     rpc_print_data("INPUT", buf, bytes_received); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| @ -481,8 +487,8 @@ void rpc_send_and_release(Rpc* rpc, PB_Main* message) { | |||||||
|     RpcSession* session = &rpc->session; |     RpcSession* session = &rpc->session; | ||||||
|     pb_ostream_t ostream = PB_OSTREAM_SIZING; |     pb_ostream_t ostream = PB_OSTREAM_SIZING; | ||||||
| 
 | 
 | ||||||
| #if DEBUG_PRINT | #if SRV_RPC_DEBUG | ||||||
|     FURI_LOG_I(RPC_TAG, "OUTPUT:"); |     FURI_LOG_I(TAG, "OUTPUT:"); | ||||||
|     rpc_print_message(message); |     rpc_print_message(message); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| @ -494,7 +500,7 @@ void rpc_send_and_release(Rpc* rpc, PB_Main* message) { | |||||||
| 
 | 
 | ||||||
|     pb_encode_ex(&ostream, &PB_Main_msg, message, PB_ENCODE_DELIMITED); |     pb_encode_ex(&ostream, &PB_Main_msg, message, PB_ENCODE_DELIMITED); | ||||||
| 
 | 
 | ||||||
| #if DEBUG_PRINT | #if SRV_RPC_DEBUG | ||||||
|     rpc_print_data("OUTPUT", buffer, ostream.bytes_written); |     rpc_print_data("OUTPUT", buffer, ostream.bytes_written); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| @ -535,12 +541,12 @@ int32_t rpc_srv(void* p) { | |||||||
|             .callback = rpc_pb_stream_read, |             .callback = rpc_pb_stream_read, | ||||||
|             .state = rpc, |             .state = rpc, | ||||||
|             .errmsg = NULL, |             .errmsg = NULL, | ||||||
|             .bytes_left = 1024, /* max incoming message size */ |             .bytes_left = RPC_MAX_MESSAGE_SIZE, /* max incoming message size */ | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if(pb_decode_ex(&istream, &PB_Main_msg, rpc->decoded_message, PB_DECODE_DELIMITED)) { |         if(pb_decode_ex(&istream, &PB_Main_msg, rpc->decoded_message, PB_DECODE_DELIMITED)) { | ||||||
| #if DEBUG_PRINT | #if SRV_RPC_DEBUG | ||||||
|             FURI_LOG_I(RPC_TAG, "INPUT:"); |             FURI_LOG_I(TAG, "INPUT:"); | ||||||
|             rpc_print_message(rpc->decoded_message); |             rpc_print_message(rpc->decoded_message); | ||||||
| #endif | #endif | ||||||
|             RpcHandler* handler = |             RpcHandler* handler = | ||||||
| @ -549,20 +555,19 @@ int32_t rpc_srv(void* p) { | |||||||
|             if(handler && handler->message_handler) { |             if(handler && handler->message_handler) { | ||||||
|                 handler->message_handler(rpc->decoded_message, handler->context); |                 handler->message_handler(rpc->decoded_message, handler->context); | ||||||
|             } else if(!handler && !rpc->session.terminate) { |             } else if(!handler && !rpc->session.terminate) { | ||||||
|                 FURI_LOG_E( |                 FURI_LOG_E(TAG, "Unhandled message, tag: %d", rpc->decoded_message->which_content); | ||||||
|                     RPC_TAG, "Unhandled message, tag: %d", rpc->decoded_message->which_content); |  | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             xStreamBufferReset(rpc->stream); |             xStreamBufferReset(rpc->stream); | ||||||
|             if(!rpc->session.terminate) { |             if(!rpc->session.terminate) { | ||||||
|                 FURI_LOG_E(RPC_TAG, "Decode failed, error: \'%.128s\'", PB_GET_ERROR(&istream)); |                 FURI_LOG_E(TAG, "Decode failed, error: \'%.128s\'", PB_GET_ERROR(&istream)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         pb_release(&PB_Main_msg, rpc->decoded_message); |         pb_release(&PB_Main_msg, rpc->decoded_message); | ||||||
| 
 | 
 | ||||||
|         if(rpc->session.terminate) { |         if(rpc->session.terminate) { | ||||||
|             FURI_LOG_D(RPC_TAG, "Session terminated"); |             FURI_LOG_D(TAG, "Session terminated"); | ||||||
|             osEventFlagsClear(rpc->events, RPC_EVENTS_ALL); |             osEventFlagsClear(rpc->events, RPC_EVENTS_ALL); | ||||||
|             rpc_free_session(&rpc->session); |             rpc_free_session(&rpc->session); | ||||||
|             rpc->busy = false; |             rpc->busy = false; | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ | |||||||
| #include "cmsis_os.h" | #include "cmsis_os.h" | ||||||
| 
 | 
 | ||||||
| #define RPC_BUFFER_SIZE (1024) | #define RPC_BUFFER_SIZE (1024) | ||||||
|  | #define RPC_MAX_MESSAGE_SIZE (1536) | ||||||
| 
 | 
 | ||||||
| /** Rpc interface. Used for opening session only. */ | /** Rpc interface. Used for opening session only. */ | ||||||
| typedef struct Rpc Rpc; | typedef struct Rpc Rpc; | ||||||
|  | |||||||
| @ -1,14 +1,14 @@ | |||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <rpc/rpc.h> | #include <rpc/rpc.h> | ||||||
| #include <furi-hal-vcp.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     Cli* cli; |     Cli* cli; | ||||||
|     bool session_close_request; |     bool session_close_request; | ||||||
| } CliRpc; | } CliRpc; | ||||||
| 
 | 
 | ||||||
| #define CLI_READ_BUFFER_SIZE 100 | #define CLI_READ_BUFFER_SIZE 64 | ||||||
| 
 | 
 | ||||||
| static void rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t bytes_len) { | static void rpc_send_bytes_callback(void* context, uint8_t* bytes, size_t bytes_len) { | ||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
| @ -50,7 +50,8 @@ void rpc_cli_command_start_session(Cli* cli, string_t args, void* context) { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(size_received) { |         if(size_received) { | ||||||
|             rpc_session_feed(rpc_session, buffer, size_received, 3000); |             furi_assert( | ||||||
|  |                 rpc_session_feed(rpc_session, buffer, size_received, 3000) == size_received); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,12 +3,17 @@ | |||||||
| #include "gui.pb.h" | #include "gui.pb.h" | ||||||
| #include <gui/gui_i.h> | #include <gui/gui_i.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "RpcGui" | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     Rpc* rpc; |     Rpc* rpc; | ||||||
|     Gui* gui; |     Gui* gui; | ||||||
|  |     ViewPort* virtual_display_view_port; | ||||||
|  |     uint8_t* virtual_display_buffer; | ||||||
|  |     bool virtual_display_not_empty; | ||||||
| } RpcGuiSystem; | } RpcGuiSystem; | ||||||
| 
 | 
 | ||||||
| void rpc_system_gui_screen_frame_callback(uint8_t* data, size_t size, void* context) { | void rpc_system_gui_screen_stream_frame_callback(uint8_t* data, size_t size, void* context) { | ||||||
|     furi_assert(data); |     furi_assert(data); | ||||||
|     furi_assert(size == 1024); |     furi_assert(size == 1024); | ||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
| @ -17,11 +22,11 @@ void rpc_system_gui_screen_frame_callback(uint8_t* data, size_t size, void* cont | |||||||
| 
 | 
 | ||||||
|     PB_Main* frame = furi_alloc(sizeof(PB_Main)); |     PB_Main* frame = furi_alloc(sizeof(PB_Main)); | ||||||
| 
 | 
 | ||||||
|     frame->which_content = PB_Main_gui_screen_stream_frame_tag; |     frame->which_content = PB_Main_gui_screen_frame_tag; | ||||||
|     frame->command_status = PB_CommandStatus_OK; |     frame->command_status = PB_CommandStatus_OK; | ||||||
|     frame->content.gui_screen_stream_frame.data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(size)); |     frame->content.gui_screen_frame.data = furi_alloc(PB_BYTES_ARRAY_T_ALLOCSIZE(size)); | ||||||
|     uint8_t* buffer = frame->content.gui_screen_stream_frame.data->bytes; |     uint8_t* buffer = frame->content.gui_screen_frame.data->bytes; | ||||||
|     uint16_t* frame_size_msg = &frame->content.gui_screen_stream_frame.data->size; |     uint16_t* frame_size_msg = &frame->content.gui_screen_frame.data->size; | ||||||
|     *frame_size_msg = size; |     *frame_size_msg = size; | ||||||
|     memcpy(buffer, data, size); |     memcpy(buffer, data, size); | ||||||
| 
 | 
 | ||||||
| @ -37,7 +42,8 @@ void rpc_system_gui_start_screen_stream_process(const PB_Main* request, void* co | |||||||
| 
 | 
 | ||||||
|     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); |     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); | ||||||
| 
 | 
 | ||||||
|     gui_set_framebuffer_callback(rpc_gui->gui, rpc_system_gui_screen_frame_callback, context); |     gui_set_framebuffer_callback( | ||||||
|  |         rpc_gui->gui, rpc_system_gui_screen_stream_frame_callback, context); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* context) { | void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* context) { | ||||||
| @ -45,9 +51,9 @@ void rpc_system_gui_stop_screen_stream_process(const PB_Main* request, void* con | |||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
|     RpcGuiSystem* rpc_gui = context; |     RpcGuiSystem* rpc_gui = context; | ||||||
| 
 | 
 | ||||||
|     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); |  | ||||||
| 
 |  | ||||||
|     gui_set_framebuffer_callback(rpc_gui->gui, NULL, NULL); |     gui_set_framebuffer_callback(rpc_gui->gui, NULL, NULL); | ||||||
|  | 
 | ||||||
|  |     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void rpc_system_gui_send_input_event_request_process(const PB_Main* request, void* context) { | void rpc_system_gui_send_input_event_request_process(const PB_Main* request, void* context) { | ||||||
| @ -120,6 +126,88 @@ void rpc_system_gui_send_input_event_request_process(const PB_Main* request, voi | |||||||
|     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); |     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void rpc_system_gui_virtual_display_render_callback(Canvas* canvas, void* context) { | ||||||
|  |     furi_assert(canvas); | ||||||
|  |     furi_assert(context); | ||||||
|  |     RpcGuiSystem* rpc_gui = context; | ||||||
|  | 
 | ||||||
|  |     if(!rpc_gui->virtual_display_not_empty) { | ||||||
|  |         canvas_set_font(canvas, FontPrimary); | ||||||
|  |         canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignCenter, "Virtual Display"); | ||||||
|  |         canvas_draw_str_aligned(canvas, 64, 36, AlignCenter, AlignCenter, "Waiting for frames..."); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     canvas_draw_xbm(canvas, 0, 0, canvas->width, canvas->height, rpc_gui->virtual_display_buffer); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void rpc_system_gui_start_virtual_display_process(const PB_Main* request, void* context) { | ||||||
|  |     furi_assert(request); | ||||||
|  |     furi_assert(context); | ||||||
|  |     RpcGuiSystem* rpc_gui = context; | ||||||
|  | 
 | ||||||
|  |     if(rpc_gui->virtual_display_view_port) { | ||||||
|  |         rpc_send_and_release_empty( | ||||||
|  |             rpc_gui->rpc, | ||||||
|  |             request->command_id, | ||||||
|  |             PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_ALREADY_STARTED); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // TODO: consider refactoring
 | ||||||
|  |     // Using display framebuffer size as an XBM buffer size is like comparing apples and oranges
 | ||||||
|  |     // Glad they both are 1024 for now
 | ||||||
|  |     size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas); | ||||||
|  |     rpc_gui->virtual_display_buffer = furi_alloc(buffer_size); | ||||||
|  |     rpc_gui->virtual_display_view_port = view_port_alloc(); | ||||||
|  |     view_port_draw_callback_set( | ||||||
|  |         rpc_gui->virtual_display_view_port, | ||||||
|  |         rpc_system_gui_virtual_display_render_callback, | ||||||
|  |         rpc_gui); | ||||||
|  |     gui_add_view_port(rpc_gui->gui, rpc_gui->virtual_display_view_port, GuiLayerFullscreen); | ||||||
|  | 
 | ||||||
|  |     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void rpc_system_gui_stop_virtual_display_process(const PB_Main* request, void* context) { | ||||||
|  |     furi_assert(request); | ||||||
|  |     furi_assert(context); | ||||||
|  |     RpcGuiSystem* rpc_gui = context; | ||||||
|  | 
 | ||||||
|  |     if(!rpc_gui->virtual_display_view_port) { | ||||||
|  |         rpc_send_and_release_empty( | ||||||
|  |             rpc_gui->rpc, request->command_id, PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_NOT_STARTED); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     gui_remove_view_port(rpc_gui->gui, rpc_gui->virtual_display_view_port); | ||||||
|  |     view_port_free(rpc_gui->virtual_display_view_port); | ||||||
|  |     free(rpc_gui->virtual_display_buffer); | ||||||
|  |     rpc_gui->virtual_display_view_port = NULL; | ||||||
|  |     rpc_gui->virtual_display_not_empty = false; | ||||||
|  | 
 | ||||||
|  |     rpc_send_and_release_empty(rpc_gui->rpc, request->command_id, PB_CommandStatus_OK); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void rpc_system_gui_virtual_display_frame_process(const PB_Main* request, void* context) { | ||||||
|  |     furi_assert(request); | ||||||
|  |     furi_assert(context); | ||||||
|  |     RpcGuiSystem* rpc_gui = context; | ||||||
|  | 
 | ||||||
|  |     if(!rpc_gui->virtual_display_view_port) { | ||||||
|  |         FURI_LOG_W(TAG, "Virtual display is not started, ignoring incoming frame packet"); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     size_t buffer_size = canvas_get_buffer_size(rpc_gui->gui->canvas); | ||||||
|  |     memcpy( | ||||||
|  |         rpc_gui->virtual_display_buffer, | ||||||
|  |         request->content.gui_screen_frame.data->bytes, | ||||||
|  |         buffer_size); | ||||||
|  |     rpc_gui->virtual_display_not_empty = true; | ||||||
|  |     view_port_update(rpc_gui->virtual_display_view_port); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void* rpc_system_gui_alloc(Rpc* rpc) { | void* rpc_system_gui_alloc(Rpc* rpc) { | ||||||
|     furi_assert(rpc); |     furi_assert(rpc); | ||||||
| 
 | 
 | ||||||
| @ -142,6 +230,15 @@ void* rpc_system_gui_alloc(Rpc* rpc) { | |||||||
|     rpc_handler.message_handler = rpc_system_gui_send_input_event_request_process; |     rpc_handler.message_handler = rpc_system_gui_send_input_event_request_process; | ||||||
|     rpc_add_handler(rpc, PB_Main_gui_send_input_event_request_tag, &rpc_handler); |     rpc_add_handler(rpc, PB_Main_gui_send_input_event_request_tag, &rpc_handler); | ||||||
| 
 | 
 | ||||||
|  |     rpc_handler.message_handler = rpc_system_gui_start_virtual_display_process; | ||||||
|  |     rpc_add_handler(rpc, PB_Main_gui_start_virtual_display_request_tag, &rpc_handler); | ||||||
|  | 
 | ||||||
|  |     rpc_handler.message_handler = rpc_system_gui_stop_virtual_display_process; | ||||||
|  |     rpc_add_handler(rpc, PB_Main_gui_stop_virtual_display_request_tag, &rpc_handler); | ||||||
|  | 
 | ||||||
|  |     rpc_handler.message_handler = rpc_system_gui_virtual_display_frame_process; | ||||||
|  |     rpc_add_handler(rpc, PB_Main_gui_screen_frame_tag, &rpc_handler); | ||||||
|  | 
 | ||||||
|     return rpc_gui; |     return rpc_gui; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -149,6 +246,15 @@ void rpc_system_gui_free(void* ctx) { | |||||||
|     furi_assert(ctx); |     furi_assert(ctx); | ||||||
|     RpcGuiSystem* rpc_gui = ctx; |     RpcGuiSystem* rpc_gui = ctx; | ||||||
|     furi_assert(rpc_gui->gui); |     furi_assert(rpc_gui->gui); | ||||||
|  | 
 | ||||||
|  |     if(rpc_gui->virtual_display_view_port) { | ||||||
|  |         gui_remove_view_port(rpc_gui->gui, rpc_gui->virtual_display_view_port); | ||||||
|  |         view_port_free(rpc_gui->virtual_display_view_port); | ||||||
|  |         free(rpc_gui->virtual_display_buffer); | ||||||
|  |         rpc_gui->virtual_display_view_port = NULL; | ||||||
|  |         rpc_gui->virtual_display_not_empty = false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     gui_set_framebuffer_callback(rpc_gui->gui, NULL, NULL); |     gui_set_framebuffer_callback(rpc_gui->gui, NULL, NULL); | ||||||
|     furi_record_close("gui"); |     furi_record_close("gui"); | ||||||
|     free(rpc_gui); |     free(rpc_gui); | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| #include <storage/storage.h> | #include <storage/storage.h> | ||||||
| 
 | 
 | ||||||
| #define TAG "storage-test" | #define TAG "StorageTest" | ||||||
| #define BYTES_COUNT 16 | #define BYTES_COUNT 16 | ||||||
| #define TEST_STRING "TestDataStringProvidedByDiceRoll" | #define TEST_STRING "TestDataStringProvidedByDiceRoll" | ||||||
| #define SEEK_OFFSET_FROM_START 10 | #define SEEK_OFFSET_FROM_START 10 | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ typedef DIR SDDir; | |||||||
| typedef FILINFO SDFileInfo; | typedef FILINFO SDFileInfo; | ||||||
| typedef FRESULT SDError; | typedef FRESULT SDError; | ||||||
| 
 | 
 | ||||||
| #define TAG "storage-ext" | #define TAG "StorageExt" | ||||||
| #define STORAGE_PATH "/ext" | #define STORAGE_PATH "/ext" | ||||||
| /********************* Definitions ********************/ | /********************* Definitions ********************/ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| #include <lfs.h> | #include <lfs.h> | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #define TAG "storage-int" | #define TAG "StorageInt" | ||||||
| #define STORAGE_PATH "/int" | #define STORAGE_PATH "/int" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ bool subghz_set_pteset(SubGhz* subghz, const char* preset) { | |||||||
|     } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { |     } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { | ||||||
|         subghz->txrx->preset = FuriHalSubGhzPreset2FSKDev476Async; |         subghz->txrx->preset = FuriHalSubGhzPreset2FSKDev476Async; | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_E(SUBGHZ_KEY_TAG, "Unknown preset"); |         FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unknown preset"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     return true; |     return true; | ||||||
| @ -41,7 +41,7 @@ bool subghz_get_preset_name(SubGhz* subghz, string_t preset) { | |||||||
|     case FuriHalSubGhzPreset2FSKDev476Async: |     case FuriHalSubGhzPreset2FSKDev476Async: | ||||||
|         preset_name = "FuriHalSubGhzPreset2FSKDev476Async"; |         preset_name = "FuriHalSubGhzPreset2FSKDev476Async"; | ||||||
|         break; |         break; | ||||||
|         FURI_LOG_E(SUBGHZ_KEY_TAG, "Unknown preset"); |         FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unknown preset"); | ||||||
|     default: |     default: | ||||||
|         return false; |         return false; | ||||||
|         break; |         break; | ||||||
| @ -210,11 +210,12 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { | |||||||
| 
 | 
 | ||||||
|     do { |     do { | ||||||
|         if(!flipper_file_open_existing(flipper_file, string_get_cstr(path))) { |         if(!flipper_file_open_existing(flipper_file, string_get_cstr(path))) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to open file for read: %s", string_get_cstr(path)); |             FURI_LOG_E( | ||||||
|  |                 SUBGHZ_PARSER_TAG, "Unable to open file for read: %s", string_get_cstr(path)); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         if(!flipper_file_read_header(flipper_file, temp_str, &version)) { |         if(!flipper_file_read_header(flipper_file, temp_str, &version)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing or incorrect header"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing or incorrect header"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -222,18 +223,18 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { | |||||||
|             (!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && |             (!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) && | ||||||
|            version == SUBGHZ_KEY_FILE_VERSION) { |            version == SUBGHZ_KEY_FILE_VERSION) { | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Type or version mismatch"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Type or version mismatch"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(!flipper_file_read_uint32( |         if(!flipper_file_read_uint32( | ||||||
|                flipper_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) { |                flipper_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Frequency"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Frequency"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(!flipper_file_read_string(flipper_file, "Preset", temp_str)) { |         if(!flipper_file_read_string(flipper_file, "Preset", temp_str)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Preset"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Preset"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         if(!subghz_set_pteset(subghz, string_get_cstr(temp_str))) { |         if(!subghz_set_pteset(subghz, string_get_cstr(temp_str))) { | ||||||
| @ -241,14 +242,14 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(!flipper_file_read_string(flipper_file, "Protocol", temp_str)) { |         if(!flipper_file_read_string(flipper_file, "Protocol", temp_str)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Protocol"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Missing Protocol"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         subghz->txrx->protocol_result = |         subghz->txrx->protocol_result = | ||||||
|             subghz_parser_get_by_name(subghz->txrx->parser, string_get_cstr(temp_str)); |             subghz_parser_get_by_name(subghz->txrx->parser, string_get_cstr(temp_str)); | ||||||
|         if(subghz->txrx->protocol_result == NULL) { |         if(subghz->txrx->protocol_result == NULL) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "This type of protocol was not found"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "This type of protocol was not found"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         if(!subghz->txrx->protocol_result->to_load_protocol_from_file( |         if(!subghz->txrx->protocol_result->to_load_protocol_from_file( | ||||||
| @ -310,7 +311,7 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) { | |||||||
|     do { |     do { | ||||||
|         // Checking that this type of people can be saved
 |         // Checking that this type of people can be saved
 | ||||||
|         if(subghz->txrx->protocol_result->to_save_file == NULL) { |         if(subghz->txrx->protocol_result->to_save_file == NULL) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "No saving of this type of keys"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "No saving of this type of keys"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         // Create subghz folder directory if necessary
 |         // Create subghz folder directory if necessary
 | ||||||
| @ -334,19 +335,19 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) { | |||||||
| 
 | 
 | ||||||
|         // Open file
 |         // Open file
 | ||||||
|         if(!flipper_file_open_always(flipper_file, string_get_cstr(dev_file_name))) { |         if(!flipper_file_open_always(flipper_file, string_get_cstr(dev_file_name))) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to open file for write: %s", dev_file_name); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to open file for write: %s", dev_file_name); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(!flipper_file_write_header_cstr( |         if(!flipper_file_write_header_cstr( | ||||||
|                flipper_file, SUBGHZ_KEY_FILE_TYPE, SUBGHZ_KEY_FILE_VERSION)) { |                flipper_file, SUBGHZ_KEY_FILE_TYPE, SUBGHZ_KEY_FILE_VERSION)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add header"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add header"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if(!flipper_file_write_uint32( |         if(!flipper_file_write_uint32( | ||||||
|                flipper_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) { |                flipper_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Frequency"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Frequency"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -354,7 +355,7 @@ bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name) { | |||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         if(!flipper_file_write_string_cstr(flipper_file, "Preset", string_get_cstr(temp_str))) { |         if(!flipper_file_write_string_cstr(flipper_file, "Preset", string_get_cstr(temp_str))) { | ||||||
|             FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Preset"); |             FURI_LOG_E(SUBGHZ_PARSER_TAG, "Unable to add Preset"); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -8,6 +8,8 @@ | |||||||
| #include <notification/notification-messages.h> | #include <notification/notification-messages.h> | ||||||
| #include <lib/subghz/protocols/subghz_protocol_princeton.h> | #include <lib/subghz/protocols/subghz_protocol_princeton.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "SubGhzTestStatic" | ||||||
|  | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     SubghzTestStaticStatusIDLE, |     SubghzTestStaticStatusIDLE, | ||||||
|     SubghzTestStaticStatusTX, |     SubghzTestStaticStatusTX, | ||||||
| @ -99,7 +101,7 @@ bool subghz_test_static_input(InputEvent* event, void* context) { | |||||||
|                     } else { |                     } else { | ||||||
|                         notification_message_block(notification, &sequence_set_red_255); |                         notification_message_block(notification, &sequence_set_red_255); | ||||||
| 
 | 
 | ||||||
|                         FURI_LOG_I("SubghzTestStatic", "TX Start"); |                         FURI_LOG_I(TAG, "TX Start"); | ||||||
| 
 | 
 | ||||||
|                         subghz_encoder_princeton_set( |                         subghz_encoder_princeton_set( | ||||||
|                             instance->encoder, subghz_test_static_keys[model->button], 10000); |                             instance->encoder, subghz_test_static_keys[model->button], 10000); | ||||||
| @ -110,7 +112,7 @@ bool subghz_test_static_input(InputEvent* event, void* context) { | |||||||
|                     } |                     } | ||||||
|                 } else if(event->type == InputTypeRelease) { |                 } else if(event->type == InputTypeRelease) { | ||||||
|                     if(instance->satus_tx == SubghzTestStaticStatusTX) { |                     if(instance->satus_tx == SubghzTestStaticStatusTX) { | ||||||
|                         FURI_LOG_I("SubghzTestStatic", "TX Stop"); |                         FURI_LOG_I(TAG, "TX Stop"); | ||||||
|                         subghz_encoder_princeton_print_log(instance->encoder); |                         subghz_encoder_princeton_print_log(instance->encoder); | ||||||
|                         furi_hal_subghz_stop_async_tx(); |                         furi_hal_subghz_stop_async_tx(); | ||||||
|                         notification_message(notification, &sequence_reset_red); |                         notification_message(notification, &sequence_reset_red); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ static RpcSession* session = NULL; | |||||||
| static StreamBufferHandle_t output_stream = NULL; | static StreamBufferHandle_t output_stream = NULL; | ||||||
| static uint32_t command_id = 0; | static uint32_t command_id = 0; | ||||||
| 
 | 
 | ||||||
| #define TEST_RPC_TAG "TEST_RPC" | #define TAG "UnitTestsRpc" | ||||||
| #define MAX_RECEIVE_OUTPUT_TIMEOUT 3000 | #define MAX_RECEIVE_OUTPUT_TIMEOUT 3000 | ||||||
| #define MAX_NAME_LENGTH 255 | #define MAX_NAME_LENGTH 255 | ||||||
| #define MAX_DATA_SIZE 512 // have to be exact as in rpc_storage.c
 | #define MAX_DATA_SIZE 512 // have to be exact as in rpc_storage.c
 | ||||||
| @ -1334,7 +1334,7 @@ int run_minunit_test_rpc() { | |||||||
|     Storage* storage = furi_record_open("storage"); |     Storage* storage = furi_record_open("storage"); | ||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
|     if(storage_sd_status(storage) != FSE_OK) { |     if(storage_sd_status(storage) != FSE_OK) { | ||||||
|         FURI_LOG_E("UNIT_TESTS", "SD card not mounted - skip storage tests"); |         FURI_LOG_E(TAG, "SD card not mounted - skip storage tests"); | ||||||
|     } else { |     } else { | ||||||
|         MU_RUN_SUITE(test_rpc_storage); |         MU_RUN_SUITE(test_rpc_storage); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ | |||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <loader/loader.h> | #include <loader/loader.h> | ||||||
| 
 | 
 | ||||||
| #define TESTS_TAG "UNIT_TESTS" | #define TAG "UnitTests" | ||||||
| 
 | 
 | ||||||
| int run_minunit(); | int run_minunit(); | ||||||
| int run_minunit_test_irda_decoder_encoder(); | int run_minunit_test_irda_decoder_encoder(); | ||||||
| @ -42,7 +42,7 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) { | |||||||
| 
 | 
 | ||||||
|     // TODO: lock device while test running
 |     // TODO: lock device while test running
 | ||||||
|     if(loader_is_locked(loader)) { |     if(loader_is_locked(loader)) { | ||||||
|         FURI_LOG_E(TESTS_TAG, "RPC: stop all applications to run tests"); |         FURI_LOG_E(TAG, "RPC: stop all applications to run tests"); | ||||||
|         notification_message(notification, &sequence_blink_magenta_100); |         notification_message(notification, &sequence_blink_magenta_100); | ||||||
|     } else { |     } else { | ||||||
|         notification_message_block(notification, &sequence_set_only_blue_255); |         notification_message_block(notification, &sequence_set_only_blue_255); | ||||||
| @ -56,21 +56,21 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) { | |||||||
|         test_result |= run_minunit_test_flipper_file(); |         test_result |= run_minunit_test_flipper_file(); | ||||||
|         cycle_counter = (DWT->CYCCNT - cycle_counter); |         cycle_counter = (DWT->CYCCNT - cycle_counter); | ||||||
| 
 | 
 | ||||||
|         FURI_LOG_I(TESTS_TAG, "Consumed: %0.2fs", (float)cycle_counter / (SystemCoreClock)); |         FURI_LOG_I(TAG, "Consumed: %0.2fs", (float)cycle_counter / (SystemCoreClock)); | ||||||
| 
 | 
 | ||||||
|         if(test_result == 0) { |         if(test_result == 0) { | ||||||
|             delay(200); /* wait for tested services and apps to deallocate */ |             delay(200); /* wait for tested services and apps to deallocate */ | ||||||
|             uint32_t heap_after = memmgr_get_free_heap(); |             uint32_t heap_after = memmgr_get_free_heap(); | ||||||
|             notification_message(notification, &sequence_success); |             notification_message(notification, &sequence_success); | ||||||
|             if(heap_after != heap_before) { |             if(heap_after != heap_before) { | ||||||
|                 FURI_LOG_E(TESTS_TAG, "Leaked: %d", heap_before - heap_after); |                 FURI_LOG_E(TAG, "Leaked: %d", heap_before - heap_after); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_I(TESTS_TAG, "No leaks"); |                 FURI_LOG_I(TAG, "No leaks"); | ||||||
|             } |             } | ||||||
|             FURI_LOG_I(TESTS_TAG, "PASSED"); |             FURI_LOG_I(TAG, "PASSED"); | ||||||
|         } else { |         } else { | ||||||
|             notification_message(notification, &sequence_error); |             notification_message(notification, &sequence_error); | ||||||
|             FURI_LOG_E(TESTS_TAG, "FAILED"); |             FURI_LOG_E(TAG, "FAILED"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -36,7 +36,10 @@ typedef enum _PB_CommandStatus { | |||||||
|     PB_CommandStatus_ERROR_STORAGE_DIR_NOT_EMPTY = 18, /* *< Directory, you're going to remove is not empty */ |     PB_CommandStatus_ERROR_STORAGE_DIR_NOT_EMPTY = 18, /* *< Directory, you're going to remove is not empty */ | ||||||
|     /* *< Application Errors */ |     /* *< Application Errors */ | ||||||
|     PB_CommandStatus_ERROR_APP_CANT_START = 16, /* *< Can't start app - internal error */ |     PB_CommandStatus_ERROR_APP_CANT_START = 16, /* *< Can't start app - internal error */ | ||||||
|     PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED = 17 /* *< Another app is running */ |     PB_CommandStatus_ERROR_APP_SYSTEM_LOCKED = 17, /* *< Another app is running */ | ||||||
|  |     /* *< Virtual Display Errors */ | ||||||
|  |     PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_ALREADY_STARTED = 19, /* *< Virtual Display session can't be started twice */ | ||||||
|  |     PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_NOT_STARTED = 20 /* *< Virtual Display session can't be stopped when it's not started */ | ||||||
| } PB_CommandStatus; | } PB_CommandStatus; | ||||||
| 
 | 
 | ||||||
| /* Struct definitions */ | /* Struct definitions */ | ||||||
| @ -76,18 +79,20 @@ typedef struct _PB_Main { | |||||||
|         PB_StopSession stop_session; |         PB_StopSession stop_session; | ||||||
|         PB_Gui_StartScreenStreamRequest gui_start_screen_stream_request; |         PB_Gui_StartScreenStreamRequest gui_start_screen_stream_request; | ||||||
|         PB_Gui_StopScreenStreamRequest gui_stop_screen_stream_request; |         PB_Gui_StopScreenStreamRequest gui_stop_screen_stream_request; | ||||||
|         PB_Gui_ScreenStreamFrame gui_screen_stream_frame; |         PB_Gui_ScreenFrame gui_screen_frame; | ||||||
|         PB_Gui_SendInputEventRequest gui_send_input_event_request; |         PB_Gui_SendInputEventRequest gui_send_input_event_request; | ||||||
|         PB_Storage_StatRequest storage_stat_request; |         PB_Storage_StatRequest storage_stat_request; | ||||||
|         PB_Storage_StatResponse storage_stat_response; |         PB_Storage_StatResponse storage_stat_response; | ||||||
|  |         PB_Gui_StartVirtualDisplayRequest gui_start_virtual_display_request; | ||||||
|  |         PB_Gui_StopVirtualDisplayRequest gui_stop_virtual_display_request; | ||||||
|     } content;  |     } content;  | ||||||
| } PB_Main; | } PB_Main; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Helper constants for enums */ | /* Helper constants for enums */ | ||||||
| #define _PB_CommandStatus_MIN PB_CommandStatus_OK | #define _PB_CommandStatus_MIN PB_CommandStatus_OK | ||||||
| #define _PB_CommandStatus_MAX PB_CommandStatus_ERROR_STORAGE_DIR_NOT_EMPTY | #define _PB_CommandStatus_MAX PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_NOT_STARTED | ||||||
| #define _PB_CommandStatus_ARRAYSIZE ((PB_CommandStatus)(PB_CommandStatus_ERROR_STORAGE_DIR_NOT_EMPTY+1)) | #define _PB_CommandStatus_ARRAYSIZE ((PB_CommandStatus)(PB_CommandStatus_ERROR_VIRTUAL_DISPLAY_NOT_STARTED+1)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| @ -124,10 +129,12 @@ extern "C" { | |||||||
| #define PB_Main_stop_session_tag                 19 | #define PB_Main_stop_session_tag                 19 | ||||||
| #define PB_Main_gui_start_screen_stream_request_tag 20 | #define PB_Main_gui_start_screen_stream_request_tag 20 | ||||||
| #define PB_Main_gui_stop_screen_stream_request_tag 21 | #define PB_Main_gui_stop_screen_stream_request_tag 21 | ||||||
| #define PB_Main_gui_screen_stream_frame_tag      22 | #define PB_Main_gui_screen_frame_tag             22 | ||||||
| #define PB_Main_gui_send_input_event_request_tag 23 | #define PB_Main_gui_send_input_event_request_tag 23 | ||||||
| #define PB_Main_storage_stat_request_tag         24 | #define PB_Main_storage_stat_request_tag         24 | ||||||
| #define PB_Main_storage_stat_response_tag        25 | #define PB_Main_storage_stat_response_tag        25 | ||||||
|  | #define PB_Main_gui_start_virtual_display_request_tag 26 | ||||||
|  | #define PB_Main_gui_stop_virtual_display_request_tag 27 | ||||||
| 
 | 
 | ||||||
| /* Struct field encoding specification for nanopb */ | /* Struct field encoding specification for nanopb */ | ||||||
| #define PB_Empty_FIELDLIST(X, a) \ | #define PB_Empty_FIELDLIST(X, a) \ | ||||||
| @ -162,10 +169,12 @@ X(a, STATIC,   ONEOF,    MSG_W_CB, (content,app_lock_status_response,content.app | |||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,stop_session,content.stop_session),  19) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,stop_session,content.stop_session),  19) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_start_screen_stream_request,content.gui_start_screen_stream_request),  20) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_start_screen_stream_request,content.gui_start_screen_stream_request),  20) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_stop_screen_stream_request,content.gui_stop_screen_stream_request),  21) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_stop_screen_stream_request,content.gui_stop_screen_stream_request),  21) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_screen_stream_frame,content.gui_screen_stream_frame),  22) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_screen_frame,content.gui_screen_frame),  22) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_send_input_event_request,content.gui_send_input_event_request),  23) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_send_input_event_request,content.gui_send_input_event_request),  23) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_stat_request,content.storage_stat_request),  24) \ | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_stat_request,content.storage_stat_request),  24) \ | ||||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_stat_response,content.storage_stat_response),  25) | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_stat_response,content.storage_stat_response),  25) \ | ||||||
|  | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_start_virtual_display_request,content.gui_start_virtual_display_request),  26) \ | ||||||
|  | X(a, STATIC,   ONEOF,    MSG_W_CB, (content,gui_stop_virtual_display_request,content.gui_stop_virtual_display_request),  27) | ||||||
| #define PB_Main_CALLBACK NULL | #define PB_Main_CALLBACK NULL | ||||||
| #define PB_Main_DEFAULT NULL | #define PB_Main_DEFAULT NULL | ||||||
| #define PB_Main_content_empty_MSGTYPE PB_Empty | #define PB_Main_content_empty_MSGTYPE PB_Empty | ||||||
| @ -186,10 +195,12 @@ X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_stat_response,content.storag | |||||||
| #define PB_Main_content_stop_session_MSGTYPE PB_StopSession | #define PB_Main_content_stop_session_MSGTYPE PB_StopSession | ||||||
| #define PB_Main_content_gui_start_screen_stream_request_MSGTYPE PB_Gui_StartScreenStreamRequest | #define PB_Main_content_gui_start_screen_stream_request_MSGTYPE PB_Gui_StartScreenStreamRequest | ||||||
| #define PB_Main_content_gui_stop_screen_stream_request_MSGTYPE PB_Gui_StopScreenStreamRequest | #define PB_Main_content_gui_stop_screen_stream_request_MSGTYPE PB_Gui_StopScreenStreamRequest | ||||||
| #define PB_Main_content_gui_screen_stream_frame_MSGTYPE PB_Gui_ScreenStreamFrame | #define PB_Main_content_gui_screen_frame_MSGTYPE PB_Gui_ScreenFrame | ||||||
| #define PB_Main_content_gui_send_input_event_request_MSGTYPE PB_Gui_SendInputEventRequest | #define PB_Main_content_gui_send_input_event_request_MSGTYPE PB_Gui_SendInputEventRequest | ||||||
| #define PB_Main_content_storage_stat_request_MSGTYPE PB_Storage_StatRequest | #define PB_Main_content_storage_stat_request_MSGTYPE PB_Storage_StatRequest | ||||||
| #define PB_Main_content_storage_stat_response_MSGTYPE PB_Storage_StatResponse | #define PB_Main_content_storage_stat_response_MSGTYPE PB_Storage_StatResponse | ||||||
|  | #define PB_Main_content_gui_start_virtual_display_request_MSGTYPE PB_Gui_StartVirtualDisplayRequest | ||||||
|  | #define PB_Main_content_gui_stop_virtual_display_request_MSGTYPE PB_Gui_StopVirtualDisplayRequest | ||||||
| 
 | 
 | ||||||
| extern const pb_msgdesc_t PB_Empty_msg; | extern const pb_msgdesc_t PB_Empty_msg; | ||||||
| extern const pb_msgdesc_t PB_StopSession_msg; | extern const pb_msgdesc_t PB_StopSession_msg; | ||||||
| @ -203,9 +214,9 @@ extern const pb_msgdesc_t PB_Main_msg; | |||||||
| /* Maximum encoded size of messages (where known) */ | /* Maximum encoded size of messages (where known) */ | ||||||
| #define PB_Empty_size                            0 | #define PB_Empty_size                            0 | ||||||
| #define PB_StopSession_size                      0 | #define PB_StopSession_size                      0 | ||||||
| #if defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenStreamFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) | #if defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) | ||||||
| #define PB_Main_size                             (10 + sizeof(union PB_Main_content_size_union)) | #define PB_Main_size                             (10 + sizeof(union PB_Main_content_size_union)) | ||||||
| union PB_Main_content_size_union {char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenStreamFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f0[36];}; | union PB_Main_content_size_union {char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f0[36];}; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  | |||||||
| @ -6,18 +6,24 @@ | |||||||
| #error Regenerate this file with the current version of nanopb generator. | #error Regenerate this file with the current version of nanopb generator. | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | PB_BIND(PB_Gui_ScreenFrame, PB_Gui_ScreenFrame, AUTO) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| PB_BIND(PB_Gui_StartScreenStreamRequest, PB_Gui_StartScreenStreamRequest, AUTO) | PB_BIND(PB_Gui_StartScreenStreamRequest, PB_Gui_StartScreenStreamRequest, AUTO) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| PB_BIND(PB_Gui_StopScreenStreamRequest, PB_Gui_StopScreenStreamRequest, AUTO) | PB_BIND(PB_Gui_StopScreenStreamRequest, PB_Gui_StopScreenStreamRequest, AUTO) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| PB_BIND(PB_Gui_ScreenStreamFrame, PB_Gui_ScreenStreamFrame, AUTO) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| PB_BIND(PB_Gui_SendInputEventRequest, PB_Gui_SendInputEventRequest, AUTO) | PB_BIND(PB_Gui_SendInputEventRequest, PB_Gui_SendInputEventRequest, AUTO) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | PB_BIND(PB_Gui_StartVirtualDisplayRequest, PB_Gui_StartVirtualDisplayRequest, AUTO) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | PB_BIND(PB_Gui_StopVirtualDisplayRequest, PB_Gui_StopVirtualDisplayRequest, AUTO) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -28,18 +28,26 @@ typedef enum _PB_Gui_InputType { | |||||||
| } PB_Gui_InputType; | } PB_Gui_InputType; | ||||||
| 
 | 
 | ||||||
| /* Struct definitions */ | /* Struct definitions */ | ||||||
| typedef struct _PB_Gui_ScreenStreamFrame {  | typedef struct _PB_Gui_ScreenFrame {  | ||||||
|     pb_bytes_array_t *data;  |     pb_bytes_array_t *data;  | ||||||
| } PB_Gui_ScreenStreamFrame; | } PB_Gui_ScreenFrame; | ||||||
| 
 | 
 | ||||||
| typedef struct _PB_Gui_StartScreenStreamRequest {  | typedef struct _PB_Gui_StartScreenStreamRequest {  | ||||||
|     char dummy_field; |     char dummy_field; | ||||||
| } PB_Gui_StartScreenStreamRequest; | } PB_Gui_StartScreenStreamRequest; | ||||||
| 
 | 
 | ||||||
|  | typedef struct _PB_Gui_StartVirtualDisplayRequest {  | ||||||
|  |     char dummy_field; | ||||||
|  | } PB_Gui_StartVirtualDisplayRequest; | ||||||
|  | 
 | ||||||
| typedef struct _PB_Gui_StopScreenStreamRequest {  | typedef struct _PB_Gui_StopScreenStreamRequest {  | ||||||
|     char dummy_field; |     char dummy_field; | ||||||
| } PB_Gui_StopScreenStreamRequest; | } PB_Gui_StopScreenStreamRequest; | ||||||
| 
 | 
 | ||||||
|  | typedef struct _PB_Gui_StopVirtualDisplayRequest {  | ||||||
|  |     char dummy_field; | ||||||
|  | } PB_Gui_StopVirtualDisplayRequest; | ||||||
|  | 
 | ||||||
| typedef struct _PB_Gui_SendInputEventRequest {  | typedef struct _PB_Gui_SendInputEventRequest {  | ||||||
|     PB_Gui_InputKey key;  |     PB_Gui_InputKey key;  | ||||||
|     PB_Gui_InputType type;  |     PB_Gui_InputType type;  | ||||||
| @ -61,21 +69,30 @@ extern "C" { | |||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Initializer values for message structs */ | /* Initializer values for message structs */ | ||||||
|  | #define PB_Gui_ScreenFrame_init_default          {NULL} | ||||||
| #define PB_Gui_StartScreenStreamRequest_init_default {0} | #define PB_Gui_StartScreenStreamRequest_init_default {0} | ||||||
| #define PB_Gui_StopScreenStreamRequest_init_default {0} | #define PB_Gui_StopScreenStreamRequest_init_default {0} | ||||||
| #define PB_Gui_ScreenStreamFrame_init_default    {NULL} |  | ||||||
| #define PB_Gui_SendInputEventRequest_init_default {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN} | #define PB_Gui_SendInputEventRequest_init_default {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN} | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_init_default {0} | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_init_default {0} | ||||||
|  | #define PB_Gui_ScreenFrame_init_zero             {NULL} | ||||||
| #define PB_Gui_StartScreenStreamRequest_init_zero {0} | #define PB_Gui_StartScreenStreamRequest_init_zero {0} | ||||||
| #define PB_Gui_StopScreenStreamRequest_init_zero {0} | #define PB_Gui_StopScreenStreamRequest_init_zero {0} | ||||||
| #define PB_Gui_ScreenStreamFrame_init_zero       {NULL} |  | ||||||
| #define PB_Gui_SendInputEventRequest_init_zero   {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN} | #define PB_Gui_SendInputEventRequest_init_zero   {_PB_Gui_InputKey_MIN, _PB_Gui_InputType_MIN} | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_init_zero {0} | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_init_zero {0} | ||||||
| 
 | 
 | ||||||
| /* Field tags (for use in manual encoding/decoding) */ | /* Field tags (for use in manual encoding/decoding) */ | ||||||
| #define PB_Gui_ScreenStreamFrame_data_tag        1 | #define PB_Gui_ScreenFrame_data_tag              1 | ||||||
| #define PB_Gui_SendInputEventRequest_key_tag     1 | #define PB_Gui_SendInputEventRequest_key_tag     1 | ||||||
| #define PB_Gui_SendInputEventRequest_type_tag    2 | #define PB_Gui_SendInputEventRequest_type_tag    2 | ||||||
| 
 | 
 | ||||||
| /* Struct field encoding specification for nanopb */ | /* Struct field encoding specification for nanopb */ | ||||||
|  | #define PB_Gui_ScreenFrame_FIELDLIST(X, a) \ | ||||||
|  | X(a, POINTER,  SINGULAR, BYTES,    data,              1) | ||||||
|  | #define PB_Gui_ScreenFrame_CALLBACK NULL | ||||||
|  | #define PB_Gui_ScreenFrame_DEFAULT NULL | ||||||
|  | 
 | ||||||
| #define PB_Gui_StartScreenStreamRequest_FIELDLIST(X, a) \ | #define PB_Gui_StartScreenStreamRequest_FIELDLIST(X, a) \ | ||||||
| 
 | 
 | ||||||
| #define PB_Gui_StartScreenStreamRequest_CALLBACK NULL | #define PB_Gui_StartScreenStreamRequest_CALLBACK NULL | ||||||
| @ -86,33 +103,44 @@ extern "C" { | |||||||
| #define PB_Gui_StopScreenStreamRequest_CALLBACK NULL | #define PB_Gui_StopScreenStreamRequest_CALLBACK NULL | ||||||
| #define PB_Gui_StopScreenStreamRequest_DEFAULT NULL | #define PB_Gui_StopScreenStreamRequest_DEFAULT NULL | ||||||
| 
 | 
 | ||||||
| #define PB_Gui_ScreenStreamFrame_FIELDLIST(X, a) \ |  | ||||||
| X(a, POINTER,  SINGULAR, BYTES,    data,              1) |  | ||||||
| #define PB_Gui_ScreenStreamFrame_CALLBACK NULL |  | ||||||
| #define PB_Gui_ScreenStreamFrame_DEFAULT NULL |  | ||||||
| 
 |  | ||||||
| #define PB_Gui_SendInputEventRequest_FIELDLIST(X, a) \ | #define PB_Gui_SendInputEventRequest_FIELDLIST(X, a) \ | ||||||
| X(a, STATIC,   SINGULAR, UENUM,    key,               1) \ | X(a, STATIC,   SINGULAR, UENUM,    key,               1) \ | ||||||
| X(a, STATIC,   SINGULAR, UENUM,    type,              2) | X(a, STATIC,   SINGULAR, UENUM,    type,              2) | ||||||
| #define PB_Gui_SendInputEventRequest_CALLBACK NULL | #define PB_Gui_SendInputEventRequest_CALLBACK NULL | ||||||
| #define PB_Gui_SendInputEventRequest_DEFAULT NULL | #define PB_Gui_SendInputEventRequest_DEFAULT NULL | ||||||
| 
 | 
 | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_FIELDLIST(X, a) \ | ||||||
|  | 
 | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_CALLBACK NULL | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_DEFAULT NULL | ||||||
|  | 
 | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_FIELDLIST(X, a) \ | ||||||
|  | 
 | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_CALLBACK NULL | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_DEFAULT NULL | ||||||
|  | 
 | ||||||
|  | extern const pb_msgdesc_t PB_Gui_ScreenFrame_msg; | ||||||
| extern const pb_msgdesc_t PB_Gui_StartScreenStreamRequest_msg; | extern const pb_msgdesc_t PB_Gui_StartScreenStreamRequest_msg; | ||||||
| extern const pb_msgdesc_t PB_Gui_StopScreenStreamRequest_msg; | extern const pb_msgdesc_t PB_Gui_StopScreenStreamRequest_msg; | ||||||
| extern const pb_msgdesc_t PB_Gui_ScreenStreamFrame_msg; |  | ||||||
| extern const pb_msgdesc_t PB_Gui_SendInputEventRequest_msg; | extern const pb_msgdesc_t PB_Gui_SendInputEventRequest_msg; | ||||||
|  | extern const pb_msgdesc_t PB_Gui_StartVirtualDisplayRequest_msg; | ||||||
|  | extern const pb_msgdesc_t PB_Gui_StopVirtualDisplayRequest_msg; | ||||||
| 
 | 
 | ||||||
| /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ | /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ | ||||||
|  | #define PB_Gui_ScreenFrame_fields &PB_Gui_ScreenFrame_msg | ||||||
| #define PB_Gui_StartScreenStreamRequest_fields &PB_Gui_StartScreenStreamRequest_msg | #define PB_Gui_StartScreenStreamRequest_fields &PB_Gui_StartScreenStreamRequest_msg | ||||||
| #define PB_Gui_StopScreenStreamRequest_fields &PB_Gui_StopScreenStreamRequest_msg | #define PB_Gui_StopScreenStreamRequest_fields &PB_Gui_StopScreenStreamRequest_msg | ||||||
| #define PB_Gui_ScreenStreamFrame_fields &PB_Gui_ScreenStreamFrame_msg |  | ||||||
| #define PB_Gui_SendInputEventRequest_fields &PB_Gui_SendInputEventRequest_msg | #define PB_Gui_SendInputEventRequest_fields &PB_Gui_SendInputEventRequest_msg | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_fields &PB_Gui_StartVirtualDisplayRequest_msg | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_fields &PB_Gui_StopVirtualDisplayRequest_msg | ||||||
| 
 | 
 | ||||||
| /* Maximum encoded size of messages (where known) */ | /* Maximum encoded size of messages (where known) */ | ||||||
| /* PB_Gui_ScreenStreamFrame_size depends on runtime parameters */ | /* PB_Gui_ScreenFrame_size depends on runtime parameters */ | ||||||
| #define PB_Gui_SendInputEventRequest_size        4 | #define PB_Gui_SendInputEventRequest_size        4 | ||||||
| #define PB_Gui_StartScreenStreamRequest_size     0 | #define PB_Gui_StartScreenStreamRequest_size     0 | ||||||
|  | #define PB_Gui_StartVirtualDisplayRequest_size   0 | ||||||
| #define PB_Gui_StopScreenStreamRequest_size      0 | #define PB_Gui_StopScreenStreamRequest_size      0 | ||||||
|  | #define PB_Gui_StopVirtualDisplayRequest_size    0 | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } /* extern "C" */ | } /* extern "C" */ | ||||||
|  | |||||||
| @ -1 +1 @@ | |||||||
| Subproject commit 0e6d374ab1a12f95a3cd04444376a261e7252db4 | Subproject commit 6be7def6087c4d277386381ff2792fa622933668 | ||||||
| @ -3,10 +3,12 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <furi-hal-version.h> | #include <furi-hal-version.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Flipper" | ||||||
|  | 
 | ||||||
| static void flipper_print_version(const char* target, const Version* version) { | static void flipper_print_version(const char* target, const Version* version) { | ||||||
|     if(version) { |     if(version) { | ||||||
|         FURI_LOG_I( |         FURI_LOG_I( | ||||||
|             "FLIPPER", |             TAG, | ||||||
|             "\r\n\t%s version:\t%s\r\n" |             "\r\n\t%s version:\t%s\r\n" | ||||||
|             "\tBuild date:\t\t%s\r\n" |             "\tBuild date:\t\t%s\r\n" | ||||||
|             "\tGit Commit:\t\t%s (%s)\r\n" |             "\tGit Commit:\t\t%s (%s)\r\n" | ||||||
| @ -18,7 +20,7 @@ static void flipper_print_version(const char* target, const Version* version) { | |||||||
|             version_get_gitbranchnum(version), |             version_get_gitbranchnum(version), | ||||||
|             version_get_gitbranch(version)); |             version_get_gitbranch(version)); | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_I("FLIPPER", "No build info for %s", target); |         FURI_LOG_I(TAG, "No build info for %s", target); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -31,10 +33,10 @@ void flipper_init() { | |||||||
|     version = (const Version*)furi_hal_version_get_firmware_version(); |     version = (const Version*)furi_hal_version_get_firmware_version(); | ||||||
|     flipper_print_version("Firmware", version); |     flipper_print_version("Firmware", version); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FLIPPER", "starting services"); |     FURI_LOG_I(TAG, "starting services"); | ||||||
| 
 | 
 | ||||||
|     for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) { |     for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) { | ||||||
|         FURI_LOG_I("FLIPPER", "starting service %s", FLIPPER_SERVICES[i].name); |         FURI_LOG_I(TAG, "starting service %s", FLIPPER_SERVICES[i].name); | ||||||
| 
 | 
 | ||||||
|         FuriThread* thread = furi_thread_alloc(); |         FuriThread* thread = furi_thread_alloc(); | ||||||
| 
 | 
 | ||||||
| @ -45,5 +47,5 @@ void flipper_init() { | |||||||
|         furi_thread_start(thread); |         furi_thread_start(thread); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FLIPPER", "services startup complete"); |     FURI_LOG_I(TAG, "services startup complete"); | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								firmware/targets/f6/Inc/stm32_assert.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								firmware/targets/f6/Inc/stm32_assert.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | /**
 | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @file    stm32_assert.h | ||||||
|  |   * @brief   STM32 assert file. | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @attention | ||||||
|  |   * | ||||||
|  |   * <h2><center>© Copyright (c) 2019 STMicroelectronics. | ||||||
|  |   * All rights reserved.</center></h2> | ||||||
|  |   * | ||||||
|  |   * This software component is licensed by ST under BSD 3-Clause license, | ||||||
|  |   * the "License"; You may not use this file except in compliance with the | ||||||
|  |   * License. You may obtain a copy of the License at: | ||||||
|  |   *                        opensource.org/licenses/BSD-3-Clause | ||||||
|  |   * | ||||||
|  |   ****************************************************************************** | ||||||
|  |   */ | ||||||
|  | 
 | ||||||
|  | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
|  | #ifndef __STM32_ASSERT_H | ||||||
|  | #define __STM32_ASSERT_H | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  |  extern "C" { | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef  USE_FULL_ASSERT | ||||||
|  |   #define assert_param(expr) ((expr) ? (void)0U : assert_failed()) | ||||||
|  |   void assert_failed(); | ||||||
|  | #else | ||||||
|  |   #define assert_param(expr) ((void)0U) | ||||||
|  | #endif /* USE_FULL_ASSERT */ | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #endif /* __STM32_ASSERT_H */ | ||||||
|  | 
 | ||||||
|  | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||||
| @ -184,7 +184,7 @@ | |||||||
|   * @brief Uncomment the line below to expanse the "assert_param" macro in the |   * @brief Uncomment the line below to expanse the "assert_param" macro in the | ||||||
|   *        HAL drivers code |   *        HAL drivers code | ||||||
|   */ |   */ | ||||||
| /* #define USE_FULL_ASSERT    1U */ | #define USE_FULL_ASSERT    1U | ||||||
| 
 | 
 | ||||||
| /* ################## SPI peripheral configuration ########################## */ | /* ################## SPI peripheral configuration ########################## */ | ||||||
| 
 | 
 | ||||||
| @ -329,17 +329,8 @@ | |||||||
| 
 | 
 | ||||||
| /* Exported macro ------------------------------------------------------------*/ | /* Exported macro ------------------------------------------------------------*/ | ||||||
| #ifdef  USE_FULL_ASSERT | #ifdef  USE_FULL_ASSERT | ||||||
| /**
 |   #define assert_param(expr) ((expr) ? (void)0U : assert_failed()) | ||||||
|   * @brief  The assert_param macro is used for function's parameters check. |   void assert_failed(); | ||||||
|   * @param expr If expr is false, it calls assert_failed function |  | ||||||
|   *         which reports the name of the source file and the source |  | ||||||
|   *         line number of the call that failed. |  | ||||||
|   *         If expr is true, it returns no value. |  | ||||||
|   * @retval None |  | ||||||
|   */ |  | ||||||
|   #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) |  | ||||||
| /* Exported functions ------------------------------------------------------- */ |  | ||||||
|   void assert_failed(uint8_t* file, uint32_t line); |  | ||||||
| #else | #else | ||||||
|   #define assert_param(expr) ((void)0U) |   #define assert_param(expr) ((void)0U) | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| #include "fatfs/fatfs.h" |  | ||||||
| 
 |  | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| #include <flipper.h> | #include <flipper.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Main" | ||||||
|  | 
 | ||||||
| int main(void) { | int main(void) { | ||||||
|     // Initialize FURI layer
 |     // Initialize FURI layer
 | ||||||
|     furi_init(); |     furi_init(); | ||||||
| @ -16,13 +16,9 @@ int main(void) { | |||||||
|     // Flipper FURI HAL
 |     // Flipper FURI HAL
 | ||||||
|     furi_hal_init(); |     furi_hal_init(); | ||||||
| 
 | 
 | ||||||
|     // 3rd party
 |  | ||||||
|     MX_FATFS_Init(); |  | ||||||
|     FURI_LOG_I("HAL", "FATFS OK"); |  | ||||||
| 
 |  | ||||||
|     // CMSIS initialization
 |     // CMSIS initialization
 | ||||||
|     osKernelInitialize(); |     osKernelInitialize(); | ||||||
|     FURI_LOG_I("HAL", "KERNEL OK"); |     FURI_LOG_I(TAG, "KERNEL OK"); | ||||||
| 
 | 
 | ||||||
|     // Init flipper
 |     // Init flipper
 | ||||||
|     flipper_init(); |     flipper_init(); | ||||||
| @ -47,9 +43,6 @@ void Error_Handler(void) { | |||||||
|     * @retval None |     * @retval None | ||||||
|     */ |     */ | ||||||
| void assert_failed(uint8_t *file, uint32_t line) { | void assert_failed(uint8_t *file, uint32_t line) { | ||||||
|     /* USER CODE BEGIN 6 */ |     furi_crash("HAL assert failed"); | ||||||
|     /* User can add his own implementation to report the file name and line number,
 |  | ||||||
|          tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |  | ||||||
|     /* USER CODE END 6 */ |  | ||||||
| } | } | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define BATTERY_SERVICE_TAG "battery service" | #define TAG "BtBatterySvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t svc_handle; |     uint16_t svc_handle; | ||||||
| @ -23,7 +23,7 @@ void battery_svc_start() { | |||||||
|     // Add Battery service
 |     // Add Battery service
 | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle); |     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Battery service: %d", status); | ||||||
|     } |     } | ||||||
|     // Add Battery level characteristic
 |     // Add Battery level characteristic
 | ||||||
|     status = aci_gatt_add_char(battery_svc->svc_handle, |     status = aci_gatt_add_char(battery_svc->svc_handle, | ||||||
| @ -37,7 +37,7 @@ void battery_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &battery_svc->char_level_handle); |                                 &battery_svc->char_level_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery level characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add Battery level characteristic: %d", status); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -47,12 +47,12 @@ void battery_svc_stop() { | |||||||
|         // Delete Battery level characteristic
 |         // Delete Battery level characteristic
 | ||||||
|         status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle); |         status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery level characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Battery level characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete Battery service
 |         // Delete Battery service
 | ||||||
|         status = aci_gatt_del_service(battery_svc->svc_handle); |         status = aci_gatt_del_service(battery_svc->svc_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Battery service: %d", status); | ||||||
|         } |         } | ||||||
|         free(battery_svc); |         free(battery_svc); | ||||||
|         battery_svc = NULL; |         battery_svc = NULL; | ||||||
| @ -65,14 +65,14 @@ bool battery_svc_update_level(uint8_t battery_charge) { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     // Update battery level characteristic
 |     // Update battery level characteristic
 | ||||||
|     FURI_LOG_I(BATTERY_SERVICE_TAG, "Updating battery level characteristic"); |     FURI_LOG_I(TAG, "Updating battery level characteristic"); | ||||||
|     tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle, |     tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle, | ||||||
|                                           battery_svc->char_level_handle, |                                           battery_svc->char_level_handle, | ||||||
|                                           0, |                                           0, | ||||||
|                                           1, |                                           1, | ||||||
|                                           &battery_charge); |                                           &battery_charge); | ||||||
|     if(result) { |     if(result) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed updating RX characteristic: %d", result); |         FURI_LOG_E(TAG, "Failed updating RX characteristic: %d", result); | ||||||
|     } |     } | ||||||
|     return result != BLE_STATUS_SUCCESS; |     return result != BLE_STATUS_SUCCESS; | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #define BLE_APP_TAG "ble app" | #define TAG "Bt" | ||||||
| 
 | 
 | ||||||
| PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer; | PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer; | ||||||
| PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE]; | PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE]; | ||||||
| @ -53,7 +53,7 @@ bool ble_app_init() { | |||||||
|     }; |     }; | ||||||
|     status = SHCI_C2_Config(&config_param); |     status = SHCI_C2_Config(&config_param); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BLE_APP_TAG, "Failed to configure 2nd core: %d", status); |         FURI_LOG_E(TAG, "Failed to configure 2nd core: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Start ble stack on 2nd core
 |     // Start ble stack on 2nd core
 | ||||||
| @ -82,7 +82,7 @@ bool ble_app_init() { | |||||||
|     }; |     }; | ||||||
|     status = SHCI_C2_BLE_Init(&ble_init_cmd_packet); |     status = SHCI_C2_BLE_Init(&ble_init_cmd_packet); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BLE_APP_TAG, "Failed to start ble stack: %d", status); |         FURI_LOG_E(TAG, "Failed to start ble stack: %d", status); | ||||||
|     } |     } | ||||||
|     return status == SHCI_Success; |     return status == SHCI_Success; | ||||||
| } | } | ||||||
|  | |||||||
| @ -10,6 +10,8 @@ | |||||||
| #include "app_debug.h" | #include "app_debug.h" | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Core2" | ||||||
|  | 
 | ||||||
| #define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U)) | #define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U)) | ||||||
| 
 | 
 | ||||||
| PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE]; | PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE]; | ||||||
| @ -125,20 +127,20 @@ static void ble_glue_sys_user_event_callback( void * pPayload ) { | |||||||
|      |      | ||||||
|     if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) { |     if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) { | ||||||
|         if(ble_app_init()) { |         if(ble_app_init()) { | ||||||
|             FURI_LOG_I("Core2", "BLE stack started"); |             FURI_LOG_I(TAG, "BLE stack started"); | ||||||
|             ble_glue->status = BleGlueStatusStarted; |             ble_glue->status = BleGlueStatusStarted; | ||||||
|             if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) { |             if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) { | ||||||
|                 FURI_LOG_I("Core2", "Flash activity control switched to SEM7"); |                 FURI_LOG_I(TAG, "Flash activity control switched to SEM7"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E("Core2", "Failed to switch flash activity control to SEM7"); |                 FURI_LOG_E(TAG, "Failed to switch flash activity control to SEM7"); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E("Core2", "BLE stack startup failed"); |             FURI_LOG_E(TAG, "BLE stack startup failed"); | ||||||
|             ble_glue->status = BleGlueStatusBleStackMissing; |             ble_glue->status = BleGlueStatusBleStackMissing; | ||||||
|         } |         } | ||||||
|         furi_hal_power_insomnia_exit(); |         furi_hal_power_insomnia_exit(); | ||||||
|     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) { |     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) { | ||||||
|         FURI_LOG_E("Core2", "Error during initialization"); |         FURI_LOG_E(TAG, "Error during initialization"); | ||||||
|         furi_hal_power_insomnia_exit(); |         furi_hal_power_insomnia_exit(); | ||||||
|     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) { |     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) { | ||||||
|         SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload; |         SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload; | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define DEV_INFO_SVC_TAG "dev info service" | #define TAG "BtDevInfoSvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t service_handle; |     uint16_t service_handle; | ||||||
| @ -29,7 +29,7 @@ void dev_info_svc_start() { | |||||||
|     uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID; |     uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID; | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle); |     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add Device Information Service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Device Information Service: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add characteristics
 |     // Add characteristics
 | ||||||
| @ -45,7 +45,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->man_name_char_handle); |                                 &dev_info_svc->man_name_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add manufacturer name char: %d", status); |         FURI_LOG_E(TAG, "Failed to add manufacturer name char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = SERIAL_NUMBER_UUID; |     uuid = SERIAL_NUMBER_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -59,7 +59,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->serial_num_char_handle); |                                 &dev_info_svc->serial_num_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add serial number char: %d", status); |         FURI_LOG_E(TAG, "Failed to add serial number char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = FIRMWARE_REVISION_UUID; |     uuid = FIRMWARE_REVISION_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -73,7 +73,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->firmware_rev_char_handle); |                                 &dev_info_svc->firmware_rev_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add firmware revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to add firmware revision char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = SOFTWARE_REVISION_UUID; |     uuid = SOFTWARE_REVISION_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -87,7 +87,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->software_rev_char_handle); |                                 &dev_info_svc->software_rev_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add software revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to add software revision char: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Update characteristics
 |     // Update characteristics
 | ||||||
| @ -97,7 +97,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_man_name), |                                         strlen(dev_info_man_name), | ||||||
|                                         (uint8_t*)dev_info_man_name); |                                         (uint8_t*)dev_info_man_name); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update manufacturer name char: %d", status); |         FURI_LOG_E(TAG, "Failed to update manufacturer name char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->serial_num_char_handle, |                                         dev_info_svc->serial_num_char_handle, | ||||||
| @ -105,7 +105,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_serial_num), |                                         strlen(dev_info_serial_num), | ||||||
|                                         (uint8_t*)dev_info_serial_num); |                                         (uint8_t*)dev_info_serial_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update serial number char: %d", status); |         FURI_LOG_E(TAG, "Failed to update serial number char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->firmware_rev_char_handle, |                                         dev_info_svc->firmware_rev_char_handle, | ||||||
| @ -113,7 +113,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_firmware_rev_num), |                                         strlen(dev_info_firmware_rev_num), | ||||||
|                                         (uint8_t*)dev_info_firmware_rev_num); |                                         (uint8_t*)dev_info_firmware_rev_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update firmware revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to update firmware revision char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->software_rev_char_handle, |                                         dev_info_svc->software_rev_char_handle, | ||||||
| @ -121,7 +121,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_software_rev_num), |                                         strlen(dev_info_software_rev_num), | ||||||
|                                         (uint8_t*)dev_info_software_rev_num); |                                         (uint8_t*)dev_info_software_rev_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update software revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to update software revision char: %d", status); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -131,24 +131,24 @@ void dev_info_svc_stop() { | |||||||
|         // Delete service characteristics
 |         // Delete service characteristics
 | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete manufacturer name char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete manufacturer name char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete serial number char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete serial number char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete firmware revision char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete firmware revision char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete software revision char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete software revision char: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete service
 |         // Delete service
 | ||||||
|         status = aci_gatt_del_service(dev_info_svc->service_handle); |         status = aci_gatt_del_service(dev_info_svc->service_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete device info service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete device info service: %d", status); | ||||||
|         } |         } | ||||||
|         free(dev_info_svc); |         free(dev_info_svc); | ||||||
|         dev_info_svc = NULL; |         dev_info_svc = NULL; | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #define GAP_TAG "BLE" | #define TAG "BtGap" | ||||||
| 
 | 
 | ||||||
| #define FAST_ADV_TIMEOUT 30000 | #define FAST_ADV_TIMEOUT 30000 | ||||||
| #define INITIAL_ADV_TIMEOUT 60000 | #define INITIAL_ADV_TIMEOUT 60000 | ||||||
| @ -80,7 +80,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) { |             if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) { | ||||||
|                 gap->gap_svc.connection_handle = 0; |                 gap->gap_svc.connection_handle = 0; | ||||||
|                 gap->state = GapStateIdle; |                 gap->state = GapStateIdle; | ||||||
|                 FURI_LOG_I(GAP_TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason); |                 FURI_LOG_I(TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason); | ||||||
|             } |             } | ||||||
|             if(gap->enable_adv) { |             if(gap->enable_adv) { | ||||||
|                 // Restart advertising
 |                 // Restart advertising
 | ||||||
| @ -96,28 +96,28 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             meta_evt = (evt_le_meta_event*) event_pckt->data; |             meta_evt = (evt_le_meta_event*) event_pckt->data; | ||||||
|             switch (meta_evt->subevent) { |             switch (meta_evt->subevent) { | ||||||
|                 case EVT_LE_CONN_UPDATE_COMPLETE: |                 case EVT_LE_CONN_UPDATE_COMPLETE: | ||||||
|                 FURI_LOG_D(GAP_TAG, "Connection update event"); |                 FURI_LOG_D(TAG, "Connection update event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|                 case EVT_LE_PHY_UPDATE_COMPLETE: |                 case EVT_LE_PHY_UPDATE_COMPLETE: | ||||||
|                 evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data; |                 evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data; | ||||||
|                 if(evt_le_phy_update_complete->Status) { |                 if(evt_le_phy_update_complete->Status) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status); |                     FURI_LOG_E(TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "Update PHY succeed"); |                     FURI_LOG_I(TAG, "Update PHY succeed"); | ||||||
|                 } |                 } | ||||||
|                 ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy); |                 ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy); | ||||||
|                 if(ret) { |                 if(ret) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Read PHY failed, status: %d", ret); |                     FURI_LOG_E(TAG, "Read PHY failed, status: %d", ret); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy); |                     FURI_LOG_I(TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|                 case EVT_LE_CONN_COMPLETE: |                 case EVT_LE_CONN_COMPLETE: | ||||||
|                 furi_hal_power_insomnia_enter(); |                 furi_hal_power_insomnia_enter(); | ||||||
|                 hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data; |                 hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data; | ||||||
|                 FURI_LOG_I(GAP_TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle); |                 FURI_LOG_I(TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle); | ||||||
| 
 | 
 | ||||||
|                 // Stop advertising as connection completed
 |                 // Stop advertising as connection completed
 | ||||||
|                 osTimerStop(gap->advertise_timer); |                 osTimerStop(gap->advertise_timer); | ||||||
| @ -141,7 +141,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|                 aci_gap_pairing_complete_event_rp0 *pairing_complete; |                 aci_gap_pairing_complete_event_rp0 *pairing_complete; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_LIMITED_DISCOVERABLE: |             case EVT_BLUE_GAP_LIMITED_DISCOVERABLE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Limited discoverable event"); |                 FURI_LOG_I(TAG, "Limited discoverable event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_PASS_KEY_REQUEST: |             case EVT_BLUE_GAP_PASS_KEY_REQUEST: | ||||||
| @ -149,39 +149,39 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|                 // Generate random PIN code
 |                 // Generate random PIN code
 | ||||||
|                 uint32_t pin = rand() % 999999; |                 uint32_t pin = rand() % 999999; | ||||||
|                 aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin); |                 aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin); | ||||||
|                 FURI_LOG_I(GAP_TAG, "Pass key request event. Pin: %d", pin); |                 FURI_LOG_I(TAG, "Pass key request event. Pin: %d", pin); | ||||||
|                 BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin}; |                 BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin}; | ||||||
|                 gap->on_event_cb(event, gap->context); |                 gap->on_event_cb(event, gap->context); | ||||||
|             } |             } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_AUTHORIZATION_REQUEST: |             case EVT_BLUE_GAP_AUTHORIZATION_REQUEST: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Authorization request event"); |                 FURI_LOG_I(TAG, "Authorization request event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED: |             case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Slave security initiated"); |                 FURI_LOG_I(TAG, "Slave security initiated"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_BOND_LOST: |             case EVT_BLUE_GAP_BOND_LOST: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Bond lost event. Start rebonding"); |                 FURI_LOG_I(TAG, "Bond lost event. Start rebonding"); | ||||||
|                 aci_gap_allow_rebond(gap->gap_svc.connection_handle); |                 aci_gap_allow_rebond(gap->gap_svc.connection_handle); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_DEVICE_FOUND: |             case EVT_BLUE_GAP_DEVICE_FOUND: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Device found event"); |                 FURI_LOG_I(TAG, "Device found event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_ADDR_NOT_RESOLVED: |             case EVT_BLUE_GAP_ADDR_NOT_RESOLVED: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Address not resolved event"); |                 FURI_LOG_I(TAG, "Address not resolved event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION: |             case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Key press notification event"); |                 FURI_LOG_I(TAG, "Key press notification event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE: |             case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Hex_value = %lx", |                 FURI_LOG_I(TAG, "Hex_value = %lx", | ||||||
|                             ((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value); |                             ((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value); | ||||||
|                 aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1); |                 aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1); | ||||||
|                 break; |                 break; | ||||||
| @ -189,17 +189,17 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             case EVT_BLUE_GAP_PAIRING_CMPLT: |             case EVT_BLUE_GAP_PAIRING_CMPLT: | ||||||
|                 pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data; |                 pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data; | ||||||
|                 if (pairing_complete->Status) { |                 if (pairing_complete->Status) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status); |                     FURI_LOG_E(TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status); | ||||||
|                     aci_gap_terminate(gap->gap_svc.connection_handle, 5); |                     aci_gap_terminate(gap->gap_svc.connection_handle, 5); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "Pairing complete"); |                     FURI_LOG_I(TAG, "Pairing complete"); | ||||||
|                     BleEvent event = {.type = BleEventTypeConnected}; |                     BleEvent event = {.type = BleEventTypeConnected}; | ||||||
|                     gap->on_event_cb(event, gap->context); |                     gap->on_event_cb(event, gap->context); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_PROCEDURE_COMPLETE: |             case EVT_BLUE_GAP_PROCEDURE_COMPLETE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Procedure complete event"); |                 FURI_LOG_I(TAG, "Procedure complete event"); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             default: |             default: | ||||||
| @ -286,11 +286,11 @@ static void gap_init_svc(Gap* gap) { | |||||||
|     // Set GAP characteristics
 |     // Set GAP characteristics
 | ||||||
|     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name); |     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name); | ||||||
|     if (status) { |     if (status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Failed updating name characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed updating name characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid); |     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Failed updating appearence characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed updating appearence characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Set default PHY
 |     // Set default PHY
 | ||||||
|     hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED); |     hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED); | ||||||
| @ -322,7 +322,7 @@ static void gap_advertise_start(GapState new_state) | |||||||
|         // Stop advertising
 |         // Stop advertising
 | ||||||
|         status = aci_gap_set_non_discoverable(); |         status = aci_gap_set_non_discoverable(); | ||||||
|         if (status) { |         if (status) { | ||||||
|             FURI_LOG_E(GAP_TAG, "Stop Advertising Failed, result: %d", status); |             FURI_LOG_E(TAG, "Stop Advertising Failed, result: %d", status); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     // Configure advertising
 |     // Configure advertising
 | ||||||
| @ -331,7 +331,7 @@ static void gap_advertise_start(GapState new_state) | |||||||
|                                         strlen(name), (uint8_t*)name, |                                         strlen(name), (uint8_t*)name, | ||||||
|                                         gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0); |                                         gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Set discoverable err: %d", status); |         FURI_LOG_E(TAG, "Set discoverable err: %d", status); | ||||||
|     } |     } | ||||||
|     gap->state = new_state; |     gap->state = new_state; | ||||||
|     BleEvent event = {.type = BleEventTypeStartAdvertising}; |     BleEvent event = {.type = BleEventTypeStartAdvertising}; | ||||||
| @ -355,14 +355,14 @@ static void gap_advertise_stop() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gap_start_advertising() { | void gap_start_advertising() { | ||||||
|     FURI_LOG_I(GAP_TAG, "Start advertising"); |     FURI_LOG_I(TAG, "Start advertising"); | ||||||
|     gap->enable_adv = true; |     gap->enable_adv = true; | ||||||
|     GapCommand command = GapCommandAdvFast; |     GapCommand command = GapCommandAdvFast; | ||||||
|     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); |     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gap_stop_advertising() { | void gap_stop_advertising() { | ||||||
|     FURI_LOG_I(GAP_TAG, "Stop advertising"); |     FURI_LOG_I(TAG, "Stop advertising"); | ||||||
|     gap->enable_adv = false; |     gap->enable_adv = false; | ||||||
|     GapCommand command = GapCommandAdvStop; |     GapCommand command = GapCommandAdvStop; | ||||||
|     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); |     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define SERIAL_SERVICE_TAG "serial service" | #define TAG "BtSerialSvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t svc_handle; |     uint16_t svc_handle; | ||||||
| @ -37,26 +37,26 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void *event) { | |||||||
|             if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) { |             if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) { | ||||||
|                 // Descriptor handle
 |                 // Descriptor handle
 | ||||||
|                 ret = SVCCTL_EvtAckFlowEnable; |                 ret = SVCCTL_EvtAckFlowEnable; | ||||||
|                 FURI_LOG_D(SERIAL_SERVICE_TAG, "RX descriptor event"); |                 FURI_LOG_D(TAG, "RX descriptor event"); | ||||||
|             } else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) { |             } else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) { | ||||||
|                 FURI_LOG_D(SERIAL_SERVICE_TAG, "Received %d bytes", attribute_modified->Attr_Data_Length); |                 FURI_LOG_D(TAG, "Received %d bytes", attribute_modified->Attr_Data_Length); | ||||||
|                 if(serial_svc->on_received_cb) { |                 if(serial_svc->on_received_cb) { | ||||||
|                     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); |                     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); | ||||||
|                     if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) { |                     if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) { | ||||||
|                         FURI_LOG_W( |                         FURI_LOG_W( | ||||||
|                             SERIAL_SERVICE_TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!", |                             TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!", | ||||||
|                             attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive); |                             attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive); | ||||||
|                     } |                     } | ||||||
|                     serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length); |                     serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length); | ||||||
|                     uint32_t buff_free_size = |                     uint32_t buff_free_size = | ||||||
|                         serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context); |                         serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context); | ||||||
|                     FURI_LOG_D(SERIAL_SERVICE_TAG, "Available buff size: %d", buff_free_size); |                     FURI_LOG_D(TAG, "Available buff size: %d", buff_free_size); | ||||||
|                     furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK); |                     furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK); | ||||||
|                 } |                 } | ||||||
|                 ret = SVCCTL_EvtAckFlowEnable; |                 ret = SVCCTL_EvtAckFlowEnable; | ||||||
|             } |             } | ||||||
|         } else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) { |         } else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) { | ||||||
|             FURI_LOG_D(SERIAL_SERVICE_TAG, "Ack received", blecore_evt->ecode); |             FURI_LOG_D(TAG, "Ack received", blecore_evt->ecode); | ||||||
|             if(serial_svc->on_sent_cb) { |             if(serial_svc->on_sent_cb) { | ||||||
|                 serial_svc->on_sent_cb(serial_svc->context); |                 serial_svc->on_sent_cb(serial_svc->context); | ||||||
|             } |             } | ||||||
| @ -75,7 +75,7 @@ void serial_svc_start() { | |||||||
|     // Add service
 |     // Add service
 | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle); |     status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Serial service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Serial service: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add RX characteristics
 |     // Add RX characteristics
 | ||||||
| @ -88,7 +88,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_VARIABLE, |                                 CHAR_VALUE_LEN_VARIABLE, | ||||||
|                                 &serial_svc->rx_char_handle); |                                 &serial_svc->rx_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add RX characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add RX characteristic: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add TX characteristic
 |     // Add TX characteristic
 | ||||||
| @ -101,7 +101,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_VARIABLE, |                                 CHAR_VALUE_LEN_VARIABLE, | ||||||
|                                 &serial_svc->tx_char_handle); |                                 &serial_svc->tx_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add TX characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add TX characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Add Flow Control characteristic
 |     // Add Flow Control characteristic
 | ||||||
|     status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid, |     status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid, | ||||||
| @ -113,7 +113,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &serial_svc->flow_ctrl_char_handle); |                                 &serial_svc->flow_ctrl_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Flow Control characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add Flow Control characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Allocate buffer size mutex
 |     // Allocate buffer size mutex
 | ||||||
|     serial_svc->buff_size_mtx = osMutexNew(NULL); |     serial_svc->buff_size_mtx = osMutexNew(NULL); | ||||||
| @ -136,7 +136,7 @@ void serial_svc_notify_buffer_is_empty() { | |||||||
| 
 | 
 | ||||||
|     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); |     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); | ||||||
|     if(serial_svc->bytes_ready_to_receive == 0) { |     if(serial_svc->bytes_ready_to_receive == 0) { | ||||||
|         FURI_LOG_D(SERIAL_SERVICE_TAG, "Buffer is empty. Notifying client"); |         FURI_LOG_D(TAG, "Buffer is empty. Notifying client"); | ||||||
|         serial_svc->bytes_ready_to_receive = serial_svc->buff_size; |         serial_svc->bytes_ready_to_receive = serial_svc->buff_size; | ||||||
|         uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size); |         uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size); | ||||||
|         aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed); |         aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed); | ||||||
| @ -150,20 +150,20 @@ void serial_svc_stop() { | |||||||
|         // Delete characteristics
 |         // Delete characteristics
 | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete TX characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete TX characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete RX characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete RX characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Flow Control characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Flow Control characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete service
 |         // Delete service
 | ||||||
|         status = aci_gatt_del_service(serial_svc->svc_handle); |         status = aci_gatt_del_service(serial_svc->svc_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Serial service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Serial service: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete buffer size mutex
 |         // Delete buffer size mutex
 | ||||||
|         osMutexDelete(serial_svc->buff_size_mtx); |         osMutexDelete(serial_svc->buff_size_mtx); | ||||||
| @ -182,7 +182,7 @@ bool serial_svc_update_tx(uint8_t* data, uint8_t data_len) { | |||||||
|                                         data_len, |                                         data_len, | ||||||
|                                         data); |                                         data); | ||||||
|     if(result) { |     if(result) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed updating TX characteristic: %d", result); |         FURI_LOG_E(TAG, "Failed updating TX characteristic: %d", result); | ||||||
|     } |     } | ||||||
|     return result != BLE_STATUS_SUCCESS; |     return result != BLE_STATUS_SUCCESS; | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ | |||||||
| #include <stm32wbxx_ll_rtc.h> | #include <stm32wbxx_ll_rtc.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalBoot" | ||||||
|  | 
 | ||||||
| // Boot request enum
 | // Boot request enum
 | ||||||
| #define BOOT_REQUEST_TAINTED 0x00000000 | #define BOOT_REQUEST_TAINTED 0x00000000 | ||||||
| #define BOOT_REQUEST_CLEAN 0xDADEDADE | #define BOOT_REQUEST_CLEAN 0xDADEDADE | ||||||
| @ -11,7 +13,7 @@ void furi_hal_bootloader_init() { | |||||||
| #ifndef DEBUG | #ifndef DEBUG | ||||||
|     LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED); |     LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED); | ||||||
| #endif | #endif | ||||||
|     FURI_LOG_I("FuriHalBoot", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) { | void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) { | ||||||
|  | |||||||
| @ -5,6 +5,8 @@ | |||||||
| #include <stm32wbxx_ll_rcc.h> | #include <stm32wbxx_ll_rcc.h> | ||||||
| #include <stm32wbxx_ll_utils.h> | #include <stm32wbxx_ll_utils.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalClock" | ||||||
|  | 
 | ||||||
| #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) | #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) | ||||||
| #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) | #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) | ||||||
| 
 | 
 | ||||||
| @ -123,7 +125,7 @@ void furi_hal_clock_init() { | |||||||
|     // APB2
 |     // APB2
 | ||||||
|     LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); |     LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalClock", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_clock_switch_to_hsi() { | void furi_hal_clock_switch_to_hsi() { | ||||||
|  | |||||||
| @ -4,6 +4,8 @@ | |||||||
| #include <lib/heatshrink/heatshrink_encoder.h> | #include <lib/heatshrink/heatshrink_encoder.h> | ||||||
| #include <lib/heatshrink/heatshrink_decoder.h> | #include <lib/heatshrink/heatshrink_decoder.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalCompress" | ||||||
|  | 
 | ||||||
| #define FURI_HAL_COMPRESS_ICON_ENCODED_BUFF_SIZE (512) | #define FURI_HAL_COMPRESS_ICON_ENCODED_BUFF_SIZE (512) | ||||||
| #define FURI_HAL_COMPRESS_ICON_DECODED_BUFF_SIZE (1024) | #define FURI_HAL_COMPRESS_ICON_DECODED_BUFF_SIZE (1024) | ||||||
| 
 | 
 | ||||||
| @ -46,7 +48,7 @@ void furi_hal_compress_icon_init() { | |||||||
|         FURI_HAL_COMPRESS_LOOKAHEAD_BUFF_SIZE_LOG); |         FURI_HAL_COMPRESS_LOOKAHEAD_BUFF_SIZE_LOG); | ||||||
|     heatshrink_decoder_reset(icon_decoder->decoder); |     heatshrink_decoder_reset(icon_decoder->decoder); | ||||||
|     memset(icon_decoder->decoded_buff, 0, sizeof(icon_decoder->decoded_buff)); |     memset(icon_decoder->decoded_buff, 0, sizeof(icon_decoder->decoded_buff)); | ||||||
|     FURI_LOG_I("FuriHalCompress", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_compress_icon_decode(const uint8_t* icon_data, uint8_t** decoded_buff) {  | void furi_hal_compress_icon_decode(const uint8_t* icon_data, uint8_t** decoded_buff) {  | ||||||
|  | |||||||
| @ -6,8 +6,12 @@ | |||||||
| #include <stm32wbxx_ll_usart.h> | #include <stm32wbxx_ll_usart.h> | ||||||
| #include <m-string.h> | #include <m-string.h> | ||||||
| 
 | 
 | ||||||
|  | #include <utilities_conf.h> | ||||||
|  | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalConsole" | ||||||
|  | 
 | ||||||
| #define CONSOLE_BAUDRATE 230400 | #define CONSOLE_BAUDRATE 230400 | ||||||
| 
 | 
 | ||||||
| volatile bool furi_hal_console_alive = false; | volatile bool furi_hal_console_alive = false; | ||||||
| @ -16,7 +20,7 @@ void furi_hal_console_init() { | |||||||
|     furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE); |     furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE); | ||||||
|     furi_hal_console_alive = true; |     furi_hal_console_alive = true; | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalConsole", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_enable() { | void furi_hal_console_enable() { | ||||||
| @ -35,22 +39,26 @@ void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) { | |||||||
|     if (!furi_hal_console_alive) |     if (!furi_hal_console_alive) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|  |     UTILS_ENTER_CRITICAL_SECTION(); | ||||||
|     // Transmit data
 |     // Transmit data
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); | ||||||
|     // Wait for TC flag to be raised for last char
 |     // Wait for TC flag to be raised for last char
 | ||||||
|     while (!LL_USART_IsActiveFlag_TC(USART1)); |     while (!LL_USART_IsActiveFlag_TC(USART1)); | ||||||
|  |     UTILS_EXIT_CRITICAL_SECTION(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) { | void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) { | ||||||
|     if (!furi_hal_console_alive) |     if (!furi_hal_console_alive) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|  |     UTILS_ENTER_CRITICAL_SECTION(); | ||||||
|     // Transmit data
 |     // Transmit data
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); | ||||||
|     // Transmit new line symbols
 |     // Transmit new line symbols
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2); | ||||||
|     // Wait for TC flag to be raised for last char
 |     // Wait for TC flag to be raised for last char
 | ||||||
|     while (!LL_USART_IsActiveFlag_TC(USART1)); |     while (!LL_USART_IsActiveFlag_TC(USART1)); | ||||||
|  |     UTILS_EXIT_CRITICAL_SECTION(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_printf(const char format[], ...) { | void furi_hal_console_printf(const char format[], ...) { | ||||||
|  | |||||||
| @ -3,10 +3,12 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <shci.h> | #include <shci.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalCrypto" | ||||||
|  | 
 | ||||||
| CRYP_HandleTypeDef crypt; | CRYP_HandleTypeDef crypt; | ||||||
| 
 | 
 | ||||||
| void furi_hal_crypto_init() { | void furi_hal_crypto_init() { | ||||||
|     FURI_LOG_I("FuriHalCrypto", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot) { | bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot) { | ||||||
|  | |||||||
| @ -3,6 +3,8 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <cmsis_os2.h> | #include <cmsis_os2.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalDelay" | ||||||
|  | 
 | ||||||
| static uint32_t clk_per_microsecond; | static uint32_t clk_per_microsecond; | ||||||
| 
 | 
 | ||||||
| void furi_hal_delay_init(void) { | void furi_hal_delay_init(void) { | ||||||
| @ -10,7 +12,7 @@ void furi_hal_delay_init(void) { | |||||||
|     DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; |     DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; | ||||||
|     DWT->CYCCNT = 0U; |     DWT->CYCCNT = 0U; | ||||||
|     clk_per_microsecond = SystemCoreClock / 1000000.0f; |     clk_per_microsecond = SystemCoreClock / 1000000.0f; | ||||||
|     FURI_LOG_I("FuriHalDelay", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void delay_us(float microseconds) { | void delay_us(float microseconds) { | ||||||
|  | |||||||
| @ -6,6 +6,8 @@ | |||||||
| #include <stm32wbxx_ll_cortex.h> | #include <stm32wbxx_ll_cortex.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalI2C" | ||||||
|  | 
 | ||||||
| osMutexId_t furi_hal_i2c_mutex = NULL; | osMutexId_t furi_hal_i2c_mutex = NULL; | ||||||
| 
 | 
 | ||||||
| void furi_hal_i2c_init() { | void furi_hal_i2c_init() { | ||||||
| @ -42,7 +44,7 @@ void furi_hal_i2c_init() { | |||||||
|     LL_I2C_DisableOwnAddress2(POWER_I2C); |     LL_I2C_DisableOwnAddress2(POWER_I2C); | ||||||
|     LL_I2C_DisableGeneralCall(POWER_I2C); |     LL_I2C_DisableGeneralCall(POWER_I2C); | ||||||
|     LL_I2C_EnableClockStretching(POWER_I2C); |     LL_I2C_EnableClockStretching(POWER_I2C); | ||||||
|     FURI_LOG_I("FuriHalI2C", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_i2c_tx( | bool furi_hal_i2c_tx( | ||||||
|  | |||||||
| @ -4,6 +4,8 @@ | |||||||
| #include <main.h> | #include <main.h> | ||||||
| #include <stm32wbxx_ll_tim.h> | #include <stm32wbxx_ll_tim.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalInterrupt" | ||||||
|  | 
 | ||||||
| volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL; | volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL; | ||||||
| volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL; | volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL; | ||||||
| 
 | 
 | ||||||
| @ -22,7 +24,7 @@ void furi_hal_interrupt_init() { | |||||||
|     NVIC_SetPriority(DMA1_Channel1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0)); |     NVIC_SetPriority(DMA1_Channel1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0)); | ||||||
|     NVIC_EnableIRQ(DMA1_Channel1_IRQn); |     NVIC_EnableIRQ(DMA1_Channel1_IRQn); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalInterrupt", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) { | void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) { | ||||||
| @ -161,10 +163,10 @@ void TAMP_STAMP_LSECSS_IRQHandler(void) { | |||||||
|     if (LL_RCC_IsActiveFlag_LSECSS()) { |     if (LL_RCC_IsActiveFlag_LSECSS()) { | ||||||
|         LL_RCC_ClearFlag_LSECSS(); |         LL_RCC_ClearFlag_LSECSS(); | ||||||
|         if (!LL_RCC_LSE_IsReady()) { |         if (!LL_RCC_LSE_IsReady()) { | ||||||
|             FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: resetting system"); |             FURI_LOG_E(TAG, "LSE CSS fired: resetting system"); | ||||||
|             NVIC_SystemReset(); |             NVIC_SystemReset(); | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: but LSE is alive"); |             FURI_LOG_E(TAG, "LSE CSS fired: but LSE is alive"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -176,7 +178,7 @@ void RCC_IRQHandler(void) { | |||||||
| void NMI_Handler(void) { | void NMI_Handler(void) { | ||||||
|     if (LL_RCC_IsActiveFlag_HSECSS()) { |     if (LL_RCC_IsActiveFlag_HSECSS()) { | ||||||
|         LL_RCC_ClearFlag_HSECSS(); |         LL_RCC_ClearFlag_HSECSS(); | ||||||
|         FURI_LOG_E("FuriHalInterrupt", "HSE CSS fired: resetting system"); |         FURI_LOG_E(TAG, "HSE CSS fired: resetting system"); | ||||||
|         NVIC_SystemReset(); |         NVIC_SystemReset(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include <furi-hal-light.h> | #include <furi-hal-light.h> | ||||||
| #include <lp5562.h> | #include <lp5562.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalLight" | ||||||
|  | 
 | ||||||
| #define LED_CURRENT_RED     50 | #define LED_CURRENT_RED     50 | ||||||
| #define LED_CURRENT_GREEN   50 | #define LED_CURRENT_GREEN   50 | ||||||
| #define LED_CURRENT_BLUE    50 | #define LED_CURRENT_BLUE    50 | ||||||
| @ -21,7 +23,7 @@ void furi_hal_light_init() { | |||||||
| 
 | 
 | ||||||
|     lp5562_enable(); |     lp5562_enable(); | ||||||
|     lp5562_configure(); |     lp5562_configure(); | ||||||
|     FURI_LOG_I("FuriHalLight", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_light_set(Light light, uint8_t value) { | void furi_hal_light_set(Light light, uint8_t value) { | ||||||
|  | |||||||
| @ -1,15 +1,17 @@ | |||||||
| #include "furi-hal-nfc.h" | #include "furi-hal-nfc.h" | ||||||
| #include <st25r3916.h> | #include <st25r3916.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalNfc" | ||||||
|  | 
 | ||||||
| static const uint32_t clocks_in_ms = 64 * 1000; | static const uint32_t clocks_in_ms = 64 * 1000; | ||||||
| 
 | 
 | ||||||
| void furi_hal_nfc_init() { | void furi_hal_nfc_init() { | ||||||
|     ReturnCode ret = rfalNfcInitialize(); |     ReturnCode ret = rfalNfcInitialize(); | ||||||
|     if(ret == ERR_NONE) { |     if(ret == ERR_NONE) { | ||||||
|         furi_hal_nfc_start_sleep(); |         furi_hal_nfc_start_sleep(); | ||||||
|         FURI_LOG_I("FuriHalNfc", "Init OK"); |         FURI_LOG_I(TAG, "Init OK"); | ||||||
|     } else { |     } else { | ||||||
|         FURI_LOG_W("FuriHalNfc", "Initialization failed, RFAL returned: %d", ret); |         FURI_LOG_W(TAG, "Initialization failed, RFAL returned: %d", ret); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -63,7 +65,7 @@ bool furi_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t ti | |||||||
|     while(state != RFAL_NFC_STATE_ACTIVATED) { |     while(state != RFAL_NFC_STATE_ACTIVATED) { | ||||||
|         rfalNfcWorker(); |         rfalNfcWorker(); | ||||||
|         state = rfalNfcGetState(); |         state = rfalNfcGetState(); | ||||||
|         FURI_LOG_D("HAL NFC", "Current state %d", state); |         FURI_LOG_D(TAG, "Current state %d", state); | ||||||
|         if(state == RFAL_NFC_STATE_POLL_ACTIVATION) { |         if(state == RFAL_NFC_STATE_POLL_ACTIVATION) { | ||||||
|             start = DWT->CYCCNT; |             start = DWT->CYCCNT; | ||||||
|             continue; |             continue; | ||||||
| @ -73,7 +75,7 @@ bool furi_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t ti | |||||||
|         } |         } | ||||||
|         if(DWT->CYCCNT - start > timeout * clocks_in_ms) { |         if(DWT->CYCCNT - start > timeout * clocks_in_ms) { | ||||||
|             rfalNfcDeactivate(true); |             rfalNfcDeactivate(true); | ||||||
|             FURI_LOG_D("HAL NFC", "Timeout"); |             FURI_LOG_D(TAG, "Timeout"); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         osThreadYield(); |         osThreadYield(); | ||||||
|  | |||||||
| @ -5,6 +5,8 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalOs" | ||||||
|  | 
 | ||||||
| #define FURI_HAL_OS_CLK_FREQUENCY 32768 | #define FURI_HAL_OS_CLK_FREQUENCY 32768 | ||||||
| #define FURI_HAL_OS_TICK_PER_SECOND 1024 | #define FURI_HAL_OS_TICK_PER_SECOND 1024 | ||||||
| #define FURI_HAL_OS_CLK_PER_TICK (FURI_HAL_OS_CLK_FREQUENCY / FURI_HAL_OS_TICK_PER_SECOND) | #define FURI_HAL_OS_CLK_PER_TICK (FURI_HAL_OS_CLK_FREQUENCY / FURI_HAL_OS_TICK_PER_SECOND) | ||||||
| @ -44,7 +46,7 @@ void furi_hal_os_init() { | |||||||
|     osTimerStart(second_timer, 1024); |     osTimerStart(second_timer, 1024); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalOs", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LPTIM2_IRQHandler(void) { | void LPTIM2_IRQHandler(void) { | ||||||
|  | |||||||
| @ -15,6 +15,8 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalPower" | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     volatile uint8_t insomnia; |     volatile uint8_t insomnia; | ||||||
|     volatile uint8_t deep_insomnia; |     volatile uint8_t deep_insomnia; | ||||||
| @ -74,7 +76,7 @@ void furi_hal_power_init() { | |||||||
|     LL_PWR_SMPS_SetMode(LL_PWR_SMPS_STEP_DOWN); |     LL_PWR_SMPS_SetMode(LL_PWR_SMPS_STEP_DOWN); | ||||||
|     bq27220_init(&cedv); |     bq27220_init(&cedv); | ||||||
|     bq25896_init(); |     bq25896_init(); | ||||||
|     FURI_LOG_I("FuriHalPower", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint16_t furi_hal_power_insomnia_level() { | uint16_t furi_hal_power_insomnia_level() { | ||||||
|  | |||||||
| @ -104,7 +104,7 @@ void furi_hal_rfid_tim_read(float freq, float duty_cycle) { | |||||||
|     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; | ||||||
|     sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |     sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; | ||||||
|     sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |     sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; | ||||||
|     if(HAL_TIM_OC_ConfigChannel(&LFRFID_READ_TIM, &sConfigOC, LFRFID_READ_CHANNEL) != HAL_OK) { |     if(HAL_TIM_PWM_ConfigChannel(&LFRFID_READ_TIM, &sConfigOC, LFRFID_READ_CHANNEL) != HAL_OK) { | ||||||
|         Error_Handler(); |         Error_Handler(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -142,7 +142,6 @@ void furi_hal_rfid_tim_emulate(float freq) { | |||||||
|     TIM_ClockConfigTypeDef sClockSourceConfig = {0}; |     TIM_ClockConfigTypeDef sClockSourceConfig = {0}; | ||||||
|     TIM_MasterConfigTypeDef sMasterConfig = {0}; |     TIM_MasterConfigTypeDef sMasterConfig = {0}; | ||||||
|     TIM_OC_InitTypeDef sConfigOC = {0}; |     TIM_OC_InitTypeDef sConfigOC = {0}; | ||||||
|     TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; |  | ||||||
| 
 | 
 | ||||||
|     // basic PWM setup with needed freq and internal clock
 |     // basic PWM setup with needed freq and internal clock
 | ||||||
|     LFRFID_EMULATE_TIM.Init.Prescaler = prescaler; |     LFRFID_EMULATE_TIM.Init.Prescaler = prescaler; | ||||||
| @ -182,24 +181,6 @@ void furi_hal_rfid_tim_emulate(float freq) { | |||||||
|        HAL_OK) { |        HAL_OK) { | ||||||
|         Error_Handler(); |         Error_Handler(); | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     // no deadtime
 |  | ||||||
|     sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; |  | ||||||
|     sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; |  | ||||||
|     sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; |  | ||||||
|     sBreakDeadTimeConfig.DeadTime = 0; |  | ||||||
|     sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; |  | ||||||
|     sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; |  | ||||||
|     sBreakDeadTimeConfig.BreakFilter = 0; |  | ||||||
|     sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT; |  | ||||||
|     sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE; |  | ||||||
|     sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; |  | ||||||
|     sBreakDeadTimeConfig.Break2Filter = 0; |  | ||||||
|     sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT; |  | ||||||
|     sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; |  | ||||||
|     if(HAL_TIMEx_ConfigBreakDeadTime(&LFRFID_EMULATE_TIM, &sBreakDeadTimeConfig) != HAL_OK) { |  | ||||||
|         Error_Handler(); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_rfid_tim_emulate_start() { | void furi_hal_rfid_tim_emulate_start() { | ||||||
|  | |||||||
| @ -9,6 +9,8 @@ | |||||||
| #include <stm32wbxx_ll_utils.h> | #include <stm32wbxx_ll_utils.h> | ||||||
| #include <stm32wbxx_ll_cortex.h> | #include <stm32wbxx_ll_cortex.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalSpi" | ||||||
|  | 
 | ||||||
| void furi_hal_spi_init() { | void furi_hal_spi_init() { | ||||||
|     // Spi structure is const, but mutex is not
 |     // Spi structure is const, but mutex is not
 | ||||||
|     // Need some hell-ish casting to make it work
 |     // Need some hell-ish casting to make it work
 | ||||||
| @ -33,7 +35,7 @@ void furi_hal_spi_init() { | |||||||
|     hal_gpio_init_ex(&gpio_spi_d_mosi, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2); |     hal_gpio_init_ex(&gpio_spi_d_mosi, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2); | ||||||
|     hal_gpio_init_ex(&gpio_spi_d_sck, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2); |     hal_gpio_init_ex(&gpio_spi_d_sck, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalSpi", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_spi_bus_lock(const FuriHalSpiBus* bus) { | void furi_hal_spi_bus_lock(const FuriHalSpiBus* bus) { | ||||||
|  | |||||||
| @ -10,6 +10,8 @@ | |||||||
| #include <cc1101.h> | #include <cc1101.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalSubGhz" | ||||||
|  | 
 | ||||||
| static volatile SubGhzState furi_hal_subghz_state = SubGhzStateInit; | static volatile SubGhzState furi_hal_subghz_state = SubGhzStateInit; | ||||||
| static volatile SubGhzRegulation furi_hal_subghz_regulation = SubGhzRegulationTxRx; | static volatile SubGhzRegulation furi_hal_subghz_regulation = SubGhzRegulationTxRx; | ||||||
| 
 | 
 | ||||||
| @ -303,7 +305,7 @@ void furi_hal_subghz_init() { | |||||||
|     cc1101_shutdown(device); |     cc1101_shutdown(device); | ||||||
| 
 | 
 | ||||||
|     furi_hal_spi_device_return(device); |     furi_hal_spi_device_return(device); | ||||||
|     FURI_LOG_I("FuriHalSubGhz", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_subghz_sleep() { | void furi_hal_subghz_sleep() { | ||||||
|  | |||||||
| @ -5,6 +5,8 @@ | |||||||
| 
 | 
 | ||||||
| #include "usb.h" | #include "usb.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalUsb" | ||||||
|  | 
 | ||||||
| #define USB_RECONNECT_DELAY 500 | #define USB_RECONNECT_DELAY 500 | ||||||
| 
 | 
 | ||||||
| extern struct UsbInterface usb_cdc_single; | extern struct UsbInterface usb_cdc_single; | ||||||
| @ -64,7 +66,7 @@ void furi_hal_usb_init(void) { | |||||||
|     HAL_NVIC_SetPriority(USB_LP_IRQn, 5, 0); |     HAL_NVIC_SetPriority(USB_LP_IRQn, 5, 0); | ||||||
|     NVIC_EnableIRQ(USB_LP_IRQn); |     NVIC_EnableIRQ(USB_LP_IRQn); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalUsb", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_usb_set_config(UsbMode new_mode) { | void furi_hal_usb_set_config(UsbMode new_mode) { | ||||||
| @ -81,7 +83,7 @@ void furi_hal_usb_set_config(UsbMode new_mode) { | |||||||
|                 usb_if_modes[usb_config.mode_cur]->deinit(&udev); |                 usb_if_modes[usb_config.mode_cur]->deinit(&udev); | ||||||
|             if (usb_if_modes[new_mode] != NULL) { |             if (usb_if_modes[new_mode] != NULL) { | ||||||
|                 usb_if_modes[new_mode]->init(&udev, usb_if_modes[new_mode]); |                 usb_if_modes[new_mode]->init(&udev, usb_if_modes[new_mode]); | ||||||
|                 FURI_LOG_I("FuriHalUsb", "USB mode change %u -> %u", usb_config.mode_cur, new_mode); |                 FURI_LOG_I(TAG, "USB mode change %u -> %u", usb_config.mode_cur, new_mode); | ||||||
|                 usb_config.enabled = true; |                 usb_config.enabled = true; | ||||||
|                 usb_config.mode_cur = new_mode; |                 usb_config.mode_cur = new_mode; | ||||||
|             } |             } | ||||||
| @ -98,7 +100,7 @@ void furi_hal_usb_disable() { | |||||||
|         susp_evt(&udev, 0, 0); |         susp_evt(&udev, 0, 0); | ||||||
|         usbd_connect(&udev, false); |         usbd_connect(&udev, false); | ||||||
|         usb_config.enabled = false; |         usb_config.enabled = false; | ||||||
|         FURI_LOG_I("FuriHalUsb", "USB Disable"); |         FURI_LOG_I(TAG, "USB Disable"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -106,7 +108,7 @@ void furi_hal_usb_enable() { | |||||||
|     if ((!usb_config.enabled) && (usb_if_modes[usb_config.mode_cur] != NULL)) { |     if ((!usb_config.enabled) && (usb_if_modes[usb_config.mode_cur] != NULL)) { | ||||||
|         usbd_connect(&udev, true); |         usbd_connect(&udev, true); | ||||||
|         usb_config.enabled = true; |         usb_config.enabled = true; | ||||||
|         FURI_LOG_I("FuriHalUsb", "USB Enable"); |         FURI_LOG_I(TAG, "USB Enable"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,8 +1,10 @@ | |||||||
| #include <furi-hal-usb-cdc_i.h> | #include <furi-hal-usb-cdc_i.h> | ||||||
| 
 | #include <furi-hal-console.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <stream_buffer.h> | #include <stream_buffer.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalVcp" | ||||||
|  | 
 | ||||||
| #define USB_CDC_PKT_LEN CDC_DATA_SZ | #define USB_CDC_PKT_LEN CDC_DATA_SZ | ||||||
| #define VCP_RX_BUF_SIZE (USB_CDC_PKT_LEN * 3) | #define VCP_RX_BUF_SIZE (USB_CDC_PKT_LEN * 3) | ||||||
| #define VCP_TX_BUF_SIZE (USB_CDC_PKT_LEN * 3) | #define VCP_TX_BUF_SIZE (USB_CDC_PKT_LEN * 3) | ||||||
| @ -17,11 +19,11 @@ typedef enum { | |||||||
|     VcpEvtDisable       = (1 << 4), |     VcpEvtDisable       = (1 << 4), | ||||||
|     VcpEvtRx            = (1 << 5), |     VcpEvtRx            = (1 << 5), | ||||||
|     VcpEvtTx            = (1 << 6), |     VcpEvtTx            = (1 << 6), | ||||||
|     VcpEvtRxDone        = (1 << 7), |     VcpEvtStreamRx      = (1 << 7), | ||||||
|     VcpEvtTxDone        = (1 << 8), |     VcpEvtStreamTx      = (1 << 8), | ||||||
| } WorkerEvtFlags; | } WorkerEvtFlags; | ||||||
| 
 | 
 | ||||||
| #define VCP_THREAD_FLAG_ALL (VcpEvtConnect | VcpEvtDisconnect | VcpEvtEnable | VcpEvtDisable | VcpEvtRx | VcpEvtTx | VcpEvtRxDone | VcpEvtTxDone) | #define VCP_THREAD_FLAG_ALL (VcpEvtConnect | VcpEvtDisconnect | VcpEvtEnable | VcpEvtDisable | VcpEvtRx | VcpEvtTx | VcpEvtStreamRx | VcpEvtStreamTx) | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     FuriThread* thread; |     FuriThread* thread; | ||||||
| @ -62,17 +64,17 @@ void furi_hal_vcp_init() { | |||||||
| 
 | 
 | ||||||
|     vcp->thread = furi_thread_alloc(); |     vcp->thread = furi_thread_alloc(); | ||||||
|     furi_thread_set_name(vcp->thread, "VcpWorker"); |     furi_thread_set_name(vcp->thread, "VcpWorker"); | ||||||
|     furi_thread_set_stack_size(vcp->thread, 512); |     furi_thread_set_stack_size(vcp->thread, 1024); | ||||||
|     furi_thread_set_callback(vcp->thread, vcp_worker); |     furi_thread_set_callback(vcp->thread, vcp_worker); | ||||||
|     furi_thread_start(vcp->thread); |     furi_thread_start(vcp->thread); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalVcp", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int32_t vcp_worker(void* context) { | static int32_t vcp_worker(void* context) { | ||||||
|     bool enabled = true; |     bool enabled = true; | ||||||
|     bool tx_idle = false; |     bool tx_idle = false; | ||||||
|     bool rx_pending = false; |     size_t missed_rx = 0; | ||||||
| 
 | 
 | ||||||
|     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb); |     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb); | ||||||
| 
 | 
 | ||||||
| @ -81,42 +83,50 @@ static int32_t vcp_worker(void* context) { | |||||||
|         furi_assert((flags & osFlagsError) == 0); |         furi_assert((flags & osFlagsError) == 0); | ||||||
| 
 | 
 | ||||||
|         // New data received
 |         // New data received
 | ||||||
|         if((flags & VcpEvtRxDone) && enabled) { |         if((flags & VcpEvtStreamRx) && enabled && missed_rx > 0) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP StreamRx\r\n"); | ||||||
|  | #endif | ||||||
|             if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) { |             if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) { | ||||||
|                 size_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); |                 flags |= VcpEvtRx; | ||||||
|                 if (len > 0) |                 missed_rx--; | ||||||
|                     xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever); |             } | ||||||
|                 else |  | ||||||
|                     rx_pending = false; |  | ||||||
|             } else |  | ||||||
|                 rx_pending = true; // Buffer is full, retry later
 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Rx buffer was read, maybe there is enough space for new data?
 |         // Rx buffer was read, maybe there is enough space for new data?
 | ||||||
|         if((flags & VcpEvtRx) && rx_pending) { |         if((flags & VcpEvtRx)) { | ||||||
|             if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) { |             if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) { | ||||||
|                 size_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); |                 int32_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); | ||||||
|                 if (len > 0) | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|                     xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever); |                 furi_hal_console_printf("VCP Rx %d\r\n", len); | ||||||
|                 else | #endif | ||||||
|                     rx_pending = false; |                 if (len > 0) { | ||||||
|  |                     furi_check(xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever) == len); | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |                 furi_hal_console_puts("VCP Rx missed\r\n"); | ||||||
|  | #endif | ||||||
|  |                 missed_rx++; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // New data in Tx buffer
 |         // New data in Tx buffer
 | ||||||
|         if((flags & VcpEvtTx) && enabled) { |         if((flags & VcpEvtStreamTx) && enabled) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP StreamTx\r\n"); | ||||||
|  | #endif | ||||||
|             if (tx_idle) { |             if (tx_idle) { | ||||||
|                 size_t len = xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0); |                 flags |= VcpEvtTx; | ||||||
|                 if (len > 0) { |  | ||||||
|                     tx_idle = false; |  | ||||||
|                     furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // CDC write transfer done
 |         // CDC write transfer done
 | ||||||
|         if((flags & VcpEvtTxDone) && enabled) { |         if((flags & VcpEvtTx) && enabled) { | ||||||
|             size_t len = xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0); |             size_t len = xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0); | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_printf("VCP Tx %d\r\n", len); | ||||||
|  | #endif | ||||||
|             if (len > 0) { // Some data left in Tx buffer. Sending it now
 |             if (len > 0) { // Some data left in Tx buffer. Sending it now
 | ||||||
|                 tx_idle = false; |                 tx_idle = false; | ||||||
|                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); |                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); | ||||||
| @ -127,6 +137,9 @@ static int32_t vcp_worker(void* context) { | |||||||
| 
 | 
 | ||||||
|         // VCP session opened
 |         // VCP session opened
 | ||||||
|         if((flags & VcpEvtConnect) && enabled) { |         if((flags & VcpEvtConnect) && enabled) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP Connect\r\n"); | ||||||
|  | #endif | ||||||
|             if (vcp->connected == false) { |             if (vcp->connected == false) { | ||||||
|                 vcp->connected = true; |                 vcp->connected = true; | ||||||
|                 xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever); |                 xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever); | ||||||
| @ -135,6 +148,9 @@ static int32_t vcp_worker(void* context) { | |||||||
| 
 | 
 | ||||||
|         // VCP session closed
 |         // VCP session closed
 | ||||||
|         if((flags & VcpEvtDisconnect) && enabled) { |         if((flags & VcpEvtDisconnect) && enabled) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP Disconnect\r\n"); | ||||||
|  | #endif | ||||||
|             if (vcp->connected == true) { |             if (vcp->connected == true) { | ||||||
|                 vcp->connected = false; |                 vcp->connected = false; | ||||||
|                 xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever); |                 xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever); | ||||||
| @ -143,6 +159,9 @@ static int32_t vcp_worker(void* context) { | |||||||
| 
 | 
 | ||||||
|         // VCP enabled
 |         // VCP enabled
 | ||||||
|         if((flags & VcpEvtEnable) && !enabled){ |         if((flags & VcpEvtEnable) && !enabled){ | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP Enable\r\n"); | ||||||
|  | #endif | ||||||
|             furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb); |             furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb); | ||||||
|             enabled = true; |             enabled = true; | ||||||
|             furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); // flush Rx buffer
 |             furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); // flush Rx buffer
 | ||||||
| @ -154,6 +173,9 @@ static int32_t vcp_worker(void* context) { | |||||||
| 
 | 
 | ||||||
|         // VCP disabled
 |         // VCP disabled
 | ||||||
|         if((flags & VcpEvtDisable) && enabled) { |         if((flags & VcpEvtDisable) && enabled) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |             furi_hal_console_puts("VCP Disable\r\n"); | ||||||
|  | #endif | ||||||
|             enabled = false; |             enabled = false; | ||||||
|             vcp->connected = false; |             vcp->connected = false; | ||||||
|             xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever); |             xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever); | ||||||
| @ -182,9 +204,9 @@ size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeo | |||||||
|             batch_size = VCP_RX_BUF_SIZE; |             batch_size = VCP_RX_BUF_SIZE; | ||||||
| 
 | 
 | ||||||
|         size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout); |         size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout); | ||||||
|         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRx); |  | ||||||
|         if (len == 0) |         if (len == 0) | ||||||
|             break; |             break; | ||||||
|  |         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamRx); | ||||||
|         size -= len; |         size -= len; | ||||||
|         buffer += len; |         buffer += len; | ||||||
|         rx_cnt += len; |         rx_cnt += len; | ||||||
| @ -207,7 +229,7 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) { | |||||||
|             batch_size = VCP_TX_BUF_SIZE; |             batch_size = VCP_TX_BUF_SIZE; | ||||||
| 
 | 
 | ||||||
|         xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever); |         xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever); | ||||||
|         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTx); |         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamTx); | ||||||
| 
 | 
 | ||||||
|         size -= batch_size; |         size -= batch_size; | ||||||
|         buffer += batch_size; |         buffer += batch_size; | ||||||
| @ -215,6 +237,9 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void vcp_state_callback(uint8_t state) { | static void vcp_state_callback(uint8_t state) { | ||||||
|  | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |     furi_hal_console_puts("VCP State\r\n"); | ||||||
|  | #endif | ||||||
|     if (state == 0) { |     if (state == 0) { | ||||||
|         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtDisconnect); |         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtDisconnect); | ||||||
|     } |     } | ||||||
| @ -223,7 +248,9 @@ static void vcp_state_callback(uint8_t state) { | |||||||
| static void vcp_on_cdc_control_line(uint8_t state) { | static void vcp_on_cdc_control_line(uint8_t state) { | ||||||
|     // bit 0: DTR state, bit 1: RTS state
 |     // bit 0: DTR state, bit 1: RTS state
 | ||||||
|     bool dtr = state & (1 << 0); |     bool dtr = state & (1 << 0); | ||||||
| 
 | #ifdef FURI_HAL_USB_VCP_DEBUG | ||||||
|  |     furi_hal_console_puts("VCP CtrlLine\r\n"); | ||||||
|  | #endif | ||||||
|     if (dtr == true) { |     if (dtr == true) { | ||||||
|         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtConnect); |         osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtConnect); | ||||||
|     } else { |     } else { | ||||||
| @ -232,12 +259,12 @@ static void vcp_on_cdc_control_line(uint8_t state) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void vcp_on_cdc_rx() { | static void vcp_on_cdc_rx() { | ||||||
|     uint32_t ret = osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRxDone); |     uint32_t ret = osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRx); | ||||||
|     furi_assert((ret & osFlagsError) == 0); |     furi_assert((ret & osFlagsError) == 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void vcp_on_cdc_tx_complete() { | static void vcp_on_cdc_tx_complete() { | ||||||
|     osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTxDone); |     osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTx); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_vcp_is_connected(void) { | bool furi_hal_vcp_is_connected(void) { | ||||||
|  | |||||||
| @ -7,6 +7,8 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include "ble.h" | #include "ble.h" | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalVersion" | ||||||
|  | 
 | ||||||
| #define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE | #define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE | ||||||
| #define FURI_HAL_VERSION_OTP_ADDRESS OTP_AREA_BASE | #define FURI_HAL_VERSION_OTP_ADDRESS OTP_AREA_BASE | ||||||
| 
 | 
 | ||||||
| @ -191,7 +193,7 @@ void furi_hal_version_init() { | |||||||
|         break; |         break; | ||||||
|         default: furi_crash(NULL); |         default: furi_crash(NULL); | ||||||
|     } |     } | ||||||
|     FURI_LOG_I("FuriHalVersion", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_version_do_i_belong_here() { | bool furi_hal_version_do_i_belong_here() { | ||||||
|  | |||||||
| @ -1,10 +1,12 @@ | |||||||
| #include <furi-hal-vibro.h> | #include <furi-hal-vibro.h> | ||||||
| #include <furi-hal-gpio.h> | #include <furi-hal-gpio.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalVibro" | ||||||
|  | 
 | ||||||
| void furi_hal_vibro_init() { | void furi_hal_vibro_init() { | ||||||
|     hal_gpio_init(&vibro_gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); |     hal_gpio_init(&vibro_gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); | ||||||
|     hal_gpio_write(&vibro_gpio, false); |     hal_gpio_write(&vibro_gpio, false); | ||||||
|     FURI_LOG_I("FuriHalVibro", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,6 +7,10 @@ | |||||||
| 
 | 
 | ||||||
| #include <stm32wbxx_ll_cortex.h> | #include <stm32wbxx_ll_cortex.h> | ||||||
| 
 | 
 | ||||||
|  | #include <fatfs.h> | ||||||
|  | 
 | ||||||
|  | #define TAG "FuriHal" | ||||||
|  | 
 | ||||||
| void furi_hal_init() { | void furi_hal_init() { | ||||||
|     furi_hal_clock_init(); |     furi_hal_clock_init(); | ||||||
|     furi_hal_console_init(); |     furi_hal_console_init(); | ||||||
| @ -14,23 +18,23 @@ void furi_hal_init() { | |||||||
|     furi_hal_delay_init(); |     furi_hal_delay_init(); | ||||||
| 
 | 
 | ||||||
|     MX_GPIO_Init(); |     MX_GPIO_Init(); | ||||||
|     FURI_LOG_I("HAL", "GPIO OK"); |     FURI_LOG_I(TAG, "GPIO OK"); | ||||||
| 
 | 
 | ||||||
|     MX_RTC_Init(); |     MX_RTC_Init(); | ||||||
|     FURI_LOG_I("HAL", "RTC OK"); |     FURI_LOG_I(TAG, "RTC OK"); | ||||||
|     furi_hal_bootloader_init(); |     furi_hal_bootloader_init(); | ||||||
|     furi_hal_version_init(); |     furi_hal_version_init(); | ||||||
| 
 | 
 | ||||||
|     furi_hal_spi_init(); |     furi_hal_spi_init(); | ||||||
| 
 | 
 | ||||||
|     MX_TIM1_Init(); |     MX_TIM1_Init(); | ||||||
|     FURI_LOG_I("HAL", "TIM1 OK"); |     FURI_LOG_I(TAG, "TIM1 OK"); | ||||||
|     MX_TIM2_Init(); |     MX_TIM2_Init(); | ||||||
|     FURI_LOG_I("HAL", "TIM2 OK"); |     FURI_LOG_I(TAG, "TIM2 OK"); | ||||||
|     MX_TIM16_Init(); |     MX_TIM16_Init(); | ||||||
|     FURI_LOG_I("HAL", "TIM16 OK"); |     FURI_LOG_I(TAG, "TIM16 OK"); | ||||||
|     MX_COMP1_Init(); |     MX_COMP1_Init(); | ||||||
|     FURI_LOG_I("HAL", "COMP1 OK"); |     FURI_LOG_I(TAG, "COMP1 OK"); | ||||||
| 
 | 
 | ||||||
|     furi_hal_crypto_init(); |     furi_hal_crypto_init(); | ||||||
| 
 | 
 | ||||||
| @ -38,7 +42,7 @@ void furi_hal_init() { | |||||||
|     furi_hal_usb_init(); |     furi_hal_usb_init(); | ||||||
|     furi_hal_usb_set_config(UsbModeVcpSingle); |     furi_hal_usb_set_config(UsbModeVcpSingle); | ||||||
|     furi_hal_vcp_init(); |     furi_hal_vcp_init(); | ||||||
|     FURI_LOG_I("HAL", "USB OK"); |     FURI_LOG_I(TAG, "USB OK"); | ||||||
| 
 | 
 | ||||||
|     furi_hal_i2c_init(); |     furi_hal_i2c_init(); | ||||||
| 
 | 
 | ||||||
| @ -55,6 +59,10 @@ void furi_hal_init() { | |||||||
|     // FreeRTOS glue
 |     // FreeRTOS glue
 | ||||||
|     furi_hal_os_init(); |     furi_hal_os_init(); | ||||||
| 
 | 
 | ||||||
|  |     // FatFS driver initialization
 | ||||||
|  |     MX_FATFS_Init(); | ||||||
|  |     FURI_LOG_I(TAG, "FATFS OK"); | ||||||
|  | 
 | ||||||
|     // Partial null pointer dereference protection
 |     // Partial null pointer dereference protection
 | ||||||
|     LL_MPU_Disable(); |     LL_MPU_Disable(); | ||||||
|     LL_MPU_ConfigRegion( |     LL_MPU_ConfigRegion( | ||||||
|  | |||||||
| @ -128,6 +128,11 @@ ifeq ($(FURI_HAL_OS_DEBUG), 1) | |||||||
| CFLAGS += -DFURI_HAL_OS_DEBUG | CFLAGS += -DFURI_HAL_OS_DEBUG | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
|  | FURI_HAL_USB_VCP_DEBUG ?= 0 | ||||||
|  | ifeq ($(FURI_HAL_USB_VCP_DEBUG), 1) | ||||||
|  | CFLAGS += -DFURI_HAL_USB_VCP_DEBUG | ||||||
|  | endif | ||||||
|  | 
 | ||||||
| FURI_HAL_SUBGHZ_TX_GPIO ?= 0 | FURI_HAL_SUBGHZ_TX_GPIO ?= 0 | ||||||
| ifneq ($(FURI_HAL_SUBGHZ_TX_GPIO), 0) | ifneq ($(FURI_HAL_SUBGHZ_TX_GPIO), 0) | ||||||
| CFLAGS += -DFURI_HAL_SUBGHZ_TX_GPIO=$(FURI_HAL_SUBGHZ_TX_GPIO) | CFLAGS += -DFURI_HAL_SUBGHZ_TX_GPIO=$(FURI_HAL_SUBGHZ_TX_GPIO) | ||||||
| @ -144,10 +149,10 @@ C_SOURCES += $(wildcard $(FURI_HAL_DIR)/*.c) | |||||||
| # Other
 | # Other
 | ||||||
| CFLAGS += \
 | CFLAGS += \
 | ||||||
| 	-I$(MXPROJECT_DIR)/Inc \
 | 	-I$(MXPROJECT_DIR)/Inc \
 | ||||||
| 	-I$(MXPROJECT_DIR)/Src/fatfs | 	-I$(MXPROJECT_DIR)/fatfs | ||||||
| C_SOURCES += \
 | C_SOURCES += \
 | ||||||
| 	$(wildcard $(MXPROJECT_DIR)/Src/*.c) \
 | 	$(wildcard $(MXPROJECT_DIR)/Src/*.c) \
 | ||||||
| 	$(wildcard $(MXPROJECT_DIR)/Src/fatfs/*.c) | 	$(wildcard $(MXPROJECT_DIR)/fatfs/*.c) | ||||||
| 
 | 
 | ||||||
| # Linker options
 | # Linker options
 | ||||||
| ifeq ($(NO_BOOTLOADER), 1) | ifeq ($(NO_BOOTLOADER), 1) | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								firmware/targets/f7/Inc/stm32_assert.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								firmware/targets/f7/Inc/stm32_assert.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | /**
 | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @file    stm32_assert.h | ||||||
|  |   * @brief   STM32 assert file. | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @attention | ||||||
|  |   * | ||||||
|  |   * <h2><center>© Copyright (c) 2019 STMicroelectronics. | ||||||
|  |   * All rights reserved.</center></h2> | ||||||
|  |   * | ||||||
|  |   * This software component is licensed by ST under BSD 3-Clause license, | ||||||
|  |   * the "License"; You may not use this file except in compliance with the | ||||||
|  |   * License. You may obtain a copy of the License at: | ||||||
|  |   *                        opensource.org/licenses/BSD-3-Clause | ||||||
|  |   * | ||||||
|  |   ****************************************************************************** | ||||||
|  |   */ | ||||||
|  | 
 | ||||||
|  | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
|  | #ifndef __STM32_ASSERT_H | ||||||
|  | #define __STM32_ASSERT_H | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  |  extern "C" { | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef  USE_FULL_ASSERT | ||||||
|  |   #define assert_param(expr) ((expr) ? (void)0U : assert_failed()) | ||||||
|  |   void assert_failed(); | ||||||
|  | #else | ||||||
|  |   #define assert_param(expr) ((void)0U) | ||||||
|  | #endif /* USE_FULL_ASSERT */ | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #endif /* __STM32_ASSERT_H */ | ||||||
|  | 
 | ||||||
|  | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||||
| @ -184,7 +184,7 @@ | |||||||
|   * @brief Uncomment the line below to expanse the "assert_param" macro in the |   * @brief Uncomment the line below to expanse the "assert_param" macro in the | ||||||
|   *        HAL drivers code |   *        HAL drivers code | ||||||
|   */ |   */ | ||||||
| /* #define USE_FULL_ASSERT    1U */ | #define USE_FULL_ASSERT    1U | ||||||
| 
 | 
 | ||||||
| /* ################## SPI peripheral configuration ########################## */ | /* ################## SPI peripheral configuration ########################## */ | ||||||
| 
 | 
 | ||||||
| @ -329,17 +329,8 @@ | |||||||
| 
 | 
 | ||||||
| /* Exported macro ------------------------------------------------------------*/ | /* Exported macro ------------------------------------------------------------*/ | ||||||
| #ifdef  USE_FULL_ASSERT | #ifdef  USE_FULL_ASSERT | ||||||
| /**
 |   #define assert_param(expr) ((expr) ? (void)0U : assert_failed()) | ||||||
|   * @brief  The assert_param macro is used for function's parameters check. |   void assert_failed(); | ||||||
|   * @param expr If expr is false, it calls assert_failed function |  | ||||||
|   *         which reports the name of the source file and the source |  | ||||||
|   *         line number of the call that failed. |  | ||||||
|   *         If expr is true, it returns no value. |  | ||||||
|   * @retval None |  | ||||||
|   */ |  | ||||||
|   #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) |  | ||||||
| /* Exported functions ------------------------------------------------------- */ |  | ||||||
|   void assert_failed(uint8_t* file, uint32_t line); |  | ||||||
| #else | #else | ||||||
|   #define assert_param(expr) ((void)0U) |   #define assert_param(expr) ((void)0U) | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| #include "fatfs/fatfs.h" |  | ||||||
| 
 |  | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| #include <flipper.h> | #include <flipper.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Main" | ||||||
|  | 
 | ||||||
| int main(void) { | int main(void) { | ||||||
|     // Initialize FURI layer
 |     // Initialize FURI layer
 | ||||||
|     furi_init(); |     furi_init(); | ||||||
| @ -16,13 +16,9 @@ int main(void) { | |||||||
|     // Flipper FURI HAL
 |     // Flipper FURI HAL
 | ||||||
|     furi_hal_init(); |     furi_hal_init(); | ||||||
| 
 | 
 | ||||||
|     // 3rd party
 |  | ||||||
|     MX_FATFS_Init(); |  | ||||||
|     FURI_LOG_I("HAL", "FATFS OK"); |  | ||||||
| 
 |  | ||||||
|     // CMSIS initialization
 |     // CMSIS initialization
 | ||||||
|     osKernelInitialize(); |     osKernelInitialize(); | ||||||
|     FURI_LOG_I("HAL", "KERNEL OK"); |     FURI_LOG_I(TAG, "KERNEL OK"); | ||||||
| 
 | 
 | ||||||
|     // Init flipper
 |     // Init flipper
 | ||||||
|     flipper_init(); |     flipper_init(); | ||||||
| @ -47,9 +43,6 @@ void Error_Handler(void) { | |||||||
|     * @retval None |     * @retval None | ||||||
|     */ |     */ | ||||||
| void assert_failed(uint8_t *file, uint32_t line) { | void assert_failed(uint8_t *file, uint32_t line) { | ||||||
|     /* USER CODE BEGIN 6 */ |     furi_crash("HAL assert failed"); | ||||||
|     /* User can add his own implementation to report the file name and line number,
 |  | ||||||
|          tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |  | ||||||
|     /* USER CODE END 6 */ |  | ||||||
| } | } | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define BATTERY_SERVICE_TAG "battery service" | #define TAG "BtBatterySvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t svc_handle; |     uint16_t svc_handle; | ||||||
| @ -23,7 +23,7 @@ void battery_svc_start() { | |||||||
|     // Add Battery service
 |     // Add Battery service
 | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle); |     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Battery service: %d", status); | ||||||
|     } |     } | ||||||
|     // Add Battery level characteristic
 |     // Add Battery level characteristic
 | ||||||
|     status = aci_gatt_add_char(battery_svc->svc_handle, |     status = aci_gatt_add_char(battery_svc->svc_handle, | ||||||
| @ -37,7 +37,7 @@ void battery_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &battery_svc->char_level_handle); |                                 &battery_svc->char_level_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery level characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add Battery level characteristic: %d", status); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -47,12 +47,12 @@ void battery_svc_stop() { | |||||||
|         // Delete Battery level characteristic
 |         // Delete Battery level characteristic
 | ||||||
|         status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle); |         status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery level characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Battery level characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete Battery service
 |         // Delete Battery service
 | ||||||
|         status = aci_gatt_del_service(battery_svc->svc_handle); |         status = aci_gatt_del_service(battery_svc->svc_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Battery service: %d", status); | ||||||
|         } |         } | ||||||
|         free(battery_svc); |         free(battery_svc); | ||||||
|         battery_svc = NULL; |         battery_svc = NULL; | ||||||
| @ -65,14 +65,14 @@ bool battery_svc_update_level(uint8_t battery_charge) { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     // Update battery level characteristic
 |     // Update battery level characteristic
 | ||||||
|     FURI_LOG_I(BATTERY_SERVICE_TAG, "Updating battery level characteristic"); |     FURI_LOG_I(TAG, "Updating battery level characteristic"); | ||||||
|     tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle, |     tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle, | ||||||
|                                           battery_svc->char_level_handle, |                                           battery_svc->char_level_handle, | ||||||
|                                           0, |                                           0, | ||||||
|                                           1, |                                           1, | ||||||
|                                           &battery_charge); |                                           &battery_charge); | ||||||
|     if(result) { |     if(result) { | ||||||
|         FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed updating RX characteristic: %d", result); |         FURI_LOG_E(TAG, "Failed updating RX characteristic: %d", result); | ||||||
|     } |     } | ||||||
|     return result != BLE_STATUS_SUCCESS; |     return result != BLE_STATUS_SUCCESS; | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #define BLE_APP_TAG "ble app" | #define TAG "Bt" | ||||||
| 
 | 
 | ||||||
| PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer; | PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer; | ||||||
| PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE]; | PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE]; | ||||||
| @ -53,7 +53,7 @@ bool ble_app_init() { | |||||||
|     }; |     }; | ||||||
|     status = SHCI_C2_Config(&config_param); |     status = SHCI_C2_Config(&config_param); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BLE_APP_TAG, "Failed to configure 2nd core: %d", status); |         FURI_LOG_E(TAG, "Failed to configure 2nd core: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Start ble stack on 2nd core
 |     // Start ble stack on 2nd core
 | ||||||
| @ -82,7 +82,7 @@ bool ble_app_init() { | |||||||
|     }; |     }; | ||||||
|     status = SHCI_C2_BLE_Init(&ble_init_cmd_packet); |     status = SHCI_C2_BLE_Init(&ble_init_cmd_packet); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(BLE_APP_TAG, "Failed to start ble stack: %d", status); |         FURI_LOG_E(TAG, "Failed to start ble stack: %d", status); | ||||||
|     } |     } | ||||||
|     return status == SHCI_Success; |     return status == SHCI_Success; | ||||||
| } | } | ||||||
|  | |||||||
| @ -10,6 +10,8 @@ | |||||||
| #include "app_debug.h" | #include "app_debug.h" | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "Core2" | ||||||
|  | 
 | ||||||
| #define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U)) | #define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U)) | ||||||
| 
 | 
 | ||||||
| PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE]; | PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE]; | ||||||
| @ -125,20 +127,20 @@ static void ble_glue_sys_user_event_callback( void * pPayload ) { | |||||||
|      |      | ||||||
|     if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) { |     if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) { | ||||||
|         if(ble_app_init()) { |         if(ble_app_init()) { | ||||||
|             FURI_LOG_I("Core2", "BLE stack started"); |             FURI_LOG_I(TAG, "BLE stack started"); | ||||||
|             ble_glue->status = BleGlueStatusStarted; |             ble_glue->status = BleGlueStatusStarted; | ||||||
|             if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) { |             if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) { | ||||||
|                 FURI_LOG_I("Core2", "Flash activity control switched to SEM7"); |                 FURI_LOG_I(TAG, "Flash activity control switched to SEM7"); | ||||||
|             } else { |             } else { | ||||||
|                 FURI_LOG_E("Core2", "Failed to switch flash activity control to SEM7"); |                 FURI_LOG_E(TAG, "Failed to switch flash activity control to SEM7"); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E("Core2", "BLE stack startup failed"); |             FURI_LOG_E(TAG, "BLE stack startup failed"); | ||||||
|             ble_glue->status = BleGlueStatusBleStackMissing; |             ble_glue->status = BleGlueStatusBleStackMissing; | ||||||
|         } |         } | ||||||
|         furi_hal_power_insomnia_exit(); |         furi_hal_power_insomnia_exit(); | ||||||
|     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) { |     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) { | ||||||
|         FURI_LOG_E("Core2", "Error during initialization"); |         FURI_LOG_E(TAG, "Error during initialization"); | ||||||
|         furi_hal_power_insomnia_exit(); |         furi_hal_power_insomnia_exit(); | ||||||
|     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) { |     } else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) { | ||||||
|         SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload; |         SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload; | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define DEV_INFO_SVC_TAG "dev info service" | #define TAG "BtDevInfoSvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t service_handle; |     uint16_t service_handle; | ||||||
| @ -29,7 +29,7 @@ void dev_info_svc_start() { | |||||||
|     uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID; |     uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID; | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle); |     status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add Device Information Service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Device Information Service: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add characteristics
 |     // Add characteristics
 | ||||||
| @ -45,7 +45,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->man_name_char_handle); |                                 &dev_info_svc->man_name_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add manufacturer name char: %d", status); |         FURI_LOG_E(TAG, "Failed to add manufacturer name char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = SERIAL_NUMBER_UUID; |     uuid = SERIAL_NUMBER_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -59,7 +59,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->serial_num_char_handle); |                                 &dev_info_svc->serial_num_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add serial number char: %d", status); |         FURI_LOG_E(TAG, "Failed to add serial number char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = FIRMWARE_REVISION_UUID; |     uuid = FIRMWARE_REVISION_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -73,7 +73,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->firmware_rev_char_handle); |                                 &dev_info_svc->firmware_rev_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add firmware revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to add firmware revision char: %d", status); | ||||||
|     } |     } | ||||||
|     uuid = SOFTWARE_REVISION_UUID; |     uuid = SOFTWARE_REVISION_UUID; | ||||||
|     status = aci_gatt_add_char(dev_info_svc->service_handle, |     status = aci_gatt_add_char(dev_info_svc->service_handle, | ||||||
| @ -87,7 +87,7 @@ void dev_info_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &dev_info_svc->software_rev_char_handle); |                                 &dev_info_svc->software_rev_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add software revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to add software revision char: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Update characteristics
 |     // Update characteristics
 | ||||||
| @ -97,7 +97,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_man_name), |                                         strlen(dev_info_man_name), | ||||||
|                                         (uint8_t*)dev_info_man_name); |                                         (uint8_t*)dev_info_man_name); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update manufacturer name char: %d", status); |         FURI_LOG_E(TAG, "Failed to update manufacturer name char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->serial_num_char_handle, |                                         dev_info_svc->serial_num_char_handle, | ||||||
| @ -105,7 +105,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_serial_num), |                                         strlen(dev_info_serial_num), | ||||||
|                                         (uint8_t*)dev_info_serial_num); |                                         (uint8_t*)dev_info_serial_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update serial number char: %d", status); |         FURI_LOG_E(TAG, "Failed to update serial number char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->firmware_rev_char_handle, |                                         dev_info_svc->firmware_rev_char_handle, | ||||||
| @ -113,7 +113,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_firmware_rev_num), |                                         strlen(dev_info_firmware_rev_num), | ||||||
|                                         (uint8_t*)dev_info_firmware_rev_num); |                                         (uint8_t*)dev_info_firmware_rev_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update firmware revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to update firmware revision char: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(dev_info_svc->service_handle, |     status = aci_gatt_update_char_value(dev_info_svc->service_handle, | ||||||
|                                         dev_info_svc->software_rev_char_handle, |                                         dev_info_svc->software_rev_char_handle, | ||||||
| @ -121,7 +121,7 @@ void dev_info_svc_start() { | |||||||
|                                         strlen(dev_info_software_rev_num), |                                         strlen(dev_info_software_rev_num), | ||||||
|                                         (uint8_t*)dev_info_software_rev_num); |                                         (uint8_t*)dev_info_software_rev_num); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update software revision char: %d", status); |         FURI_LOG_E(TAG, "Failed to update software revision char: %d", status); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -131,24 +131,24 @@ void dev_info_svc_stop() { | |||||||
|         // Delete service characteristics
 |         // Delete service characteristics
 | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete manufacturer name char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete manufacturer name char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete serial number char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete serial number char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete firmware revision char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete firmware revision char: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle); |         status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete software revision char: %d", status); |             FURI_LOG_E(TAG, "Failed to delete software revision char: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete service
 |         // Delete service
 | ||||||
|         status = aci_gatt_del_service(dev_info_svc->service_handle); |         status = aci_gatt_del_service(dev_info_svc->service_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete device info service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete device info service: %d", status); | ||||||
|         } |         } | ||||||
|         free(dev_info_svc); |         free(dev_info_svc); | ||||||
|         dev_info_svc = NULL; |         dev_info_svc = NULL; | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi-hal.h> | #include <furi-hal.h> | ||||||
| 
 | 
 | ||||||
| #define GAP_TAG "BLE" | #define TAG "BtGap" | ||||||
| 
 | 
 | ||||||
| #define FAST_ADV_TIMEOUT 30000 | #define FAST_ADV_TIMEOUT 30000 | ||||||
| #define INITIAL_ADV_TIMEOUT 60000 | #define INITIAL_ADV_TIMEOUT 60000 | ||||||
| @ -80,7 +80,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) { |             if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) { | ||||||
|                 gap->gap_svc.connection_handle = 0; |                 gap->gap_svc.connection_handle = 0; | ||||||
|                 gap->state = GapStateIdle; |                 gap->state = GapStateIdle; | ||||||
|                 FURI_LOG_I(GAP_TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason); |                 FURI_LOG_I(TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason); | ||||||
|             } |             } | ||||||
|             if(gap->enable_adv) { |             if(gap->enable_adv) { | ||||||
|                 // Restart advertising
 |                 // Restart advertising
 | ||||||
| @ -96,28 +96,28 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             meta_evt = (evt_le_meta_event*) event_pckt->data; |             meta_evt = (evt_le_meta_event*) event_pckt->data; | ||||||
|             switch (meta_evt->subevent) { |             switch (meta_evt->subevent) { | ||||||
|                 case EVT_LE_CONN_UPDATE_COMPLETE: |                 case EVT_LE_CONN_UPDATE_COMPLETE: | ||||||
|                 FURI_LOG_D(GAP_TAG, "Connection update event"); |                 FURI_LOG_D(TAG, "Connection update event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|                 case EVT_LE_PHY_UPDATE_COMPLETE: |                 case EVT_LE_PHY_UPDATE_COMPLETE: | ||||||
|                 evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data; |                 evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data; | ||||||
|                 if(evt_le_phy_update_complete->Status) { |                 if(evt_le_phy_update_complete->Status) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status); |                     FURI_LOG_E(TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "Update PHY succeed"); |                     FURI_LOG_I(TAG, "Update PHY succeed"); | ||||||
|                 } |                 } | ||||||
|                 ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy); |                 ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy); | ||||||
|                 if(ret) { |                 if(ret) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Read PHY failed, status: %d", ret); |                     FURI_LOG_E(TAG, "Read PHY failed, status: %d", ret); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy); |                     FURI_LOG_I(TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|                 case EVT_LE_CONN_COMPLETE: |                 case EVT_LE_CONN_COMPLETE: | ||||||
|                 furi_hal_power_insomnia_enter(); |                 furi_hal_power_insomnia_enter(); | ||||||
|                 hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data; |                 hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data; | ||||||
|                 FURI_LOG_I(GAP_TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle); |                 FURI_LOG_I(TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle); | ||||||
| 
 | 
 | ||||||
|                 // Stop advertising as connection completed
 |                 // Stop advertising as connection completed
 | ||||||
|                 osTimerStop(gap->advertise_timer); |                 osTimerStop(gap->advertise_timer); | ||||||
| @ -141,7 +141,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|                 aci_gap_pairing_complete_event_rp0 *pairing_complete; |                 aci_gap_pairing_complete_event_rp0 *pairing_complete; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_LIMITED_DISCOVERABLE: |             case EVT_BLUE_GAP_LIMITED_DISCOVERABLE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Limited discoverable event"); |                 FURI_LOG_I(TAG, "Limited discoverable event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_PASS_KEY_REQUEST: |             case EVT_BLUE_GAP_PASS_KEY_REQUEST: | ||||||
| @ -149,39 +149,39 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|                 // Generate random PIN code
 |                 // Generate random PIN code
 | ||||||
|                 uint32_t pin = rand() % 999999; |                 uint32_t pin = rand() % 999999; | ||||||
|                 aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin); |                 aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin); | ||||||
|                 FURI_LOG_I(GAP_TAG, "Pass key request event. Pin: %d", pin); |                 FURI_LOG_I(TAG, "Pass key request event. Pin: %d", pin); | ||||||
|                 BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin}; |                 BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin}; | ||||||
|                 gap->on_event_cb(event, gap->context); |                 gap->on_event_cb(event, gap->context); | ||||||
|             } |             } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_AUTHORIZATION_REQUEST: |             case EVT_BLUE_GAP_AUTHORIZATION_REQUEST: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Authorization request event"); |                 FURI_LOG_I(TAG, "Authorization request event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED: |             case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Slave security initiated"); |                 FURI_LOG_I(TAG, "Slave security initiated"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_BOND_LOST: |             case EVT_BLUE_GAP_BOND_LOST: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Bond lost event. Start rebonding"); |                 FURI_LOG_I(TAG, "Bond lost event. Start rebonding"); | ||||||
|                 aci_gap_allow_rebond(gap->gap_svc.connection_handle); |                 aci_gap_allow_rebond(gap->gap_svc.connection_handle); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_DEVICE_FOUND: |             case EVT_BLUE_GAP_DEVICE_FOUND: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Device found event"); |                 FURI_LOG_I(TAG, "Device found event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_ADDR_NOT_RESOLVED: |             case EVT_BLUE_GAP_ADDR_NOT_RESOLVED: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Address not resolved event"); |                 FURI_LOG_I(TAG, "Address not resolved event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION: |             case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Key press notification event"); |                 FURI_LOG_I(TAG, "Key press notification event"); | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE: |             case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Hex_value = %lx", |                 FURI_LOG_I(TAG, "Hex_value = %lx", | ||||||
|                             ((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value); |                             ((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value); | ||||||
|                 aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1); |                 aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1); | ||||||
|                 break; |                 break; | ||||||
| @ -189,17 +189,17 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt ) | |||||||
|             case EVT_BLUE_GAP_PAIRING_CMPLT: |             case EVT_BLUE_GAP_PAIRING_CMPLT: | ||||||
|                 pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data; |                 pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data; | ||||||
|                 if (pairing_complete->Status) { |                 if (pairing_complete->Status) { | ||||||
|                     FURI_LOG_E(GAP_TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status); |                     FURI_LOG_E(TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status); | ||||||
|                     aci_gap_terminate(gap->gap_svc.connection_handle, 5); |                     aci_gap_terminate(gap->gap_svc.connection_handle, 5); | ||||||
|                 } else { |                 } else { | ||||||
|                     FURI_LOG_I(GAP_TAG, "Pairing complete"); |                     FURI_LOG_I(TAG, "Pairing complete"); | ||||||
|                     BleEvent event = {.type = BleEventTypeConnected}; |                     BleEvent event = {.type = BleEventTypeConnected}; | ||||||
|                     gap->on_event_cb(event, gap->context); |                     gap->on_event_cb(event, gap->context); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case EVT_BLUE_GAP_PROCEDURE_COMPLETE: |             case EVT_BLUE_GAP_PROCEDURE_COMPLETE: | ||||||
|                 FURI_LOG_I(GAP_TAG, "Procedure complete event"); |                 FURI_LOG_I(TAG, "Procedure complete event"); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             default: |             default: | ||||||
| @ -286,11 +286,11 @@ static void gap_init_svc(Gap* gap) { | |||||||
|     // Set GAP characteristics
 |     // Set GAP characteristics
 | ||||||
|     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name); |     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name); | ||||||
|     if (status) { |     if (status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Failed updating name characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed updating name characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid); |     status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Failed updating appearence characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed updating appearence characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Set default PHY
 |     // Set default PHY
 | ||||||
|     hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED); |     hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED); | ||||||
| @ -322,7 +322,7 @@ static void gap_advertise_start(GapState new_state) | |||||||
|         // Stop advertising
 |         // Stop advertising
 | ||||||
|         status = aci_gap_set_non_discoverable(); |         status = aci_gap_set_non_discoverable(); | ||||||
|         if (status) { |         if (status) { | ||||||
|             FURI_LOG_E(GAP_TAG, "Stop Advertising Failed, result: %d", status); |             FURI_LOG_E(TAG, "Stop Advertising Failed, result: %d", status); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     // Configure advertising
 |     // Configure advertising
 | ||||||
| @ -331,7 +331,7 @@ static void gap_advertise_start(GapState new_state) | |||||||
|                                         strlen(name), (uint8_t*)name, |                                         strlen(name), (uint8_t*)name, | ||||||
|                                         gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0); |                                         gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(GAP_TAG, "Set discoverable err: %d", status); |         FURI_LOG_E(TAG, "Set discoverable err: %d", status); | ||||||
|     } |     } | ||||||
|     gap->state = new_state; |     gap->state = new_state; | ||||||
|     BleEvent event = {.type = BleEventTypeStartAdvertising}; |     BleEvent event = {.type = BleEventTypeStartAdvertising}; | ||||||
| @ -355,14 +355,14 @@ static void gap_advertise_stop() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gap_start_advertising() { | void gap_start_advertising() { | ||||||
|     FURI_LOG_I(GAP_TAG, "Start advertising"); |     FURI_LOG_I(TAG, "Start advertising"); | ||||||
|     gap->enable_adv = true; |     gap->enable_adv = true; | ||||||
|     GapCommand command = GapCommandAdvFast; |     GapCommand command = GapCommandAdvFast; | ||||||
|     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); |     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gap_stop_advertising() { | void gap_stop_advertising() { | ||||||
|     FURI_LOG_I(GAP_TAG, "Stop advertising"); |     FURI_LOG_I(TAG, "Stop advertising"); | ||||||
|     gap->enable_adv = false; |     gap->enable_adv = false; | ||||||
|     GapCommand command = GapCommandAdvStop; |     GapCommand command = GapCommandAdvStop; | ||||||
|     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); |     furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK); | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
| #define SERIAL_SERVICE_TAG "serial service" | #define TAG "BtSerialSvc" | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     uint16_t svc_handle; |     uint16_t svc_handle; | ||||||
| @ -37,26 +37,26 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void *event) { | |||||||
|             if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) { |             if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) { | ||||||
|                 // Descriptor handle
 |                 // Descriptor handle
 | ||||||
|                 ret = SVCCTL_EvtAckFlowEnable; |                 ret = SVCCTL_EvtAckFlowEnable; | ||||||
|                 FURI_LOG_D(SERIAL_SERVICE_TAG, "RX descriptor event"); |                 FURI_LOG_D(TAG, "RX descriptor event"); | ||||||
|             } else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) { |             } else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) { | ||||||
|                 FURI_LOG_D(SERIAL_SERVICE_TAG, "Received %d bytes", attribute_modified->Attr_Data_Length); |                 FURI_LOG_D(TAG, "Received %d bytes", attribute_modified->Attr_Data_Length); | ||||||
|                 if(serial_svc->on_received_cb) { |                 if(serial_svc->on_received_cb) { | ||||||
|                     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); |                     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); | ||||||
|                     if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) { |                     if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) { | ||||||
|                         FURI_LOG_W( |                         FURI_LOG_W( | ||||||
|                             SERIAL_SERVICE_TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!", |                             TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!", | ||||||
|                             attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive); |                             attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive); | ||||||
|                     } |                     } | ||||||
|                     serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length); |                     serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length); | ||||||
|                     uint32_t buff_free_size = |                     uint32_t buff_free_size = | ||||||
|                         serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context); |                         serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context); | ||||||
|                     FURI_LOG_D(SERIAL_SERVICE_TAG, "Available buff size: %d", buff_free_size); |                     FURI_LOG_D(TAG, "Available buff size: %d", buff_free_size); | ||||||
|                     furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK); |                     furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK); | ||||||
|                 } |                 } | ||||||
|                 ret = SVCCTL_EvtAckFlowEnable; |                 ret = SVCCTL_EvtAckFlowEnable; | ||||||
|             } |             } | ||||||
|         } else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) { |         } else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) { | ||||||
|             FURI_LOG_D(SERIAL_SERVICE_TAG, "Ack received", blecore_evt->ecode); |             FURI_LOG_D(TAG, "Ack received", blecore_evt->ecode); | ||||||
|             if(serial_svc->on_sent_cb) { |             if(serial_svc->on_sent_cb) { | ||||||
|                 serial_svc->on_sent_cb(serial_svc->context); |                 serial_svc->on_sent_cb(serial_svc->context); | ||||||
|             } |             } | ||||||
| @ -75,7 +75,7 @@ void serial_svc_start() { | |||||||
|     // Add service
 |     // Add service
 | ||||||
|     status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle); |     status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Serial service: %d", status); |         FURI_LOG_E(TAG, "Failed to add Serial service: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add RX characteristics
 |     // Add RX characteristics
 | ||||||
| @ -88,7 +88,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_VARIABLE, |                                 CHAR_VALUE_LEN_VARIABLE, | ||||||
|                                 &serial_svc->rx_char_handle); |                                 &serial_svc->rx_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add RX characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add RX characteristic: %d", status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Add TX characteristic
 |     // Add TX characteristic
 | ||||||
| @ -101,7 +101,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_VARIABLE, |                                 CHAR_VALUE_LEN_VARIABLE, | ||||||
|                                 &serial_svc->tx_char_handle); |                                 &serial_svc->tx_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add TX characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add TX characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Add Flow Control characteristic
 |     // Add Flow Control characteristic
 | ||||||
|     status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid, |     status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid, | ||||||
| @ -113,7 +113,7 @@ void serial_svc_start() { | |||||||
|                                 CHAR_VALUE_LEN_CONSTANT, |                                 CHAR_VALUE_LEN_CONSTANT, | ||||||
|                                 &serial_svc->flow_ctrl_char_handle); |                                 &serial_svc->flow_ctrl_char_handle); | ||||||
|     if(status) { |     if(status) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Flow Control characteristic: %d", status); |         FURI_LOG_E(TAG, "Failed to add Flow Control characteristic: %d", status); | ||||||
|     } |     } | ||||||
|     // Allocate buffer size mutex
 |     // Allocate buffer size mutex
 | ||||||
|     serial_svc->buff_size_mtx = osMutexNew(NULL); |     serial_svc->buff_size_mtx = osMutexNew(NULL); | ||||||
| @ -136,7 +136,7 @@ void serial_svc_notify_buffer_is_empty() { | |||||||
| 
 | 
 | ||||||
|     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); |     furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK); | ||||||
|     if(serial_svc->bytes_ready_to_receive == 0) { |     if(serial_svc->bytes_ready_to_receive == 0) { | ||||||
|         FURI_LOG_D(SERIAL_SERVICE_TAG, "Buffer is empty. Notifying client"); |         FURI_LOG_D(TAG, "Buffer is empty. Notifying client"); | ||||||
|         serial_svc->bytes_ready_to_receive = serial_svc->buff_size; |         serial_svc->bytes_ready_to_receive = serial_svc->buff_size; | ||||||
|         uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size); |         uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size); | ||||||
|         aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed); |         aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed); | ||||||
| @ -150,20 +150,20 @@ void serial_svc_stop() { | |||||||
|         // Delete characteristics
 |         // Delete characteristics
 | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete TX characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete TX characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete RX characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete RX characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle); |         status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Flow Control characteristic: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Flow Control characteristic: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete service
 |         // Delete service
 | ||||||
|         status = aci_gatt_del_service(serial_svc->svc_handle); |         status = aci_gatt_del_service(serial_svc->svc_handle); | ||||||
|         if(status) { |         if(status) { | ||||||
|             FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Serial service: %d", status); |             FURI_LOG_E(TAG, "Failed to delete Serial service: %d", status); | ||||||
|         } |         } | ||||||
|         // Delete buffer size mutex
 |         // Delete buffer size mutex
 | ||||||
|         osMutexDelete(serial_svc->buff_size_mtx); |         osMutexDelete(serial_svc->buff_size_mtx); | ||||||
| @ -182,7 +182,7 @@ bool serial_svc_update_tx(uint8_t* data, uint8_t data_len) { | |||||||
|                                         data_len, |                                         data_len, | ||||||
|                                         data); |                                         data); | ||||||
|     if(result) { |     if(result) { | ||||||
|         FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed updating TX characteristic: %d", result); |         FURI_LOG_E(TAG, "Failed updating TX characteristic: %d", result); | ||||||
|     } |     } | ||||||
|     return result != BLE_STATUS_SUCCESS; |     return result != BLE_STATUS_SUCCESS; | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ | |||||||
| #include <stm32wbxx_ll_rtc.h> | #include <stm32wbxx_ll_rtc.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalBoot" | ||||||
|  | 
 | ||||||
| // Boot request enum
 | // Boot request enum
 | ||||||
| #define BOOT_REQUEST_TAINTED 0x00000000 | #define BOOT_REQUEST_TAINTED 0x00000000 | ||||||
| #define BOOT_REQUEST_CLEAN 0xDADEDADE | #define BOOT_REQUEST_CLEAN 0xDADEDADE | ||||||
| @ -11,7 +13,7 @@ void furi_hal_bootloader_init() { | |||||||
| #ifndef DEBUG | #ifndef DEBUG | ||||||
|     LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED); |     LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED); | ||||||
| #endif | #endif | ||||||
|     FURI_LOG_I("FuriHalBoot", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) { | void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) { | ||||||
|  | |||||||
| @ -5,6 +5,8 @@ | |||||||
| #include <stm32wbxx_ll_rcc.h> | #include <stm32wbxx_ll_rcc.h> | ||||||
| #include <stm32wbxx_ll_utils.h> | #include <stm32wbxx_ll_utils.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalClock" | ||||||
|  | 
 | ||||||
| #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) | #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) | ||||||
| #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) | #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) | ||||||
| 
 | 
 | ||||||
| @ -123,7 +125,7 @@ void furi_hal_clock_init() { | |||||||
|     // APB2
 |     // APB2
 | ||||||
|     LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); |     LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalClock", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_clock_switch_to_hsi() { | void furi_hal_clock_switch_to_hsi() { | ||||||
|  | |||||||
| @ -4,6 +4,8 @@ | |||||||
| #include <lib/heatshrink/heatshrink_encoder.h> | #include <lib/heatshrink/heatshrink_encoder.h> | ||||||
| #include <lib/heatshrink/heatshrink_decoder.h> | #include <lib/heatshrink/heatshrink_decoder.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalCompress" | ||||||
|  | 
 | ||||||
| #define FURI_HAL_COMPRESS_ICON_ENCODED_BUFF_SIZE (512) | #define FURI_HAL_COMPRESS_ICON_ENCODED_BUFF_SIZE (512) | ||||||
| #define FURI_HAL_COMPRESS_ICON_DECODED_BUFF_SIZE (1024) | #define FURI_HAL_COMPRESS_ICON_DECODED_BUFF_SIZE (1024) | ||||||
| 
 | 
 | ||||||
| @ -46,7 +48,7 @@ void furi_hal_compress_icon_init() { | |||||||
|         FURI_HAL_COMPRESS_LOOKAHEAD_BUFF_SIZE_LOG); |         FURI_HAL_COMPRESS_LOOKAHEAD_BUFF_SIZE_LOG); | ||||||
|     heatshrink_decoder_reset(icon_decoder->decoder); |     heatshrink_decoder_reset(icon_decoder->decoder); | ||||||
|     memset(icon_decoder->decoded_buff, 0, sizeof(icon_decoder->decoded_buff)); |     memset(icon_decoder->decoded_buff, 0, sizeof(icon_decoder->decoded_buff)); | ||||||
|     FURI_LOG_I("FuriHalCompress", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_compress_icon_decode(const uint8_t* icon_data, uint8_t** decoded_buff) {  | void furi_hal_compress_icon_decode(const uint8_t* icon_data, uint8_t** decoded_buff) {  | ||||||
|  | |||||||
| @ -6,8 +6,12 @@ | |||||||
| #include <stm32wbxx_ll_usart.h> | #include <stm32wbxx_ll_usart.h> | ||||||
| #include <m-string.h> | #include <m-string.h> | ||||||
| 
 | 
 | ||||||
|  | #include <utilities_conf.h> | ||||||
|  | 
 | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalConsole" | ||||||
|  | 
 | ||||||
| #define CONSOLE_BAUDRATE 230400 | #define CONSOLE_BAUDRATE 230400 | ||||||
| 
 | 
 | ||||||
| volatile bool furi_hal_console_alive = false; | volatile bool furi_hal_console_alive = false; | ||||||
| @ -16,7 +20,7 @@ void furi_hal_console_init() { | |||||||
|     furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE); |     furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE); | ||||||
|     furi_hal_console_alive = true; |     furi_hal_console_alive = true; | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalConsole", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_enable() { | void furi_hal_console_enable() { | ||||||
| @ -35,22 +39,26 @@ void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) { | |||||||
|     if (!furi_hal_console_alive) |     if (!furi_hal_console_alive) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|  |     UTILS_ENTER_CRITICAL_SECTION(); | ||||||
|     // Transmit data
 |     // Transmit data
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); | ||||||
|     // Wait for TC flag to be raised for last char
 |     // Wait for TC flag to be raised for last char
 | ||||||
|     while (!LL_USART_IsActiveFlag_TC(USART1)); |     while (!LL_USART_IsActiveFlag_TC(USART1)); | ||||||
|  |     UTILS_EXIT_CRITICAL_SECTION(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) { | void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) { | ||||||
|     if (!furi_hal_console_alive) |     if (!furi_hal_console_alive) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|  |     UTILS_ENTER_CRITICAL_SECTION(); | ||||||
|     // Transmit data
 |     // Transmit data
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size); | ||||||
|     // Transmit new line symbols
 |     // Transmit new line symbols
 | ||||||
|     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2); |     furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2); | ||||||
|     // Wait for TC flag to be raised for last char
 |     // Wait for TC flag to be raised for last char
 | ||||||
|     while (!LL_USART_IsActiveFlag_TC(USART1)); |     while (!LL_USART_IsActiveFlag_TC(USART1)); | ||||||
|  |     UTILS_EXIT_CRITICAL_SECTION(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_console_printf(const char format[], ...) { | void furi_hal_console_printf(const char format[], ...) { | ||||||
|  | |||||||
| @ -3,10 +3,12 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <shci.h> | #include <shci.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalCrypto" | ||||||
|  | 
 | ||||||
| CRYP_HandleTypeDef crypt; | CRYP_HandleTypeDef crypt; | ||||||
| 
 | 
 | ||||||
| void furi_hal_crypto_init() { | void furi_hal_crypto_init() { | ||||||
|     FURI_LOG_I("FuriHalCrypto", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot) { | bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot) { | ||||||
|  | |||||||
| @ -3,6 +3,8 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
| #include <cmsis_os2.h> | #include <cmsis_os2.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalDelay" | ||||||
|  | 
 | ||||||
| static uint32_t clk_per_microsecond; | static uint32_t clk_per_microsecond; | ||||||
| 
 | 
 | ||||||
| void furi_hal_delay_init(void) { | void furi_hal_delay_init(void) { | ||||||
| @ -10,7 +12,7 @@ void furi_hal_delay_init(void) { | |||||||
|     DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; |     DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; | ||||||
|     DWT->CYCCNT = 0U; |     DWT->CYCCNT = 0U; | ||||||
|     clk_per_microsecond = SystemCoreClock / 1000000.0f; |     clk_per_microsecond = SystemCoreClock / 1000000.0f; | ||||||
|     FURI_LOG_I("FuriHalDelay", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void delay_us(float microseconds) { | void delay_us(float microseconds) { | ||||||
|  | |||||||
| @ -6,6 +6,8 @@ | |||||||
| #include <stm32wbxx_ll_cortex.h> | #include <stm32wbxx_ll_cortex.h> | ||||||
| #include <furi.h> | #include <furi.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalI2C" | ||||||
|  | 
 | ||||||
| osMutexId_t furi_hal_i2c_mutex = NULL; | osMutexId_t furi_hal_i2c_mutex = NULL; | ||||||
| 
 | 
 | ||||||
| void furi_hal_i2c_init() { | void furi_hal_i2c_init() { | ||||||
| @ -42,7 +44,7 @@ void furi_hal_i2c_init() { | |||||||
|     LL_I2C_DisableOwnAddress2(POWER_I2C); |     LL_I2C_DisableOwnAddress2(POWER_I2C); | ||||||
|     LL_I2C_DisableGeneralCall(POWER_I2C); |     LL_I2C_DisableGeneralCall(POWER_I2C); | ||||||
|     LL_I2C_EnableClockStretching(POWER_I2C); |     LL_I2C_EnableClockStretching(POWER_I2C); | ||||||
|     FURI_LOG_I("FuriHalI2C", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_hal_i2c_tx( | bool furi_hal_i2c_tx( | ||||||
|  | |||||||
| @ -4,6 +4,8 @@ | |||||||
| #include <main.h> | #include <main.h> | ||||||
| #include <stm32wbxx_ll_tim.h> | #include <stm32wbxx_ll_tim.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalInterrupt" | ||||||
|  | 
 | ||||||
| volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL; | volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL; | ||||||
| volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL; | volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL; | ||||||
| 
 | 
 | ||||||
| @ -22,7 +24,7 @@ void furi_hal_interrupt_init() { | |||||||
|     NVIC_SetPriority(DMA1_Channel1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0)); |     NVIC_SetPriority(DMA1_Channel1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0)); | ||||||
|     NVIC_EnableIRQ(DMA1_Channel1_IRQn); |     NVIC_EnableIRQ(DMA1_Channel1_IRQn); | ||||||
| 
 | 
 | ||||||
|     FURI_LOG_I("FuriHalInterrupt", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) { | void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) { | ||||||
| @ -161,10 +163,10 @@ void TAMP_STAMP_LSECSS_IRQHandler(void) { | |||||||
|     if (LL_RCC_IsActiveFlag_LSECSS()) { |     if (LL_RCC_IsActiveFlag_LSECSS()) { | ||||||
|         LL_RCC_ClearFlag_LSECSS(); |         LL_RCC_ClearFlag_LSECSS(); | ||||||
|         if (!LL_RCC_LSE_IsReady()) { |         if (!LL_RCC_LSE_IsReady()) { | ||||||
|             FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: resetting system"); |             FURI_LOG_E(TAG, "LSE CSS fired: resetting system"); | ||||||
|             NVIC_SystemReset(); |             NVIC_SystemReset(); | ||||||
|         } else { |         } else { | ||||||
|             FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: but LSE is alive"); |             FURI_LOG_E(TAG, "LSE CSS fired: but LSE is alive"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -176,7 +178,7 @@ void RCC_IRQHandler(void) { | |||||||
| void NMI_Handler(void) { | void NMI_Handler(void) { | ||||||
|     if (LL_RCC_IsActiveFlag_HSECSS()) { |     if (LL_RCC_IsActiveFlag_HSECSS()) { | ||||||
|         LL_RCC_ClearFlag_HSECSS(); |         LL_RCC_ClearFlag_HSECSS(); | ||||||
|         FURI_LOG_E("FuriHalInterrupt", "HSE CSS fired: resetting system"); |         FURI_LOG_E(TAG, "HSE CSS fired: resetting system"); | ||||||
|         NVIC_SystemReset(); |         NVIC_SystemReset(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include <furi-hal-light.h> | #include <furi-hal-light.h> | ||||||
| #include <lp5562.h> | #include <lp5562.h> | ||||||
| 
 | 
 | ||||||
|  | #define TAG "FuriHalLight" | ||||||
|  | 
 | ||||||
| #define LED_CURRENT_RED     50 | #define LED_CURRENT_RED     50 | ||||||
| #define LED_CURRENT_GREEN   50 | #define LED_CURRENT_GREEN   50 | ||||||
| #define LED_CURRENT_BLUE    50 | #define LED_CURRENT_BLUE    50 | ||||||
| @ -21,7 +23,7 @@ void furi_hal_light_init() { | |||||||
| 
 | 
 | ||||||
|     lp5562_enable(); |     lp5562_enable(); | ||||||
|     lp5562_configure(); |     lp5562_configure(); | ||||||
|     FURI_LOG_I("FuriHalLight", "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_light_set(Light light, uint8_t value) { | void furi_hal_light_set(Light light, uint8_t value) { | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Anna Prosvetova
						Anna Prosvetova