cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 WB55 Nucleo BLE: How to use indicate instead of notify.

Matthew Shaw
Associate II

I am trying to use the indication property instead of the notification property based on the heart rate example for the WB55. I have modified the gatt characteristic to advertise an indication. I have the android I am connecting to sending a CCCD to which it gets a successful response. I then try to send my indication.

To send an indication instead of a notification I believe I have to use: aci_gatt_update_char_value_ext function. I am unsure of the parameters required and there seems to be no up to date documentation for this function that includes all parameters. I know that my notification call works that looks like so:

result = aci_gatt_update_char_value(aTemplateContext.TemplateSvcHdle, //Service Handle
									 aTemplateContext.TemplateNotifyServerToClientCharHdle, //Char Handle
									  0, /* Value offset */
									  TEST_PAYLOAD_LENGTH, /* value length */
									 (uint8_t *)  pPayload); //Value

But my call to the extended function returns an INVALID_PARAMS error:

result = aci_gatt_update_char_value_ext(connectionHandle, //Conn_Handle_To_Notify
    				aTemplateContext.TemplateSvcHdle, //Service_Handle
					aTemplateContext.TemplateNotifyServerToClientCharHdle, //Char_Handle
					0x02, //Update_Type: Indication??
					2, //Char_Length
					0, //Value_Offset
					TEST_PAYLOAD_LENGTH, //Value_Length
					(uint8_t *)  pPayload); //Value

I am particularly concerned about the params not included in the original call: Connection handle, Update type and Char length.

Connection handle I have passed from app_ble.c during the connection calls. This feels hacky but it should in theory work as long as the handle doesn’t change.

The update type doesn’t seem well documented but I found one source which suggested it be set to 0x02 to mean indication.

The char length I don’t understand at all. No documentation for this exists. This is separate from payload/value length and we shouldn’t have to report the length of the characteristic UUID in this send? If anyone knows what this is I’d be grateful, the only example I found online has this set as a magic number to 1.

Anyone who can either point me to up to date documentation or a working example would also be appreciated.

3 REPLIES 3
Matthew Shaw
Associate II

I modified the Char length to be that of the payload length.

  		result = aci_gatt_update_char_value_ext(connectionHandle, //Conn_Handle_To_Notify
    				aTemplateContext.TemplateSvcHdle, //Service_Handle
					aTemplateContext.TemplateNotifyServerToClientCharHdle,//Char_Handle
					0x02, //Update_Type: Indication??
					TEST_PAYLOAD_LENGTH+5, //Char_Length
					0, //Value_Offset
					TEST_PAYLOAD_LENGTH, //Value_Length
					(uint8_t *)  pPayload); //Value

I’m not entirely sure that this is correct but the error I am receiving has changed from INVALID_PARAMS to BLE_STATUS_NOT_ALLOWED. Seems like the parameters are probably more correct now but I can’t find any explanation for the “NOT_ALLOWED�? error. Any ideas are welcome. The android is receiving the data being sent to it which is promising but I’m not convinced that I’m reliably sending the data as our calculated drop rate is still extremely high. I'm concerned that maybe the CCCD step hasn't been initiated correctly or something to that effect?

Matthew Shaw
Associate II

I aded the call to a loop that reattempts the send in a while loop until the message is sent successfully.

result = BLE_STATUS_FAILED;
    		while(result != BLE_STATUS_SUCCESS)
    		{
				result = aci_gatt_update_char_value_ext(connectionHandle,//Conn_Handle_To_Notify
						aTemplateContext.TemplateSvcHdle, //Service_Handle
						aTemplateContext.TemplateNotifyServerToClientCharHdle,//Char_Handle
						0x02, //Update_Type: Indication??
						TEST_PAYLOAD_LENGTH, //Char_Length
						0, //Value_Offset
						TEST_PAYLOAD_LENGTH, //Value_Length
						(uint8_t *)  pPayload); //Value
    		}

This has the effect of limiting my dropped packets but my throughput is considerably lowered. At full blast I can stream notifications at 18KBps, now with indications I am only getting 2KBps. Is this normal or are the errors slowing down my streaming?

Does the error BLE_STATUS_NOT_ALLOWED indicate that I am not allowed to send another BLE message yet? I wouldn’t have expected it to cut my throughput by a factor of 9.

Any advice or inormation on this would be appreciated. Next I will try to use a WRITE that requires an acknowledgement and compare with indications.

Aware that I am responding to this after 2 years, but could act as a reference to the other users who end up here:

The API Documentation is available in 2 places:

  1. STM32WB Bluetooth® Low Energy (BLE) wireless interface (AN5270) (Pg. 119 in Rev. 9)
  2. Almost similar info is available in the header file: ble_gatt_aci.h

The Conn_Handle_To_Notify can be set to 0 to connect to the connected clients.

I also have not yet had a complete success with this implementation. There is a confusion in Char_Length and Value_Length which I am yet to resolve.

Value_Length parameter is a 8 bit param. And the doc mentions that the length should be mentioned in octets so it should be 2 if the data is an array of characters.

Will update if I am able to resolve it.