GithubHelp home page GithubHelp logo

Scanning? about bluepy HOT 7 CLOSED

ianharvey avatar ianharvey commented on July 24, 2024
Scanning?

from bluepy.

Comments (7)

IanHarvey avatar IanHarvey commented on July 24, 2024 1

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.

IanHarvey avatar IanHarvey commented on July 24, 2024

So, the issues that come to mind are -

  1. 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)
  1. 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.

oleiman avatar oleiman commented on July 24, 2024

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.

IanHarvey avatar IanHarvey commented on July 24, 2024

Sorry for being slow - I should have some time to look at it this week.

Thanks
Ian

from bluepy.

OrenLederman avatar OrenLederman commented on July 24, 2024

Any updates on lescan? Can be very useful

from bluepy.

pcborenstein avatar pcborenstein commented on July 24, 2024

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.

ShuffleBox avatar ShuffleBox commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.