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

s130 slave NUS service, No CCCD discovered

Hello,

I am having an working application with S120 and S110; master and slave application. Now I need the master and slave functionality on the same board and using S130 softdevice 1.0.0v and with 9.0 SDK with custom board.

I referred the ble_app_hrs_rscs_relay project and in my application on power up, the device will work in slave mode. I am using NUS service and testing the peripheral activity on the Master Control Panel and getting the error No CCCD discovered, cannot enable services when I try to enable services in MCP.

This is the code snippet to add service and characteristic for peripheral role:

ble_uuid_t        service_uuid;
ble_uuid128_t     base_uuid = BLE_UUID_RES_BASE_UUID;
service_uuid.uuid = 0x0001;

// Initialize the service structure.
p_sos_v->conn_handle             = BLE_CONN_HANDLE_INVALID;
p_sos_v->data_handler            = p_sos_v_init->evt_handler;
p_sos_v->is_notification_enabled = false;

// add custom base UUID
err_code = sd_ble_uuid_vs_add(&base_uuid, &p_sos_v->uuid_type);
if(err_code != NRF_SUCCESS)
 {
 	return err_code;
 }

service_uuid.type = p_sos_v->uuid_type;

// Add the service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                    &service_uuid,
                                    &p_sos_v->service_handle);
if(err_code != NRF_SUCCESS)
 {
 	return err_code;
 }

// Add the RX Characteristic.
err_code = sos_v_rx_characteristic_add(p_sos_v, p_sos_v_init);		// send from slave
if (err_code != NRF_SUCCESS)
{
    return err_code;
}

Characteristic code snippet:

static uint32_t sos_v_rx_characteristic_add(ble_sos_v_t            * p_sos_v,
                                            const ble_sos_v_init_t * p_sos_v_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_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm);

cccd_md.vloc = BLE_GATTS_VLOC_STACK;

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

char_md.char_props.notify = 1;
char_md.char_props.read   = 0;
char_md.char_props.write  = 0;
char_md.char_props.write_wo_resp = 0;
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_sos_v->uuid_type;
ble_uuid.uuid             = BLE_UUID_NUS_RX_CHARACTERISTIC;

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

BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&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  = sizeof(uint8_t);
attr_char_value.init_offs = 0;
attr_char_value.max_len   = BLE_NUS_MAX_RX_CHAR_LEN;

return sd_ble_gatts_characteristic_add(p_sos_v->service_handle,
								 &char_md,
								 &attr_char_value,
								 &p_sos_v->sos_v_rx_handles);
}

Does anyone know the reason for the error in MCP or am I missing any configurations to be done to work with S130?

Regards, Sowmya

Parents Reply Children
No Data
Related