Comments (9)
I don't have time to look at this in detail right now. However I did a project that had four buttons and needed to know which one was activated. Take a look and let me know if you have questions still.
Be warned, it doesn't use Bluezero
https://ukbaz.github.io/howto/proj_big_btn.html
from python-bluezero.
OK, I'm not sure I understand the question.
The code can see what devices are connected
using the org.bluez.Device1
interface on D-Bus ObjectManager
.
The org.bluez.GattCharacteristic
interface has a notifying
property that is True, if notifications or indications on the characteristic are currently enabled.
The setup is that the GATT server doesn't know which device it needs to notified. It just does the notification and the connected
and notifying
properties define if that device gets a notification.
Examples of monitoring changes in interfaces or properties are at:
python-bluezero/bluezero/adapter.py
Lines 91 to 103 in 2b0aba8
from python-bluezero.
I have taken a look at the BlueZ issue you linked to and it seems similar to:
bluez/bluez#153
This looks like it is something more fundamental than a Bluezero issue so I'm not sure that I can help.
I'm not sure how actively issues on the BlueZ github repo are monitored. You might be better raising this on the BlueZ Slack http://www.bluez.org/contact/
from python-bluezero.
The re-pairing/re-bonding pop up is because the iOS device I connected to has less secure method (legacy bonding or no Man-In-The-Middle MITM). The solution is to disable LE Secure Connection btmgmt sc off
(https://lore.kernel.org/all/[email protected]/T/) and use encrypt-
flags.
Thank you so much @ukBaz for your wonderful support.
from python-bluezero.
Thanks for your quick reply and suggestion. As far as I know, in your project the device runs the python script is the GATT client, thus, it knows which GATT server (the Button) or address (with Dbus path) it writes to or gets notified from. What I want to achieve is in the opposite direction, where the GATT server knows the address of the GATT client to notify.
from python-bluezero.
Sorry for the unclear question. I think you got it correctly, I want to design a GATT Server that it knows the address of which devices that use the read, write and notify methods. Thanks to bluez, for read and write methods, this can be done with options
argument, but there's no such thing like that for notify. That's why I wonder if there's another way to do this.
At first, I wanted to go with LE Secure Connection paring/bonding by using secure-
flags (secure-read
, secure-write
) for characteristics and authenticating the connections with a customized agent similar to simple-agent. However, I caught an issue that the pairing/bonding dialog would pop up everytime the client in iOS tries to issue a connection to the GATT Server (in Raspberry Pi 4) even if the client and the server was successfully bonded and the long term key was generated in the previous bonding/pairing. I raised an issue with bluez here.
Because of this, I decided to go with unauthenticated connection (without using paring/bonding) and applied an additional software encryption on top of the unauthenticated connection. The GATT server has a characteristic used for authentication (encrypted passcode for example). Whenever a right passcode is written to the server via this characteristic, the client will be able to access other characteristics. To sum up, I want to design a filter to prevent those clients that are not in the whitelist to access the server, which leads to the question I raised above.
Thanks for your time and constructive comments. Please let me if you know how to resolve the problem with the unexpected LE Secure Connection pairing/bonding dialog.
from python-bluezero.
For the unwanted pairing request on ios, could it be the following issue?
#336
from python-bluezero.
No, in #336 the pairing dialog is sent repeatedly, and I already fixed it by disabling the battery plugin. But this issue is different, the pairing/bonding dialog would pop up just like 2 devices have never been paired, even if they was successfully paired. When I tracked down the btmon trace, the exchange of the Long Term Key was successful, but somehow the iOS device still requested for a new pairing. This also happens when I manually advertised a characteristic with secure-write
and secure-read
flags (the same issue happens also for encrypt-
flags) in bluetoothctl
. To avoid duplicates, could you have a look at this?
from python-bluezero.
Thanks for suggestions, I'll try to raise the issue on bluez Slack.
An interesting thing that I figured out recently is that the Local Signature Key and Remote Signature Key weren't generated for the iOS device despite the successful pairing/bonding and being able to connect and send/receive packets from each other. Below is the content of the info
from /var/lib/bluetooth/<adapter address>/<remote device address>/info
Android:
[IdentityResolvingKey]
Key=99FE463029B3757BA52B3CF1CBF3DE21
[RemoteSignatureKey]
Key=7B2A1EDD02692198D0E2696ED0AC7FC4
Counter=0
Authenticated=true
[LocalSignatureKey]
Key=4D30B0B91F4A8F3B26DFEA9212E16FC3
Counter=0
Authenticated=true
[SlaveLongTermKey]
Key=32D173B88A2AF7B31FDD72AF2B0B9982
Authenticated=3
EncSize=16
EDiv=0
Rand=0
[General]
Name=
AddressType=public
SupportedTechnologies=LE;
Trusted=false
Blocked=false
[ServiceChanged]
CCC_LE=2
iOS:
[IdentityResolvingKey]
Key=BE56BC749F700F69C9B7C90EC59A3C87
[SlaveLongTermKey]
Key=B42A588FEB434F2937F6696519C0FD4D
Authenticated=3
EncSize=16
EDiv=0
Rand=0
[General]
Name=
AddressType=public
SupportedTechnologies=LE;
Trusted=false
Blocked=false
[ServiceChanged]
CCC_LE=2
from python-bluezero.
Related Issues (20)
- Disabling BlueZ request to pair with central on connect. HOT 5
- AttributeError: module 'bluezero.async_tools' has no attribute 'EventLoop' HOT 9
- Tests failing and blocking release HOT 1
- Can't install dbus-python to use bluezero HOT 3
- Error "dbus.exceptions.DBusException: org.bluez.Error.NotAvailable: Operation currently not available" on central HOT 8
- using class methods as callbacks fails for writes HOT 2
- Method to determinate current/negotiated MTU for connection HOT 7
- Documentation about PIN on pairing HOT 6
- Name a service and a characteristic HOT 1
- Advertisment of peripheral HOT 3
- Unable to set `DiscoverableTimeout` HOT 2
- What is srv_id 0 zero? HOT 1
- Enable services changed on Generic Attribute service HOT 1
- Wait notification functionality feature HOT 2
- Setting Manufacturer data in Advertiser only works if data is less than 3 bytes long HOT 4
- How to show Txpower in advertisement data HOT 12
- How to add Flags inside Advertising Data? HOT 7
- How to use btmgmt_sync.send('AddAdvertising', ...) HOT 1
- Passing a 'flags' dictionary to 'write_value' in GATT.py ends in exception HOT 12
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 python-bluezero.