Skip to content

Commit ed246a1

Browse files
[Android]Pass write response status from jni to application
1 parent acedec1 commit ed246a1

File tree

22 files changed

+65330
-526
lines changed

22 files changed

+65330
-526
lines changed

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import chip.devicecontroller.model.AttributeWriteRequest
1717
import chip.devicecontroller.model.ChipAttributePath
1818
import chip.devicecontroller.model.ChipEventPath
1919
import chip.devicecontroller.model.NodeState
20+
import chip.devicecontroller.model.Status
2021
import com.google.chip.chiptool.ChipClient
2122
import com.google.chip.chiptool.GenericChipDeviceListener
2223
import com.google.chip.chiptool.R
@@ -191,8 +192,8 @@ class BasicClientFragment : Fragment() {
191192
Log.e(TAG, "Write ${attribute.name} failure", ex)
192193
}
193194

194-
override fun onResponse(attributePath: ChipAttributePath?) {
195-
showMessage("Write ${attribute.name} success")
195+
override fun onResponse(attributePath: ChipAttributePath, status: Status) {
196+
showMessage("Write ${attribute.name} response: $status")
196197
}
197198
},
198199
devicePtr,

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import chip.devicecontroller.model.AttributeWriteRequest
3232
import chip.devicecontroller.model.ChipAttributePath
3333
import chip.devicecontroller.model.ChipEventPath
3434
import chip.devicecontroller.model.NodeState
35+
import chip.devicecontroller.model.Status
3536
import com.google.chip.chiptool.ChipClient
3637
import com.google.chip.chiptool.GenericChipDeviceListener
3738
import com.google.chip.chiptool.R
@@ -223,9 +224,9 @@ class OtaProviderClientFragment : Fragment() {
223224
showMessage("Error : ${e.toString()}")
224225
}
225226

226-
override fun onResponse(attributePath: ChipAttributePath?) {
227+
override fun onResponse(attributePath: ChipAttributePath, status: Status) {
227228
Log.d(TAG, "onResponse")
228-
showMessage("write Success")
229+
showMessage("$attributePath : Write response: $status")
229230
}
230231
},
231232
ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId),
@@ -350,9 +351,9 @@ class OtaProviderClientFragment : Fragment() {
350351
showMessage("error : ${e.toString()}")
351352
}
352353

353-
override fun onResponse(attributePath: ChipAttributePath?) {
354+
override fun onResponse(attributePath: ChipAttributePath, status: Status) {
354355
Log.d(TAG, "onResponse")
355-
showMessage("write success")
356+
showMessage("$attributePath : Write response: $status")
356357
}
357358
},
358359
ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId),

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import chip.devicecontroller.model.ChipEventPath
2727
import chip.devicecontroller.model.ChipPathId
2828
import chip.devicecontroller.model.InvokeElement
2929
import chip.devicecontroller.model.NodeState
30+
import chip.devicecontroller.model.Status
3031
import com.google.chip.chiptool.ChipClient
3132
import com.google.chip.chiptool.R
3233
import com.google.chip.chiptool.databinding.WildcardFragmentBinding
@@ -92,8 +93,8 @@ class WildcardFragment : Fragment() {
9293
Log.e(TAG, "Report error for $attributePath: $ex")
9394
}
9495

95-
override fun onResponse(attributePath: ChipAttributePath?) {
96-
val text = "$attributePath : Write Success"
96+
override fun onResponse(attributePath: ChipAttributePath, status: Status) {
97+
val text = "$attributePath : Write response: $status"
9798
requireActivity().runOnUiThread { binding.outputTv.text = text }
9899
}
99100

examples/java-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImReadCommand.kt

+3-6
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ class PairOnNetworkLongImReadCommand(
6767
}
6868

6969
fun checkUnitTestClusterGeneralStatus(status: Status): Boolean =
70-
(status.getStatus() == CLUSTER_ID_TEST_GENERAL_ERROR_STATUS) &&
71-
!status.getClusterStatus().isPresent()
70+
(status.getStatus() == Status.Code.InvalidDataType) && !status.getClusterStatus().isPresent()
7271

7372
fun checkUnitTestClusterClusterStatus(status: Status): Boolean =
74-
(status.getStatus() == CLUSTER_ID_TEST_CLUSTER_ERROR_STATUS) &&
73+
(status.getStatus() == Status.Code.Failure) &&
7574
status.getClusterStatus().isPresent() &&
76-
status.getClusterStatus().get() == CLUSTER_ID_TEST_CLUSTER_ERROR_CLUSTER_STATUS
75+
(status.getClusterStatus().get() == CLUSTER_ID_TEST_CLUSTER_ERROR_CLUSTER_STATUS)
7776

7877
private fun validateResponse(nodeState: NodeState) {
7978
val endpointZero =
@@ -243,8 +242,6 @@ class PairOnNetworkLongImReadCommand(
243242
private const val CLUSTER_ID_BASIC_VERSION = 0L
244243
private const val CLUSTER_ID_TEST_GENERAL_ERROR_BOOLEAN = 0x0031L
245244
private const val CLUSTER_ID_TEST_CLUSTER_ERROR_BOOLEAN = 0x0032L
246-
private const val CLUSTER_ID_TEST_GENERAL_ERROR_STATUS = 0x8d
247-
private const val CLUSTER_ID_TEST_CLUSTER_ERROR_STATUS = 1
248245
private const val CLUSTER_ID_TEST_CLUSTER_ERROR_CLUSTER_STATUS = 17
249246
}
250247
}

examples/java-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCal
2222
import chip.devicecontroller.WriteAttributesCallback
2323
import chip.devicecontroller.model.AttributeWriteRequest
2424
import chip.devicecontroller.model.ChipAttributePath
25+
import chip.devicecontroller.model.Status
2526
import com.matter.controller.commands.common.CredentialsIssuer
2627
import java.util.logging.Level
2728
import java.util.logging.Logger
@@ -51,11 +52,8 @@ class PairOnNetworkLongImWriteCommand(
5152
setFailure("write failure")
5253
}
5354

54-
override fun onResponse(attributePath: ChipAttributePath?) {
55-
logger.log(Level.INFO, "Write receive OnResponse on ")
56-
if (attributePath != null) {
57-
logger.log(Level.INFO, attributePath.toString())
58-
}
55+
override fun onResponse(attributePath: ChipAttributePath, status: Status) {
56+
logger.log(Level.INFO, "$attributePath : Write response: $status")
5957
setSuccess()
6058
}
6159
}

kotlin-detect-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ style:
3636
- "**/src/controller/java/src/matter/tlv/types.kt"
3737
- "**/src/controller/java/src/matter/tlv/utils.kt"
3838
- "**/src/controller/java/src/matter/tlv/values.kt"
39-
- "**/src/controller/java/src/chip/WildcardImport
40-
examples/android/CHIPTest/app/src/androidTest/java/com/tcl/chip/chiptest/ExampleInstrumentedTest.kt"
39+
- "**/src/controller/java/src/matter/tlv/values.kt"
40+
- "**/src/controller/java/src/matter/controller/model/Status.kt"
4141
- "**/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt"
4242
- "**/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt"
4343
- "**/src/controller/java/tests/matter/jsontlv/JsonToTlvToJsonTest.kt"

scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja

+10-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import chip.devicecontroller.model.ClusterState;
102102
import chip.devicecontroller.model.EndpointState;
103103
import chip.devicecontroller.model.InvokeElement;
104104
import chip.devicecontroller.model.NodeState;
105+
import chip.devicecontroller.model.Status;
105106

106107
import javax.annotation.Nullable;
107108
import java.util.ArrayList;
@@ -318,8 +319,15 @@ public class ChipClusters {
318319
}
319320

320321
@Override
321-
public void onResponse(ChipAttributePath attributePath) {
322-
callback.onSuccess();
322+
public void onResponse(ChipAttributePath attributePath, Status status) {
323+
if (status.getStatus() == Status.Code.Success)
324+
{
325+
callback.onSuccess();
326+
}
327+
else
328+
{
329+
callback.onError(new StatusException(status.getStatus()));
330+
}
323331
}
324332

325333
@Override

0 commit comments

Comments
 (0)