@@ -209,9 +209,14 @@ public void changeAppState(AppState newState, Bundle extras) {
209
209
EventBus .getDefault ().post (new UpdateEvent (UpdateEventType .EVENT_STATE_CHANGE_UPDATE ));
210
210
startLocalDeviceDiscovery ();
211
211
for (Map .Entry <String , String > entry : matterRmNodeIdMap .entrySet ()) {
212
+ String nodeId = entry .getKey ();
212
213
String matterNodeId = entry .getValue ();
213
214
ChipClientHelper clientHelper = new ChipClientHelper (this );
214
- clientHelper .initChipClientInBackground (matterNodeId );
215
+ if (!chipClientMap .containsKey (matterNodeId )) {
216
+ clientHelper .initChipClientInBackground (matterNodeId );
217
+ } else {
218
+ clientHelper .getCurrentValues (nodeId , matterNodeId , nodeMap .get (nodeId ));
219
+ }
215
220
}
216
221
break ;
217
222
}
@@ -539,64 +544,6 @@ public void onNetworkFailure(Exception exception) {
539
544
});
540
545
}
541
546
542
- private void initChipController (String matterNodeId ) {
543
- Log .d (TAG , "Init ChipController for matter node id : " + matterNodeId );
544
- if (TextUtils .isEmpty (matterNodeId )) {
545
- Log .e (TAG , "======= Init ChipController will not be done. Matter node id is not available" );
546
- return ;
547
- }
548
-
549
- for (Map .Entry <String , Group > entry : groupMap .entrySet ()) {
550
-
551
- if (entry .getValue ().isMatter ()) {
552
- Group g = entry .getValue ();
553
- HashMap <String , String > nodeDetails = g .getNodeDetails ();
554
- if (nodeDetails != null ) {
555
- for (Map .Entry <String , String > detail : nodeDetails .entrySet ()) {
556
-
557
- String nodeId = detail .getKey ();
558
- String mNodeId = detail .getValue ();
559
- String fabricId = "" ;
560
- String ipk = "" ;
561
- String rootCa = "" ;
562
- String catIdOp = "" ;
563
-
564
- if (!matterNodeId .equals (mNodeId )) {
565
- continue ;
566
- }
567
-
568
- Log .d (TAG , "Node detail, node id : " + nodeId + " and matter node id : " + matterNodeId );
569
-
570
- if (g .getFabricDetails () != null ) {
571
- fabricId = g .getFabricDetails ().getFabricId ();
572
- rootCa = g .getFabricDetails ().getRootCa ();
573
- ipk = g .getFabricDetails ().getIpk ();
574
- catIdOp = g .getFabricDetails ().getGroupCatIdOperate ();
575
-
576
- if (!chipClientMap .containsKey (matterNodeId )) {
577
- if (!TextUtils .isEmpty (fabricId ) && !TextUtils .isEmpty (rootCa )
578
- && !TextUtils .isEmpty (ipk ) && !TextUtils .isEmpty (matterNodeId ) && !TextUtils .isEmpty (matterNodeId )) {
579
- ChipClient chipClient = new ChipClient (this , g .getGroupId ()
580
- , fabricId , rootCa , ipk , catIdOp );
581
- chipClientMap .put (matterNodeId , chipClient );
582
- }
583
- }
584
- fetchDeviceMatterInfo (matterNodeId , nodeId );
585
-
586
- EspNode node = nodeMap .get (nodeId );
587
- if (node != null ) {
588
- String nodeType = node .getNewNodeType ();
589
- if (!TextUtils .isEmpty (nodeType ) && nodeType .equals (AppConstants .NODE_TYPE_PURE_MATTER )) {
590
- addParamsForMatterOnlyDevice (nodeId , matterNodeId , node );
591
- }
592
- }
593
- }
594
- }
595
- }
596
- }
597
- }
598
- }
599
-
600
547
private void initChipControllerForHomeGroup () {
601
548
602
549
Log .d (TAG , "============================= init ChipController for home group" );
@@ -767,7 +714,7 @@ public void addParamsForMatterOnlyDevice(String nodeId, String matterNodeId, Esp
767
714
brightnessParam .setDataType ("int" );
768
715
brightnessParam .setUiType (AppConstants .UI_TYPE_SLIDER );
769
716
brightnessParam .setParamType (AppConstants .PARAM_TYPE_BRIGHTNESS );
770
- brightnessParam .setName ("Brightness" );
717
+ brightnessParam .setName (AppConstants . PARAM_BRIGHTNESS );
771
718
brightnessParam .setMinBounds (0 );
772
719
brightnessParam .setMaxBounds (100 );
773
720
brightnessParam .setProperties (properties );
@@ -806,7 +753,7 @@ public void addParamsForMatterOnlyDevice(String nodeId, String matterNodeId, Esp
806
753
saturation .setDataType ("int" );
807
754
saturation .setUiType (AppConstants .UI_TYPE_SLIDER );
808
755
saturation .setParamType (AppConstants .PARAM_TYPE_SATURATION );
809
- saturation .setName ("Saturation" );
756
+ saturation .setName (AppConstants . PARAM_SATURATION );
810
757
saturation .setProperties (properties );
811
758
saturation .setMinBounds (0 );
812
759
saturation .setMaxBounds (100 );
@@ -820,7 +767,7 @@ public void addParamsForMatterOnlyDevice(String nodeId, String matterNodeId, Esp
820
767
hue .setDataType ("int" );
821
768
hue .setUiType (AppConstants .UI_TYPE_HUE_SLIDER );
822
769
hue .setParamType (AppConstants .PARAM_TYPE_HUE );
823
- hue .setName ("Hue" );
770
+ hue .setName (AppConstants . PARAM_HUE );
824
771
hue .setProperties (properties );
825
772
params .add (hue );
826
773
}
@@ -1253,7 +1200,7 @@ private void addToggleParam(ArrayList<Param> params, ArrayList<String> propertie
1253
1200
param .setDataType ("bool" );
1254
1201
param .setUiType (AppConstants .UI_TYPE_TOGGLE );
1255
1202
param .setParamType (AppConstants .PARAM_TYPE_POWER );
1256
- param .setName ("Power" );
1203
+ param .setName (AppConstants . PARAM_POWER );
1257
1204
param .setSwitchStatus (false );
1258
1205
param .setProperties (properties );
1259
1206
params .add (param );
0 commit comments