Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A1Device changes require testing #8

Open
a1aw opened this issue Aug 18, 2017 · 4 comments
Open

A1Device changes require testing #8

a1aw opened this issue Aug 18, 2017 · 4 comments

Comments

@a1aw
Copy link
Owner

a1aw commented Aug 18, 2017

@computerlyrik I have removed the following code:

if (pl[0x4] >= 48 && pl[0x4] <= 57) {
                String decodeValue1;
                String decodeValue2;
                byte value1;
                byte value2;
                decodeValue1 = String.valueOf(pl[0x4]);
                decodeValue2 = String.valueOf(pl[0x5]);
                value1 = Short.decode(decodeValue1).byteValue();
                value2 = Short.decode(decodeValue2).byteValue();
                sensorData.setTemperature((float) ((value1 * 10 + value2) / 10.0));
                decodeValue1 = String.valueOf(pl[0x6]);
                decodeValue2 = String.valueOf(pl[0x7]);
                value1 = Short.decode(decodeValue1).byteValue();
                value2 = Short.decode(decodeValue2).byteValue();
                sensorData.setHumidity((float) ((value1 * 10 + value2) / 10.0));
                decodeValue1 = String.valueOf(pl[0x8]);
                sensorData.setLight(Short.decode(decodeValue1).byteValue());
                decodeValue1 = String.valueOf(pl[0x0a]);
                sensorData.setAirquality(Short.decode(decodeValue1).byteValue());
                decodeValue1 = String.valueOf(pl[0xc]);
                sensorData.setNoise(Short.decode(decodeValue1).byteValue());
            } else {
                sensorData.setTemperature((float) ((pl[0x4] * 10 + pl[0x5]) / 10.0));
                sensorData.setHumidity((float) ((pl[0x6] * 10 + pl[0x7]) / 10.0));
                sensorData.setLight(pl[0x8]);
                sensorData.setAirquality(pl[0x0a]);
                sensorData.setNoise(pl[0xc]);
            }

Something crazy. 😸 I don't have a A1 device currently. Can you help me to test it out the current code?

@computerlyrik
Copy link
Contributor

computerlyrik commented Aug 20, 2017

I am happy to help debugging!

At first: The tracelog is not written on my system. Thus i will paste the log inline.
Result: Communication working, result invalid:

Running com.github.mob41.blapi.DevicesTest
[main] DEBUG com.github.mob41.blapi.BLDevice - Discovering devices
[main] DEBUG com.github.mob41.blapi.BLDevice - Constructing DiscoveryPacket
[main] DEBUG com.github.mob41.blapi.pkt.dis.DiscoveryPacket - DiscoveryPacket constructor start
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - cal=1503217199382 tz=Europe/Berlin
[main] DEBUG com.github.mob41.blapi.pkt.dis.DiscoveryPacket - localIpAddr= ovo/192.168.42.105
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - Raw offset: 3600000
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - Calculated offset: getRawOffset/1000/-3600=1000
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - min=19 hr=10
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - year=2017 dayOfWk=6
[main] TRACE com.github.mob41.blapi.pkt.dis.DiscoveryPacket - dayOfMn=20 month=8
[main] DEBUG com.github.mob41.blapi.pkt.dis.DiscoveryPacket - tzOffset>0: 0x08=3e8 0x09-0x0b=0x00
[main] DEBUG com.github.mob41.blapi.pkt.dis.DiscoveryPacket - checksum=ffffc2d0
[main] DEBUG com.github.mob41.blapi.pkt.dis.DiscoveryPacket - DiscoveryPacket constructor end
[main] DEBUG com.github.mob41.blapi.BLDevice - Sending broadcast
[main] DEBUG com.github.mob41.blapi.BLDevice - No timeout was set. Blocking thread until received
[main] DEBUG com.github.mob41.blapi.BLDevice - Waiting for datagrams
[main] DEBUG com.github.mob41.blapi.BLDevice - Received. Closing socket
[main] DEBUG com.github.mob41.blapi.BLDevice - Info: host=192.168.42.110 mac=b:ffffff88:ffffffe4:34:ffffffea:34 deviceType=0x2714
[main] DEBUG com.github.mob41.blapi.BLDevice - Creating BLDevice instance
[main] DEBUG com.github.mob41.blapi.BLDevice - Adding to found devices list
[main] DEBUG com.github.mob41.blapi.BLDevice - Converting list to array
[main] DEBUG com.github.mob41.blapi.BLDevice - End of device discovery
[main] INFO com.github.mob41.blapi.DevicesTest - BLDevice returned 1 number of devices.
[main] INFO com.github.mob41.blapi.DevicesTest - BLDevice mac is b:ffffff88:ffffffe4:34:ffffffea:34
[main] DEBUG com.github.mob41.blapi.BLDevice - Authentication method starts
[main] DEBUG com.github.mob41.blapi.BLDevice - Constructing AuthCmdPayload
[main] DEBUG com.github.mob41.blapi.BLDevice - Sending CmdPacket with AuthCmdPayload: cmd=65 len=80
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: 0,0,0,0,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,54,65,73,74,20,20,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Constructor CmdPacket starts
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - count=14919 cmdPayload.cmd=65 payload.len=80
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - New count: 14920 (added by 1)
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Creating byte array with data
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Running checksum for headers
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Headers checksum: c3a1
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Creating AES instance with provided key [9, 118, 40, 52, 63, -23, -98, 35, 118, 92, 21, 19, -84, -49, -117, 2], iv [86, 46, 23, -103, 109, 9, 61, 40, -35, -77, -70, 105, 90, 46, 111, 88]
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Encrypting payload
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: 45,34,52,ffffffe7,fffffff9,2e,ffffffda,ffffff95,ffffff83,44,ffffff93,8,35,ffffffef,ffffff9a,6d,fffffffb,69,2d,ffffffc3,70,ffffffb9,4,43,ffffffac,5c,ffffffd6,3f,ffffffbb,53,ffffffad,fffffffa,8,ffffff81,4c,ffffffa7,fffffff8,ffffffcf,41,71,0,32,ffffff8e,57,c,3b,ffffff86,ffffffc9,4d,5,70,ffffff84,49,ffffffa3,ffffff89,ffffffe2,ffffff9a,ffffffe1,4,54,36,ffffffa0,5b,ffffffdd,ffffffdc,2,ffffffc1,61,ffffffaf,13,25,ffffffe8,7e,19,ffffffb0,fffffff7,ffffffd1,ffffffce,6,ffffff8d,
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Encrypted. len=80
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Running whole packet checksum
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Whole packet checksum: bdda
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - End of CmdPacket constructor
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: 5a,ffffffa5,ffffffaa,55,5a,ffffffa5,ffffffaa,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,ffffffda,ffffffbd,0,0,2a,27,65,0,48,3a,b,ffffff88,ffffffe4,34,ffffffea,34,0,0,0,0,ffffffa1,ffffffc3,0,0,45,34,52,ffffffe7,fffffff9,2e,ffffffda,ffffff95,ffffff83,44,ffffff93,8,35,ffffffef,ffffff9a,6d,fffffffb,69,2d,ffffffc3,70,ffffffb9,4,43,ffffffac,5c,ffffffd6,3f,ffffffbb,53,ffffffad,fffffffa,8,ffffff81,4c,ffffffa7,fffffff8,ffffffcf,41,71,0,32,ffffff8e,57,c,3b,ffffff86,ffffffc9,4d,5,70,ffffff84,49,ffffffa3,ffffff89,ffffffe2,ffffff9a,ffffffe1,4,54,36,ffffffa0,5b,ffffffdd,ffffffdc,2,ffffffc1,61,ffffffaf,13,25,ffffffe8,7e,19,ffffffb0,fffffff7,ffffffd1,ffffffce,6,ffffff8d,
[main] DEBUG com.github.mob41.blapi.BLDevice - DESTIP: 192.168.42.110
[main] DEBUG com.github.mob41.blapi.BLDevice - DESTPORT: 80
[main] DEBUG com.github.mob41.blapi.BLDevice - Received datagram
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: 5a,ffffffa5,ffffffaa,55,5a,ffffffa5,ffffffaa,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,ffffffd9,0,0,2a,27,ffffffe9,3,48,3a,b,ffffff88,ffffffe4,34,ffffffea,34,0,0,0,0,56,ffffffcb,0,0,52,50,2,ffffffad,ffffffa4,ffffff8e,ffffffa5,ffffffb1,7b,ffffff80,ffffffba,1e,71,ffffff86,1a,72,ffffffbf,62,fffffff0,ffffffef,ffffffe6,79,ffffff84,5e,ffffffc3,ffffffbd,ffffffc8,ffffffb1,ffffff83,77,ffffff97,28,
[main] DEBUG com.github.mob41.blapi.BLDevice - Getting encrypted data from 0x38 to the end
[main] DEBUG com.github.mob41.blapi.BLDevice - encDataLen=32
[main] DEBUG com.github.mob41.blapi.BLDevice - Creating AES instance with initial iv, key
[main] DEBUG com.github.mob41.blapi.BLDevice - Decrypting encrypted data
[main] DEBUG com.github.mob41.blapi.BLDevice - Decrypted. len=32
[main] DEBUG com.github.mob41.blapi.BLDevice - Packet received payload bytes: 0200000008266F3B750C5C1AE2F248794FD93558E8B4A8E9878FE4BBAA000000
[main] DEBUG com.github.mob41.blapi.BLDevice - Getting key from 0x04 to 0x14
[main] DEBUG com.github.mob41.blapi.BLDevice - Packet received key bytes: 08266F3B750C5C1AE2F248794FD93558
[main] DEBUG com.github.mob41.blapi.BLDevice - Getting ID from 0x00 to 0x04
[main] DEBUG com.github.mob41.blapi.BLDevice - Packet received id bytes: 02000000
[main] DEBUG com.github.mob41.blapi.BLDevice - ID len=4
[main] DEBUG com.github.mob41.blapi.BLDevice - End of authentication method
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Constructor CmdPacket starts
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - count=14920 cmdPayload.cmd=6a payload.len=16
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - New count: 14921 (added by 1)
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Creating byte array with data
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Running checksum for headers
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Headers checksum: beb0
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Creating AES instance with provided key [8, 38, 111, 59, 117, 12, 92, 26, -30, -14, 72, 121, 79, -39, 53, 88], iv [86, 46, 23, -103, 109, 9, 61, 40, -35, -77, -70, 105, 90, 46, 111, 88]
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Encrypting payload
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: ffffffa7,fffffffd,ffffffb4,ffffffba,62,5a,ffffffe2,ffffffc2,f,11,29,ffffffc5,6c,ffffff87,ffffffff,ffffffda,
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Encrypted. len=16
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - Running whole packet checksum
[main] TRACE com.github.mob41.blapi.pkt.CmdPacket - Whole packet checksum: be6e
[main] DEBUG com.github.mob41.blapi.pkt.CmdPacket - End of CmdPacket constructor
[main] TRACE com.github.mob41.blapi.BLDevice - printBytes: 5a,ffffffa5,ffffffaa,55,5a,ffffffa5,ffffffaa,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6e,ffffffbe,0,0,2a,27,6a,0,49,3a,b,ffffff88,ffffffe4,34,ffffffea,34,2,0,0,0,ffffffb0,ffffffbe,0,0,ffffffa7,fffffffd,ffffffb4,ffffffba,62,5a,ffffffe2,ffffffc2,f,11,29,ffffffc5,6c,ffffff87,ffffffff,ffffffda,
[main] DEBUG com.github.mob41.blapi.BLDevice - DESTIP: 192.168.42.110
[main] DEBUG com.github.mob41.blapi.BLDevice - DESTPORT: 80
[main] DEBUG com.github.mob41.blapi.A1Device - checkSensors Packet received bytes: 5AA5AA555AA5AA5500000000000000000000000000000000000000000000000076D900002A27E903483A0B88E434EA340000000056CB0000525002ADA48EA5B17B80BA1E71861A72BF62F0EFE679845EC3BDC8B183779728000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
[main] DEBUG com.github.mob41.blapi.A1Device - checkSensors Packet received bytes (decrypted): 64CECB2A3B25E167FF1714700B1C2EF4E284F1050D355CF4D28A8255352A64B805F2CFC7EBD8143CCCC07A3B048BDF9DBA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5BA903F280DA190620F7DB28A87FC48B5
[main] INFO com.github.mob41.blapi.DevicesTest - A1Device Temp: 62.7, Humidity: -20.7, light: -1, air_quality: unknown, noise: 11
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.332 sec

@computerlyrik
Copy link
Contributor

@mob41 Found out (probably again :) ) how to enable log output.
Please add a hint to README for reporting bugs / help development, enable trace file output on src/main/test/simplelogger.properties
Also, i propose to rename the file to broadlink-java-api.trace.log.txt - otherwise github will not process it (does not support *.log files)

Here goes the file:

broadlink-java-api.trace.log.txt

@a1aw
Copy link
Owner Author

a1aw commented Aug 20, 2017

I created https://github.com/mob41/broadlink-java-api/blob/master/CONTRIBUTING.md but seems not showing when creating a new issue?

@a1aw
Copy link
Owner Author

a1aw commented Oct 4, 2017

I will undo the changes and review the code tmr.

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

No branches or pull requests

2 participants