0

Is it possible to use BLE advertisement type ADV_NONCONN_IND
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Is it possible to use BLE advertisement type ADV_NONCONN_IND

by andreas_johnsen on Wed Mar 31, 2021 4:48 pm

Hei,

Is it possible to use BLE advertisement type ADV_NONCONN_IND (non-connectable, non-scannable, undirected) with CircuitPython?

I can switch between ADV_IND (connectable, scannable, undirected) and ADV_SCAN_IND (non-connectable, scannable, undirected) by setting the attribute 'connectable' of an Advertisement object to 'True' or 'False'. But haven't figured out if it is possible to use ADV_NONCONN_IND with CP.

In the source code of 'def start_advertising()' in https://github.com/adafruit/Adafruit_Ci ... _init__.py it look like there always will be a 'scan_response' before 'self._adapter.start_advertising()' is called. If none scan_reponse is passed as parameter to 'start_advertising()', one will be created before calling the adapter.

I'm using nRF52840 Dongle with CP ver 6.0.1

andreas_johnsen
 
Posts: 11
Joined: Sun Apr 19, 2020 1:42 pm

Re: Is it possible to use BLE advertisement type ADV_NONCONN

by tannewt on Thu Apr 01, 2021 5:30 pm

The core can do it: https://github.com/adafruit/circuitpyth ... ter.c#L647

I think the library won't let you pass an empty scan_response. Changing this line to this would allow it:

Code: Select all | TOGGLE FULL SIZE
if scan_response is None and len(advertisement_bytes) <= 31:


Want to try it and make a PR if it works? That'd allow you to pass `scan_response=b""`

tannewt
 
Posts: 2349
Joined: Thu Oct 06, 2016 8:48 pm

Re: Is it possible to use BLE advertisement type ADV_NONCONN

by andreas_johnsen on Fri Apr 02, 2021 3:09 pm

Thank you very much for the suggestion. I will try to make a PR if it works as intended.

andreas_johnsen
 
Posts: 11
Joined: Sun Apr 19, 2020 1:42 pm

Please be positive and constructive with your questions and comments.