[FL-3264] Various stop mode fixes (#2584)
* BleGlue: log hci_cmd_resp invocation * BleGlue: increase BleHciDriver stack size * ble hid app: increase stack * ble: comment unnecessary hci reset * BleGlue: stricter checks in communication with core2, cleanup code * Furi: enter insomnia when executing from RAM --------- Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
		@@ -68,7 +68,7 @@ static const APPD_GpioConfig_t aGpioConfigList[GPIO_CFG_NBR_OF_FEATURES] = {
 | 
			
		||||
    {GPIOA, LL_GPIO_PIN_0, 0, 0}, /* END_OF_CONNECTION_EVENT - Set on Entry / Reset on Exit */
 | 
			
		||||
    {GPIOA, LL_GPIO_PIN_0, 0, 0}, /* TIMER_SERVER_CALLBACK - Toggle on Entry */
 | 
			
		||||
    {GPIOA, LL_GPIO_PIN_4, 1, 0}, /* PES_ACTIVITY - Set on Entry / Reset on Exit */
 | 
			
		||||
    {GPIOB, LL_GPIO_PIN_2, 1, 0}, /* MB_BLE_SEND_EVT - Set on Entry / Reset on Exit */
 | 
			
		||||
    {GPIOC, LL_GPIO_PIN_0, 1, 0}, /* MB_BLE_SEND_EVT - Set on Entry / Reset on Exit */
 | 
			
		||||
    /* From v1.3.0 */
 | 
			
		||||
    {GPIOA, LL_GPIO_PIN_0, 0, 0}, /* BLE_NO_DELAY - Set on Entry / Reset on Exit */
 | 
			
		||||
    {GPIOA, LL_GPIO_PIN_0, 0, 0}, /* BLE_STACK_STORE_NVM_CB - Set on Entry / Reset on Exit */
 | 
			
		||||
 
 | 
			
		||||
@@ -137,38 +137,33 @@ static int32_t ble_app_hci_thread(void* arg) {
 | 
			
		||||
// Called by WPAN lib
 | 
			
		||||
void hci_notify_asynch_evt(void* pdata) {
 | 
			
		||||
    UNUSED(pdata);
 | 
			
		||||
    if(ble_app) {
 | 
			
		||||
        FuriThreadId thread_id = furi_thread_get_id(ble_app->thread);
 | 
			
		||||
        furi_assert(thread_id);
 | 
			
		||||
        furi_thread_flags_set(thread_id, BLE_APP_FLAG_HCI_EVENT);
 | 
			
		||||
    }
 | 
			
		||||
    furi_check(ble_app);
 | 
			
		||||
    FuriThreadId thread_id = furi_thread_get_id(ble_app->thread);
 | 
			
		||||
    furi_assert(thread_id);
 | 
			
		||||
    furi_thread_flags_set(thread_id, BLE_APP_FLAG_HCI_EVENT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hci_cmd_resp_release(uint32_t flag) {
 | 
			
		||||
    UNUSED(flag);
 | 
			
		||||
    if(ble_app) {
 | 
			
		||||
        furi_semaphore_release(ble_app->hci_sem);
 | 
			
		||||
    }
 | 
			
		||||
    furi_check(ble_app);
 | 
			
		||||
    furi_check(furi_semaphore_release(ble_app->hci_sem) == FuriStatusOk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hci_cmd_resp_wait(uint32_t timeout) {
 | 
			
		||||
    UNUSED(timeout);
 | 
			
		||||
    if(ble_app) {
 | 
			
		||||
        furi_semaphore_acquire(ble_app->hci_sem, FuriWaitForever);
 | 
			
		||||
    }
 | 
			
		||||
    furi_check(ble_app);
 | 
			
		||||
    furi_check(furi_semaphore_acquire(ble_app->hci_sem, timeout) == FuriStatusOk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ble_app_hci_event_handler(void* pPayload) {
 | 
			
		||||
    SVCCTL_UserEvtFlowStatus_t svctl_return_status;
 | 
			
		||||
    tHCI_UserEvtRxParam* pParam = (tHCI_UserEvtRxParam*)pPayload;
 | 
			
		||||
 | 
			
		||||
    if(ble_app) {
 | 
			
		||||
        svctl_return_status = SVCCTL_UserEvtRx((void*)&(pParam->pckt->evtserial));
 | 
			
		||||
        if(svctl_return_status != SVCCTL_UserEvtFlowDisable) {
 | 
			
		||||
            pParam->status = HCI_TL_UserEventFlow_Enable;
 | 
			
		||||
        } else {
 | 
			
		||||
            pParam->status = HCI_TL_UserEventFlow_Disable;
 | 
			
		||||
        }
 | 
			
		||||
    furi_check(ble_app);
 | 
			
		||||
    svctl_return_status = SVCCTL_UserEvtRx((void*)&(pParam->pckt->evtserial));
 | 
			
		||||
    if(svctl_return_status != SVCCTL_UserEvtFlowDisable) {
 | 
			
		||||
        pParam->status = HCI_TL_UserEventFlow_Enable;
 | 
			
		||||
    } else {
 | 
			
		||||
        pParam->status = HCI_TL_UserEventFlow_Disable;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -289,8 +289,6 @@ static void gap_init_svc(Gap* gap) {
 | 
			
		||||
    tBleStatus status;
 | 
			
		||||
    uint32_t srd_bd_addr[2];
 | 
			
		||||
 | 
			
		||||
    // HCI Reset to synchronise BLE Stack
 | 
			
		||||
    hci_reset();
 | 
			
		||||
    // Configure mac address
 | 
			
		||||
    aci_hal_write_config_data(
 | 
			
		||||
        CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, gap->config->mac_address);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user