Open uniejo opened 10 years ago
Hey @uniejo, thanks for the suggestion. I've made a release 0.5.1 that has this fix (see here). Can you test this out? Do you know what commands that need to be sent to the stick to actually make it link to the Circle Plus to setup the link? I think we need to add these commands in case the network key is not reported so that it is setup correctly.
Regards, Lieven.
On 29. july 2014, Lieven Hollevoet notifications@github.com wrote:
Hey @uniejo https://github.com/uniejo, thanks for the suggestion. I've made a release 0.5.1 that has this fix. Can you test this out?
It appears to work just fine. I assume that the warning is a result of one of the values missing later on. I did not look further into this.
~/PlugwiseOnLinux> perl -Ilib -MDevice::Plugwise -E 'my $pw=Device::Plugwise->new(device=>"/dev/ttyUSB0")' Use of uninitialized value $address in substr at lib/Device/Plugwise.pm line 743. ~/PlugwiseOnLinux>
(I had said that it could be reproduced by giving the plus device a reset. It was actually a stick reset. I had to use Windows Source program to remove association during first setup, since I have not yet found the commands to do a full stick reset from Perl)
Do you know what commands that need to be sent to the stick to actually
make it link to the Circle Plus to setup the link? I think we need to add these commands in case the network key is not reported so that it is setup correctly.
Regards, Lieven.
— Reply to this email directly or view it on GitHub https://github.com/hollie/device-plugwise-perl/issues/3#issuecomment-50527502 .
I may have the commands for setting up a connection. However it does not yet seem to work consistently. (I got a bit sidetracked writing my own Plugwise module that uses AnyEvent, and has a table of command formats, and parameters so that commands can be packed and unpacked without adding special code around calling commands. It supports callback triggers for ack/response/errors/timeouts)
In order to set up a link between the stick and the plus device you need to know the mac address of the plus device (Or would it be possible to do a scan for a plus device at that point?) . After that point it is not needed as the stick knows it (and reports it back).
Here is a bit of log output from the script that I am still working on. It may show how to connect a stick with a plus device. (My findings has been inspired by https://github.com/hackstuces/PlugwiseOnLinux/blob/master/pair_pol_v1.py )
Setting alias plus = 000D6F00029C44B9 SEND 000A B43C "initialize_stick" RECV 0000 00D3 00C1 "ack" - "Successful" RECV 0011 00D3 000D6F00029008C4 01 00 "initialize_stick_response" Stick is not associated with a plus device. stick_mac = 000D6F00029008C4 Device status to plus_mac => 000D6F00029C44B9 SEND 0023 000D6F00029008C4 7F70 "device_status" RECV 0000 00D4 00C1 "ack" - "Successful" SEND 0023 000D6F00029C44B9 D128 "device_status" RECV 0024 00D4 000D6F00029008C4 00000000 00000000 00 80 653907008512 4E0842BB 00 "device_status_response" device_status_response from Stick : {"circle_mac" => "000D6F00029008C4","firmware_version" => "2078-09-12T20:43:00.000000","format" => "{type:4:0024} {seq:4} {circle_mac:16} {time:8} {logaddr:8} {power_state:2} {hertz:2} {hardware_version:12} {firmware_version:8} {device_type:2}","type" => "0024","firmware_version_orig" => "4E0842BB","time" => "2000-01-01T00:00:00.000000","name" => "device_status_response","line_raw" => "002400D4000D6F00029008C4000000000000000000806539070085124E0842BB002CFB","tty" => "/dev/ttyUSB0","hardware_version" => "653907008512","checksum_status" => "valid","logaddr_orig" => "00000000","hertz" => 80,"power_state" => "00","checksum" => "2CFB","line" => "0024 00D4 000D6F00029008C4 00000000 00000000 00 80 653907008512 4E0842BB 00","seq" => "00D4","logaddr" => 0,"device_type_text" => "Stick","timestamp" => "2014-05-06T18:57:33.620340","device_type" => "00","time_orig" => "00000000"} RECV 0000 00D5 00C1 "ack" - "Successful" SEND 0004 00 01 0000000000000000 0000000000000000 1CEA "link_plus" RECV (Comment line) # APSRequestNodeInfo: Source MAC: 000D6F00029008C4# APSRequestNodeInfo: Destination MAC: 000D6F00029C44B9 RECV 0000 00D6 00C1 "ack" - "Successful" SEND 0001 CAAB "pairing_request" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C4 "pairing_pending_response" RECV 0003 00D6 00C0 "pairing_ok_response"
(The last pairing pending responces arrive with about 5-10 seconds apart; Total sequence takes about 40 seconds)
/Erik
When connecting a Stick to a Plus device that has been reset (power reset sequence), the 0011 return reply is shorter, resulting in Device::Plugwise refusing to talk to the stick, making it impossible use Device::Plugwise to send commands to set up a link.
On one Stick I get the following reply with a link: RECV 0011 000D 000D6F00029008C4 01 01 9F0D6F00029C44B9 1D9F FF And this reply without a link: RECV 0011 001B 000D6F00029008C4 01 00
I suggest changing the pattern on line 333 of Device/Plugwise.pm as follows:
This adds a "(?:" ... ")?" around the 2 last elements (network_key(16) & short_key(4))