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

Notify - Not updating in MCP

I'm running: SDK 7.1, PCA10028 eval board, SD310 2.0.1, MCP 3.8.0.7

I'm trying to get Notifications to work. I have two attributes. I write to one and have it update the value of the second, which then is set to Notify the Central (in this case Nordic's MCP).

I connect, discover and enable services. When I write to the first attribute, the write works. I then call sd_ble_gatts_hvx(...), no errors are returned (err_code == 0); The value for the second attribute remains unchanged in the MCP. However if I read the attribute from the MCP it returns the updated value.

I turn on LED on my dev board when I get a BLE_EVT_TX_COMPLETE - this event never occurs, if I don't read the second attribute. Read the attribute, the BLE_EVT_TX_COMPLETE event will occur, but sometimes takes several seconds.

After the BLE_EVT_TX_COMPLETE event I can not write or read anything from the peripheral device.

What am I doing wrong?

Code: Set up of attribute that Notifies the Central. Note, I only enable notify, but I can still read it from the MCP

    char_md.char_props.notify 			= 1;
		
    char_md.char_props.write  			= 1;
	char_md.char_props.write_wo_resp 	= 1;
		

	char_md.char_user_desc_max_size  	= sizeof("Batt");
	char_md.char_user_desc_size 			= sizeof("Batt");
    char_md.p_char_user_desc    			= (uint8_t *)char_user_desc;
    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;

Code To Notify The Central:

uint16_t				d_len;
ble_gatts_hvx_params_t	reset_param;
uint32_t				err_code;

d_len = 1;
reset_param.handle 	= p_blinds->pwr_batt_cap_handles.value_handle;
reset_param.type   	= BLE_GATT_HVX_NOTIFICATION;
reset_param.p_len 	= &d_len;
reset_param.p_data 	= buf;
reset_param.offset 	= 0;
err_code = sd_ble_gatts_hvx(p_blinds->conn_handle, &reset_param);

Do I need to do anything else? Thanks, Clint

Parents Reply Children
  • Stian - Did you enable notifications in MCP? - Yes, I've written to the CCCD handle manually, and used the MCP's Enable Services Button. MCP shows: CharacteristicConfigurationsBits: Notification (0x0001)

  • My code to initialize cccd_md:

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&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.write  	 = 1;
    char_md.char_props.write_wo_resp = 1;
    char_md.char_user_desc_max_size  = sizeof("Batt");
    char_md.char_user_desc_size 	 = sizeof("Batt");
    char_md.p_char_user_desc    	 = (uint8_t *)char_user_desc;
    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_blinds->uuid_type;
    ble_uuid.uuid = PWR_BATT_CAP_UUID;
    
    memset(&attr_md, 0, sizeof(attr_md));
    
Related