cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG - Unable to advertise 128-bits services

paul19
Associate III

I'm using a X-NUCLEO-BNRG2A1 shield on a NUCLEO-L476RG board.

I am able to advertise 16-bits and 32-bits services using aci_gap_update_adv_data(), but trying with a 128-bits service always ends up with a "BAD PARAMETER" error. What am I missing? (I'm calling aci_gap_update_adv_data() with a single AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST command).

1 ACCEPTED SOLUTION

Accepted Solutions
Winfred LU
ST Employee

Please refer to the ACI document, after BlueNRG GUI is installed, it is located:

file:///C:/Program%20Files%20(x86)/STMicroelectronics/BlueNRG%20GUI%203.2.1/Docs/gui_aci_html/bluenrg_1_v2_x.html

In the description of ACI_GAP_UPDATE_ADV_DATA:

This command can be used to update the advertising data for a particular AD type. If the AD type specified does not exist, then it is added to the advertising data. If the overall advertising data length is more than 31 octets after the update, then the command is rejected and the old data is retained.

Alternately, you may choose to use (SIG standard) HCI instead of ST specific ACI: HCI_LE_SET_ADVERTISING_DATA.

The LE_Set_Advertising_Data command is used to set the data used in advertising packets that have a data field. Only the significant part of the Advertising_Data is transmitted in the advertising packets, as defined in [Vol 3] Part C, Section 11., (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.7)

This way you have 31-byte limit each time, to set the whole data.

The sequences for HCI calls for reference:

  • HCI_LE_Set_Advertising_Parameters()
  • HCI_LE_Set_Advertising_Data()
  • HCI_LE_Set_Scan_Resp_Data()
  • HCI_LE_Set_Advertise_Enable()

View solution in original post

5 REPLIES 5
Winfred LU
ST Employee

There shall be no restriction on the content being advertised.

Could you check the total length of the advertising packets?

Please also check if AD type is configured properly.

paul19
Associate III

@Winfred LU, thanks a lot for your answer.​

It was indeed a length issue. I got the wrong idea that every call to aci_gap_update_adv_data() has its own 31 bytes limit. I was calling aci_gap_update_adv_data() twice and it seems the length added up. I solved the problem by using a scan response.

You advised to "check the total length of the advertising packets", but I found this difficult. Suppose you call aci_gap_set_discoverable() with a name and a list of services, then aci_gap_update_adv_data() several times with more data, where in the ACI library can you see the actual advertisement packet length?

Winfred LU
ST Employee

Please refer to the ACI document, after BlueNRG GUI is installed, it is located:

file:///C:/Program%20Files%20(x86)/STMicroelectronics/BlueNRG%20GUI%203.2.1/Docs/gui_aci_html/bluenrg_1_v2_x.html

In the description of ACI_GAP_UPDATE_ADV_DATA:

This command can be used to update the advertising data for a particular AD type. If the AD type specified does not exist, then it is added to the advertising data. If the overall advertising data length is more than 31 octets after the update, then the command is rejected and the old data is retained.

Alternately, you may choose to use (SIG standard) HCI instead of ST specific ACI: HCI_LE_SET_ADVERTISING_DATA.

The LE_Set_Advertising_Data command is used to set the data used in advertising packets that have a data field. Only the significant part of the Advertising_Data is transmitted in the advertising packets, as defined in [Vol 3] Part C, Section 11., (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.7)

This way you have 31-byte limit each time, to set the whole data.

The sequences for HCI calls for reference:

  • HCI_LE_Set_Advertising_Parameters()
  • HCI_LE_Set_Advertising_Data()
  • HCI_LE_Set_Scan_Resp_Data()
  • HCI_LE_Set_Advertise_Enable()

paul19
Associate III

Thanks, that helps a lot. The important piece here is HCI_LE_Set_Advertise_Enable(), indicating clearly that you have to prepare advertising with multiple commands, before turning it on.

But in my case, starting from ST sample code, HCI_LE_Set_Advertise_Enable() is not used. aci_gap_set_discoverable() seems to be used instead. Am I right? Do you advise against using ACI?

There is no preferable which (HCI or ACI) shall be used.

Just be careful about the differences when using ACI calls.