I'm trying to follow mmwise tutorial (https://github.com/mmwise/sphero_ros) to use my sphero SPRK+ in a ROS environment. I am unable to get the SPRK+ to connect to my PC using bluetoothctl or the bluetooth screen.
I have tried in both Oracle Virtualbox Ubuntu 14.04 with indigo ROS and Raspberry Pi 3 with ROS stretch. The error is exactly the same in both for the bluetoothctl, it is as follows:
[bluetooth]# pair F7:AF:AF:64:39:66
Attempting to pair with F7:AF:AF:64:39:66
[CHG] Device F7:AF:AF:64:39:66 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device F7:AF:AF:64:39:66 Connected: no
If I connect to the SPRK+ before pairing, it succeeds and changes to
[bluetooth]# connect F7:AF:AF:64:39:66
Attempting to connect to F7:AF:AF:64:39:66
[CHG] Device F7:AF:AF:64:39:66 Connected: yes
Connection successful
[NEW] Primary Service
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0008
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0008/char0009
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0008/char0009/desc000b
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Primary Service
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service000c
22bb746f-2ba0-7554-2d6f-726568705327
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service000c/char000d
22bb746f-2ba1-7554-2d6f-726568705327
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service000c/char000f
22bb746f-2ba6-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service000c/char000f/desc0011
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Primary Service
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012
22bb746f-2bb0-7554-2d6f-726568705327
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0013
22bb746f-2bb1-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0013/desc0015
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0016
22bb746f-2bb2-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0016/desc0018
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0019
22bb746f-2bb6-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0019/desc001b
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0019/desc001c
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char001d
22bb746f-2bb7-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char001d/desc001f
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0020
22bb746f-2bb8-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0020/desc0022
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0023
22bb746f-2bb9-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0023/desc0025
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0026
22bb746f-2bba-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0026/desc0028
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0029
22bb746f-2bbd-7554-2d6f-726568705327
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char002b
22bb746f-2bbe-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char002b/desc002d
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char002e
22bb746f-2bbf-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char002e/desc0030
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0031
22bb746f-3bba-7554-2d6f-726568705327
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0012/char0031/desc0033
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Primary Service
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0034
00001016-d102-11e1-9b23-00025b00a5a5
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0034/char0035
00001013-d102-11e1-9b23-00025b00a5a5
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0034/char0037
00001017-d102-11e1-9b23-00025b00a5a5
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0034/char0039
00001014-d102-11e1-9b23-00025b00a5a5
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service0034/char0039/desc003b
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Primary Service
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c
0000180a-0000-1000-8000-00805f9b34fb
Device Information
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char003d
00002a27-0000-1000-8000-00805f9b34fb
Hardware Revision String
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char003f
00002a25-0000-1000-8000-00805f9b34fb
Serial Number String
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char003f/desc0041
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char0042
00002a24-0000-1000-8000-00805f9b34fb
Model Number String
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char0044
00002a29-0000-1000-8000-00805f9b34fb
Manufacturer Name String
[NEW] Characteristic
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char0046
00002a26-0000-1000-8000-00805f9b34fb
Firmware Revision String
[NEW] Descriptor
/org/bluez/hci0/dev_F7_AF_AF_64_39_66/service003c/char0046/desc0048
00002904-0000-1000-8000-00805f9b34fb
Characteristic Format
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 00001016-d102-11e1-9b23-00025b00a5a5
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 22bb746f-2ba0-7554-2d6f-726568705327
[CHG] Device F7:AF:AF:64:39:66 UUIDs: 22bb746f-2bb0-7554-2d6f-726568705327
[CHG] Device F7:AF:AF:64:39:66 ServicesResolved: yes
[SK-3966]#
Then further attempt to pair results in
[SK-3966]# pair
Attempting to pair with
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device F7:AF:AF:64:39:66 ServicesResolved: no
[CHG] Device F7:AF:AF:64:39:66 Connected: no
Attempt to connect using the regular bluetooth settings screen in Ubuntu 14.04 results in Setting up "SK-3999" failed.
I've tried adding my pi user to the group lp as found in another post and I'm pretty sure my bluetooth on both is working fine, as it scans and finds things. Any ideas?
Behavior of bluetoothctl you see is expected. In BLE, authentication and encryption are bound with Characteristics (data). When you try to connect with a peripheral device, GATT discovery happens, services get resolved and connection establishes successfully.
But, when you try to read or write data to/from the peripheral device for the first time, that's when the security requirements of the GATT service are verified and pairing request is generated and pairing takes place.
That is the reason bluetoothctl connect succeeds and pair is failing in your case.
If the GATT services on your peripheral device require authentication, then you
may need to know the authentication pin depending on the IO capabilities of the device. Below is an example of authentication using bluetoothctl:
[bluetooth]# agent DisplayYesNo
Agent is already registered
[bluetooth]#pair 00:45:41:34:04:BA:8B
Request confirmation
[agent] Confirm passkey 547334 (yes/no): yes
Authentication methods in Bluetooth Low Energy depends on IO capabilities of the connecting devices. For example IO capabilities of a smart phone is KeyBoardDisplay, IO capabilities of a BLE wrist band is NoInputNoOutput. Documents of your BLE device in question should say more about its authentication method.
Related
I am working on a project using a Raspberry PI4 under Bullseye 64 bits and an Android smartphone. There is no Wi-Fi nor internet available.
I would like to inform Android the Raspberry has just started.
In the past I did something similar: when I turn may car on, I get a callback on my phone. To do that, on boot, I register a broadcast for android.bluetooth.device.action.ACL_CONNECTED. It works fine, because as soon as I turn the car on, the Bluetooth of the car connects to the phone.
Now in my current project the car role is played by the raspberry PI. I have connected the smartphone to the Raspberry PI using the standard Android UI. It works fine.
Later, from the Raspberry PI I run bluetoothctl connect MAC where MAC is the mac address of my smartphone. It works well, the devices are connected, and I get the callback in Android.
The problem comes from the fact the smartphone sees the Raspberry like headset, so I cannot hear the sounds played on my smartphone : there are send to Raspberry.
I spends days trying to fix that issue, but I did not found any solution. For example, if I tried to modify the bluetoothd daemon on the PI like this:
ExecStart=/usr/libexec/bluetooth/bluetoothd --noplugin=*
It is not working : I cannot connect the PI from the smartphone. I guess it is due to the profiles implemented in Android: If I remove everything from Bluetooth daemon Android does not found anything suitable.
Have you any idea how I could solve the issue?
Notice I could disconnect few seconds after connection as all I need is the information the Raspberry has started but I am not happy with that solution, the user may notice the interruption.
Thank you.
This might work. It may have been depracated or sidelined by dBus, so no promises. Try deleting the Pi's audio service with sdptool.
First list the services:
sudo sdptool records local
Find the service that looks like an audio link and note its handle which will be listed like this:
Service RecHandle: 0x10002
Then delete the service
sudo sdptool del 10002
I tried your suggestions, but I did not succeed.
Firstly I tried the usual process
Connect the smartphone to the PI from the standard Android UX.
On the PI, in bluetoothctl
I see this :
[NEW] Device yy:yy:yy:yy:yy:yy MyPhoneName
Request confirmation
[agent] Confirm passkey 798942 (yes/no): yes
[CHG] Device yy:yy:yy:yy:yy:yy Modalias: usb:v0FCEp020Dd0010
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 10000057-5749-5448-0037-000000000000
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: a82efa21-ae5c-3dde-9bbc-f16da7b16c5a
[CHG] Device yy:yy:yy:yy:yy:yy ServicesResolved: yes
[CHG] Device yy:yy:yy:yy:yy:yy Paired: yes
[CHG] Device yy:yy:yy:yy:yy:yy ServicesResolved: no
[CHG] Device yy:yy:yy:yy:yy:yy Connected: no
Android tried several times the connections.
I tried again from Android I see this :
[CHG] Device 3C:01:EF:6F:A8:BF Connected: yes
Authorize service
[agent] Authorize service 00001108-0000-1000-8000-00805f9b34fb (yes/no): yes
Next step : forget the PI from the phone and remove the phone from the PI
bluetoothctl remove yy:yy:yy:yy:yy:yy
Secondly remove the records using sdptool
Now removing the 2 records: (I did that after adding ‘—compat’ to bluetoothd in order to make sdptool working):
$ sudo sdptool browse local
Browsing FF:FF:FF:00:00:00 ...
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)
Profile Descriptor List:
"PnP Information" (0x1200)
Version: 0x0103
Browsing FF:FF:FF:00:00:00 ...
Service Search failed: Invalid argument
Service Name: Generic Access Profile
Service Provider: BlueZ
Service RecHandle: 0x10001
Service Class ID List:
"Generic Access" (0x1800)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 31
"ATT" (0x0007)
uint16: 0x0001
uint16: 0x0005
Service Name: Generic Attribute Profile
Service Provider: BlueZ
Service RecHandle: 0x10002
Service Class ID List:
"Generic Attribute" (0x1801)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 31
"ATT" (0x0007)
uint16: 0x0006
uint16: 0x000f
Service Name: Device Information
Service Provider: BlueZ
Service RecHandle: 0x10003
Service Class ID List:
"" (0x180a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 31
"ATT" (0x0007)
uint16: 0x0010
uint16: 0x0012
Service Name: **Headset Voice gateway**
Service RecHandle: 0x10004
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0102
Service Name: **Headset unit**
Service RecHandle: 0x10005
Service Class ID List:
"Headset" (0x1108)
"" (0x1131)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0102
So I removed the to last services :
$ sudo sdptool del 0x10004
Service Record deleted.
$ sudo sdptool del 0x10005
Service Record deleted.
If again I run sudo sdptool browse local, there are gone.
But If I run
bluetootctl show
I do not see any changes :
[bluetooth]# show
Controller xx:xx:xx:xx:xx:xx (public)
Name: mypi
Alias: mypi
Class: 0x00200000
Powered: yes
Discoverable: yes
DiscoverableTimeout: 0x00000000
Pairable: yes
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Headset (00001108-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0537
Discovering: no
Roles: central
Roles: peripheral
Advertising Features:
ActiveInstances: 0x00 (0)
SupportedInstances: 0x05 (5)
SupportedIncludes: tx-power
SupportedIncludes: appearance
SupportedIncludes: local-name
Again, paring from the smartphone :
[NEW] Device yy:yy:yy:yy:yy:yy MyPhoneName
Request confirmation
[agent] Confirm passkey 887536 (yes/no): yes
[CHG] Device yy:yy:yy:yy:yy:yy Modalias: usb:v0FCEp020Dd0010
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: 10000057-5749-5448-0037-000000000000
[CHG] Device yy:yy:yy:yy:yy:yy UUIDs: a82efa21-ae5c-3dde-9bbc-f16da7b16c5a
[CHG] Device yy:yy:yy:yy:yy:yy ServicesResolved: yes
[CHG] Device yy:yy:yy:yy:yy:yy Paired: yes
[CHG] Device yy:yy:yy:yy:yy:yy ServicesResolved: no
[CHG] Device yy:yy:yy:yy:yy:yy Connected: no
The connection is failing.
I guess Android to not get any suitable services, so it gave up.
I have noticed one thing: if I restart the bluetooth daemon (sudo systemctl restart bluetooth) the 2 records are back.
I am wondering if there is something in Raspberry PI OS which force these 2 services.
Conclusion
I am stuck.
I thought I had solved my problem because when I initiate the connection to phone from the PI (after the pairing from the phone), Android triggers an event ACTION_ACL_CONNECTED followed by a ACTION_ACL_DISCONNECTED which is enough for me.
Unfortunately, it only works for a while. If I wait too long, I can't get it to work.
I want to use a Gamesir T1d gamepad (Bluetooth) to read it's commands with Python, on a Raspberry Pi 3 B+ (Buster).
I am able to connect the gamepad via Bluetooth:
[CHG] Device C6:86:A1:04:BB:53 RSSI: -78
[bluetooth]# connect C6:86:A1:04:BB:53
Attempting to connect to C6:86:A1:04:BB:53
[CHG] Device C6:86:A1:04:BB:53 Connected: yes
Connection successful
[CHG] Device C6:86:A1:04:BB:53 ServicesResolved: yes
[Gamesir-T1d-BB53]# pair C6:86:A1:04:BB:53
Attempting to pair with C6:86:A1:04:BB:53
[CHG] Device C6:86:A1:04:BB:53 Paired: yes
Pairing successful
[Gamesir-T1d-BB53]# info
Device C6:86:A1:04:BB:53 (random)
Name: Gamesir-T1d-BB53
Alias: Gamesir-T1d-BB53
Paired: yes
Trusted: yes
Blocked: no
Connected: yes
LegacyPairing: no
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb)
UUID: Unknown (00008650-0000-1000-8000-00805f9b34fb)
Modalias: bluetooth:v000Dp0000d0110
RSSI: -78
[Gamesir-T1d-BB53]#
However, there is no event created under
/dev/input/
which I would need to read and map the gamepad's commands into Python.
When connecting a Bluetooth mouse, I can see events being created, so this seems to be a gamepad specific issue.
I was already trying xboxdrv, but without success, probably since the gamesir is not listed as supported device? Also, I have no glue if this is just a missing driver issue, or if there is a generic driver which could work, or if this is a driver issue at all.
What I am missing here?
Is it possible to connect more than two bluetooth dongles(adapters) to the linux machine and use them for read/write/communication with other external bluetooth devices simultaneously? So that there are will be more than one bluetooth device bluez can recognize and work with in parallel.
To complete #sam's answer as I was looking at doing the them. Here is the demonstration of two bluetooth adapter in Linux with bluetoothctl:
Without any USB Bluetooth dongle on my laptop I see:
[bluetooth]# list
Controller 84:EF:18:1E:5B:8A olivier-ThinkPad-E460 #1 [default]
After I hotplug the USB Bluetooth dongle, I can see:
[NEW] Controller 5C:F3:70:8A:A6:97 olivier-ThinkPad-E460 #2 [default]
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Controller 5C:F3:70:8A:A6:97 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[bluetooth]# list
Controller 84:EF:18:1E:5B:8A olivier-ThinkPad-E460 #1 [default]
Controller 5C:F3:70:8A:A6:97 olivier-ThinkPad-E460 #2
To select the USB Bluetooth dongle which has for MAC address 5C:F3:70:8A:A6:97:
[bluetooth]# select 5C:F3:70:8A:A6:97
[bluetooth]# list
Controller 84:EF:18:1E:5B:8A olivier-ThinkPad-E460 #1
Controller 5C:F3:70:8A:A6:97 olivier-ThinkPad-E460 #2 [default]
We can see the USB adapter is now marked as [default].
When I scan for bluetooth devices, I can see it use the USB dongle:
[bluetooth]# scan on
Discovery started
[CHG] Controller 5C:F3:70:8A:A6:97 Discovering: yes
[NEW] Device A0:E6:F8:37:AE:94 5AAA=mRwb6qK$v_~xL5O#uK)AqfHK
[NEW] Device 54:E5:F7:BC:4C:D9 54-E5-F7-BC-4C-D9
Same when I want to connect:
[bluetooth]# connect DE:79:A2:A1:E9:FA
Attempting to connect to DE:79:A2:A1:E9:FA
[CHG] Device DE:79:A2:A1:E9:FA Connected: yes
Connection successful
[NEW] Primary Service
/org/bluez/hci1/dev_DE_79_A2_A1_E9_FA/service0008
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Characteristic
/org/bluez/hci1/dev_DE_79_A2_A1_E9_FA/service0008/char0009
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
Notice the hci1 in the DBUS path: /org/bluez/hci1/dev_DE_79_A2_A1_E9_FA
yes its possible. Use bluetoothctl command line tool provided by bluez to select adapter.
Each device will recognized with different adapter. You can choose the adapter and give commands
I am doing a project where I need to create communication between two Raspberry Pi 3 on stretch (RPi) wirelessly with callback functionalities using C++ code. The first is supposed to send data to the second one. I decided to create a bluetooth connexion between the two using the on-board bluetooth-chips.
So first I decided to compile Linux Bluetooth Stack: Bluez on both RPi from source, version 5.50. Following this tutorial : https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation on Adafruit. I managed to send a message from one pi to another using these codes :https://people.csail.mit.edu/albert/bluez-intro/x502.html. But to read a message sent by the client, I have to call the function "read(client, buf, sizeof(buf))" as shown in the server code which is a bit restrictive. I want to be notified whenever a message is received so that a callback function can be called. I saw it could be done by enabling notifications on the GATT Characteristics used for the communication.
This level of specification is not really shown on the C++ codes I got from https://people.csail.mit.edu/albert/bluez-intro/x502.html. After having improved my knowledge on GATT with this : https://www.novelbits.io/bluetooth-gatt-services-characteristics/ , I decided to follow Tony D's youtube tutorial on how to use Bluez APi
https://www.youtube.com/watch?v=5fQR2PHMDWE.
To make it easier, I decided to left one RPi aside and tried to connect a Bluetooth audio headset JBL T450BT which use Bluetooth 4.0, so it is supposed to support Bluetooth Low Energy.
On bluetoothctl here's the problem, I manage to power on the controller, scan on and detect the headset. I then trust, pair and connect. In GATT menu, I enter the command : list-attributes [dev address]. Bluetoothctl prints no error but returns nothing and is ready to receive other command lines.
sudo bluetoothctl
[bluetooth]# show
Controller XX:XX:XX:XX:XX:XX (public)
Name: VoitureRPi
Alias: VoitureRPi
Class: 0x004c0000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
UUID: Handsfree Audio Gateway (0000111f-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0532
Discovering: no
[bluetooth]# scan on
Device 78:44:05:BC:12:0C JBL T450BT
[bluetooth]# trust 78:44:05:BC:12:0C
[CHG] Device 78:44:05:BC:12:0C Trusted: yes
Changing 78:44:05:BC:12:0C trust succeeded
[bluetooth]# pair 78:44:05:BC:12:0C
Attempting to pair with 78:44:05:BC:12:0C
[CHG] Device 78:44:05:BC:12:0C Connected: yes
[CHG] Device 78:44:05:BC:12:0C UUIDs: 00001108-0000-1000-8000-00805f9b34fb
[CHG] Device 78:44:05:BC:12:0C UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device 78:44:05:BC:12:0C UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 78:44:05:BC:12:0C UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 78:44:05:BC:12:0C UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device 78:44:05:BC:12:0C ServicesResolved: yes
[CHG] Device 78:44:05:BC:12:0C Paired: yes
Pairing successful
[CHG] Device 78:44:05:BC:12:0C ServicesResolved: no
[CHG] Device 78:44:05:BC:12:0C Connected: no
[bluetooth]# connect 78:44:05:BC:12:0C
Attempting to connect to 78:44:05:BC:12:0C
[CHG] Device 78:44:05:BC:12:0C Connected: yes
Connection successful
[CHG] Device 78:44:05:BC:12:0C ServicesResolved: yes
[JBL T450BT]# menu gatt
[JBL T450BT]# list-attributes 78:44:05:BC:12:0C
[JBL T450BT]#
From there I get no answer from bluetoothctl but no error as well, as I told you. I am not able to discover services/characteristics.
On the youtube tuto I followed,it was told that the GATT services and Characteristics discovery was done during the pairing/first connexion. I assume that the Pi intends to do it but fails. That's maybe why I get the sequence :
connected: yes, ServicesResolved: yes Paired successfully and then ServicesResolved: no, connected no. Nothing like : [NEW] XXX Service or Characteristcs is shown.
I don't think the problem comes from the headset because it does the same thing on other devices I connect to. I have both pulseaudio and bluealsa packages installed on the RPi.
As mentionned in this tuto
Here the bluetooth status :
systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-11-08 11:29:38 CET; 27min ago
Docs: man:bluetoothd(8)
Main PID: 2646 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─2646 /usr/local/libexec/bluetooth/bluetoothd --experimental
Here's what hciconfig gives :
hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:A8:0C:20 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:11205 acl:76 sco:0 events:520 errors:0
TX bytes:219869 acl:433 sco:0 commands:150 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'VoitureRPi'
Class: 0x4c0000
Service Classes: Rendering, Capturing, Telephony
Device Class: Miscellaneous,
HCI Version: 4.1 (0x7) Revision: 0x168
LMP Version: 4.1 (0x7) Subversion: 0x2209
Manufacturer: Broadcom Corporation (15)
Here's also what the D-Bus introspection tool returns :
busctl tree org.bluez
└─/org
└─/org/bluez
└─/org/bluez/hci0
└─/org/bluez/hci0/dev_78_44_05_BC_12_0C
├─/org/bluez/hci0/dev_78_44_05_BC_12_0C/fd1
└─/org/bluez/hci0/dev_78_44_05_BC_12_0C/player0
For people who got problems with pairing and connecting, this source was a huge help :https://www.sigmdel.ca/michel/ha/rpi/bluetooth_02_en.html
Anyway so that's my problem. I want to access Characteristics and their UUID's to be able to modify their permission or to create a new service with its own characteristics suited to my project.
To this point I think this is the only way to implement a notifier with a callback in a bluetooth communication. Maybe I'm wrong. Do you have any clue whatsoever ? :)
Thanks to A.Baur, the "--experimental" option was the last missing thing.
My system:Debian 10 + KDE
Installed:
- bluez-*
- bluetooth
- pulseaudio-module-bluetooth
Steps:
1. stop bluetooth service: >sudo systemctl stop bluetooth
2. modify: /etc/init.d/bluetooth ; by adding to the line:
SSD_OPTIONS="**--experimental** --oknodo --quiet --exec $DAEMON -- $NOPLUGIN_OPTION"
3. start bluetooth service: >sudo systemctl start bluetooth
4. connect to Bose QC35 II by bluetoothctl or other GUI tool.
I got it working in RPi with python examples of advertisement and gatt server from bluez-5.50. I used nRF tool to test it.
I have a raspberry pi 3 and a 4th generation apple tv remote.
I don't understand why I am unable to see the remote when I scan with the raspberry pi using "hcitool scan" command.
I have to say that I can see other bluetooth device during the scan but never the remote.
I can see the remote when I scan with my iPhone.
My ATV4 is unplugged and i have put the remote on pair mode (menu + volume up)
What is wrong ? Thanks
I've been looking into this for a little while, and my conclusion so far is that there may be something a bit non-standard or unusual about the bluetooth in the Siri Remote / 4th generation Apple TV remote. Certainly it manages to upset LightBlue on my Mac and iPhone in slightly different ways.
If I use bluetoothctl, the remote does show up and I can connect to it (at least if I hold menu+volumeup for 5 seconds whilst bluetoothctl has discovery enabled):
root#raspberrypi:/home/pi# bluetoothctl
[NEW] Controller B8:27:EB:6C:15:98 raspberrypi [default]
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:6C:15:98 Discovering: yes
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[NEW] Device 78:9F:70:5E:A3:14 DJ7Q6MZ9GQQT
[NEW] Device 67:8F:99:BC:EE:C5 67-8F-99-BC-EE-C5
[CHG] Device 67:8F:99:BC:EE:C5 RSSI: -64
[CHG] Device 67:8F:99:BC:EE:C5 RSSI: -44
[CHG] Device 67:8F:99:BC:EE:C5 RSSI: -64
[CHG] Device 67:8F:99:BC:EE:C5 RSSI: -44
[bluetooth]# connect 78:9F:70:5E:A3:14
Attempting to connect to 78:9F:70:5E:A3:14
[CHG] Device 78:9F:70:5E:A3:14 Connected: yes
Connection successful
[CHG] Device 78:9F:70:5E:A3:14 UUIDs:
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
0000180a-0000-1000-8000-00805f9b34fb
0000180f-0000-1000-8000-00805f9b34fb
00001812-0000-1000-8000-00805f9b34fb
0000181e-0000-1000-8000-00805f9b34fb
8341f2b4-c013-4f04-8197-c4cdb42e26dc
[CHG] Device 78:9F:70:5E:A3:14 Appearance: 0x03c0
[CHG] Device 78:9F:70:5E:A3:14 Modalias: bluetooth:v004Cp0266d0000