Fix GUI freeze after NFC classic read (#1074)
* nfc worker: add delay for task switching * device info service: fix rpc version characteristic * firmware: move FreeRTOSConfig.h to target include * dev_info service: fix typo * ble glue: use osThreadFlags instead of osEventFlags * Infrared: fix issue with timer lockup * FuriHal: yeld in flash lock routine * ble: change connection parameters, display actual params * ble: verify connection parameters * ble: fix typo Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -24,7 +24,6 @@ typedef struct {
|
||||
osMutexId_t hci_mtx;
|
||||
osSemaphoreId_t hci_sem;
|
||||
FuriThread* thread;
|
||||
osEventFlagsId_t event_flags;
|
||||
} BleApp;
|
||||
|
||||
static BleApp* ble_app = NULL;
|
||||
@@ -39,7 +38,6 @@ bool ble_app_init() {
|
||||
// Allocate semafore and mutex for ble command buffer access
|
||||
ble_app->hci_mtx = osMutexNew(NULL);
|
||||
ble_app->hci_sem = osSemaphoreNew(1, 0, NULL);
|
||||
ble_app->event_flags = osEventFlagsNew(NULL);
|
||||
// HCI transport layer thread to handle user asynch events
|
||||
ble_app->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(ble_app->thread, "BleHciDriver");
|
||||
@@ -108,15 +106,14 @@ void ble_app_get_key_storage_buff(uint8_t** addr, uint16_t* size) {
|
||||
|
||||
void ble_app_thread_stop() {
|
||||
if(ble_app) {
|
||||
osEventFlagsSet(ble_app->event_flags, BLE_APP_FLAG_KILL_THREAD);
|
||||
osThreadId_t thread_id = furi_thread_get_thread_id(ble_app->thread);
|
||||
furi_assert(thread_id);
|
||||
osThreadFlagsSet(thread_id, BLE_APP_FLAG_KILL_THREAD);
|
||||
furi_thread_join(ble_app->thread);
|
||||
furi_thread_free(ble_app->thread);
|
||||
// Wait to make sure that EventFlags delivers pending events before memory free
|
||||
osDelay(50);
|
||||
// Free resources
|
||||
osMutexDelete(ble_app->hci_mtx);
|
||||
osSemaphoreDelete(ble_app->hci_sem);
|
||||
osEventFlagsDelete(ble_app->event_flags);
|
||||
free(ble_app);
|
||||
ble_app = NULL;
|
||||
memset(&ble_app_cmd_buffer, 0, sizeof(ble_app_cmd_buffer));
|
||||
@@ -125,9 +122,9 @@ void ble_app_thread_stop() {
|
||||
|
||||
static int32_t ble_app_hci_thread(void* arg) {
|
||||
uint32_t flags = 0;
|
||||
|
||||
while(1) {
|
||||
flags = osEventFlagsWait(
|
||||
ble_app->event_flags, BLE_APP_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
flags = osThreadFlagsWait(BLE_APP_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
if(flags & BLE_APP_FLAG_KILL_THREAD) {
|
||||
break;
|
||||
}
|
||||
@@ -142,7 +139,9 @@ static int32_t ble_app_hci_thread(void* arg) {
|
||||
// Called by WPAN lib
|
||||
void hci_notify_asynch_evt(void* pdata) {
|
||||
if(ble_app) {
|
||||
osEventFlagsSet(ble_app->event_flags, BLE_APP_FLAG_HCI_EVENT);
|
||||
osThreadId_t thread_id = furi_thread_get_thread_id(ble_app->thread);
|
||||
furi_assert(thread_id);
|
||||
osThreadFlagsSet(thread_id, BLE_APP_FLAG_HCI_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user