This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

iMAC connects automatically after disconnecting a BLE device

A bit more detailed:
A bug has been detected on the device under development. It is connected with the fact that if you try to disconnect a connected device on an iMAC Catalina, then it automatically reconnects.
On Android, this works well.
 
To exclude my mistakes I used an example from nordic HID_KEYBOARD. But it has the same problem.
In the example, I disabled

init.config.ble_adv_directed_high_duty_enabled = false;
init.config.ble_adv_directed_enabled = false;

Included logs received the following:

00> <info> ble_bas: Battery notification has been sent using conn_handle: 0x0000
00> <info> app: Disconnected
00> <info> app: m_whitelist_peer_cnt 2, MAX_PEERS_WLIST 8
00> <debug> app: pm_whitelist_get returns 1 addr in whitelist and 1 irk whitelist
00> <info> app: Fast advertising with whitelist.
00> <debug> peer_manager_handler: Event PM_EVT_BONDED_PEER_CONNECTED
00> <debug> peer_manager_handler: Previously bonded peer connected: role: Peripheral, conn_handle: 0, peer_id: 0
00> <debug> peer_manager_handler: Event PM_EVT_CONN_SEC_PARAMS_REQ
00> <debug> peer_manager_handler: Security parameter request
00> <debug> peer_manager_handler: Event PM_EVT_PEER_DATA_UPDATE_SUCCEEDED
00> <debug> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
00> <debug> peer_manager_handler: Event PM_EVT_LOCAL_DB_CACHE_APPLIED
00> <debug> peer_manager_handler: Previously stored local DB applied: conn_handle: 0, peer_id: 0
00> <info> app: Connected
00> <debug> peer_manager_handler: Event PM_EVT_CONN_SEC_START


But the problem remained the same. In addition, I tried to reset the pointer to p_peer_addr and disable whitelist, it did not help.
I don’t understand something or is it an iMAC problem?
Thanks!

Parents
  • What if the problem is in the connection settings?

    Maybe the device is too tempting to connect?

    #define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000)  
    #define NEXT_CONN_PARAMS_UPDATE_DELAY    APP_TIMER_TICKS(30000) 
    #define MAX_CONN_PARAMS_UPDATE_COUNT     3                     
    
    static void conn_params_error_handler(uint32_t nrf_error)
    {
        APP_ERROR_HANDLER(nrf_error);
    }
    
    static void conn_params_init(void)
    {
        ret_code_t             err_code;
        ble_conn_params_init_t cp_init;
    
        memset(&cp_init, 0, sizeof(cp_init));
    
        cp_init.p_conn_params                  = NULL;
        cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
        cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
        cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
        cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
        cp_init.disconnect_on_fail             = false;
        cp_init.evt_handler                    = NULL;
        cp_init.error_handler                  = conn_params_error_handler;
        
        err_code = ble_conn_params_init(&cp_init);
        APP_ERROR_CHECK(err_code);
    }

Reply
  • What if the problem is in the connection settings?

    Maybe the device is too tempting to connect?

    #define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000)  
    #define NEXT_CONN_PARAMS_UPDATE_DELAY    APP_TIMER_TICKS(30000) 
    #define MAX_CONN_PARAMS_UPDATE_COUNT     3                     
    
    static void conn_params_error_handler(uint32_t nrf_error)
    {
        APP_ERROR_HANDLER(nrf_error);
    }
    
    static void conn_params_init(void)
    {
        ret_code_t             err_code;
        ble_conn_params_init_t cp_init;
    
        memset(&cp_init, 0, sizeof(cp_init));
    
        cp_init.p_conn_params                  = NULL;
        cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
        cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
        cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
        cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
        cp_init.disconnect_on_fail             = false;
        cp_init.evt_handler                    = NULL;
        cp_init.error_handler                  = conn_params_error_handler;
        
        err_code = ble_conn_params_init(&cp_init);
        APP_ERROR_CHECK(err_code);
    }

Children
No Data
Related