Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

BLE Broadcast help needed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BLE Broadcast help needed

by AndSar on Fri Feb 28, 2020 2:32 pm

Hi, sorry for the off-topic but I no longer have "permission" to open a new (second) support ticket ...

I'm testing the BLE broadcast on a Feather nRF52840 Express (sender):

https://github.com/adafruit/Adafruit_Ci ... pletest.py

and this script on a Circuit Playground Bluefruit (receiver):

https://github.com/adafruit/Adafruit_Ci ... ed_scan.py

It's all right, but from the Circuit Playground Bluefruit, I can't print the received temperature.

I know it is still under development, including the documentation ...

Who can help me?

THANK YOU

AndSar
 
Posts: 16
Joined: Wed Mar 07, 2018 9:50 am

Re: BLE Broadcast help needed

by danhalbert on Fri Feb 28, 2020 2:47 pm

[I tested your permissions, and you should be able to create a new topic. It might have been in the wrong subforum, which might have caused an error. In any case, I split off your reply into a separate topic.]

It's all right, but from the Circuit Playground Bluefruit, I can't print the received temperature.


Could you give more details about what is and is not working?

danhalbert
 
Posts: 1966
Joined: Tue Aug 08, 2017 12:37 pm

Re: BLE Broadcast help needed

by AndSar on Sat Feb 29, 2020 3:08 am

danhalbert thanks for your time!

1. Feather nRF52840 Express send:

<AdafruitSensorMeasurement temperature=24.0 >

2. Circuit Playground Bluefruit via print("\t" + repr(advertisement)) receives and prints:

.Advertisement(data=b"\x0e\xff\x22\x08\x06\x04\x0a\x00\x00\xa0\x41\x03\x03\x00\x03")
.Advertisement(data=b"\x02\x0a\x00\x0e\x09\x43\x49\x52\x43\x55\x49\x54\x50\x59\x33\x65\x34\x39")


Now, how do I decode the advertisement to take the temperature value which is 24.0?

THANKS AGAIN

AndSar
 
Posts: 16
Joined: Wed Mar 07, 2018 9:50 am

Re: BLE Broadcast help needed

by tannewt on Mon Mar 02, 2020 8:32 pm

Hi AndSar, when starting the scan provide the AdafruitSensorMeasurement class as the first argument:

Code: Select all | TOGGLE FULL SIZE
for measurement in ble.start_scan(adafruit_ble_broadcastnet.AdafruitSensorMeasurement):


If that doesn't work, then please post your scanning code. Thanks!

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

Re: BLE Broadcast help needed

by AndSar on Tue Mar 03, 2020 4:26 am

Hi tannewt,
I edited your https://github.com/adafruit/Adafruit_Ci ... ed_scan.py
it seems to work!

Code: Select all | TOGGLE FULL SIZE
from adafruit_ble import BLERadio

from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
import adafruit_ble_broadcastnet

ble = BLERadio()
print("scanning")
found = set()
scan_responses = set()

for advertisement in ble.start_scan(adafruit_ble_broadcastnet.AdafruitSensorMeasurement):
    addr = advertisement.address
    if advertisement.scan_response and addr not in scan_responses: scan_responses.add(addr)
    elif not advertisement.scan_response and addr not in found: found.add(addr)
    else: continue

    print(advertisement.temperature)

print("scan done")


One last thing, is there a specific method / attribute (or "while True", but where to put it?) to scan and receive the advertisement (temperature) every 30 seconds?

THANK YOU VERY MUCH!

AndSar
 
Posts: 16
Joined: Wed Mar 07, 2018 9:50 am

Re: BLE Broadcast help needed

by tannewt on Tue Mar 03, 2020 1:46 pm

We don't really have examples of scanning off and on because you will likely miss advertisements then. You can do this though with something like:

Code: Select all | TOGGLE FULL SIZE
while True:
  for advertisement in ble.start_scan(adafruit_ble_broadcastnet.AdafruitSensorMeasurement):
    ...
  ble.stop_scan()
  time.sleep(30)

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

Re: BLE Broadcast help needed

by AndSar on Tue Mar 03, 2020 2:31 pm

PERFECT, tannewt THANKS AGAIN!

AndSar
 
Posts: 16
Joined: Wed Mar 07, 2018 9:50 am

Please be positive and constructive with your questions and comments.