Comments (7)
If BlueZ provided a .so file with functions I could call, ctypes would be the way to do it. Sadly, it doesn't - things like 'gatttool' are made from a whole load of source files compiled into a monolithic executable. It's difficult to even make this into a useful library because it's based around a GLib 'GMainLoop', which sends callbacks to various handlers when things happen on the Bluetooth socket. For these to work, g_main_loop_run() has to be running continuously, which makes it hard to run Python at the same time...
So, ideally, I might write a pure-Python implementation which talks directly to the kernel on a Bluetooth socket, but that a lot of code to rewrite.
from bluepy.
Thank you very much for the detailed explanation.
I believe the answer might be through the development of an API in close
collaboration with the Bluez project ... Splitting their gattool into
library + exe. Probably something like a btle_initialize() and
btle_finalize() to start and stop the event loop in a separate thread will
have to be introduced in such an API. Or, as you mentioned, a complete
reimplementation of their stuff in pure python. But I wouldn't go down that
road unless the first one looks very ambushed. Let me know if you make some
progress the one way or the other !
On Thu, Mar 13, 2014 at 8:42 AM, Ian Harvey [email protected]:
If BlueZ provided a .so file with functions I could call, ctypes would be
the way to do it. Sadly, it doesn't - things like 'gatttool' are made from
a whole load of source files compiled into a monolithic executable. It's
difficult to even make this into a useful library because it's based around
a GLib 'GMainLoop', which sends callbacks to various handlers when things
happen on the Bluetooth socket. For these to work, g_main_loop_run() has to
be running continuously, which makes it hard to run Python at the same
time...So, ideally, I might write a pure-Python implementation which talks
directly to the kernel on a Bluetooth socket, but that a lot of code to
rewrite.Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-37506991
.
from bluepy.
This is what bluepy should really be doing, IMO. I started a branch a while ago (I'll have to dig it out--it's on another machine) that moves toward making a bluepy shared library. From there, you could create a C application for command-line experimentation (like currently), and direct python support via https://docs.python.org/2/extending/extending.html
from bluepy.
@ryaneleary can you expand a bit what you are doing?
I'm in the (slow) process of refactoring bluepy to have it work in a generic async environment (tornado, twisted, asyncio, etc). Do you think what you are doing is going to help in this direction as well?
from bluepy.
By making a bluepy shared object library, you could create a native python module (a la https://docs.python.org/2/extending/extending.html). This would avoid the pipe-based inter-process communication that bluepy requires currently.
from bluepy.
Why not using the dbus api instead of poking with C code? See api docs (*-api.txt) here https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc
from bluepy.
The dbus API post-dates the original bluepy work, it wasn't available when I started. Also, it's still labelled 'experimental'.
I'm closing this issue now; of all the things I might do with bluepy, rewriting existing functionality is a very low priority.
Thanks
Ian
from bluepy.
Related Issues (20)
- How to get PDU Type?
- Passive scan returns weird connectable
- bluepy-helper crashes HOT 1
- 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
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.