Skip to content

Commit

Permalink
Insteon: Catch, Report and Recover from Errors in Sync All Links
Browse files Browse the repository at this point in the history
This enables the same feature that has been available in the scan_all_links function.  If an error occurs while attempting to sync_all_links, MH now recovers from the error, and continues to process the remainin objects in Sync_All.  At the conclusion of the Sync_All routine a message is displayed identifying the failed objects.

Partial Fix hollie#73
  • Loading branch information
krkeegan committed Oct 23, 2013
1 parent b0d9622 commit a57834e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/Insteon/AllLinkDatabase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions lib/Insteon/BaseInsteon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 "
Expand Down Expand Up @@ -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";
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/Insteon/BaseInterface.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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();
}
}
Expand Down

0 comments on commit a57834e

Please sign in to comment.