Best config. BLE Nimble Host for pairing and bonding smartphones.

manfre90
Posts: 3
Joined: Sun Dec 04, 2022 3:27 pm

Best config. BLE Nimble Host for pairing and bonding smartphones.

Postby manfre90 » Wed Dec 21, 2022 11:19 am

Hi everyone,
I'm just trying to figuring out which is the best conf and sync_cb if in my application I want to pair with Android/iOs smartphones.

This is my configuration for the secure manager.

Code: Select all

ble_hs_cfg.sm_io_cap = 0;
ble_hs_cfg.sm_bonding = 1;
ble_hs_cfg.sm_our_key_dist   = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;  
ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
ble_hs_cfg.sm_mitm = 1;
ble_hs_cfg.sm_sc = 1;
This is my sync call back

Code: Select all

ble_hs_id_infer_auto(0, &addr_type);

uint8_t addr_val[6];
    ble_hs_id_copy_addr(&addr_type, addr_val, NULL);  
    printf("\033[0;36m");
    printf("Smartkey (host) address:\n");
        for (int j = 0; j < 6; j++) {
         printf("\033[0;36m");
         printf("%x ",addr_val[j]);         
      } 
    printf("\n");
    
    advertise();
This lead me to an addr_type: 0. Public and static. But i've got problem managing:
- When I unpair client side (Smarphone) and not server side (ESP32) --> it kind recognise the smartphone but can't get encryption status change = 0.
- When I unpair server side (ESP32) (for this I've got a button which perform ble_store_clear() ) and not client side (Smartphone) --> First connection r/w over an encrypted gatt fails, the second connection will be ok.

Thanks for your help.

Who is online

Users browsing this forum: Bing [Bot] and 247 guests