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

Adding scan response gives invalid flags

I see this quote in response to a question asking for examples on how to code a scan response

possibly not - but it's trivial - just encode the scan response in the same way you encode the advertising data and then add the encoded data to the p_sr_data and srdlen of the sd_ble_gap_adv_data_set(). Or if you're using the Advertising and Scan Response encoder library, one layer higher, the unencoded data into the last argument of ble_adv_data_set()p_srdata, if if you're using the entire advertising module, ble_advertising_init() with a non-NULL p_srdata second paramter.

Trivial it aint!!! Well at least regardless of what I place in the scan response I get invalid flags unless the scan response is empty.

Its a scannable advertsiement!

adv_properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;

Then there is this very confusing statement in the documentation:

The format of the advertising data will be checked by this call to ensure interoperability.
* Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
* duplicating the local name in the advertising data and scan response data.

I assumed what this means is that I duplicate the flags setting done in the advertisement and the friendly name setting in the advertisement. This is all I do and the advertisement alone works but when I add the scan response INVALID FLAGS!  Go figure. It doesn't seem to matter what I pit in there I get the same result

SO PLEASE

Provide an example that WORKS for a connectable peripheral.

Using the advertisement alone I have several Androids whose LeScanner (Lollipop +) do NOT report certain advertisements generated by the Nordic nRF52... dongle. Changing the NAME in the advertisement makes it detectable. I have only seen this behavior with ads generated by the Nordic chip (no market device I have worked with has that problem. I am beginning to think it has something to do with the messed up scan response from the Nordic. Sniffers DO detect the ads. I know Android needs to have a response to a scan request so I am trying desperately to generate one.

Here is the contents of the advertisement and scan response data

Advertisement 02, 01, 06, 0A, 09, 42, 70, 54, 69, 6D, 65, 4F, 6E, 65, 07, 03, 10, 18, 0A, 18, 05, 18
Scan Response 02, 01, 06, 0A, 09, 42, 70, 54, 69, 6D, 65, 4F, 6E, 65
Failed to set advertisement data. Error code: invalid flags

Parents Reply
  • I guess it is best to ignore the note. I have checked on the air and the advertisement and scan response are what I expect given how I have populated it. And I DO duplicate the name in both. So that is clearly not an issue. Might I suggest that the Note say the both the adv and scan response are limited to 31 bytes? The rest of the text makes no sense and is not even true as I can duplicate the name.

Children
No Data
Related