Git Product home page Git Product logo

Comments (9)

ukBaz avatar ukBaz commented on September 25, 2024 1

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.

ukBaz avatar ukBaz commented on September 25, 2024 1

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:

self.bus.add_signal_receiver(self._interfaces_added,
dbus_interface=constants.DBUS_OM_IFACE,
signal_name='InterfacesAdded')
self.bus.add_signal_receiver(self._interfaces_removed,
dbus_interface=constants.DBUS_OM_IFACE,
signal_name='InterfacesRemoved')
self.bus.add_signal_receiver(self._properties_changed,
dbus_interface=dbus.PROPERTIES_IFACE,
signal_name='PropertiesChanged',
arg0=constants.DEVICE_INTERFACE,
path_keyword='path')

from python-bluezero.

ukBaz avatar ukBaz commented on September 25, 2024 1

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.

xzZero avatar xzZero commented on September 25, 2024 1

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.

xzZero avatar xzZero commented on September 25, 2024

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.

xzZero avatar xzZero commented on September 25, 2024

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.

ukBaz avatar ukBaz commented on September 25, 2024

For the unwanted pairing request on ios, could it be the following issue?
#336

from python-bluezero.

xzZero avatar xzZero commented on September 25, 2024

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.

xzZero avatar xzZero commented on September 25, 2024

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)

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.