@@ -45,7 +45,7 @@ import matter.tlv.AnonymousTag
45
45
import matter.tlv.TlvReader
46
46
import matter.tlv.TlvWriter
47
47
48
- class WildcardFragment : Fragment () {
48
+ class WildcardFragment : Fragment (), AddressUpdateFragment.ICDCheckInMessageCallback {
49
49
private var _binding : WildcardFragmentBinding ? = null
50
50
private val binding
51
51
get() = _binding !!
@@ -63,6 +63,23 @@ class WildcardFragment : Fragment() {
63
63
private val invokePath = ArrayList <InvokeElement >()
64
64
private val subscribeIdList = ArrayList <ULong >()
65
65
66
+ data class ReadICDConfig (val isFabricFiltered : Boolean , val eventMin : Long? )
67
+
68
+ data class SubscribeICDConfig (
69
+ val minInterval : Int ,
70
+ val maxInterval : Int ,
71
+ val keepSubscriptions : Boolean ,
72
+ val isFabricFiltered : Boolean ,
73
+ val eventMin : Long?
74
+ )
75
+
76
+ data class WriteInvokeICDConfig (val timedRequestTimeoutMs : Int , val imTimeoutMs : Int )
77
+
78
+ private var readICDConfig: ReadICDConfig ? = null
79
+ private var subscribeICDConfig: SubscribeICDConfig ? = null
80
+ private var writeICDConfig: WriteInvokeICDConfig ? = null
81
+ private var invokeICDConfig: WriteInvokeICDConfig ? = null
82
+
66
83
private val reportCallback =
67
84
object : ReportCallback {
68
85
override fun onError (
@@ -173,6 +190,45 @@ class WildcardFragment : Fragment() {
173
190
return binding.root
174
191
}
175
192
193
+ override fun onResume () {
194
+ super .onResume()
195
+ addressUpdateFragment.setNotifyCheckInMessageCallback(this )
196
+ }
197
+
198
+ override fun onPause () {
199
+ addressUpdateFragment.setNotifyCheckInMessageCallback(null )
200
+ super .onPause()
201
+ }
202
+
203
+ override fun notifyCheckInMessage () {
204
+ Log .d(TAG , " notifyCheckInMessage" )
205
+ if (attributePath.isNotEmpty() || eventPath.isNotEmpty()) {
206
+ if (binding.readRadioBtn.isChecked && readICDConfig != null ) {
207
+ scope.launch { read(readICDConfig!! .isFabricFiltered, readICDConfig!! .eventMin) }
208
+ } else if (binding.subscribeRadioBtn.isChecked && subscribeICDConfig != null ) {
209
+ scope.launch {
210
+ subscribe(
211
+ subscribeICDConfig!! .minInterval,
212
+ subscribeICDConfig!! .maxInterval,
213
+ subscribeICDConfig!! .keepSubscriptions,
214
+ subscribeICDConfig!! .isFabricFiltered,
215
+ subscribeICDConfig!! .eventMin
216
+ )
217
+ }
218
+ }
219
+ } else if (
220
+ binding.writeRadioBtn.isChecked && writePath.isNotEmpty() && writeICDConfig != null
221
+ ) {
222
+ scope.launch { write(writeICDConfig!! .timedRequestTimeoutMs, writeICDConfig!! .imTimeoutMs) }
223
+ } else if (
224
+ binding.invokeRadioBtn.isChecked && invokePath.isNotEmpty() && invokeICDConfig != null
225
+ ) {
226
+ scope.launch {
227
+ invoke(invokeICDConfig!! .timedRequestTimeoutMs, invokeICDConfig!! .imTimeoutMs)
228
+ }
229
+ }
230
+ }
231
+
176
232
private fun setVisibilityEachView (radioBtnId : Int ) {
177
233
val readBtnOn = (radioBtnId == R .id.readRadioBtn)
178
234
val subscribeBtnOn = (radioBtnId == R .id.subscribeRadioBtn)
@@ -520,7 +576,12 @@ class WildcardFragment : Fragment() {
520
576
if (eventPath.isNotEmpty() && eventMinEd.text.isNotBlank()) {
521
577
eventMin = eventMinEd.text.toString().toULong().toLong()
522
578
}
523
- read(isFabricFilteredEd.selectedItem.toString().toBoolean(), eventMin)
579
+ if (addressUpdateFragment.isICDDevice()) {
580
+ readICDConfig =
581
+ ReadICDConfig (isFabricFilteredEd.selectedItem.toString().toBoolean(), eventMin)
582
+ } else {
583
+ read(isFabricFilteredEd.selectedItem.toString().toBoolean(), eventMin)
584
+ }
524
585
requireActivity().runOnUiThread { dialog.dismiss() }
525
586
}
526
587
}
@@ -537,18 +598,23 @@ class WildcardFragment : Fragment() {
537
598
dialogView.findViewById<EditText >(R .id.timedRequestTimeoutEd).text.toString()
538
599
val imTimeout = dialogView.findViewById<EditText >(R .id.imTimeoutEd).text.toString()
539
600
scope.launch {
540
- write(
601
+ val timedRequestTimeoutInt =
541
602
if (timedRequestTimeoutMs.isEmpty()) {
542
603
0
543
604
} else {
544
605
timedRequestTimeoutMs.toInt()
545
- },
606
+ }
607
+ val imTimeoutInt =
546
608
if (imTimeout.isEmpty()) {
547
609
0
548
610
} else {
549
611
imTimeout.toInt()
550
612
}
551
- )
613
+ if (addressUpdateFragment.isICDDevice()) {
614
+ writeICDConfig = WriteInvokeICDConfig (timedRequestTimeoutInt, imTimeoutInt)
615
+ } else {
616
+ write(timedRequestTimeoutInt, imTimeoutInt)
617
+ }
552
618
requireActivity().runOnUiThread { dialog.dismiss() }
553
619
}
554
620
}
@@ -588,13 +654,24 @@ class WildcardFragment : Fragment() {
588
654
if (eventPath.isNotEmpty() && eventMinEd.text.isNotBlank()) {
589
655
eventMin = eventMinEd.text.toString().toULong().toLong()
590
656
}
591
- subscribe(
592
- minIntervalEd.text.toString().toInt(),
593
- maxIntervalEd.text.toString().toInt(),
594
- keepSubscriptionsSp.selectedItem.toString().toBoolean(),
595
- isFabricFilteredSp.selectedItem.toString().toBoolean(),
596
- eventMin,
597
- )
657
+ if (addressUpdateFragment.isICDDevice()) {
658
+ subscribeICDConfig =
659
+ SubscribeICDConfig (
660
+ minIntervalEd.text.toString().toInt(),
661
+ maxIntervalEd.text.toString().toInt(),
662
+ keepSubscriptionsSp.selectedItem.toString().toBoolean(),
663
+ isFabricFilteredSp.selectedItem.toString().toBoolean(),
664
+ eventMin
665
+ )
666
+ } else {
667
+ subscribe(
668
+ minIntervalEd.text.toString().toInt(),
669
+ maxIntervalEd.text.toString().toInt(),
670
+ keepSubscriptionsSp.selectedItem.toString().toBoolean(),
671
+ isFabricFilteredSp.selectedItem.toString().toBoolean(),
672
+ eventMin
673
+ )
674
+ }
598
675
} else {
599
676
Log .e(TAG , " minInterval or maxInterval is empty!" )
600
677
}
@@ -614,18 +691,23 @@ class WildcardFragment : Fragment() {
614
691
dialogView.findViewById<EditText >(R .id.timedRequestTimeoutEd).text.toString()
615
692
val imTimeout = dialogView.findViewById<EditText >(R .id.imTimeoutEd).text.toString()
616
693
scope.launch {
617
- invoke(
694
+ val timedRequestTimeoutInt =
618
695
if (timedRequestTimeoutMs.isEmpty()) {
619
696
0
620
697
} else {
621
698
timedRequestTimeoutMs.toInt()
622
- },
699
+ }
700
+ val imTimeoutInt =
623
701
if (imTimeout.isEmpty()) {
624
702
0
625
703
} else {
626
704
imTimeout.toInt()
627
705
}
628
- )
706
+ if (addressUpdateFragment.isICDDevice()) {
707
+ invokeICDConfig = WriteInvokeICDConfig (timedRequestTimeoutInt, imTimeoutInt)
708
+ } else {
709
+ invoke(timedRequestTimeoutInt, imTimeoutInt)
710
+ }
629
711
requireActivity().runOnUiThread { dialog.dismiss() }
630
712
}
631
713
}
0 commit comments