Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

get_connected() returns true but I get GDBus.Error:org.bluez.Error.Failed: Not connected #170

Open
crfrancis opened this issue Dec 27, 2019 · 0 comments

Comments

@crfrancis
Copy link

I have been developing a BLE-TCP exchange application in C++ on a Raspberry-Pi (previously v.3+, now v.4).

It sets up BLE connections to 3 different Arduinos, where I have written the code on them as well. It communicated to another R-Pi app written in Xojo which manages a lot more hardware.

With the Pi 3+ running Stretch, with Bluez 4.47 (I think -- not sure at the moment) everything worked fine, bar some occasional segmentation errors on first start up (ie running my BLE-TCP app just after boot-up) which always disappeared on a second attempt.

To simplify troubleshooting I am connecting to only one of them at the moment, an Arduino 33 BLE acting as an attitude sensor. It has 3 characteristics: pitch and roll which is Notify only, firmware version which is Read only, and a heartbeat counter which updates every 10 seconds and is Notify only

I have quite a few diagnostic messages. Here is an example of the output which is troubling me:

// omitted some start-up messages

main(): Get devices
getDevices(): Bluetooth manager found
getDevices(): Start discovery
getDevices(): Error: Timeout was reached
getDevices(): Discovered devices list. Loop #0

// some irrelevant discoveries deleted here

Name = IMU-Paramount, Address = D8:18:45:AE:91:B0, Connected = 1
--> Found imuParamount, Address = D8:18:45:AE:91:B0 devicesFound = 3
// 3 because the other 2 Arduinos were found before

--> Found imuParamount, Path = /org/bluez/hci0/dev_D8_18_45_AE_91_B0
--> MAC address = D8:18:45:AE:91:B0
getDevice(): BLE Discovery stopped = true
main(): Calling connectIMUdevice(PARAMOUNT_UNIT)
connectIMUparamount(): Trying to connect to imuParamount (Arduino)
connectIMUparamount(): Apparently connected to imuParamount Arduino // ie returned True
connectIMUparamount(): get_connect results in TRUE
connectIMUparamount(): Got Paramount imuServiceP
connectIMUparamount(): Got pitchRoll Characteristic
Starting pitchRoll notifications.
Added pitchRoll notifications.
connectIMUparamount(): Got imuFirmwareP Characteristic
connectIMUparamount(): Got imuCounterP Characteristic
Starting counter notifications.
Added counter notifications.

// some omitted messages

main(): TCP - received from Roof Control: :GF 1# <- this means "get Firmware version"
decode(): matched :GF 1#
decode(): Error in Paramount imuFirmwareP->read_value(): GDBus.Error:org.bluez.Error.Failed: Not connected

// The TCP client got the not connected message so commanded a disconnect

main(): TCP - received from Roof Control: :D 1#
decode(): Received :D 1# so disconnecting imuParamount
disconnectIMUparamount(): Disconnecting imuParamount device D8:18:45:AE:91:B0
disconnectIMUparamount(): Disconnect imuParamount device D8:18:45:AE:91:B0 failed
disconnectIMUparamount(): BLE Error: Timeout was reached

So it seems that the tinyb method get_connected() returns a value which is inconsistent with the status on the DBBus. Also the Arduino lights an on-board LED if a entral connects, and it is not lit, so it looks that it is get_connected() which is wrong.

Is there a work-around?

thanks,
Richard

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant