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

Is there anything wrong with my value characteristic initiation function?

Hello, please refer to the below code, in particular, did I get the cccd handle right?

static uint32_t mesh_value_char_add(void)
{
/* BLE GATT metadata */
  ble_gatts_attr_md_t cccd_md;
memset(&cccd_md, 0, sizeof(cccd_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);//set to 1
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);//set to 1
cccd_md.vloc = BLE_GATTS_VLOC_STACK;

	ble_gatts_char_md_t ble_char_md;

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

ble_char_md.char_props.read = 1;
ble_char_md.char_props.notify = 1;


ble_char_md.p_char_pf = NULL;
ble_char_md.p_cccd_md = &cccd_md;
ble_char_md.p_char_user_desc = NULL;
ble_char_md.p_user_desc_md = NULL;

	ble_char_md.char_props.write_wo_resp = 1;
ble_char_md.char_props.write = 1;//*

		ble_char_md.p_char_user_desc = NULL;
ble_char_md.p_user_desc_md = NULL;

	ble_gatts_attr_md_t ble_attr_md;

memset(&ble_attr_md, 0, sizeof(ble_attr_md));
	
	ble_attr_md.read_perm.lv = 1;
ble_attr_md.read_perm.sm = 1;
ble_attr_md.write_perm.lv = 1;
ble_attr_md.write_perm.sm = 1;
	
	
ble_attr_md.rd_auth = 1;//*
ble_attr_md.wr_auth = 1;//*
ble_attr_md.vlen = 1;
	ble_attr_md.vloc = BLE_GATTS_VLOC_STACK;
	


//ble_char_md.char_props.auth_signed_wr =1;



/* ble characteristic UUID */
ble_uuid_t ble_uuid;

ble_uuid.type = m_mesh_base_uuid_type;
ble_uuid.uuid = MESH_VALUE_CHAR_UUID;

/* ble attribute */
ble_gatts_attr_t ble_attr;
uint8_t default_value = 0;

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

ble_attr.init_len = 1;
ble_attr.init_offs = 0;
ble_attr.max_len = sizeof(mesh_gatt_evt_t);
ble_attr.p_attr_md = &ble_attr_md;
ble_attr.p_uuid = &ble_uuid;
ble_attr.p_value = &default_value;

/* add to service */
uint32_t error_code = sd_ble_gatts_characteristic_add(
        m_mesh_service.service_handle,
        &ble_char_md,
        &ble_attr,
        &m_mesh_service.ble_val_char_handles);

if (error_code != NRF_SUCCESS)
{
    return NRF_ERROR_INTERNAL;
}

return NRF_SUCCESS;
}

Is there any problem? I want an open link with the lowest security, enable notification and read and write.

I also have an meta data characteristic, although I'm not exactly sure what it's for.

Parents Reply Children
No Data
Related