Comments (7)
As mentioned in issues #70 and issues #81, scanning is now implemented! There are no docs yet, and you still have to be root (or fiddle with /dev/hciXX permissions yourselves).
Cheers
IH
from bluepy.
So, the issues that come to mind are -
- The scan results turn up asynchronously over a period of time (e.g. a couple of a minutes), so you'd need to choose a Pythonic way of presenting this. Options include.
- a call which blocks while it scans, and sends results to a callback object (simple, but blocking is kinda antisocial in many situations)
- a call which starts a thread to deliver scan results to some callback object in the background (except threads are always harder than they look)
- fit it into the asyncio framework (but then it's Python-3 only, not simple for simple things, and dictates the whole structure of your program)
- I need to figure out why 'hcitool lescan' requires root - this seems unreasonable to me. It can probably be fixed with setting permissions on /dev/something appropriately - more research needed.
from bluepy.
Hey Ian,
I've had the opportunity to work on this a bit over the last week. I have a
very simple blocking scanner class in place that scans for a predetermined
period and generates a list of BLE device addresses. Still requires root
access to configure the scan, still not totally sure why.
I basically just pasted the (slightly modified) source for the hcitool
lescan into bluepy-helper.c, sending data back over stdout in the normal
way. The timeout is a little bit hacky, but that scanner loop needs to exit
somehow, otherwise I can't exit the bluepy-helper gracefully. I
guess the whole scan could happen asynchronously in the helper; sounds like
a pain, but might be worth doing.
I doubt this is something worth pushing upstream, but it might be a good
jumping off point. I need this stuff for some demos we're spinning up, so
I'll be poking at it intermittently. Any feedback would be great.
https://github.com/nio-blocks/bluepy/tree/feature/discovery
Thanks,
Oren
EDIT: typo and email response garbage
from bluepy.
Sorry for being slow - I should have some time to look at it this week.
Thanks
Ian
from bluepy.
Any updates on lescan? Can be very useful
from bluepy.
Why does lescan require sudo permission? You must have found a way around it already because you can't connect to a bluetooth device without scanning and finding it.
I've noticed the gatttool can connect to a device without sudo, but hcitool lecc does require sudo. Why is this? I assume answering the first question answers the second too...
from bluepy.
If I remember correctly, if you add your user to the lp group, you should be able to. (Edit for clarity: should be able to access the bluetooth device in that manner. I'm not sure about the implementation of scanning with bluepy)
I didn't look to find the reason it's wired up to that group, but that was the solution when I was accessing a bluetooth adaptor as a regular user on Raspbian (raspberry pi2). Worth a shot.
from bluepy.
Related Issues (20)
- Sampling frequency HOT 6
- thon3
- BluePy not compatible with Python 3.10 or newer
- Multiple Instances of a single Service
- Reading Accelerometer Data from SensorTag CC2650
- Try to use timeout HOT 4
- getting temperature data
- unable to make it work on Python 3.7.3
- Failed to connect to peripheral <my mac address>, addr type: random HOT 4
- Select a host Bluetooth device (the one that starts the connection) HOT 7
- ResourceWarning: unclosed file <_io.TextIOWrapper name=6 encoding='UTF-8'>
- Infinite timeout
- HCI Selection Failure HOT 1
- Help! Loaded everything but doesn't see the camera.
- Unable to set connection parameters and advertasing parameters Thingy:52
- Bluepy and Bookworm HOT 6
- Can't connect to any peripherals with Bluetooth adapter hci1
- te
- get_services.py: unable to generate uuids.json
- Timeout too large exception in btle.py when system time jumps due to NTP correction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluepy.