Black Lives Matter - Action and Equality.
0

How to read iBeacon BLE Advertisements
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to read iBeacon BLE Advertisements

by chjade84 on Mon May 11, 2020 9:42 pm

Is there a good resource for a relative noob in reading the data from BLE iBeacons? Work on it this afternoon go to the point of getting back some data but not in a useful format.

Code: Select all | TOGGLE FULL SIZE
code.py output:
scanning
{255: b"L\x00\x02\x15t'\x8b\xda\xb6DE \x8f\x0cr\x0e\xaf\x05\x995\xff\xe0\xff\xe1\xc5", 1: b'\x06'}

{2: b'\xe0\xff', 9: b'HMSensor\x00\x00\x00\x00\x00', 10: b'\xe9', 22: b'\x00\xb0\x00\x16\x00\x00'}


I feel like there is a library function out there I'm not aware of to turn the raw data into a useful temperature and humidity reading.

This was the code I found to at least make sure I was connecting and to the right thing. Now I just need to turn all ^ that into something useful.

Code: Select all | TOGGLE FULL SIZE
from adafruit_ble import BLERadio
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement


......

ble = BLERadio()
  print("scanning")
  found = set()
  scan_responses = set()
  # By providing Advertisement as well we include everything, not just specific advertisements.
  for advertisement in ble.start_scan(ProvideServicesAdvertisement, Advertisement):
    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.data_dict)
    print()

  print("scan done")

chjade84
 
Posts: 5
Joined: Mon Apr 27, 2020 2:38 pm

Re: How to read iBeacon BLE Advertisements

by tannewt on Tue May 12, 2020 2:08 pm

What beacon are you using?

We don't currently have an iBeacon library. Eddystone is the closest thing we have: https://github.com/adafruit/Adafruit_Ci ... _init__.py

The data structure your printing is advertising packet split by ADT. You can parse the values depending on the iBeacon spec.

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

Re: How to read iBeacon BLE Advertisements

by chjade84 on Tue May 12, 2020 2:14 pm

Hey. Yeah we were just talking about this on Discord. I think I'm just in over my head. I thought the iBeacon protocol was going to be easy to use but it seems not. (and I don't know how to parse the data that is coming back)

Cheap little guys from eBay. https://www.ebay.com/sch/i.html?_from=R ... 5&_sacat=0

chjade84
 
Posts: 5
Joined: Mon Apr 27, 2020 2:38 pm

Please be positive and constructive with your questions and comments.