Commit 563cda0 1 parent 4105312 commit 563cda0 Copy full SHA for 563cda0
File tree 2 files changed +26
-3
lines changed
com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee
com.zsmartsystems.zigbee.dongle.ember/src/main/java/com/zsmartsystems/zigbee/dongle/ember
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -575,7 +575,6 @@ public ZigBeeStatus startup(boolean reinitialize) {
575
575
ncp .sendManyToOneRouteRequest (concentratorType , radius );
576
576
}
577
577
578
- ncp .getConfiguration (EzspConfigId .EZSP_CONFIG_PACKET_BUFFER_COUNT );
579
578
return joinedNetwork ? ZigBeeStatus .SUCCESS : ZigBeeStatus .BAD_RESPONSE ;
580
579
}
581
580
@@ -763,7 +762,27 @@ public ZigBeeStatus setNetworkState(ZigBeeNetworkState networkState) {
763
762
// token area once - subsequent writes will fail, and therefore changing IEEE address (eg from a
764
763
// backup/restore) may fail.
765
764
ncp .tokenFactoryReset (false , false );
766
- return ncp .leaveNetwork () == EmberStatus .EMBER_SUCCESS ? ZigBeeStatus .SUCCESS : ZigBeeStatus .FAILURE ;
765
+ if (ncp .leaveNetwork () != EmberStatus .EMBER_SUCCESS ) {
766
+ return ZigBeeStatus .FAILURE ;
767
+ }
768
+
769
+ // Wait for the notification from the NCP that it is offline.
770
+ // This comes through the EzspStackStatusHandler which is processed elsewhere
771
+ // and sets networkStateUp to false
772
+ long timer = System .currentTimeMillis () + WAIT_FOR_ONLINE ;
773
+ do {
774
+ if (!networkStateUp ) {
775
+ return ZigBeeStatus .SUCCESS ;
776
+ }
777
+
778
+ try {
779
+ Thread .sleep (250 );
780
+ } catch (InterruptedException e ) {
781
+ break ;
782
+ }
783
+ } while (timer > System .currentTimeMillis ());
784
+
785
+ return ZigBeeStatus .INVALID_STATE ;
767
786
case ONLINE :
768
787
return ncp .networkInit () == EmberStatus .EMBER_SUCCESS ? ZigBeeStatus .SUCCESS : ZigBeeStatus .FAILURE ;
769
788
default :
Original file line number Diff line number Diff line change @@ -2092,7 +2092,11 @@ public ZigBeeStatus restoreBackup(UUID uuid) {
2092
2092
logger .debug ("RestoreBackup: Backup read from {}" , uuid );
2093
2093
2094
2094
// Take the network offline for reconfiguration
2095
- transport .setNetworkState (ZigBeeNetworkState .UNINITIALISED );
2095
+ ZigBeeStatus offlineResponse = transport .setNetworkState (ZigBeeNetworkState .UNINITIALISED );
2096
+ if (offlineResponse != ZigBeeStatus .SUCCESS ) {
2097
+ logger .error ("RestoreBackup: Failed to set network to UNINITIALISED with response {}" , offlineResponse );
2098
+ return ZigBeeStatus .INVALID_STATE ;
2099
+ }
2096
2100
2097
2101
// To properly re-add nodes, we must be INITIALIZING
2098
2102
// To call startup, we must be INITIALIZING
You can’t perform that action at this time.
0 commit comments