Aranet4-Python
Aranet4-Python copied to clipboard
Scan works, but querying with MAC address doesn't
I'm on Arch Linux and the device is paired. aranetctl --scan
works:
$ aranetctl --scan
Looking for Aranet devices...
=======================================
Name: Aranet4 1BC2D
Address: EC:94:30:8D:5A:B9
/usr/lib/python3.11/site-packages/aranet4/aranetctl.py:165: FutureWarning: BLEDevice.rssi is deprecated and will be removed in a future version of Bleak, use AdvertisementData.rssi instead
print(f" RSSI: {advertisement.device.rssi} dBm")
RSSI: -64 dBm
--------------------------------------
CO2: 688 pm
Temperature: 24.8 °C
Humidity: 45 %
Pressure: 1003.5 hPa
Battery: 36 %
Status Disp.: GREEN
Age: 31/120
Counter: -1
Scan finished. Found 1
But trying to connect with the MAC address doesn't:
$ aranetctl EC:94:30:8D:5A:B9
Traceback (most recent call last):
File "/usr/bin/aranetctl", line 33, in <module>
sys.exit(load_entry_point('aranet4==2.2.2', 'console_scripts', 'aranetctl')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/aranet4/aranetctl.py", line 273, in entry_point
main(argv=sys.argv[1:])
File "/usr/lib/python3.11/site-packages/aranet4/aranetctl.py", line 264, in main
current = client.get_current_readings(args.device_mac)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/aranet4/client.py", line 643, in get_current_readings
return asyncio.run(_current_reading(mac_address))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/aranet4/client.py", line 633, in _current_reading
await monitor.connect()
File "/usr/lib/python3.11/site-packages/aranet4/client.py", line 378, in connect
await self.device.connect()
File "/usr/lib/python3.11/site-packages/bleak/__init__.py", line 605, in connect
return await self._backend.connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 268, in connect
await self.get_services(
File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 656, in get_services
self.services = await manager.get_services(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 644, in get_services
await self._wait_for_services_discovery(device_path)
File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 779, in _wait_for_services_discovery
raise BleakError("failed to discover services, device disconnected")
bleak.exc.BleakError: failed to discover services, device disconnected
I am not able to reproduce this myself. Can you access GATT service using different programs? For example bluetoothctl?
bluetoothctl
menu gatt
list-attributes [device_mac]
Doesn't seem to be working with bluetoothctl either:
$ bluetoothctl
hci0 new_settings: powered bondable ssp br/edr le secure-conn
Agent registered
[CHG] Controller E8:48:B8:C8:20:00 Pairable: yes
[bluetooth]# pair EC:94:30:8D:5A:B9
Attempting to pair with EC:94:30:8D:5A:B9
[bluetooth]# info EC:94:30:8D:5A:B9
Device EC:94:30:8D:5A:B9 (random)
Name: Aranet4 1BC2D
Alias: Aranet4 1BC2D
Paired: yes
Bonded: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: no
UUID: Unknown (0000fce0-0000-1000-8000-00805f9b34fb)
ManufacturerData Key: 0x0702 (1794)
ManufacturerData Value:
21 05 03 01 00 0c 0f 01 07 05 ab 01 c3 27 45 21 !............'E!
02 78 00 72 00 46 .x.r.F
[bluetooth]# menu gatt
Menu gatt:
Available commands:
-------------------
list-attributes [dev/local] List attributes
select-attribute <attribute/UUID/local> [attribute/UUID] Select attribute
attribute-info [attribute/UUID] Select attribute
read [offset] Read attribute value
write <data=xx xx ...> [offset] [type] Write attribute value
acquire-write Acquire Write file descriptor
release-write Release Write file descriptor
acquire-notify Acquire Notify file descriptor
release-notify Release Notify file descriptor
notify <on/off> Notify attribute value
clone [dev/attribute/UUID] Clone a device or attribute
register-application [UUID ...] Register profile to connect
unregister-application Unregister profile
register-service <UUID> [handle] Register application service.
unregister-service <UUID/object> Unregister application service
register-includes <UUID> [handle] Register as Included service in.
unregister-includes <Service-UUID><Inc-UUID> Unregister Included service.
register-characteristic <UUID> <Flags=read,write,notify...> [handle] Register application characteristic
unregister-characteristic <UUID/object> Unregister application characteristic
register-descriptor <UUID> <Flags=read,write...> [handle] Register application descriptor
unregister-descriptor <UUID/object> Unregister application descriptor
back Return to main menu
version Display version
quit Quit program
exit Quit program
help Display help about this program
export Print environment variables
[bluetooth]# list-attributes EC:94:30:8D:5A:B9
[DEL] Device 16:CB:19:39:76:D2 16-CB-19-39-76-D2
[bluetooth]# list-attributes EC:94:30:8D:5A:B9
[bluetooth]#
This might be an issue with BlueZ.
For me version 5.50
is working. (bluetoothd -v
)
Hmm, I'm on 5.69 so maybe something changed recently?
Additional data point:
Running on Raspberry Pi 3, buster
bluetoothd -v
reports 5.50
But the aranetctl
traceback is a bit different, most notably it reports bleak.exc.BleakError: Characteristic with UUID f0cd3001-95da-4f4b-9ac8-aa55d312af0c could not be found!
Full traceback:
Traceback (most recent call last):
File "/usr/local/bin/aranetctl", line 10, in <module>
sys.exit(entry_point())
File "/usr/local/lib/python3.7/dist-packages/aranet4/aranetctl.py", line 273, in entry_point
main(argv=sys.argv[1:])
File "/usr/local/lib/python3.7/dist-packages/aranet4/aranetctl.py", line 264, in main
current = client.get_current_readings(args.device_mac)
File "/usr/local/lib/python3.7/dist-packages/aranet4/client.py", line 643, in get_current_readings
return asyncio.run(_current_reading(mac_address))
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/dist-packages/aranet4/client.py", line 634, in _current_reading
readings = await monitor.current_readings(details=True)
File "/usr/local/lib/python3.7/dist-packages/aranet4/client.py", line 405, in current_readings
raw_bytes = await self.device.read_gatt_char(uuid)
File "/usr/local/lib/python3.7/dist-packages/bleak/__init__.py", line 637, in read_gatt_char
return await self._backend.read_gatt_char(char_specifier, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 723, in read_gatt_char
char_specifier
bleak.exc.BleakError: Characteristic with UUID f0cd3001-95da-4f4b-9ac8-aa55d312af0c could not be found!
bluetoothctl info
reports UUIDs Generic Access Profile, Generic Attribute Profile, Device Information, Battery Service, Unknown (0000fce0-0000-1000-8000-00805f9b34fb)
and Vendor specific (b2152466-d600-11e8-9f8b-f2801f1b9fd1)
. Nothing reported for list-attributes
. Definitely don't see the "not found" UUID.
@joconor
What characteristics do you see under 0000fce0-0000-1000-8000-00805f9b34fb
service?
Do you see f0cd1503-95da-4f4b-9ac8-aa55d312af0c
or f0cd1504-95da-4f4b-9ac8-aa55d312af0c
?
Which version is your Aranet running?
Same issue on Fedora 39.
Firmware version: v1.3.5
$ bluetoothctl info E4:C1:71:38:65:D7
Device E4:C1:71:38:65:D7 (random)
Name: Aranet4 ...
Alias: Aranet4 ...
Paired: yes
Bonded: yes
Trusted: no
Blocked: no
Connected: no
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: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
UUID: Unknown (0000fce0-0000-1000-8000-00805f9b34fb)
UUID: Nordic Semiconductor AS.. (0000fe59-0000-1000-8000-00805f9b34fb)
ManufacturerData Key: ...
ManufacturerData Value:
...
RSSI: 0xffffffb5 (-75)
$ bluetoothctl
list-attributes
# list-attributes E4:C1:71:38:65:D7
Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025
0000fce0-0000-1000-8000-00805f9b34fb
Unknown
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char003b
f0cd3002-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0039
f0cd2005-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0037
f0cd3001-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0035
f0cd2004-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0033
f0cd1502-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0030
f0cd2003-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0030/desc0032
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char002e
f0cd2002-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char002c
f0cd2001-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char002a
f0cd1503-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0028
f0cd1402-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0025/char0026
f0cd1401-95da-4f4b-9ac8-aa55d312af0c
Vendor specific
Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016
0000180a-0000-1000-8000-00805f9b34fb
Device Information
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char0023
00002a23-0000-1000-8000-00805f9b34fb
System ID
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char0021
00002a28-0000-1000-8000-00805f9b34fb
Software Revision String
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char001f
00002a26-0000-1000-8000-00805f9b34fb
Firmware Revision String
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char001d
00002a27-0000-1000-8000-00805f9b34fb
Hardware Revision String
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char001b
00002a25-0000-1000-8000-00805f9b34fb
Serial Number String
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char0019
00002a24-0000-1000-8000-00805f9b34fb
Model Number String
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0016/char0017
00002a29-0000-1000-8000-00805f9b34fb
Manufacturer Name String
Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0012
0000180f-0000-1000-8000-00805f9b34fb
Battery Service
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0012/char0013
00002a19-0000-1000-8000-00805f9b34fb
Battery Level
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service0012/char0013/desc0015
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000e
0000fe59-0000-1000-8000-00805f9b34fb
Nordic Semiconductor ASA
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000e/char000f
8ec90003-f315-4f60-9fb8-838830daea50
Vendor specific
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000e/char000f/desc0011
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000a
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000a/char000b
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_E4_C1_71_38_65_D7/service000a/char000b/desc000d
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Similar issue. Running on Raspberry Pi 4 Firmware 1.4.14
admin@raspberrypi:~ $ sudo aranetctl --scan
Looking for Aranet devices...
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
/usr/local/lib/python3.11/dist-packages/aranet4/aranetctl.py:165: FutureWarning: BLEDevice.rssi is deprecated and will be removed in a future version of Bleak, use AdvertisementData.rssi instead
print(f" RSSI: {advertisement.device.rssi} dBm")
RSSI: -71 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 4/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -67 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 5/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -68 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 6/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -65 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 6/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -70 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 6/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -67 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 7/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -67 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 8/60
Counter: -1
=======================================
Name: Aranet4 00523
Address: C2:DB:C0:DC:E4:55
RSSI: -71 dBm
--------------------------------------
CO2: 994 pm
Temperature: 21.2 C
Humidity: 30 %
Pressure: 996.8 hPa
Battery: 6 %
Status Disp.: GREEN
Age: 8/60
Counter: -1
Scan finished. Found 1
Scan finished. Found 1
admin@raspberrypi:~ $ aranetctl C2:DB:C0:DC:E4:55
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 209, in connect
reply = await self._bus.call(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/dbus_fast/aio/message_bus.py", line 384, in call
await future
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/aranetctl", line 8, in <module>
sys.exit(entry_point())
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/aranetctl.py", line 273, in entry_point
main(argv=sys.argv[1:])
File "/usr/local/lib/python3.11/dist-packages/aranet4/aranetctl.py", line 264, in main
current = client.get_current_readings(args.device_mac)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 643, in get_current_readings
return asyncio.run(_current_reading(mac_address))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 633, in _current_reading
await monitor.connect()
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 378, in connect
await self.device.connect()
File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 605, in connect
return await self._backend.connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 146, in connect
async with async_timeout(timeout):
File "/usr/lib/python3.11/asyncio/timeouts.py", line 98, in __aexit__
raise TimeoutError
TimeoutError
admin@raspberrypi:~ $
and then after trying again, this error:
admin@raspberrypi:~ $ aranetctl C2:DB:C0:DC:E4:55
Traceback (most recent call last):
File "/usr/local/bin/aranetctl", line 8, in <module>
sys.exit(entry_point())
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/aranetctl.py", line 273, in entry_point
main(argv=sys.argv[1:])
File "/usr/local/lib/python3.11/dist-packages/aranet4/aranetctl.py", line 264, in main
current = client.get_current_readings(args.device_mac)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 643, in get_current_readings
return asyncio.run(_current_reading(mac_address))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 633, in _current_reading
await monitor.connect()
File "/usr/local/lib/python3.11/dist-packages/aranet4/client.py", line 378, in connect
await self.device.connect()
File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 605, in connect
return await self._backend.connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 268, in connect
await self.get_services(
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 656, in get_services
self.services = await manager.get_services(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/manager.py", line 644, in get_services
await self._wait_for_services_discovery(device_path)
File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/manager.py", line 779, in _wait_for_services_discovery
raise BleakError("failed to discover services, device disconnected")
bleak.exc.BleakError: failed to discover services, device disconnected
admin@raspberrypi:~ $ a
Make sure you have paired Pi to Aranet and other devices (like phone app) is not connected to it.
Hi Anrijs, thank you for your advice. It seems pairing doesn't really go as expected.
admin@raspberrypi:~ $ bluetoothctl
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller D8:3A:DD:57:52:22 Discovering: yes
[CHG] Device C2:DB:C0:DC:E4:55 RSSI: -75
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Key: 0x0702
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Value:
21 0e 04 01 00 06 0f 01 b9 03 ba 01 7c 26 23 03 !.........|&#.
01 3c 00 08 00 ac
[bluetooth]# pair C2:DB:C0:DC:E4:55
Attempting to pair with C2:DB:C0:DC:E4:55
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Key: 0x0702
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Value:
21 0e 04 01 00 06 0f 01 cb 03 ba 01 7c 26 23 03 !.........|&#.
01 3c 00 11 00 ad .<...
The pair command doesn't seem to do much? I don't get any confirmation about the pairing process. It just keeps repeating this:
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Key: 0x0702
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Value:
21 0e 04 01 00 06 0f 01 cf 03 bb 01 7b 26 23 03 !.........{&#.
01 3c 00 2d 00 b0 .<.-.
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Key: 0x0702
[CHG] Device C2:DB:C0:DC:E4:55 ManufacturerData Value:
21 0e 04 01 00 06 0f 01 c2 03 bb 01 7b 26 23 03 !.........{&#.
01 3c 00 01 00 b1
Update:
After I unbonded the device from my phone, I was able to get the following:
[bluetooth]# connect C2:DB:C0:DC:E4:55
Attempting to connect to C2:DB:C0:DC:E4:55
[CHG] Device C2:DB:C0:DC:E4:55 Connected: yes
Connection successful
[CHG] Device C2:DB:C0:DC:E4:55 Connected: no
So it seems it automatically disconnects as soon as possible? Then if I try using aranetctl, I get the same error I mentioned above.
Any ideas?
Thanks!
After pair
command, you should see PIN input and Aranet screen should show it (same as when pairing with phone)
Try following this instruction:
Open bluetoothctl: sudo bluetoothctl
Enable passcode support: agent KeyboardOnly
Enable adapter: power on
Scan devices: scan on
When found your device, stop scan: scan off
Pair device: pair <DEVICE_ADDRESS>
Disconnect if automatically connected: disconnect <DEVICE_ADDRESS>
Exit from bluetooth ctl: exit
if that fails, reboot and try again
Hi Anrijs, I actually managed to do it. This was the trick though:
[bluetooth]# remove C2:DB:C0:DC:E4:55
[DEL] Device C2:DB:C0:DC:E4:55 Aranet4 00523
Device has been removed
[bluetooth]# trust C2:DB:C0:DC:E4:55
Device C2:DB:C0:DC:E4:55 not available
[bluetooth]# scan on
Discovery started
[CHG] Controller D8:3A:DD:57:52:22 Discovering: yes
[NEW] Device C2:DB:C0:DC:E4:55 Aranet4 00523
[bluetooth]# scan off
[CHG] Device C2:DB:C0:DC:E4:55 RSSI is nil
[CHG] Controller D8:3A:DD:57:52:22 Discovering: no
Discovery stopped
[bluetooth]# trust C2:DB:C0:DC:E4:55
[CHG] Device C2:DB:C0:DC:E4:55 Trusted: yes
Changing C2:DB:C0:DC:E4:55 trust succeeded
[bluetooth]# pair C2:DB:C0:DC:E4:55
Attempting to pair with C2:DB:C0:DC:E4:55
[CHG] Device C2:DB:C0:DC:E4:55 Connected: yes
Request passkey
And then it started working. Thank you for assistance!
I would like to add the solution for me.
None of the above worked for me, but it got me close.
- I didn't realize, you must be connected to the aranet device with bluetooth BEFORE you run your python program to connect to it.
- Scanning for it will be successful at long ranges in my experience, but in order for the device to not pair and then immediately unpair, as others experienced as well, you must have the aranet device VERY close to your system. I put it 1ft away, re-ran the pair command and BAM. I was asked for a PIN, and the aranet device suddenly displayed a number. Typed it in and was connected
At that point, the python programs all worked, which specified the MAC and requested current readings.
Before that, only the scanning python examples worked.
My dumb self went and upgraded from a Raspberry Pi Zero 2 W to a Raspberry Pi 5, trying to get this to work. That was never the problem. It should work on any Raspberry Pi I bet. I haven't tested again with the zero 2w though.