Git Product home page Git Product logo

python-bluezero's People

Contributors

a-krawciw avatar akvadrako avatar alexisgeoffrey avatar boardend avatar btashton avatar chadrockey avatar cotsog avatar eliotlandrum avatar fahirahd avatar freedreamer82 avatar ispite avatar jojo134 avatar joshbaran avatar kratz00 avatar markuspiotrowski avatar mdxs avatar mr499 avatar philsippl avatar tonystark-jr avatar ts-kris avatar tyten avatar ukbaz avatar waynekeenan avatar xloem avatar yoko-chance avatar yotabits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-bluezero's Issues

Typo in method name _pin_pwn_control

The method should be called _pin_pwm_control and not pw**n** as it is currently.

https://github.com/ukBaz/python-bluezero/blob/master/bluezero/microbit.py#L432

This would be a great simple pull request opportunity for anyone wanting to get involved with the project (or maybe just someone that wanted to practice doing a pull-request)

You will need to:

  • Fork the repository.
  • Make the fix.
  • Submit a pull request to the project

Some tutorials that might be helpful are:
https://guides.github.com/activities/forking/
https://help.github.com/articles/fork-a-repo/
https://opensource.com/life/16/3/submit-github-pull-request

gatt.py is not generic

There is code in the gatt.py that is there for only example/read_battery.py.

It even uses the KEYS_SVC_UUID for the battery service. :-(

app.add_device_name('BluezeroLight') fails

Traceback (most recent call last):
File "/home/pi/pycharm.projects/bluezero/examples/level10/light_switch.py", line 99, in
app.add_device_name('BluezeroLight')
File "/home/pi/pycharm.projects/bluezero/bluezero/peripheral.py", line 183, in add_device_name
self.dongle.alias(device_name)
TypeError: 'dbus.String' object is not callable

Bluetooth LE on a Pi3 running Raspbian - How to get it working

Prior to the May'16 Raspbian release with the 4.4 Kernel (which needs the steps below applied) my last 'known good' versions were:

https://downloads.raspberrypi.org/raspbian/images/raspbian-2016-02-29/2016-02-26-raspbian-jessie.zip
sudo rpi-update 692dde0c1586f7310301379a502b9680d0c104fd
BlueZ: 5.39

To get the GATT advertising working on the latest Raspian I had to make a few tweaks involving:

  • Installing and patching Bluez 5.39 with a set of Pi kernel maintainers patches for the Pi3
  • config.txt settings
  • Running the bluezero examples with sudo (which I didn't think was necessary before)

Note: This will let the example work and 'hciconfig' shows a 'real' MAC address as opposed to an address of AA:AA:AA:AA:AA,which is a symptom of the hciattach issue. However, running show in bluetootctrl shows No default controller available - so something is still not quite right.

Patch BlueZ source

Obtain the BlueZ source, I've tested with 5.39.

cd bluez-5.39
wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
unzip 3b07a1eb296862da889609a84f8e10b299b7442d.zip
git apply  -v c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d/*

You should see:

Checking patch tools/hciattach.c...
Applied patch tools/hciattach.c cleanly.
Checking patch tools/hciattach_bcm43xx.c...
Applied patch tools/hciattach_bcm43xx.c cleanly.
Checking patch tools/hciattach.c...
Applied patch tools/hciattach.c cleanly.
Checking patch tools/hciattach_bcm43xx.c...
Applied patch tools/hciattach_bcm43xx.c cleanly.

Then configure, compile and install BlueZ as per the bluezero instructions found here

config.txt

For reference, this is my entire /boot/config.txt which includes some commented out lines tried whilst investigating, things worked better without them in the end.

dtparam=audio=on
lcd_rotate=2
start_x=1
gpu_mem=128
framebuffer_width=1280
framebuffer_height=720
#core_freq=250
#enable_uart=1
#dtoverlay=pi3-miniuart-bt

Peripheral name of blinkt_ble example not being resolved until after first connect

When trying to connect to the Blinkt peripheral with the Blinkt central the name is not being resolved until after the first connection.

Enabling NameResolving in the /etc/bluetooth/main.conf on the Raspberry Pi that is the central device seemed like it would do the correct thing although it didn't.

# Enable name resolving after inquiry. Set it to 'false' if you don't need
# remote devices name and want shorter discovery cycle. Defaults to 'true'.
NameResolving = true

The name on the peripheral RPi is set in the etc/bluetooth/main.conf file

On the second connection to the peripheral it has been cached by BlueZ and works as expected

"Failed to register advertisement" when running "cpu_temperature.py"

@ukBaz I installed Bluez 5.43 on Raspberry Pi 3 following the instructions. There are two issues happening.

First, the status shown below has the error messages (last three lines):

May 11 23:06:45 raspberrypi bluetoothd[6575]: Bluetooth daemon 5.43
May 11 23:06:45 raspberrypi systemd[1]: Started Bluetooth service.
May 11 23:06:45 raspberrypi bluetoothd[6575]: Bluetooth management interface 1.9 initialized
May 11 23:06:45 raspberrypi bluetoothd[6575]: Failed to obtain handles for "Service Changed" characteristic
May 11 23:06:45 raspberrypi bluetoothd[6575]: Not enough free handles to register service
May 11 23:06:45 raspberrypi bluetoothd[6575]: gatt-example-adapter-driver: Input/output error (5)

Second, after I run "cpu_temperature.py" and connected the Raspberry Pi with a central (e.g., smartphone app), everything works correctly. However, once I stoped the python script and tries to run it again, then I get the following error message:

CPU temperature is 51.5C
b'\x1e\x14'
Failed to register advertisement: org.bluez.Error.Failed: Failed to register advertisement

Any idea how I could fix these issues? Appreciate it.

Interacting with a MIPOW PLAYBULB Flameless Candle

There are various tutorials on the internet about how to interact over BLE with the above devices.
The two that I have used for reference are:
http://colinkraft.com/candle/candle.php
https://codelabs.developers.google.com/codelabs/candle-bluetooth/#0

To summarize this appear to be the API:

CANDLE_SERVICE_UUID = 0xFF02
CANDLE_DEVICE_NAME_UUID = 0xFFFF
CANDLE_COLOR_UUID = 0xFFFC
CANDLE_EFFECTS_UUID = 0xFFFB
Flashing = [0x00, r, g, b, 0x00, 0x00, 0x1F, 0x00]
Candle = [0x00, r, g, b, 0x04, 0x00, 0x01, 0x00]
Pulse = [0x00, r, g, b, 0x01, 0x00, 0x09, 0x00]
Rainbow = [0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00]
Rainbow Fade = [0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x26, 0x00]
Effects off = [0x00, r, g, b, 0x05, 0x00, 0x01, 0x00]

Standard:

Battery Service 	= 0x180F
Battery Level Characteristic=  0x2A19

The candle can be 'blown out'. I'm not sure how this is detected.

dbus module missing in the setup.py

Obviously, bluezero needs dbus (adapter.py has an import dbus). This should be in the dependency list in the setup.py so that installing bluezero pulls the right dependencies together.

What versions of Python to specify in Travis-CI

Have had problems getting tests to run with Python 3.3 & 3.4 as I need the virtual environment.

Commented out for now. Need to have a think as to what versions to test with and revisit.

Should pypy version be included?

Support Characteristic Presentation Format descriptor (0x2904)

This descriptor is composed of five parts: format, exponent, unit, name space and description. The Format field determines how a single value contained in the Characteristic Value is formatted. The types of format supported are:

Format Short Name Description Exponent Value
0x00 rfu Reserved for future use No
0x01 boolean unsigned 1 - bit; 0 = false, 1 = true No
0x02 2bit unsigned 2 - bit integer No
0x03 nibble unsigned 4 - bit integer No
0x04 uint8 unsigned 8 - bit integer Yes
0x05 uint12 unsigned 12 - bit integer Yes
0x06 uint16 unsigned 16 - bit integer Yes
0x07 uint24 unsigned 24 - bit integer Yes
0x08 uint32 unsigned 32 - bit integer Yes
0x09 uint48 unsigned 48 - bit integer Yes
0x0A uint64 unsigned 64 - bit integer Yes
0x0B uint128 unsigned 128 - bit integer Yes
0x0C sint8 signed 8 - bit integer Yes
0x0D sint12 signed 12 - bit integer Yes
0x0E sint16 signed 16 - bit integer Yes
0x0F sint24 signed 24 - bit integer Yes
0x10 sint32 signed 32 - bit integer Yes
0x11 sint48 signed 48 - bit integer Yes
0x12 sint64 signed 64 - bit integer Yes
0x13 sint128 signed 128 - bit integer Yes
0x14 float32 IEEE - 754 32 - bit floating point No
0x15 float64 IEEE - 754 64 - bit floating point No
0x16 SFLOAT IEEE - 11073 16 - bit SFLOAT No
0x17 FLOAT IEEE - 11073 32 - bit FLOAT No
0x18 duint16 IEEE - 20601 format No
0x19 utf8s UTF - 8 string No
0x1A utf16s UTF - 16 string No
0x1B struct Opaque structure No

This means that numbers need to be presented correctly to the dbus ReadValue and also converted from WriteValue. My proposal is to have a series of utility functions like the following:

def int_to_dbus_uint16(value):
    as_bytes = value.to_bytes(
        (value.bit_length() // 8) + 1, byteorder='little')
    return_val = []
    for byte in as_bytes:
        return_val.append(dbus.Byte(byte))
    return return_val

Change style guide checker from pep8 to pycodestyle

pycodestyle is a tool to check Python code against some of the style conventions in PEP 8.
This package used to be called pep8 but was renamed to pycodestyle to reduce confusion.

Update install instructions and travis setup to use this new package.

How to implement secure characteristic?

Hello.
In my project I'd like to create GATT service with some characteristics.
And i want to make them secure (ask pairing to access them). Unsecure characteristics works fine.
Is it Possible ?
I have tried some flags in localGATT.Characteristic function - ['read', 'notify','secure'] , ['secure read', 'notify']...
No one works.
Is it possible to create secure characteristics by your framework ?

Thank you

Connection ":1.5" is not allowed to own the service

I am trying to run fatbeacon.py and I get this error. Ideas?

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.5" is not allowed to own the service "ukBaz.bluezero" due to security policies in the configuration file

Unable to run fatbeacon example

I have downloaded bluezero from github (main), and also installed bluez 5.42 from source.

When I run sudo python fatbeacon.py, I get:

ERROR:dbus.connection:Unable to set arguments (u'/ukBaz/bluezero/advertisement0000', {}) according to signature None: <type 'exceptions.ValueError'>: Unable to guess signature from an empty dict
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 604, in msg_reply_handler
    reply_handler(*message.get_args_list(**get_args_opts))
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 401, in _introspect_reply_handler
    self._introspect_execute_queue()
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 387, in _introspect_execute_queue
    proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 137, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 584, in call_async
    message.append(signature=signature, *args)
ValueError: Unable to guess signature from an empty dict
GATT application registered

What could be the cause?

Thanks

Travis CI tests failing

The travis CI virtual environment seems to have changed and tests are not working.

Complaining about "ImportError: No module named dbus" on python 2.7

Failing earlier on python 3.3 with pep8 issue

Python Threads don't run - patch for fix included

It's not possible for Python threads to run in the background without adding this:

diff --git a/bluezero/peripheral.py b/bluezero/peripheral.py
index 64bb8d0..4ae3cc0 100644
--- a/bluezero/peripheral.py
+++ b/bluezero/peripheral.py
@@ -48,6 +48,8 @@ class FailedException(dbus.exceptions.DBusException):

 class Application(dbus.service.Object):
     def __init__(self):
+        GObject.threads_init()
+        dbus.mainloop.glib.threads_init()
         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
         self.mainloop = GObject.MainLoop()
         self.bus = dbus.SystemBus()

Use "".format rather than %

Ensure the code is consistent in the formatting statements used. Hopefully the title is self explanatory.

Web Bluetooth fails on characteristic write

A write to characteristic causes this error:

ERROR:dbus.service:Unable to append (None,) to message with signature v: <class 'TypeError'>: Don't know which D-Bus type to use to encode type "NoneType"

Bluezero retrospective

I feel this repository/library is at a watershed moment. As there are a number people showing some level of interest I wanted to inform and hopefully get feedback on where I think we need to go next.

Building BlueZ from source

Having to build BlueZ from source is putting people off. Even though the steps are documented it doesn’t fit with the desired goal of making Bluetooth accessible.
The main Linux platforms we have been using have OSes based on Debian and Debian’s next version (Stretch) is going to have BlueZ 5.43 as the default.

It’s all about DBus

When I started this library I hadn’t quite appreciated how much it was going to be about DBus. The information at the bottom this link https://www.freedesktop.org/wiki/Software/DBusBindings/ says that python-dbus shouldn’t be used for new applications. Of the list it suggests, it appears pydbus is the most appropriate for this project.
This issue LEW21/pydbus#20 did seem like it was going to cause an issue. However it appears that Debian Stretch has a new enough version of GLib that it is OK.
Using pydbus removes the need for a lot of code that has been created in the Bluezero library such as adapter.py, device.py and GATT.py

Testing

Testing and coverage metrics have never really been enabled on this library. There are a number of reasons behind this mainly based around restrictions of installing libraries on Travis and the usability of dbusmock library.
Not having a usable test strategy for this library is a big (unresolved) issue!

Going forward

Get ready for the release of Debian Stretch:

  • Switch from using python-dbus to pydbus.
  • Focus on BlueZ 5.43

This leaves the big issue as testing and probably the area where I would most appreciate people's input.
The ideal would to get something working that would allow testing on Travis. I believe because of python3-gi package then that limits us to running with Python 3.2 on Travis. Python 3.2 is a problem with the coverage utilities.
One possible solution is to use a container system like Docker on Travis.
Let’s assume we can fix the python3-gi/Travis issue with containers, then that leaves the issue of how to mock DBus calls as there will be no real Bluetooth hardware.
Should effort be put into dbusmock https://github.com/martinpitt/python-dbusmock or look at mocking this a different way?

The other option is to turn away from Travis and mocking and set up actual hardware for automating testing locally that uses real Bluetooth links. This could be Linux to Linux or even Linux to micro:bit with scripts that gets feedback over the network or USB from the remote device.
The downside with this is that it is a barrier to other people contributing.

Unable to set arguments ('/ukBaz/bluezero/advertisement0000', {})

Getting this error. Raspberry Pi is up to date and using bluez 5.45.

ERROR:dbus.connection:Unable to set arguments ('/ukBaz/bluezero/advertisement0000', {}) according to signature None: <class 'ValueError'>: Unable to guess signature from an empty dict
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 604, in msg_reply_handler
reply_handler(*message.get_args_list(**get_args_opts))
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 401, in _introspect_reply_handler
self._introspect_execute_queue()
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 387, in _introspect_execute_queue
proxy_method(*args, **keywords)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 137, in call
**keywords)
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 584, in call_async
message.append(signature=signature, *args)
ValueError: Unable to guess signature from an empty dict

Notify when writing to characteristic

I need to emulate a peripheral with my rpi, so I've installed a demo board and written some code starting from blinkt_ble.py.
To test I'm using an iOS app. I can enable notification on my characteristic and I can write on it.
If I change value from code my iOS app receive the notification, if I write to characteristic from my iOS app I get notified of the new value.
Now I need to do something with this value on python side.
I've tried to add a callback to my characteristic and after a lot of tries I've understood how to receive bytes when a write a value on it.
Following your example, I've created a class to receive the callback and associated with something like this:

bleIstance.myCharacteristic.add_call_back(CBIstance.receivingFunction).
Now inside "receivingFunction" I can find my bytes with "bytes = args[1]["Value"]"

Everything perfect, but in this way my iOS doesn't receive any notification so I cannot update the value on screen.
I've checked the sourcecode but I'm not so experienced in python/dbus/ble, I suppose that with this callback I'm preventing the dbus notification to be sent.
If I comment out the callback all works normally.

Any idea on how to fix this?

Now I'm updating bluez to 5.45 to see if it fix something (also to fix #127 )

BlueZero on a Pi 3

Hi,

I am fairly sure I have followed all the various instructions here but I am still getting

Traceback (most recent call last):
File "microbit_button.py", line 15, in
from bluezero import constants
ImportError: No module named bluezero

Bluetooth status gives

● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Sun 2017-02-05 19:29:02 UTC; 8min ago
Docs: man:bluetoothd(8)
Main PID: 694 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─694 /usr/libexec/bluetooth/bluetoothd

Which means it's running (right?)

bluetoothctl
[bluetooth]# [NEW] Controller B8:27:EB:AA:9F:FF CosmicPi05 [default]
[bluetooth]# version
Version 5.43

Bit of a newbie question. Any ideas?

Is there a set of uptodate consolidated instructions?

Thanks

Cosma

Slow performance

I am using the blinkt_ble as a template for a high thoughput GATT service. I am doing a speed test and I am getting about 2 "writes" a second. I need about 50. Is there something in localGatt or blinkt to speed up how fast it can process incoming characteristic writes? Thanks.

make bytes code work for python2 and python3

In peripheral.py we have this for Python3
self.value = array.array('B', bytes(name, encoding='utf-8'))
and this for python2
self.value = array.array('B', bytes(name))
Investigate how this can be coded so it works for both versions of Python

add bluez build and install instructions to README or INSTALL

One day this hopefully wont't be necessary, but for now it would be good to have a recipe on how to setup the bleeding edge bluez.

So for example, this is what I have in my notes (for Raspian Jessie) but needs tweaking (specifically, i'm not convinced I've got all the paths in the configure step covered and I can't remember why I really disabled cups, maybe just to speed up build time / remove some dependancies).

I've added this as a suggested documentation request that really needs validation by a second pair of eyes; rather than a tried and tested pull requested of a rigorously tested recipe (although I've done it dozens of times now :) )

Install build and install dependancies:

sudo apt-get install libglib2.0-dev libdbus-1-dev libical-dev libusb-1.0-0.dev libreadline-dev checkinstall

Download and Configure source build

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.39.tar.xz
tar xf bluez-5.39.tar.xz
cd bluez-5.39

./configure \
        --libdir=/lib \
        --libexec=/lib \
        --enable-experimental \
        --disable-cups 

make -j 4

The -j 4 will perform a concurrent build using all 4 cores, if you have them :)

Perform an install

This is performed as a removable debian package as opposed to make install which does a blind file copy that is hard to remove.

sudo systemctl stop bluetooth
sudo checkinstall

The check install step will prompt for some user input, I think I have a defaults file somewhere, but it's not too onerous todo manually as many values are automatically and sensibly defaulted (some being saved to disk)
The bonus is you get a *.deb file too. This file /shouldn't/ really be passed around, but it might work on other Pi's :)

Enable the experimental option when the daemon starts

sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/' /lib/systemd/system/bluetooth.service

Light the blue touch paper...

sudo systemctl daemon-reload && sudo systemctl restart bluetooth && sudo systemctl status bluetooth
sudo hciconfig hci0 up
hciconfig

Light can't be switched remotely

The value of the 'switch' characteristic can be read by the central device.
However it doesn't seem to be updated from the central device.

Using HCI connection to Linux kernel

During the various discussions on #126 it was raised about experimenting with using the HCI interface directly to the kernel.

If this library takes that route I would like to see if this can be done within Python rather than depend on other libraries and C bindings.

import socket
sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
sock.bind((0,))
my_bytes = bytearray()
my_bytes.append(0)
my_bytes.append(4)
sock.send(my_bytes)

Gives the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument

Any suggestions on what I'm doing wrong?

How to implement micro:bit event service

Do you have any sample code how to implement bluetooth event service on micro:bit?

I have added these functions with the necessary UUID for the event service (event ID 100, event value 0), but it didn't work.

def event_config(self):
        self.event_client_req_characteristic_iface.WriteValue([100, 0], ())


    def _event_notify_cb(self):
        print('Event subscribed!!!')
        return 1

    def subscribe_event(self, user_callback):
        btn_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                     self.event_characteristic_path)
        btn_iface = tools.get_dbus_iface(constants.DBUS_PROP_IFACE,
                                         btn_obj)
        btn_iface.connect_to_signal('PropertiesChanged',
                                    user_callback)
        btn_obj.StartNotify(reply_handler=self._event_notify_cb,
                            error_handler=tools.generic_error_cb,
                            dbus_interface=constants.GATT_CHRC_IFACE)

Can't write characteristic value from iPhone

HI, thank you very much for the sharing.

I am building a application between RPi 3 and iPhone(iPhone is central), all the things are good, but when I try to write the value of characteristic using function:
[self.selectPeripheral writeValue:data forCharacteristic:self.selectCharacteristic type:CBCharacteristicWriteWithResponse];

It can not go through and the ERROR description is below:
ERROR:dbus.service:Unable to append (None,) to message with signature v: <type 'exceptions.TypeError'>: Don't know which D-Bus type to use to encode type "NoneType"

Several days passed, still didn't figure out.

Any help will be appreciated!

raspberry pi dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: No such property 'ServicesResolved'

pi@raspberrypi:~ $ sudo python3 /home/pi/python-bluezero/microbit_button.py E4:BE:8D:F3:BB:B4
Traceback (most recent call last):
  File "/home/pi/python-bluezero/microbit_button.py", line 188, in <module>
    central(str(args.address))
  File "/home/pi/python-bluezero/microbit_button.py", line 130, in central
    ubit.connect()
  File "/home/pi/python-bluezero/microbit_button.py", line 63, in connect
    'ServicesResolved'):
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: No such property 'ServicesResolved'

my raspberry pi and micro:bit is paired successfully throughout, so i am wondering what is the issue .

[bluetooth]# paired-devices
Device E4:BE:8D:F3:BB:B4 BBC micro:bit

i have also instaleed bluezero and i ran it on the terminal but to no avail.
any help extended is appreciated. Thank you.

I m currently using blueZ 5.4.3 and am using raspberry Pi3

ERROR:dbus.connection:Unable to set arguments

If you see an error such as the one mentioned in the title of this issue and perhaps looking a bit similar to this:

ERROR:dbus.connection:Unable to set arguments (dbus.ObjectPath('/ukBaz/bluezero/advertisement1978969712'), {}) according to signature None: <type 'exceptions.ValueError'>: Unable to guess signature from an empty dict

It's probably due to an incompatibility between the (likely 'old') version of BlueZ installed and running on your system and the expectations of the DBus client Python code in bluezero .

You should first check that the version your installed BlueZ is 'recent' and/or supported by bluezero, which is currently 5.39

To check your current version run:

bluetoothd --version

or

/usr/sbin/bluetoothd --version

Instantiating two instances of micro:bits causing an error message

This is the type of error message being seen

$ python3 experiments/connect_two.py 
DEBUG:root:Adapter powered
DEBUG:root:Start discovery
Property changed dict_keys([dbus.String('RSSI')])
DEBUG:root:Adapter powered
DEBUG:root:Start discovery
Property changed dict_keys([])
Property changed dict_keys([])
Property changed dict_keys([dbus.String('RSSI')])
Property changed dict_keys([dbus.String('RSSI')])
Traceback (most recent call last):
  File "/home/pi/python/python-bluezero/bluezero/adapter.py", line 215, in _discovering_timeout
    self.stop_discovery()
  File "/home/pi/python/python-bluezero/bluezero/adapter.py", line 230, in stop_discovery
    self.adapter_methods.StopDiscovery()
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.Failed: No discovery started

Unable to run level10/light_switch.py

bluez 5.42
raspberrypi
python3
bluezero/examples/level10/light_switch.py

Traceback (most recent call last):
  File "/home/pi/pycharm.projects/bluezero/examples/level10/light_switch.py", line 96, in <module>
    app = peripheral.Application()
  File "/home/pi/pycharm.projects/bluezero/bluezero/peripheral.py", line 132, in __init__
    self.dongle = adapter.Adapter(device_id)
  File "/home/pi/pycharm.projects/bluezero/bluezero/adapter.py", line 88, in __init__
    self.path)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 241, in get_object
    follow_name_owner_changes=follow_name_owner_changes)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 244, in __init__
    _dbus_bindings.validate_object_path(object_path)
TypeError: must be str, not None

Create an example peripheral to work with Science Journal app

I've just stumbled across the Science Journal app from Google. It allows you to data log sensor data on your phone.
https://play.google.com/store/apps/details?id=com.google.android.apps.forscience.whistlepunk

The bit that caught my attention was that it can also do the logging for sensors over BLE. Their GitHub repo has some Arduino examples. I would expect that this could be done with Bluezero also. The key bits of Arduino code with the BLE service and characteristic seem to be:

BLEService whistlepunkService("555a0001-0aaa-467a-9538-01f0652c74e8"); // create service
// Must be 20 char long to accomodate full-size messages.
const char *value = "                     ";
const char *config = "                     ";
BLECharacteristic valueCharacteristic( "555a0003-0aaa-467a-9538-01f0652c74e8", BLENotify, value);
BLECharacteristic configCharacteristic("555a0010-0aaa-467a-9538-01f0652c74e8", BLEWrite, config);
const unsigned short version = goosci_Version_Version_LATEST;

BLEUnsignedShortCharacteristic versionCharacteristic("555a0011-0aaa-467a-9538-01f0652c74e8", BLERead);

The app code is available at:
https://github.com/google/science-journal

Can only broadcast one beacon at a time

It should be possible to have multiple beacon adverts as part of the same advertisement. However the code currently overwrites an advert when new service data is added for the same service uuid

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.