im-0 / cometblue

Command line tool and python library for "Comet Blue" thermostat
GNU General Public License v3.0
34 stars 24 forks source link

I cannot read characteristics. #4

Open miklik72 opened 6 years ago

miklik72 commented 6 years ago

Hi, Looks that I cannot read characteristics from cometblue device from Lidl FW 0.0.9.silvercres. Via gatttoll I'm able read all characteristics. So I don't know, if I'm using some bad library or where is problem. How can I test reading characteristics by pygattlib?

OS: raspbian jessie 8.0 HW: Raspberry PI zero W


root@mm_pi0w:~/cometblue/cometblue# cometblue -L debug discover
 I|2017-08-28 18:36:19,500|15631:-1225265152| Starting discovery on adapter "hci0" with 10 seconds timeout...
 D|2017-08-28 18:36:29,580|15631:-1225265152| All discovered devices: {'B4:C9:4C:84:97:DE': 'Comet Blue'}
 I|2017-08-28 18:36:29,586|15631:-1225265152| Connecting to device "B4:C9:4C:84:97:DE"...
 D|2017-08-28 18:36:33,630|15631:-1225265152| Discovering characteristics for "B4:C9:4C:84:97:DE"...
 D|2017-08-28 18:37:48,635|15631:-1225265152| Skipping device `"`Comet Blue" ("B4:C9:4C:84:97:DE") because of exception: RuntimeError('Device is not responding!',)
 I|2017-08-28 18:37:48,638|15631:-1225265152| Discovery finished

root@mm_pi0w:~/cometblue/cometblue# gatttool -b B4:C9:4C:84:97:DE -I
[B4:C9:4C:84:97:DE][LE]> connect
Attempting to connect to B4:C9:4C:84:97:DE
Connection successful
[B4:C9:4C:84:97:DE][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x0a, char value handle: 0x0007, uuid: 00002a02-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x02, char value handle: 0x0009, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x22, char value handle: 0x000e, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x001a, char properties: 0x0a, char value handle: 0x001b, uuid: 47e9ee01-47e9-11e4-8939-164230d1df67
handle: 0x001c, char properties: 0x0a, char value handle: 0x001d, uuid: 47e9ee10-47e9-11e4-8939-164230d1df67
handle: 0x001e, char properties: 0x0a, char value handle: 0x001f, uuid: 47e9ee11-47e9-11e4-8939-164230d1df67
handle: 0x0020, char properties: 0x0a, char value handle: 0x0021, uuid: 47e9ee12-47e9-11e4-8939-164230d1df67
handle: 0x0022, char properties: 0x0a, char value handle: 0x0023, uuid: 47e9ee13-47e9-11e4-8939-164230d1df67
handle: 0x0024, char properties: 0x0a, char value handle: 0x0025, uuid: 47e9ee14-47e9-11e4-8939-164230d1df67
handle: 0x0026, char properties: 0x0a, char value handle: 0x0027, uuid: 47e9ee15-47e9-11e4-8939-164230d1df67
handle: 0x0028, char properties: 0x0a, char value handle: 0x0029, uuid: 47e9ee16-47e9-11e4-8939-164230d1df67
handle: 0x002a, char properties: 0x0a, char value handle: 0x002b, uuid: 47e9ee20-47e9-11e4-8939-164230d1df67
handle: 0x002c, char properties: 0x0a, char value handle: 0x002d, uuid: 47e9ee21-47e9-11e4-8939-164230d1df67
handle: 0x002e, char properties: 0x0a, char value handle: 0x002f, uuid: 47e9ee22-47e9-11e4-8939-164230d1df67
handle: 0x0030, char properties: 0x0a, char value handle: 0x0031, uuid: 47e9ee23-47e9-11e4-8939-164230d1df67
handle: 0x0032, char properties: 0x0a, char value handle: 0x0033, uuid: 47e9ee24-47e9-11e4-8939-164230d1df67
handle: 0x0034, char properties: 0x0a, char value handle: 0x0035, uuid: 47e9ee25-47e9-11e4-8939-164230d1df67
handle: 0x0036, char properties: 0x0a, char value handle: 0x0037, uuid: 47e9ee26-47e9-11e4-8939-164230d1df67
handle: 0x0038, char properties: 0x0a, char value handle: 0x0039, uuid: 47e9ee27-47e9-11e4-8939-164230d1df67
handle: 0x003a, char properties: 0x0a, char value handle: 0x003b, uuid: 47e9ee2a-47e9-11e4-8939-164230d1df67
handle: 0x003c, char properties: 0x0a, char value handle: 0x003d, uuid: 47e9ee2b-47e9-11e4-8939-164230d1df67
handle: 0x003e, char properties: 0x0a, char value handle: 0x003f, uuid: 47e9ee2c-47e9-11e4-8939-164230d1df67
handle: 0x0040, char properties: 0x0a, char value handle: 0x0041, uuid: 47e9ee2d-47e9-11e4-8939-164230d1df67
handle: 0x0042, char properties: 0x0a, char value handle: 0x0043, uuid: 47e9ee2e-47e9-11e4-8939-164230d1df67
handle: 0x0044, char properties: 0x1a, char value handle: 0x0045, uuid: 47e9ee40-47e9-11e4-8939-164230d1df67
handle: 0x0047, char properties: 0x08, char value handle: 0x0048, uuid: 47e9ee30-47e9-11e4-8939-164230d1df67```

B.R.
Martin Mikala
signaleleven commented 6 years ago

I could not compile easily the dependencies of this library, but by attempting to use the the thermostat with gatttool as described here http://torsten-traenkner.de/wissen/smarthome/heizung.php

...it looks like I cannot even authenticate with the PIN. It might be that the newer firmware has slightly different characteristics. A little bit of HCI snooping has to be done to see if the app is doing something different now. And probably now there are better ways of accessing GATT stuff in python.

signaleleven commented 6 years ago

And I confirm. I used the HCI snooping as described in the link above and I realized that to write the PIN it writes 0x0048 instead of 0x0047 By writing the pin on that address, I succed and I am therefore authenticated.

The expect script in the link above (once amended to use 0x0048 for the PIN) then has a way of reading and setting the current temperature, but that fails too (well, it succeeds in reading something that is not my set temperature). I assume that address is changed too. The naive "+1" on the address did not work (it reads something else). Since my snoop file contains a temperature change, I should be able to find what the app is doing to get and set the temperature, but now I have limited time ;)

tanki658 commented 6 years ago

Hi, I have the same problem with cometblue devices. Have you find a way for read temperature?

signaleleven commented 6 years ago

Hello,

I can set the temperature and read the temperature perceived by the thermostat (not very useful, it's naturally higher than ambient temp) with some changes to the expect script in the link a few posts up

I published the version I am using here: https://gist.github.com/signaleleven/ffec6d96a6d46a0eaec51e4f99f122f1

tanki658 commented 6 years ago

char-read-hnd 0x003f Error: Characteristic value/descriptor read failed: Attribute can't be read

I don't know what's wrong. Maybe the characteristics are different?

signaleleven commented 6 years ago

It could be that you have a different firmware. I assume it works with the mobile app? If you have android, you can enable HCI snoop in the developer menu, and look at the sniffed traffic with wireshark...

tanki658 commented 6 years ago

Mobile app is working good on my iphone. Which firmware version do you have? My firmware revision string: (hex) 30 2e 30 2e 31 30, (asci): 0.0.10

signaleleven commented 6 years ago

Sorry, I never came back to this, but now that GATT support on python seems to be improving I am playing with the idea of making a little library. Which characteristic are you reading for getting the firmware version? I poked around and I could not find it, and the mobile app does not show it.