diff --git a/lib/Insteon/AllLinkDatabase.pm b/lib/Insteon/AllLinkDatabase.pm index 4fcba2914..140a59d87 100644 --- a/lib/Insteon/AllLinkDatabase.pm +++ b/lib/Insteon/AllLinkDatabase.pm @@ -851,6 +851,8 @@ sub add_link # check whether the link already exists my $key = $self->get_linkkey($device_id, $group, $is_controller, $data3); + $$self{_success_callback} = ($link_parms{callback}) ? $link_parms{callback} : undef; + $$self{_failure_callback} = ($link_parms{failure_callback}) ? $link_parms{failure_callback} : undef; if (!defined($link_parms{aldb_check}) && (!$$self{device}->isa('Insteon_PLM'))){ ## Check whether ALDB is in sync $self->{callback_parms} = \%link_parms; @@ -896,8 +898,6 @@ sub add_link $ramp_rate = '0.1' unless $ramp_rate; # 0.1s is the default # get the first available memory location my $address = $self->get_first_empty_address(); - $$self{_success_callback} = ($link_parms{callback}) ? $link_parms{callback} : undef; - $$self{_failure_callback} = ($link_parms{failure_callback}) ? $link_parms{failure_callback} : undef; if ($address) { &::print_log("[Insteon::AllLinkDatabase] DEBUG2: adding link record to " . $$self{device}->get_object_name diff --git a/lib/Insteon/BaseInsteon.pm b/lib/Insteon/BaseInsteon.pm index f5e196f9e..eb6cbfb3c 100644 --- a/lib/Insteon/BaseInsteon.pm +++ b/lib/Insteon/BaseInsteon.pm @@ -2887,7 +2887,8 @@ sub sync_links my %link_req = ( member => $insteon_object, cmd => 'add', object => $self->interface, group => $self->group, is_controller => 1, callback => "$self_link_name->_process_sync_queue()", - data3 => $subaddress); + failure_callback => $failure_callback, + data3 => $self->group); $link_req{cause} = "Adding controller record to $self_link_name for $interface_name"; $link_req{data3} = $self->group; push @{$$self{sync_queue}}, \%link_req; @@ -2899,6 +2900,7 @@ sub sync_links my %link_req = ( member => $self->interface, cmd => 'add', object => $insteon_object, group => $self->group, is_controller => 0, callback => "$self_link_name->_process_sync_queue()", + failure_callback => $failure_callback, data3 => '00'); $link_req{cause} = "Adding responder record to $interface_name from $self_link_name"; push @{$$self{sync_queue}}, \%link_req; @@ -2938,6 +2940,7 @@ sub sync_links group => $self->group, is_controller => 0, on_level => $tgt_on_level, ramp_rate => $tgt_ramp_rate, callback => "$self_link_name->_process_sync_queue()", + failure_callback => $failure_callback, data3 => $member->group); $link_req{cause} = "Adding responder record to $member_name from $self_link_name"; push @{$$self{sync_queue}}, \%link_req; @@ -2948,6 +2951,7 @@ sub sync_links group => $self->group, is_controller => 0, on_level => $tgt_on_level, ramp_rate => $tgt_ramp_rate, callback => "$self_link_name->_process_sync_queue()", + failure_callback => $failure_callback, data3 => $member->group); $link_req{skip} = "Unable to add the following responder record to $member_name " ."from $self_link_name because the aldb of $member_name is " @@ -2997,6 +3001,7 @@ sub sync_links group => $self->group, is_controller => 0, on_level => $tgt_on_level, ramp_rate => $tgt_ramp_rate, callback => "$self_link_name->_process_sync_queue()", + failure_callback => $failure_callback, data3 => $member->group); $link_req{cause} = "Updating responder record on $member_name " . "to fix $cause"; @@ -3009,7 +3014,8 @@ sub sync_links my %link_req = ( member => $insteon_object, cmd => 'add', object => $member, group => $self->group, is_controller => 1, callback => "$self_link_name->_process_sync_queue()", - data3 => $subaddress); + failure_callback => $failure_callback, + data3 => $self->group); $link_req{cause} = "Adding controller record to $self_link_name for $member_name"; push @{$$self{sync_queue}}, \%link_req; } @@ -3034,11 +3040,9 @@ sub sync_links $log_text .= $sync_req{cause} . "\n"; } PRINT: for (keys %sync_req) { - next PRINT if ($_ eq 'cause'); - next PRINT if ($_ eq 'callback'); - next PRINT if ($_ eq 'member'); - next PRINT if ($_ eq 'object'); - next PRINT if ($_ eq 'skip'); + next PRINT if (($_ eq 'cause') || ($_ eq 'callback') || + ($_ eq 'member') || ($_ eq 'object') || + ($_ eq 'skip') || ($_ eq 'failure_callback')); $log_text .= "$_ = $sync_req{$_}; "; } ::print_log($log_text); diff --git a/lib/Insteon/BaseInterface.pm b/lib/Insteon/BaseInterface.pm index 0b87c4806..a010c0fed 100644 --- a/lib/Insteon/BaseInterface.pm +++ b/lib/Insteon/BaseInterface.pm @@ -369,8 +369,6 @@ sub process_queue &main::print_log("[Insteon::BaseInterface] WARN! Unable to clear acknowledge for " . ((defined($failed_message->setby)) ? $failed_message->setby->get_object_name : "undefined")); } - # clear active message - $self->clear_active_message(); # may instead want a "failure" callback separate from success callback if ($failed_message->failure_callback) { @@ -383,6 +381,8 @@ sub process_queue &::print_log("[Insteon::BaseInterface] problem w/ retry callback: $@") if $@; package Insteon::BaseInterface; } + # clear active message + $self->clear_active_message(); $self->process_queue(); } }