rgerganov / py-air-control

Command line app for controlling Philips air purifiers
MIT License
264 stars 53 forks source link

Message from device got corrupted AC2729 #73

Open kongo09 opened 3 years ago

kongo09 commented 3 years ago

I have an AC2729 which gives me the following:

pi@raspi:~ $ airctrl --ipaddr 192.168.179.12 --protocol coap
2021-01-07 22:36:34,449 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.179.12', 5683), None-None, POST-EI, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 3557C204...8 bytes
2021-01-07 22:36:34,450 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), CON-11708, POST-EI, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 3557C204...8 bytes
2021-01-07 22:36:34,451 - Thread-1   - coapthon.client.coap - DEBUG - Start receiver Thread
2021-01-07 22:36:34,452 - MainThread-Retry-11708 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-01-07 22:36:34,454 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.179.12', 5683), To None, NON-11708, CONTENT-EI, [Content-Type: 0, ] 30705B05...8 bytes
2021-01-07 22:36:34,455 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.179.12', 5683), To None, NON-11708, CONTENT-EI, [Content-Type: 0, ] 30705B05...8 bytes
2021-01-07 22:36:34,455 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-01-07 22:36:34,455 - MainThread-Retry-11708 - coapthon.client.coap - DEBUG - retransmit loop ... exit
2021-01-07 22:36:34,467 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.179.12', 5683), None-None, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-01-07 22:36:34,467 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), CON-11709, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-01-07 22:36:34,469 - MainThread-Retry-11709 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-01-07 22:36:34,485 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.179.12', 5683), To None, NON-628, CONTENT-None, [Observe: 627, Content-Type: 50, Max-Age: 60, ] 3557C20558327AC7815C...1140 bytes
2021-01-07 22:36:34,485 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.179.12', 5683), To None, NON-628, CONTENT-None, [Observe: 627, Content-Type: 50, Max-Age: 60, ] 3557C20558327AC7815C...1140 bytes
2021-01-07 22:36:34,485 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-01-07 22:36:34,485 - MainThread-Retry-11709 - coapthon.client.coap - DEBUG - retransmit loop ... exit
Message from device got corrupted
2021-01-07 22:36:34,596 - Thread-1   - coapthon.client.coap - DEBUG - Exiting receiver Thread due to request

The AirMatters app is working - presumably via the cloud as it runs on a different VLAN.

Any ideas?

rgerganov commented 3 years ago

Try commenting these two lines in coap_client.py: https://github.com/rgerganov/py-air-control/blob/master/pyairctrl/coap_client.py#L104-L105

Maybe this digest has changed ...

kongo09 commented 3 years ago

Thanks for the swift reply. This results in the following:

pi@raspi:~ $ airctrl --ipaddr 192.168.179.12 --protocol coap
2021-01-08 14:55:37,917 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.179.12', 5683), None-None, POST-UB, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 6F895209...8 bytes
2021-01-08 14:55:37,918 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), CON-20689, POST-UB, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 6F895209...8 bytes
2021-01-08 14:55:37,919 - Thread-1   - coapthon.client.coap - DEBUG - Start receiver Thread
2021-01-08 14:55:37,920 - MainThread-Retry-20689 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-01-08 14:55:37,923 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.179.12', 5683), To None, NON-20689, CONTENT-UB, [Content-Type: 0, ] 40B18CD0...8 bytes
2021-01-08 14:55:37,923 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.179.12', 5683), To None, NON-20689, CONTENT-UB, [Content-Type: 0, ] 40B18CD0...8 bytes
2021-01-08 14:55:37,923 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-01-08 14:55:37,924 - MainThread-Retry-20689 - coapthon.client.coap - DEBUG - retransmit loop ... exit
2021-01-08 14:55:37,935 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.179.12', 5683), None-None, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-01-08 14:55:37,935 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), CON-20690, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-01-08 14:55:37,937 - MainThread-Retry-20690 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-01-08 14:55:37,951 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.179.12', 5683), To None, CON-8, CONTENT-None, [Observe: 7, Content-Type: 50, Max-Age: 60, ] 6F89520AC2F2D7A2B40D...1141 bytes
2021-01-08 14:55:37,952 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.179.12', 5683), To None, CON-8, CONTENT-None, [Observe: 7, Content-Type: 50, Max-Age: 60, ] 6F89520AC2F2D7A2B40D...1141 bytes
2021-01-08 14:55:37,952 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-01-08 14:55:37,952 - MainThread-Retry-20690 - coapthon.client.coap - DEBUG - retransmit loop ... exit
2021-01-08 14:55:37,963 - Thread-1   - coapthon.layers.messagelayer - DEBUG - send_empty - From None, To None, ACK-None, EMPTY-None, [] No payload
2021-01-08 14:55:37,963 - Thread-1   - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), ACK-8, EMPTY-None, [] No payload
2021-01-08 14:55:37,963 - Thread-1   - coapthon.layers.messagelayer - DEBUG - send_empty - From None, To None, ACK-None, EMPTY-None, [] No payload
2021-01-08 14:55:37,964 - Thread-1   - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.179.12', 5683), ACK-8, EMPTY-None, [] No payload
Unexpected error:non-hexadecimal number found in fromhex() arg at position 1069
2021-01-08 14:55:38,065 - Thread-1   - coapthon.client.coap - DEBUG - Exiting receiver Thread due to request
kongo09 commented 3 years ago

If I print out the encoded_message before the code runs into the exception, it looks like this:

8756F01665ACE90B0B74AEE6D8A1BF31215C60C5AFC19199B0FC9DB5F0EEDE0FB771F0B0A75ED0AD99952256C94D231B988A17121398889A6FA1C857CFD463F6BB94536C860A6A15276DA7B74841B88F4591FEE06407890962D4CC3E193E65621D3FFAAA482F6317D7DEF21D716AB26189A7954E610893BFA614E389602F4E09437CA106663262AD6138E9B6F8241F44707EBC1C6A9CAD398FD480F5A79A788FCA76CE267DE35C04331C9AB60ECE609FEFD485BFE494BE5FE34EECFD2B2B23E8C91831E8979B86F7D7EA4D58E82E860F30383DBDBC5145BBAB32A1C3D01BC8F195149EAC88B2CDAFD5872F131D8AB22566501DCCDB3ED150416D955938C1EFC1A9CA24C069F199DF372DD1A087B20F5964F928A8F503318A37B256A25CE61E423D193CBED6DDDB6C4ADAB3E07D1E42025A6E71CFD1AE4E6A4DE1CEBD20A849AD677D18ACB05407DE842509522CE4E66113E596BFBF6CDB8CFDBD071CF66FA6C96DC8F996A1D86D91D0F1B18C3187224BB5CB887FDD85FE54F588C3E1C273B88AAB5041DD47A56E72F2FB4536D860FAA196D01135C0A1523BE4347962C2EC14D711DD1B32A0CB95D870FB7E1A939F351EE4854D259E6331E7A3D1DFE5B355BB45B0C1813DB9CBB21D15DE7270096FE15382BC482CBD7DFFE96C2100CE2D318534BA690E1220DA2FA3A2E9CD073A8428BD41AD9B6A295D643A357CC2A35FA28C623A0B77D6310FF1D80DB73341AAB0810B9E563669F448C so looking at that, the bytes.fromhex() function must fail, because this is an uneven number of characters in the message string. Right?

rgerganov commented 3 years ago

It seems they changed the way messages are encoded. I don't have a CoAP device so I can't troubleshoot, sorry.

kongo09 commented 3 years ago

The funny thing is, I seem to remember this used to work. I thought you have the same device from what I read. Anything you can point me to in order to investigate?