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

some problem with ble connection process

In the right process,like this:

but my program is :

i lost “Sent Read By Group Type Request, GATT Primary Service Declaration, Handles: 0x0001..0xffff” .

in the wireshark,some service dont be find. But in the nrf_connect i can find all service and the relevant functions are in normal use.

Did I make a mistake?this is my code

uint32_t ble_service_2_init(ble_service_2_t * p_service_2, const ble_service_2_init_t * p_service_2_init)
{
//uint32_t err_code;
//ble_uuid128_t ble_uuid;

// Initialize service structure
p_service_2->evt_handler = p_service_2_init->evt_handler;
p_service_2->conn_handle = BLE_CONN_HANDLE_INVALID;
//p_service_2->feature = p_service_2_init->feature;
p_service_2->max_len = MAX_SERVICE_2_DAT_LEN;


ble_uuid_t service_uuid;
uint32_t err_code;
// Add service
BLE_UUID_BLE_ASSIGN(service_uuid, BLE_UUID_SERVICE_2);

err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &p_service_2->service_handle);
if (err_code != NRF_SUCCESS)
{
return err_code;
}

p_service_2->uuid_type = service_uuid.type;


err_code = service_2_measurement_char1_add(p_service_2, p_service_2_init);
if (err_code != NRF_SUCCESS)
{
return err_code;
}


err_code = service_2_recv_char1_add(p_service_2, p_service_2_init);
if (err_code != NRF_SUCCESS)
{
return err_code;
}


return NRF_SUCCESS;
}

static uint32_t service_2_measurement_char1_add(ble_service_2_t * p_service_2, const ble_service_2_init_t * p_service_2_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;
ble_service_2_dat_t initial_pedo;
uint8_t encoded_pedo[MAX_SERVICE_2_DAT_LEN];

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

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
cccd_md.write_perm = p_service_2_init->service_2_meas_attr1_md.cccd_write_perm;

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

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_BLE_ASSIGN(ble_uuid, BLE_UUID_SERVICE_2_SND_CHAR1);
ble_uuid.type = p_service_2->uuid_type;
#if 0
ble_uuid_t service_uuid;
uint32_t err_code;

//BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_PUBLIC_SND_CHAR);
service_uuid.uuid = BLE_UUID_PUBLIC_SND_CHAR;
err_code = sd_ble_uuid_vs_add(&service_2_base_uuid128, &(service_uuid.type));
if (err_code != NRF_SUCCESS)
{
return err_code;
}
#endif
memset(&attr_md, 0, sizeof(attr_md));

attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm = p_service_2_init->service_2_meas_attr1_md.read_perm;
attr_md.write_perm = p_service_2_init->service_2_meas_attr1_md.write_perm;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen = 1;

memset(&attr_char_value, 0, sizeof(attr_char_value));
memset(&initial_pedo, 0, sizeof(initial_pedo));

attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = service_2_measurement_encode(p_service_2, &initial_pedo, encoded_pedo);
attr_char_value.init_offs = 0;
attr_char_value.max_len = MAX_SERVICE_2_DAT_LEN;
attr_char_value.p_value = encoded_pedo;

return sd_ble_gatts_characteristic_add(p_service_2->service_handle,
&char_md,
&attr_char_value,
&p_service_2->meas1_handles);
}

static uint32_t service_2_recv_char1_add(ble_service_2_t * p_service_2, const ble_service_2_init_t * p_service_2_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;
ble_service_2_dat_t initial_pedo;
uint8_t encoded_pedo[MAX_SERVICE_2_DAT_LEN];

#if 1
memset(&char_md, 0, sizeof(char_md));

//char_md.char_props.write= 1;
char_md.char_props.write_wo_resp = 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;
#endif

BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SERVICE_2_RECV_CHAR1);
ble_uuid.type = p_service_2->uuid_type;
#if 0
ble_uuid_t service_uuid;
uint32_t err_code;

//BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_PUBLIC_RECV_CHAR);
service_uuid.uuid = BLE_UUID_PUBLIC_RECV_CHAR;
err_code = sd_ble_uuid_vs_add(&service_2_base_uuid128, &(service_uuid.type));
if (err_code != NRF_SUCCESS)
{
return err_code;
}
#endif

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

attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm.sm = 0;//p_service_2_init->service_2_meas_attr_md.read_perm;
attr_md.read_perm.lv = 0;//p_service_2_init->service_2_meas_attr_md.read_perm;
attr_md.write_perm.sm = 1;//p_service_2_init->service_2_meas_attr_md.write_perm;
attr_md.write_perm.lv = 1;//p_service_2_init->service_2_meas_attr_md.write_perm;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen = 1;

memset(&attr_char_value, 0, sizeof(attr_char_value));
memset(&initial_pedo, 0, sizeof(initial_pedo));

attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = service_2_measurement_encode(p_service_2, &initial_pedo, encoded_pedo);
attr_char_value.init_offs = 0;
attr_char_value.max_len = MAX_SERVICE_2_DAT_LEN;
attr_char_value.p_value = encoded_pedo;

return sd_ble_gatts_characteristic_add(p_service_2->service_handle,
&char_md,
&attr_char_value,
&p_service_2->recv1_handles);
}

  • Are you talking about the "Received Error Response - Attribute Not Found, Handle 0x000a"?

    That's a normal response when there are no more entries in the ATtribute Table during a service discovery. In your case there are no more entries from handle 0xa and onwards. 

  • hi,haakonsh. i talking about"Sent Read By Group Type Request, GATT Primary Service Declaration". I'm talking about is my program doesn't have that.

  • i use iphone test,the Android dont has this problem

  • It's a normal response to a service discovery read request when there's no attribute present in the attribute table within the given range of handles that are requested. 

    The traces you've marked in red are both working, what exactly are your symptoms?