switchdoclabs / ibeacon-scanner- Goto Github PK
View Code? Open in Web Editor NEWReliable Bluetooth LE (iBeacon) scanner for Raspberry Pi
Reliable Bluetooth LE (iBeacon) scanner for Raspberry Pi
I'm looking at a project very similar to yours-- i'm wondering: what is the scanrate for your scanner? Can it complete a scan on the order of every 1-3 seconds, or is it much longer?
I'm currently using android BLE scanning, and it takes forever-- sometimes 15 seconds! I'm wondering if this is faster.
Hey, first of all let me start by thank you for sharing your code, it's helped me move forward in a project I am working on.
I am writing because I was looking into finding txpower and noticed you commented:
txpower, = struct.unpack("b", pkt[report_pkt_offset -2])
print "\t(Unknown):", txpower
But it's not commented out.
Is txpower really txpower?
Thanks!
Good morning. I use the materials you uploaded usefully. In the meantime, I keep the data of RSSI, MAJOR etc extracted from beacon manually, but do you have any additional code that can automatically extract and store data?
here is the response:
pi@raspberrypi:/Switchdoc_labs $ ls/Switchdoc_labs $ sudo python testblescan.py
ble.py bluetooth init.py osx.py _widcomm.pyd
blescan.py bluez.py msbt.py testblescan.py
blescan.pyc btcommon.py _msbt.pyd widcomm.py
pi@raspberrypi:
Traceback (most recent call last):
File "testblescan.py", line 4, in
import blescan
File "/home/pi/Switchdoc_labs/blescan.py", line 21, in
import bluetooth._bluetooth as bluez
File "/home/pi/Switchdoc_labs/bluetooth/init.py", line 43, in
from .bluez import *
File "/home/pi/Switchdoc_labs/bluetooth/bluez.py", line 6, in
import _bluetooth as _bt
ImportError: No module named _bluetooth
pi@raspberrypi:~/Switchdoc_labs $
Any ideas on what I am doing wrong?
Thanks
root@raspberrypi:/opt/beacon/iBeacon/iBeacon-Scanner-# python testblescanner.py
python: can't open file 'testblescanner.py': [Errno 2] No such file or directory
root@raspberrypi:/opt/beacon/iBeacon/iBeacon-Scanner-# python testblescan.py
Traceback (most recent call last):
File "testblescan.py", line 4, in
import blescan
File "/opt/beacon/iBeacon/iBeacon-Scanner-/blescan.py", line 21, in
import bluetooth._bluetooth as bluez
ImportError: No module named bluetooth._bluetooth
root@raspberrypi:/opt/beacon/iBeacon/iBeacon-Scanner-#
Hi,
I receive the following error when I run it:
ble thread started
Traceback (most recent call last):
File "testblescan.py", line 18, in
blescan.hci_le_set_scan_parameters(sock)
File "/home/pi/blocktrain/test/iBeacon-Scanner-/blescan.py", line 107, in hci_le_set_scan_parameters
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
_bluetooth.error: (9, 'Bad file descriptor')
Any kind of helps will be appreciated!
Thank you.
Hello,
I'm following installation instructions.
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
response is:
--2021-03-04 23:33:58-- http://node-arm.herokuapp.com/node_latest_armhf.deb
Resolving node-arm.herokuapp.com (node-arm.herokuapp.com)... 54.165.0.49, 54.85.152.210, 34.192.43.98, ...
Connecting to node-arm.herokuapp.com (node-arm.herokuapp.com)|54.165.0.49|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-03-04 23:33:58 ERROR 404: Not Found.
Isn't the iBeacon-Scanner supported anymore?
How do we filter specific manufacturer beacon at that time of scanning or before scanning?
currently I filter it after scanning is completed.
My environment is Python on Raspbian.
Any help is highly appreciated.
Thanks.
-------------- ptype: 0x04 event: 0x0f plen: 0x04
what this log mean ?
Hi,
Has anyone met the problem that the 'test.py' script stuck at the line "returnedList = blescan.parse_events(sock, 12)".
Could someone tell me how to solve this problem?
Thank you very much!
Hallo iBeacon BLE reader developers,
for a student demonstration project, I tried to write an updated version of the Bluetooth readout of Sensirion SHT31 beacon (blescan.py) with the modern python bleak package, since the original bluetooth python package is outdated:
import asyncio
from bleak import BleakClient
BLE_DEVICE_MAC_ADDRESS = "E4:A0:36:CA:7B:7E" # BLE_DEVICE_MAC_ADDRESS of the device (beacon)
TEMPERATURE_UUID = "00001234-b38d-4985-720e-0f993a68ee41"
TEMPERATURE_HANDLE = 49
def calculate_temperature(data):
print("temp:", data, type(data))
print("== temp - calc : ", (data / 65536.) * 175. - 45)
async def main(BLE_DEVICE_MAC_ADDRESS):
async with BleakClient(BLE_DEVICE_MAC_ADDRESS) as client:
services = client.services
for service in services:
for char in service.characteristics:
print("--->", char.handle)
if char.handle == TEMPERATURE_HANDLE : # TEMPERATURE_UUID :
char_data = await client.read_gatt_char(char.uuid)
print("temperature raw:", char_data, type(char_data), len(char_data))
temp_data = int.from_bytes(char_data, byteorder='little') # which bytes contain the temperature value?
calculate_temperature(temp_data)
asyncio.run(main(BLE_DEVICE_MAC_ADDRESS))
But I am stuck with the line extracting temp_data, because it is not clear to me, what part of the 4 byte array returning as char_data does really contain the temperature information which could be then converted as described in the documentation to deg. celsius (with the above formula). Could you please help ? Thanks a lot in advance.
I got the beacon result printed on linux (raspbian) terminal through command sudo python testblescan.py , but when I try to run the testblescan.py directly on the python shell (python 2.7.9) then I got an indentation error which I solved by providing right indentation to the code naming another myTestBle.py filename; afterwards, the error is regarding bluez.hci_send_cmd(4 params) from blescan.py file. It seems to me that Bluetooth modules for python is not working on my new raspberry pi 3 . I followed your http://www.raspberry-pi-geek.com/Archive/2014/06/BeaconAir-Track-your-Pi tutorial and many other documents; I installed blueZ 5.39, pybluez 0.22 and all other necessary bluethooth libraries and dependencies; I tried every possible way to deal with this, but, the result is nothing. Maybe I am missing something or I don't have the depth knowledge of this.
@switchdoclabs : I require guidelines and suggestions to solve this issue. I would be obliged for any help from anyone. Thanks in advance.
I get this error python 3.6.3:
ble thread started
Traceback (most recent call last):
File "test_blee.py", line 23, in <module>
returnedList = scan_blee.parse_events(sock, 10)
File "/home/.../blescan.py", line 141, in parse_events
subevent, = struct.unpack("B", pkt[3])
TypeError: a bytes-like object is required, not 'int'
Some data had been change in struct?
Here is the error I get when I run sudo python testblescan.py
ImportError: No module named "bluetooth._bluetooth"
I looked at several of the references, but i cannot find where there is a module that satisfies this import:
import bluetooth._bluetooth as bluez
File "testblescan.py", line 19, in
blescan.hci_enable_le_scan(sock)
File "/home/sagarika/iBeacon-Scanner--master/blescan.py", line 79, in hci_enable_le_scan
hci_toggle_le_scan(sock, 0x01)
File "/home/sagarika/iBeacon-Scanner--master/blescan.py", line 103, in hci_toggle_le_scan
bluez.hci_send_cmd(sock, OGF_LE_CTL, OCF_LE_
_bluetooth.error: (1, 'Operation not permitted')
I think it is better to be as separate question .
so ,I have a question regarding the scan rate ,how exactly the scanner can be set to scan for a certain amount of time and then return the list of found beacons?. In addition can I know what is the parameter loop_count in the function parse_events(sock, loop_count=100) is for? and what does the comment "# The inquiry should last 8 * 1.28 = 10.24 seconds" in the function means and where can be changed in the code?
I would like to scan every 3 sec for 5 sec then return the list of scanned devices. Is that possible with this scanner to be done? .I think the prameters I am looking for to be set are called a scan window (how long to scan) and interval (how long to wait between scans). Any suggestions?
hello
i want to use the scanner as a part of a project, i nee to start and then stop the scanner
how i can stop the scanner without errors ?
I tried finding a better way to contact you, but to no avail. Anyway...
I played with the iBeacon Scanner and got it working on a Raspberry Pi. However, because I've moved to Python3, I had to work with the file a little bit. The Python3 implementation of buffer read/write is different than Python2. I also went in and cleaned up the code so that only the necessary elements remained. That included removing commented code and a slew of unused variables. I left the unused config variables in but commented out. I made it so that the beacon return list doesn't include any duplicates. I also merged the test code into the main file using if name == 'main'
Here's a link to the file hosted in Dropbox so you can give it a look:
https://www.dropbox.com/s/cxck4jnm9nja7y6/blescan.py?dl=0
seem like there is a loop hidden somewhere...
i tried decode the UDID into ASCII but i missed few letters
Hi,
i want to use this code for data scanner. but i don't understand when bluetooth device address pkt[3,9] why other fields getting with negative numbers ??
for instance
pkt[report_pkt_offset -22: report_pkt_offset - 6]
thanks.
This program will hang without receiving advertising when using this test code on the Raspberry Pi 3 B+, with the following updated versions, N.B. bluez-firmware and pi-bluetooth appear to be the key changes:
ii bluez 5.43-2+rpt2+deb9u2 armhf Bluetooth tools and daemons
ii bluez-firmware 1.2-3+rpt6 all Firmware for Bluetooth devices
ii bluez-hcidump 5.43-2+rpt2+deb9u2 armhf Analyses Bluetooth HCI packets
ii libbluetooth-dev 5.43-2+rpt2+deb9u2 armhf Development files for using the BlueZ Linux Bluetooth library
ii libbluetooth3:armhf 5.43-2+rpt2+deb9u2 armhf Library to use the BlueZ Linux Bluetooth stack
ii pi-bluetooth 0.1.8 all Raspberry Pi 3 bluetooth
ii python-bluez 0.22-1 armhf Python wrappers around BlueZ for rapid bluetooth development
To do a workaround, we are using the following steps:
hciconfig hci0 down
hciconfig hci0 up
hcitool lescan
And then running our program in another terminal while the scan is running. When the lescan stops, our code keeps going as long as we don't reopen the hci0 device.
What is happening with the latest update to the Raspberry Pi BLE code and firmware? What is the behavioral change?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.