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

Bonding on IOS works but not on Android

Hello,

I have a peripheral based on SDK 9.0. I have tried to follow the peripheral proximity example to get bonding working with the app. The App is currently running in Evothings using nordicble.js.

With the settings configured below for Characteristic Encryption, the peripheral bonds perfectly with IOS devices. Upon first connection IOS prompts with a pairing request, and after you agree the device settings are stored in the Bluetooth paired device list. However, we cannot get the peripheral paired on an Android phone. We get no prompt and no data can be transferred between the phone central and the peripheral. Characteristic add functions are shown below.

Are there other settings elsewhere in the project that need to be modified to make this work? Are our current settings correct for IOS and Android to work properly?

Any guidance would be appreciated.

Thank you!

/**@brief Function for adding send_to_app characteristic.
 *
 */
static uint32_t send_to_app_char_add(ble_qiqi_t * p_qiqi, const ble_qiqi_init_t * p_qiqi_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.read   = 1;
    char_md.char_props.write  = 1;
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = NULL;
    char_md.p_sccd_md         = NULL;
    
    ble_uuid.type = p_qiqi->uuid_type;
    ble_uuid.uuid = QIQI_UUID_SEND_CHAR;
    
    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 1;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid       = &ble_uuid;
    attr_char_value.p_attr_md    = &attr_md;
    attr_char_value.init_len     = 20;
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = 40;
    attr_char_value.p_value      = NULL;
    
    return sd_ble_gatts_characteristic_add(p_qiqi->service_handle, &char_md,
                                               &attr_char_value,
                                               &p_qiqi->send_to_app_char_handles);
}

/**@brief Function for adding the get_from_app characteristic.
 *
 */
static uint32_t get_from_app_char_add(ble_qiqi_t * p_qiqi, const ble_qiqi_init_t * p_qiqi_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&cccd_md, 0, sizeof(cccd_md));

    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm); // This works with iPhone 5/5/2016
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);

    cccd_md.vloc = BLE_GATTS_VLOC_STACK;
    
    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.read   = 1;
    char_md.char_props.notify = 1;
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = &cccd_md;
    char_md.p_sccd_md         = NULL;
    
    ble_uuid.type = p_qiqi->uuid_type;
    ble_uuid.uuid = QIQI_UUID_GET_CHAR;
    
    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&attr_md.write_perm);  // This works with the iPhone 5/5/2016
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);

    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 1;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid       = &ble_uuid;
    attr_char_value.p_attr_md    = &attr_md;
    attr_char_value.init_len     = 20;//sizeof(uint8_t);
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = 40;
    attr_char_value.p_value      = NULL;
    
    return sd_ble_gatts_characteristic_add(p_qiqi->service_handle, &char_md,
                                               &attr_char_value,
                                               &p_qiqi->get_from_app_char_handles);
}
Parents Reply Children
No Data
Related