diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 9d2f17d1acf86e..01626726e0b9af 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -127,7 +127,9 @@ if (_chip_defaults.custom_toolchain != "") { "Unsupported target_cpu: ${current_cpu}. Shall be arm for webOS") } } else { - assert(false, "No toolchain specified, please specify custom_toolchain") + assert( + false, + "No toolchain specified, please specify custom_toolchain for host_os='${host_os}', target_os='${target_os}', host_cpu='${host_cpu}', target_cpu='${target_cpu}'") } set_default_toolchain(_default_toolchain) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt index f38cacbd259073..3ef61298930268 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt @@ -139,7 +139,13 @@ class BasicClientFragment : Fragment() { val attributeId = BasicInformation.Attribute.valueOf(attributeName).id val devicePtr = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } ChipClient.getDeviceController(requireContext()) .readPath( @@ -182,7 +188,13 @@ class BasicClientFragment : Fragment() { private suspend fun sendWriteAttribute(attribute: BasicInformation.Attribute, tlv: ByteArray) { val clusterId = BasicInformation.ID val devicePtr = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } ChipClient.getDeviceController(requireContext()) .write( diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt index 8943801c080c80..bbaacbd3c997ba 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt @@ -271,11 +271,16 @@ class GroupSettingFragment : Fragment() { private suspend fun sendKeySetWrite( groupKeySetStruct: GroupKeyManagementClusterGroupKeySetStruct ) { - val cluster = - ChipClusters.GroupKeyManagementCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - 0 - ) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + val cluster = ChipClusters.GroupKeyManagementCluster(devicePtr, 0) + cluster.keySetWrite( object : ChipClusters.DefaultClusterCallback { override fun onError(e: Exception?) { @@ -311,11 +316,15 @@ class GroupSettingFragment : Fragment() { } private suspend fun writeGroupKeyMap(groupId: UInt, groupKeySetId: UInt) { - val cluster = - ChipClusters.GroupKeyManagementCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - 0 - ) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + val cluster = ChipClusters.GroupKeyManagementCluster(devicePtr, 0) cluster.writeGroupKeyMapAttribute( object : ChipClusters.DefaultClusterCallback { override fun onError(e: Exception?) { @@ -356,11 +365,16 @@ class GroupSettingFragment : Fragment() { } private suspend fun sendAddGroup(groupId: UInt, groupName: String) { - val cluster = - ChipClusters.GroupsCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - 0 - ) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + val cluster = ChipClusters.GroupsCluster(devicePtr, 0) + cluster.addGroup( object : ChipClusters.GroupsCluster.AddGroupResponseCallback { override fun onError(e: Exception?) { @@ -379,11 +393,15 @@ class GroupSettingFragment : Fragment() { } private suspend fun readAccessControl() { - val cluster = - ChipClusters.AccessControlCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - 0 - ) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + val cluster = ChipClusters.AccessControlCluster(devicePtr, 0) cluster.readAclAttribute( object : ChipClusters.AccessControlCluster.AclAttributeCallback { override fun onError(e: Exception?) { @@ -437,12 +455,16 @@ class GroupSettingFragment : Fragment() { groupId: UInt, privilege: UInt ) { + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } // If GroupID is already added to AccessControl, do not add it. - val cluster = - ChipClusters.AccessControlCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - 0 - ) + val cluster = ChipClusters.AccessControlCluster(devicePtr, 0) val sendEntry = ArrayList() for (entry in value) { if ( diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt index a82f0ee60ccf35..08443d6ffb4ffc 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt @@ -121,8 +121,16 @@ class MultiAdminClientFragment : Fragment() { private suspend fun sendBasicCommissioningCommandClick() { val testDuration = binding.timeoutEd.text.toString().toInt() + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } deviceController.openPairingWindowCallback( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, testDuration, object : OpenCommissioningCallback { override fun onError(status: Int, deviceId: Long) { @@ -140,7 +148,13 @@ class MultiAdminClientFragment : Fragment() { val testDuration = binding.timeoutEd.text.toString().toInt() val testIteration = 1000 val devicePointer = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } var setupPinCode: Long? = null if (!binding.setupPinCodeEd.text.toString().isEmpty()) { @@ -181,6 +195,14 @@ class MultiAdminClientFragment : Fragment() { null ) + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } deviceController.invoke( object : InvokeCallback { override fun onError(ex: Exception?) { @@ -193,7 +215,7 @@ class MultiAdminClientFragment : Fragment() { showMessage("Revoke Commissioning success") } }, - getConnectedDevicePointer(), + devicePointer, invokeElement, timedInvokeTimeout, 0 @@ -208,6 +230,16 @@ class MultiAdminClientFragment : Fragment() { val attributeId = attribute.id val attributeName = attribute.name val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.readAttributePath( object : ReportCallback { override fun onReport(nodeState: NodeState?) { @@ -230,16 +262,12 @@ class MultiAdminClientFragment : Fragment() { showMessage("read $attributeName - error : ${e?.message}") } }, - getConnectedDevicePointer(), + devicePointer, listOf(attributePath), 0 ) } - private suspend fun getConnectedDevicePointer(): Long { - return ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - } - private fun showMessage(msg: String) { requireActivity().runOnUiThread { binding.multiAdminClusterCommandStatus.text = msg } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt index 7994deb2f07a13..d4b55194147fca 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt @@ -105,6 +105,15 @@ class OnOffClientFragment : Fragment() { val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + ChipClient.getDeviceController(requireContext()) .readPath( object : ReportCallback { @@ -128,7 +137,7 @@ class OnOffClientFragment : Fragment() { showMessage("On/Off attribute value: $value") } }, - getConnectedDevicePointer(), + devicePointer, listOf(attributePath), null, false, @@ -181,6 +190,15 @@ class OnOffClientFragment : Fragment() { ) } + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.subscribeToPath( subscriptionEstablishedCallback, resubscriptionAttemptCallback, @@ -211,7 +229,7 @@ class OnOffClientFragment : Fragment() { showReportMessage(message) } }, - getConnectedDevicePointer(), + devicePointer, listOf(attributePath), null, minInterval, @@ -265,6 +283,15 @@ class OnOffClientFragment : Fragment() { null ) + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.invoke( object : InvokeCallback { override fun onError(ex: Exception?) { @@ -277,7 +304,7 @@ class OnOffClientFragment : Fragment() { showMessage("MoveToLevel command success") } }, - getConnectedDevicePointer(), + devicePointer, invokeElement, 0, 0 @@ -298,6 +325,15 @@ class OnOffClientFragment : Fragment() { null ) + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.invoke( object : InvokeCallback { override fun onError(ex: Exception?) { @@ -310,17 +346,13 @@ class OnOffClientFragment : Fragment() { showMessage("${commandId.name} command success") } }, - getConnectedDevicePointer(), + devicePointer, invokeElement, 0, 0 ) } - private suspend fun getConnectedDevicePointer(): Long { - return ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - } - private fun showMessage(msg: String) { requireActivity().runOnUiThread { binding.commandStatusTv.text = msg } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt index 0314f9d82e652c..1fd8db6c97a13b 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt @@ -100,7 +100,13 @@ class OpCredClientFragment : Fragment() { val attributeId = attribute.id val devicePtr = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } ChipClient.getDeviceController(requireContext()) .readPath( @@ -137,7 +143,13 @@ class OpCredClientFragment : Fragment() { private suspend fun sendRemoveFabricsBtnClick(fabricIndex: UInt) { val devicePtr = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } // TODO : Need to be implement poj-to-tlv val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt index c27159193ed2dc..5d2d62ee76a690 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt @@ -114,6 +114,14 @@ class OtaProviderClientFragment : Fragment() { val attributeId = ClusterIDMapping.AccessControl.Attribute.Acl.id val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } deviceController.readAttributePath( object : ReportCallback { override fun onError( @@ -136,7 +144,7 @@ class OtaProviderClientFragment : Fragment() { requireActivity().runOnUiThread { showAddAccessControlDialog(tlv) } } }, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, listOf(attributePath), 0 ) @@ -217,6 +225,15 @@ class OtaProviderClientFragment : Fragment() { newEntry.toTlv(AnonymousTag, tlvWriter) tlvWriter.endArray() + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.write( object : WriteAttributesCallback { override fun onError(attributePath: ChipAttributePath?, e: Exception?) { @@ -229,7 +246,7 @@ class OtaProviderClientFragment : Fragment() { showMessage("$attributePath : Write response: $status") } }, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, listOf( AttributeWriteRequest.newInstance( 0, @@ -249,6 +266,14 @@ class OtaProviderClientFragment : Fragment() { val clusterId = ClusterIDMapping.OtaSoftwareUpdateRequestor.ID val attributeId = attribute.id val path = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } deviceController.readAttributePath( object : ReportCallback { override fun onError( @@ -279,7 +304,7 @@ class OtaProviderClientFragment : Fragment() { showMessage("OtaSoftwareUpdateRequestor ${attribute.name} value: $value") } }, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, listOf(path), 0 ) @@ -344,6 +369,15 @@ class OtaProviderClientFragment : Fragment() { val writeRequest = AttributeWriteRequest.newInstance(endpoint, clusterId, attributeId, tlv) + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + deviceController.write( object : WriteAttributesCallback { override fun onError(attributePath: ChipAttributePath?, e: Exception?) { @@ -356,7 +390,7 @@ class OtaProviderClientFragment : Fragment() { showMessage("$attributePath : Write response: $status") } }, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, listOf(writeRequest), 0, 0 @@ -461,11 +495,17 @@ class OtaProviderClientFragment : Fragment() { private suspend fun sendAnnounceOTAProviderBtnClick() { requireActivity().runOnUiThread { updateOTAStatusBtnClick() } + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return + } + val otaRequestCluster = - ChipClusters.OtaSoftwareUpdateRequestorCluster( - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), - OTA_REQUESTER_ENDPOINT_ID - ) + ChipClusters.OtaSoftwareUpdateRequestorCluster(devicePtr, OTA_REQUESTER_ENDPOINT_ID) otaRequestCluster.announceOTAProvider( object : DefaultClusterCallback { override fun onSuccess() { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt index cad12a5a54bc98..88d9ed63c4f91e 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt @@ -155,7 +155,13 @@ class SensorClientFragment : Fragment() { val clusterName = binding.clusterNameSpinner.selectedItem.toString() val clusterId = CLUSTERS[clusterName]!!["clusterId"] as Long val attributeId = CLUSTERS[clusterName]!!["attributeId"] as Long - val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) + val device = + try { + ChipClient.getConnectedDevicePointer(requireContext(), deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + return + } val callback = makeReadCallback(clusterName, false) deviceController.readAttributePath( @@ -177,7 +183,13 @@ class SensorClientFragment : Fragment() { val clusterName = binding.clusterNameSpinner.selectedItem.toString() val clusterId = CLUSTERS[clusterName]!!["clusterId"] as Long val attributeId = CLUSTERS[clusterName]!!["attributeId"] as Long - val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) + val device = + try { + ChipClient.getConnectedDevicePointer(requireContext(), deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + return + } val callback = makeReadCallback(clusterName, true) deviceController.subscribeToAttributePath( diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt index af119581a7047f..5b49a6d9ab05ab 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt @@ -270,12 +270,18 @@ class WildcardFragment : Fragment() { "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec" ) } - + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + return + } deviceController.subscribeToPath( subscriptionEstablishedCallback, resubscriptionAttemptCallback, reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, attributePath.ifEmpty { null }, eventPath.ifEmpty { null }, minInterval, @@ -288,9 +294,16 @@ class WildcardFragment : Fragment() { } private suspend fun read(isFabricFiltered: Boolean, eventMin: Long?) { + val devicePtr = + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + return + } deviceController.readPath( reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + devicePtr, attributePath.ifEmpty { null }, eventPath.ifEmpty { null }, isFabricFiltered, @@ -351,10 +364,16 @@ class WildcardFragment : Fragment() { version ) } - + val devicePtr = + try { + addressUpdateFragment.getDevicePointer(requireContext()) + } catch (e: IllegalStateException) { + Log.d(TAG, "getDevicePointer exception", e) + return + } deviceController.write( writeAttributeCallback, - addressUpdateFragment.getDevicePointer(requireContext()), + devicePtr, listOf(writeRequest), timedRequestTimeoutMs, imTimeoutMs @@ -379,9 +398,16 @@ class WildcardFragment : Fragment() { } else { InvokeElement.newInstance(endpointId, clusterId, commandId, null, jsonString) } + val devicePtr = + try { + addressUpdateFragment.getDevicePointer(requireContext()) + } catch (e: IllegalStateException) { + Log.d(TAG, "getDevicePointer exception", e) + return + } deviceController.invoke( invokeCallback, - addressUpdateFragment.getDevicePointer(requireContext()), + devicePtr, invokeElement, timedRequestTimeoutMs, imTimeoutMs @@ -555,7 +581,13 @@ class WildcardFragment : Fragment() { val clusterId = 62L // OperationalCredentials val attributeId = 5L // CurrentFabricIndex val deviceId = addressUpdateFragment.deviceId - val devicePointer = ChipClient.getConnectedDevicePointer(context, deviceId) + val devicePointer = + try { + ChipClient.getConnectedDevicePointer(context, deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + return 0U + } return suspendCoroutine { cont -> deviceController.readAttributePath( object : ReportCallback { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt index eb14eee23770bd..09270003a41a5e 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt @@ -67,7 +67,15 @@ class ClusterDetailFragment : Fragment() { _binding = ClusterDetailFragmentBinding.inflate(inflater, container, false) scope = viewLifecycleOwner.lifecycleScope deviceId = checkNotNull(requireArguments().getLong(DEVICE_ID)) - scope.launch { devicePtr = getConnectedDevicePointer(requireContext(), deviceId) } + scope.launch { + try { + devicePtr = getConnectedDevicePointer(requireContext(), deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("Get DevicePointer fail!") + return@launch + } + } endpointId = checkNotNull(requireArguments().getInt(ENDPOINT_ID_KEY)) historyCommand = requireArguments().getSerializable(HISTORY_COMMAND) as HistoryCommand? deviceController.setCompletionListener(GenericChipDeviceListener()) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterInteractionFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterInteractionFragment.kt index d723a93b674f7f..8847da71b87271 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterInteractionFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterInteractionFragment.kt @@ -1,6 +1,7 @@ package com.google.chip.chiptool.clusterclient.clusterinteraction import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -45,7 +46,13 @@ class ClusterInteractionFragment : Fragment() { binding.getEndpointListBtn.setOnClickListener { scope.launch { devicePtr = - ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + try { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + } catch (e: IllegalStateException) { + Log.d(TAG, "getConnectedDevicePointer exception", e) + showMessage("getConnectedDevicePointer fail!") + return@launch + } showMessage("Retrieving endpoints") binding.endpointList.visibility = View.VISIBLE } diff --git a/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp b/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp index ab0f2ef3b707a1..9d4eda96e98438 100644 --- a/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp +++ b/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp @@ -91,12 +91,11 @@ CHIP_ERROR RemoveDeviceEndpoint(SubDevice * dev) { if (gSubDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gSubDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gSubDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 27cdb3c5e2dab5..07db2ba94a534f 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -201,12 +201,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev) { if (gDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 80c8b17b7fbed5..c569e7c06e8b45 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -300,12 +300,11 @@ int RemoveDeviceEndpoint(Device * dev) { // Todo: Update this to schedule the work rather than use this lock DeviceLayer::StackLock lock; - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = nullptr; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = nullptr; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return index; } index++; diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index d21897bd2d36b6..72a997c91e9511 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -224,12 +224,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev) { if (gDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/chip-tool/commands/common/DeviceScanner.cpp b/examples/chip-tool/commands/common/DeviceScanner.cpp index 29d31c1fc80565..35d74bd06c844f 100644 --- a/examples/chip-tool/commands/common/DeviceScanner.cpp +++ b/examples/chip-tool/commands/common/DeviceScanner.cpp @@ -218,7 +218,7 @@ void DeviceScanner::Log() const auto resultsCount = mDiscoveredResults.size(); VerifyOrReturn(resultsCount > 0, ChipLogProgress(chipTool, "No device discovered.")); - uint16_t index = 0; + [[maybe_unused]] uint16_t index = 0; for (auto & instance : mDiscoveredResults) { ChipLogProgress(chipTool, "Instance Name: %s ", instance.first.c_str()); diff --git a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp index 0d1c9a032de02c..57c7574c4ea2e3 100644 --- a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp +++ b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp @@ -29,7 +29,7 @@ CHIP_ERROR DiscoverCommissionersCommand::RunCommand() void DiscoverCommissionersCommand::Shutdown() { - int commissionerCount = 0; + [[maybe_unused]] int commissionerCount = 0; for (int i = 0; i < CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; i++) { const Dnssd::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i); diff --git a/examples/common/websocket-server/WebSocketServer.cpp b/examples/common/websocket-server/WebSocketServer.cpp index 623dda3dc47527..2dba035601ea0e 100644 --- a/examples/common/websocket-server/WebSocketServer.cpp +++ b/examples/common/websocket-server/WebSocketServer.cpp @@ -24,9 +24,9 @@ #include #include -constexpr uint16_t kDefaultWebSocketServerPort = 9002; -constexpr uint16_t kMaxMessageBufferLen = 8192; -constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready"; +constexpr uint16_t kDefaultWebSocketServerPort = 9002; +constexpr uint16_t kMaxMessageBufferLen = 8192; +[[maybe_unused]] constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready"; namespace { lws * gWebSocketInstance = nullptr; diff --git a/examples/light-switch-app/genio/src/main.cpp b/examples/light-switch-app/genio/src/main.cpp index 93bb82a21b0735..d545409c706913 100644 --- a/examples/light-switch-app/genio/src/main.cpp +++ b/examples/light-switch-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/lighting-app/genio/src/AppTask.cpp b/examples/lighting-app/genio/src/AppTask.cpp index 6a121673a002a6..d948087833c4dd 100644 --- a/examples/lighting-app/genio/src/AppTask.cpp +++ b/examples/lighting-app/genio/src/AppTask.cpp @@ -66,8 +66,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - #if defined(ENABLE_CHIP_SHELL) using chip::Shell::Engine; using chip::Shell::PrintCommandHelp; diff --git a/examples/lighting-app/genio/src/main.cpp b/examples/lighting-app/genio/src/main.cpp index ab578f3f2c75bd..22f654eb5f2f50 100644 --- a/examples/lighting-app/genio/src/main.cpp +++ b/examples/lighting-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/lock-app/genio/src/AppTask.cpp b/examples/lock-app/genio/src/AppTask.cpp index 7a438dd4974d3d..1c2f0719790196 100644 --- a/examples/lock-app/genio/src/AppTask.cpp +++ b/examples/lock-app/genio/src/AppTask.cpp @@ -60,8 +60,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - namespace { TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. diff --git a/examples/lock-app/genio/src/main.cpp b/examples/lock-app/genio/src/main.cpp index 416c81c53436d7..92b16a39663ee4 100644 --- a/examples/lock-app/genio/src/main.cpp +++ b/examples/lock-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/ota-requestor-app/genio/src/AppTask.cpp b/examples/ota-requestor-app/genio/src/AppTask.cpp index 43c92cf26adeeb..50d1d080a5b7b4 100644 --- a/examples/ota-requestor-app/genio/src/AppTask.cpp +++ b/examples/ota-requestor-app/genio/src/AppTask.cpp @@ -53,8 +53,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - namespace { TaskHandle_t sAppTaskHandle; diff --git a/examples/ota-requestor-app/genio/src/main.cpp b/examples/ota-requestor-app/genio/src/main.cpp index dcd85fbb920859..e3676c5c9eacbd 100644 --- a/examples/ota-requestor-app/genio/src/main.cpp +++ b/examples/ota-requestor-app/genio/src/main.cpp @@ -53,8 +53,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; static void OTAEventsHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg) diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c index f78539d9817170..6dcfcfaf46aaac 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c @@ -569,8 +569,7 @@ static sl_status_t wfx_rsi_do_join(void) } else { - SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security); + SILABS_LOG("%s: WLAN: connecting to %s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security); /* * Join the network diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c index 8f1f895f9683f9..0c7efc723eb049 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c @@ -178,7 +178,7 @@ sl_status_t wfx_connect_to_ap(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) { - SILABS_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); + SILABS_LOG("%s: connecting to access point -> SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); } else diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c index 82976deb6a3b09..9f07d3f8f22c16 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c @@ -57,11 +57,9 @@ LDMA_TransferCfg_t ldmaRXConfig; static osSemaphoreId_t transfer_done_semaphore = NULL; -static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * userParam) +static bool dma_callback([[maybe_unused]] unsigned int channel, [[maybe_unused]] unsigned int sequenceNo, + [[maybe_unused]] void * userParam) { - UNUSED_PARAMETER(channel); - UNUSED_PARAMETER(sequenceNo); - UNUSED_PARAMETER(userParam); #if defined(SL_CATLOG_POWER_MANAGER_PRESENT) sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); #endif @@ -69,10 +67,8 @@ static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * u return false; } -static void gpio_interrupt(uint8_t interrupt_number) +static void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) { - UNUSED_PARAMETER(interrupt_number); - if (NULL != init_config.rx_irq) { init_config.rx_irq(); @@ -312,4 +308,4 @@ void sl_si91x_host_disable_bus_interrupt(void) bool sl_si91x_host_is_in_irq_context(void) { return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0U; -} \ No newline at end of file +} diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index ad6b5ed5e3418d..9097177b73a585 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -171,10 +171,7 @@ void sl_wfx_host_reset_chip(void) vTaskDelay(pdMS_TO_TICKS(3)); } -void gpio_interrupt(uint8_t interrupt_number) -{ - UNUSED_PARAMETER(interrupt_number); -} +void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) {} /***************************************************************** * @fn void rsi_hal_board_init(void) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index c43389761dcdfc..1ba06d0e715c16 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -466,8 +466,7 @@ static void wfx_rsi_save_ap_info() // translation break; } - SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security, status); + SILABS_LOG("%s: WLAN: connecting to %s, sec=%d, status=%02x", __func__, &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security, status); } /******************************************************************************************** @@ -511,8 +510,7 @@ static void wfx_rsi_do_join(void) return; } - SILABS_LOG("%s: WLAN: connecting to %s==%s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0], - wfx_rsi.sec.security); + SILABS_LOG("%s: WLAN: connecting to %s, sec=%d", __func__, &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security); /* * Join the network diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 331895bd3e524e..15915851c11a20 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -180,7 +180,7 @@ sl_status_t wfx_connect_to_ap(void) { if (wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED) { - SILABS_LOG("%s: connecting to access point -> SSID: %s, PSK:%s", __func__, &wfx_rsi.sec.ssid[0], &wfx_rsi.sec.passkey[0]); + SILABS_LOG("%s: connecting to access point -> SSID: %s", __func__, &wfx_rsi.sec.ssid[0]); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); } else diff --git a/examples/platform/silabs/main.cpp b/examples/platform/silabs/main.cpp index 3c9829edd1954f..a3155194e8d1dd 100644 --- a/examples/platform/silabs/main.cpp +++ b/examples/platform/silabs/main.cpp @@ -71,8 +71,9 @@ int main(void) void application_start(void * unused) { - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); + CHIP_ERROR err = SilabsMatterConfig::InitMatter(BLE_DEV_NAME); + if (err != CHIP_NO_ERROR) + appError(err); gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); @@ -83,8 +84,9 @@ void application_start(void * unused) chip::DeviceLayer::PlatformMgr().UnlockChipStack(); SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); + err = AppTask::GetAppTask().StartAppTask(); + if (err != CHIP_NO_ERROR) + appError(err); vTaskDelete(main_Task); } diff --git a/examples/platform/silabs/silabs_utils.cpp b/examples/platform/silabs/silabs_utils.cpp index 7231836c15bf7e..c8a068a328955c 100644 --- a/examples/platform/silabs/silabs_utils.cpp +++ b/examples/platform/silabs/silabs_utils.cpp @@ -27,7 +27,7 @@ void appError(int err) snprintf(faultMessage, sizeof faultMessage, "App Critical Error:%d", err); SILABS_LOG("!!!!!!!!!!!! %s !!!!!!!!!!!", faultMessage); chip::DeviceLayer::Silabs::OnSoftwareFaultEventHandler(faultMessage); - vTaskDelay(pdMS_TO_TICKS(1000)); + vTaskSuspendAll(); /* Force an assert. */ chipAbort(); } diff --git a/examples/thermostat/genio/src/main.cpp b/examples/thermostat/genio/src/main.cpp index 93bb82a21b0735..d545409c706913 100644 --- a/examples/thermostat/genio/src/main.cpp +++ b/examples/thermostat/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/tv-casting-app/linux/CastingUtils.cpp b/examples/tv-casting-app/linux/CastingUtils.cpp index 02b9467d884614..d4d71b5dd2c0ae 100644 --- a/examples/tv-casting-app/linux/CastingUtils.cpp +++ b/examples/tv-casting-app/linux/CastingUtils.cpp @@ -105,7 +105,7 @@ void InitCommissioningFlow(intptr_t commandArg) commissioner->LogDetail(); if (associatedConnectableVideoPlayer.HasValue()) { - TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value(); + [[maybe_unused]] TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value(); ChipLogProgress(AppServer, "Previously connected with nodeId 0x" ChipLogFormatX64 " fabricIndex: %d", ChipLogValueX64(targetVideoPlayerInfo->GetNodeId()), targetVideoPlayerInfo->GetFabricIndex()); } @@ -305,7 +305,7 @@ void PrintFabrics() ChipLogError(AppServer, " -- Not initialized"); continue; } - NodeId myNodeId = fb.GetNodeId(); + [[maybe_unused]] NodeId myNodeId = fb.GetNodeId(); ChipLogProgress(NotSpecified, "---- Current Fabric nodeId=0x" ChipLogFormatX64 " fabricId=0x" ChipLogFormatX64 " fabricIndex=%d", ChipLogValueX64(myNodeId), ChipLogValueX64(fb.GetFabricId()), fabricIndex); diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp index 41d9feb52977eb..f34b6b2ef16c34 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -257,7 +257,7 @@ void CastingPlayer::LogDetail() const { for (unsigned j = 0; j < mAttributes.numIPs; j++) { - char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf); + [[maybe_unused]] char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf); ChipLogDetail(AppServer, "\tIP Address #%d: %s", j + 1, ipAddressOut); } } diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 98f6b197a59e33..a3de0a263c3efe 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -695,7 +695,7 @@ void CastingServer::SetDefaultFabricIndex(std::functionGetEndpointId(); - EndpointId ep = emberAfClearDynamicEndpoint(index); - mContentApps[index] = nullptr; - ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)", - app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + /*[[maybe_unused]]*/ EndpointId ep = emberAfClearDynamicEndpoint(index); + mContentApps[index] = nullptr; + ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)", + app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index); if (curEndpoint == mCurrentAppEndpointId) { mCurrentAppEndpointId = kNoCurrentEndpointId; diff --git a/src/app/server/DefaultAclStorage.cpp b/src/app/server/DefaultAclStorage.cpp index 58d0d18feedda6..6f40cce2599893 100644 --- a/src/app/server/DefaultAclStorage.cpp +++ b/src/app/server/DefaultAclStorage.cpp @@ -138,7 +138,7 @@ CHIP_ERROR DefaultAclStorage::Init(PersistentStorageDelegate & persistentStorage CHIP_ERROR err; - size_t count = 0; + [[maybe_unused]] size_t count = 0; for (auto it = first; it != last; ++it) { diff --git a/src/app/util/types_stub.h b/src/app/util/types_stub.h index ac26684f850cd7..dbd1ea184169e1 100644 --- a/src/app/util/types_stub.h +++ b/src/app/util/types_stub.h @@ -166,12 +166,6 @@ typedef struct } EmberEventControl; -/** - * @description Useful macro for avoiding compiler warnings related to unused - * function arguments or unused variables. - */ -#define UNUSED_VAR(x) (void) (x) - /** * @brief Returns the value of the bitmask \c bits within * the register or byte \c reg. diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index 917c3a1251e344..fc2cfaf516524b 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -475,7 +475,7 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit // app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&gTestReadInteraction); - int testId = 0; + [[maybe_unused]] int testId = 0; // Read of E2C3A1(dedup), E*C3A1(E1C3A1 not exit, E2C3A1 exist), E2C3A* (5 supported attributes) // Expect no versions would be cached. diff --git a/src/crypto/tests/TestChipCryptoPAL.cpp b/src/crypto/tests/TestChipCryptoPAL.cpp index b2e12568b7c222..db5ee6b74480cd 100644 --- a/src/crypto/tests/TestChipCryptoPAL.cpp +++ b/src/crypto/tests/TestChipCryptoPAL.cpp @@ -2715,7 +2715,7 @@ static void TestVIDPID_StringExtraction(nlTestSuite * inSuite, void * inContext) }; // clang-format on - int caseIdx = 0; + [[maybe_unused]] int caseIdx = 0; for (const auto & testCase : kTestCases) { AttestationCertVidPid vidpid; diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h index e0b25449755f16..e0dc4bd052f0f4 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN * An access grant, which can be represented as an entry in the Matter Access * Control cluster. */ +NS_SWIFT_SENDABLE MTR_NEWLY_AVAILABLE @interface MTRAccessGrant : NSObject diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h index 7f4f88b0cfd643..dc95ddcddaeaeb 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN * A representation of a "device type revision" in the sense used in the Matter * specification. This has an identifier and a version number. */ +NS_SWIFT_SENDABLE MTR_NEWLY_AVAILABLE @interface MTRDeviceTypeRevision : NSObject diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h index 46e95bfb39a7bd..7d8c27b74b55d3 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h @@ -25,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN * MTRDeviceController. An attribute has an identifier and a value, and may or * may not be writable. */ +NS_SWIFT_SENDABLE MTR_NEWLY_AVAILABLE @interface MTRServerAttribute : NSObject diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h index 48604dd2a76797..02b0f4b274374d 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A representation of a server cluster implemented by an MTRDeviceController. */ +NS_SWIFT_SENDABLE MTR_NEWLY_AVAILABLE @interface MTRServerCluster : NSObject diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h index 13dbe8454d759e..9716692ea8895d 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h @@ -25,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A representation of an endpoint implemented by an MTRDeviceController. */ +NS_SWIFT_SENDABLE MTR_NEWLY_AVAILABLE @interface MTRServerEndpoint : NSObject diff --git a/src/lib/core/TLVReader.cpp b/src/lib/core/TLVReader.cpp index abef9af1636ca5..8368b9fb0fac04 100644 --- a/src/lib/core/TLVReader.cpp +++ b/src/lib/core/TLVReader.cpp @@ -49,6 +49,12 @@ using namespace chip::Encoding; static const uint8_t sTagSizes[] = { 0, 1, 2, 4, 2, 4, 6, 8 }; +TLVReader::TLVReader() : + ImplicitProfileId(kProfileIdNotSpecified), AppData(nullptr), mElemLenOrVal(0), mBackingStore(nullptr), mReadPoint(nullptr), + mBufEnd(nullptr), mLenRead(0), mMaxLen(0), mContainerType(kTLVType_NotSpecified), mControlByte(kTLVControlByte_NotSpecified), + mContainerOpen(false) +{} + void TLVReader::Init(const uint8_t * data, size_t dataLen) { // TODO: Maybe we can just make mMaxLen and mLenRead size_t instead? diff --git a/src/lib/core/TLVReader.h b/src/lib/core/TLVReader.h index bfb6b47f14d3f4..e86812cc2dc16b 100644 --- a/src/lib/core/TLVReader.h +++ b/src/lib/core/TLVReader.h @@ -86,6 +86,8 @@ class DLL_EXPORT TLVReader friend class TLVUpdater; public: + TLVReader(); + /** * Initializes a TLVReader object from another TLVReader object. * diff --git a/src/lib/core/tests/TestTLV.cpp b/src/lib/core/tests/TestTLV.cpp index fce0a5d17ae484..f71bce13fbd70b 100644 --- a/src/lib/core/tests/TestTLV.cpp +++ b/src/lib/core/tests/TestTLV.cpp @@ -3832,6 +3832,27 @@ void TestTLVReader_SkipOverContainer(nlTestSuite * inSuite) ForEachElement(inSuite, reader, nullptr, TestTLVReader_SkipOverContainer_ProcessElement); } +/** + * Tests using an uninitialized TLVReader. + */ +void TestTLVReaderUninitialized(nlTestSuite * inSuite) +{ + TLVReader reader; + + NL_TEST_ASSERT(inSuite, reader.GetType() == kTLVType_NotSpecified); + NL_TEST_ASSERT(inSuite, reader.GetLength() == 0); + NL_TEST_ASSERT(inSuite, reader.GetControlByte() == kTLVControlByte_NotSpecified); + NL_TEST_ASSERT(inSuite, reader.GetContainerType() == kTLVType_NotSpecified); + NL_TEST_ASSERT(inSuite, reader.GetLengthRead() == 0); + NL_TEST_ASSERT(inSuite, reader.GetRemainingLength() == 0); + NL_TEST_ASSERT(inSuite, reader.GetTotalLength() == 0); + NL_TEST_ASSERT(inSuite, reader.GetBackingStore() == nullptr); + NL_TEST_ASSERT(inSuite, reader.IsElementDouble() == false); + NL_TEST_ASSERT(inSuite, reader.GetReadPoint() == nullptr); + NL_TEST_ASSERT(inSuite, reader.ImplicitProfileId == kProfileIdNotSpecified); + NL_TEST_ASSERT(inSuite, reader.AppData == nullptr); +} + /** * Test CHIP TLV Reader */ @@ -3852,6 +3873,8 @@ void CheckTLVReader(nlTestSuite * inSuite, void * inContext) TestTLVReader_NextOverContainer(inSuite); TestTLVReader_SkipOverContainer(inSuite); + + TestTLVReaderUninitialized(inSuite); } /** diff --git a/src/platform/Darwin/CHIPDevicePlatformConfig.h b/src/platform/Darwin/CHIPDevicePlatformConfig.h index 15fdaa476e3645..7a5140494c22dd 100644 --- a/src/platform/Darwin/CHIPDevicePlatformConfig.h +++ b/src/platform/Darwin/CHIPDevicePlatformConfig.h @@ -25,7 +25,6 @@ // ==================== Platform Adaptations ==================== -#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC 1 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 diff --git a/src/platform/GLibTypeDeleter.h b/src/platform/GLibTypeDeleter.h index e6d9bfd0d2c1ed..f217d559e9cc66 100644 --- a/src/platform/GLibTypeDeleter.h +++ b/src/platform/GLibTypeDeleter.h @@ -29,10 +29,10 @@ class UniquePointerReceiver { public: UniquePointerReceiver(std::unique_ptr & target) : mTarget(target) {} - ~UniquePointerReceiver() { mTarget.reset(mValue); } T *& Get() { return mValue; } + T ** operator&() { return &mValue; } private: std::unique_ptr & mTarget; @@ -151,6 +151,14 @@ struct GAutoPtrDeleter }; template -using GAutoPtr = std::unique_ptr::deleter>; +class GAutoPtr : public std::unique_ptr::deleter> +{ +public: + using deleter = typename GAutoPtrDeleter::deleter; + using std::unique_ptr::unique_ptr; + + // Convenience method to get a UniquePointerReceiver for this object. + UniquePointerReceiver GetReceiver() { return MakeUniquePointerReceiver(*this); } +}; } // namespace chip diff --git a/src/platform/Linux/CHIPDevicePlatformConfig.h b/src/platform/Linux/CHIPDevicePlatformConfig.h index 70ed39d62899d5..530e2716308842 100644 --- a/src/platform/Linux/CHIPDevicePlatformConfig.h +++ b/src/platform/Linux/CHIPDevicePlatformConfig.h @@ -26,7 +26,6 @@ // ==================== Platform Adaptations ==================== #if CHIP_DEVICE_CONFIG_ENABLE_WIFI -#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC 1 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #else diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index eef7ce883f0042..2a57a99d507976 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -266,8 +266,7 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision() if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled) { GAutoPtr err; - wpa_fi_w1_wpa_supplicant1_interface_call_remove_all_networks_sync(mWpaSupplicant.iface, nullptr, - &MakeUniquePointerReceiver(err).Get()); + wpa_fi_w1_wpa_supplicant1_interface_call_remove_all_networks_sync(mWpaSupplicant.iface, nullptr, &err.GetReceiver()); if (err != nullptr) { @@ -388,7 +387,7 @@ void ConnectivityManagerImpl::_OnWpaPropertiesChanged(WpaFiW1Wpa_supplicant1Inte WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); - g_variant_get(changedProperties, "a{sv}", &MakeUniquePointerReceiver(iter).Get()); + g_variant_get(changedProperties, "a{sv}", &iter.GetReceiver()); while (g_variant_iter_loop(iter.get(), "{&sv}", &key, &value)) { @@ -497,8 +496,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceProxyReady(GObject * sourceObject, std::lock_guard lock(mWpaSupplicantMutex); - WpaFiW1Wpa_supplicant1Interface * iface = - wpa_fi_w1_wpa_supplicant1_interface_proxy_new_for_bus_finish(res, &MakeUniquePointerReceiver(err).Get()); + WpaFiW1Wpa_supplicant1Interface * iface = wpa_fi_w1_wpa_supplicant1_interface_proxy_new_for_bus_finish(res, &err.GetReceiver()); if (mWpaSupplicant.iface) { @@ -552,8 +550,7 @@ void ConnectivityManagerImpl::_OnWpaBssProxyReady(GObject * sourceObject, GAsync std::lock_guard lock(mWpaSupplicantMutex); - WpaFiW1Wpa_supplicant1BSS * bss = - wpa_fi_w1_wpa_supplicant1_bss_proxy_new_for_bus_finish(res, &MakeUniquePointerReceiver(err).Get()); + WpaFiW1Wpa_supplicant1BSS * bss = wpa_fi_w1_wpa_supplicant1_bss_proxy_new_for_bus_finish(res, &err.GetReceiver()); if (mWpaSupplicant.bss) { @@ -584,7 +581,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceReady(GObject * sourceObject, GAsyn std::lock_guard lock(mWpaSupplicantMutex); gboolean result = wpa_fi_w1_wpa_supplicant1_call_get_interface_finish(mWpaSupplicant.proxy, &mWpaSupplicant.interfacePath, res, - &MakeUniquePointerReceiver(err).Get()); + &err.GetReceiver()); if (result) { mWpaSupplicant.state = GDBusWpaSupplicant::WPA_GOT_INTERFACE_PATH; @@ -622,7 +619,7 @@ void ConnectivityManagerImpl::_OnWpaInterfaceReady(GObject * sourceObject, GAsyn args = g_variant_builder_end(&builder); result = wpa_fi_w1_wpa_supplicant1_call_create_interface_sync(mWpaSupplicant.proxy, args, &mWpaSupplicant.interfacePath, - nullptr, &MakeUniquePointerReceiver(error).Get()); + nullptr, &error.GetReceiver()); if (result) { @@ -747,7 +744,7 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * sourceObject, GAsyncRes std::lock_guard lock(mWpaSupplicantMutex); - mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_finish(res, &MakeUniquePointerReceiver(err).Get()); + mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_finish(res, &err.GetReceiver()); if (mWpaSupplicant.proxy != nullptr && err.get() == nullptr) { mWpaSupplicant.state = GDBusWpaSupplicant::WPA_CONNECTED; @@ -898,7 +895,7 @@ void ConnectivityManagerImpl::DriveAPState() GAutoPtr error(nullptr); gboolean result = wpa_fi_w1_wpa_supplicant1_interface_call_remove_network_sync( - mWpaSupplicant.iface, mWpaSupplicant.networkPath, nullptr, &MakeUniquePointerReceiver(error).Get()); + mWpaSupplicant.iface, mWpaSupplicant.networkPath, nullptr, &error.GetReceiver()); if (result) { @@ -963,7 +960,7 @@ CHIP_ERROR ConnectivityManagerImpl::ConfigureWiFiAP() args = g_variant_builder_end(&builder); gboolean result = wpa_fi_w1_wpa_supplicant1_interface_call_add_network_sync( - mWpaSupplicant.iface, args, &mWpaSupplicant.networkPath, nullptr, &MakeUniquePointerReceiver(err).Get()); + mWpaSupplicant.iface, args, &mWpaSupplicant.networkPath, nullptr, &err.GetReceiver()); if (result) { @@ -972,7 +969,7 @@ CHIP_ERROR ConnectivityManagerImpl::ConfigureWiFiAP() ChipLogProgress(DeviceLayer, "wpa_supplicant: added network: SSID: %s: %s", ssid, mWpaSupplicant.networkPath); result = wpa_fi_w1_wpa_supplicant1_interface_call_select_network_sync(mWpaSupplicant.iface, mWpaSupplicant.networkPath, - nullptr, &MakeUniquePointerReceiver(error).Get()); + nullptr, &error.GetReceiver()); if (result) { ChipLogProgress(DeviceLayer, "wpa_supplicant: succeeded to start softAP: SSID: %s", ssid); @@ -1033,7 +1030,7 @@ ConnectivityManagerImpl::_ConnectWiFiNetworkAsync(GVariant * args, GAutoPtr error; result = wpa_fi_w1_wpa_supplicant1_interface_call_remove_network_sync(mWpaSupplicant.iface, networkPath, nullptr, - &MakeUniquePointerReceiver(error).Get()); + &error.GetReceiver()); if (result) { @@ -1055,7 +1052,7 @@ ConnectivityManagerImpl::_ConnectWiFiNetworkAsync(GVariant * args, } result = wpa_fi_w1_wpa_supplicant1_interface_call_add_network_sync(mWpaSupplicant.iface, args, &mWpaSupplicant.networkPath, - nullptr, &MakeUniquePointerReceiver(err).Get()); + nullptr, &err.GetReceiver()); if (result) { @@ -1127,7 +1124,7 @@ static CHIP_ERROR AddOrReplaceBlob(WpaFiW1Wpa_supplicant1Interface * iface, cons const char * name = (strncmp(nameOrRef, refPrefix.data(), refPrefix.size()) == 0) ? nameOrRef + refPrefix.size() : nameOrRef; GAutoPtr err; - if (!wpa_fi_w1_wpa_supplicant1_interface_call_remove_blob_sync(iface, name, nullptr, &MakeUniquePointerReceiver(err).Get())) + if (!wpa_fi_w1_wpa_supplicant1_interface_call_remove_blob_sync(iface, name, nullptr, &err.GetReceiver())) { GAutoPtr remoteError(g_dbus_error_get_remote_error(err.get())); if (!(remoteError && strcmp(remoteError.get(), kWpaSupplicantBlobUnknown) == 0)) @@ -1138,8 +1135,7 @@ static CHIP_ERROR AddOrReplaceBlob(WpaFiW1Wpa_supplicant1Interface * iface, cons err.reset(); } if (!wpa_fi_w1_wpa_supplicant1_interface_call_add_blob_sync( - iface, name, g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, data.data(), data.size(), 1), nullptr, - &MakeUniquePointerReceiver(err).Get())) + iface, name, g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, data.data(), data.size(), 1), nullptr, &err.GetReceiver())) { ChipLogError(DeviceLayer, "wpa_supplicant: failed to add blob: %s", err ? err->message : "unknown error"); return CHIP_ERROR_INTERNAL; @@ -1239,8 +1235,8 @@ void ConnectivityManagerImpl::_ConnectWiFiNetworkAsyncCallback(GObject * sourceO std::lock_guard lock(mWpaSupplicantMutex); { - gboolean result = wpa_fi_w1_wpa_supplicant1_interface_call_select_network_finish(mWpaSupplicant.iface, res, - &MakeUniquePointerReceiver(err).Get()); + gboolean result = + wpa_fi_w1_wpa_supplicant1_interface_call_select_network_finish(mWpaSupplicant.iface, res, &err.GetReceiver()); if (!result) { ChipLogError(DeviceLayer, "Failed to perform connect network: %s", err == nullptr ? "unknown error" : err->message); @@ -1257,8 +1253,7 @@ void ConnectivityManagerImpl::_ConnectWiFiNetworkAsyncCallback(GObject * sourceO return; } - result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, - &MakeUniquePointerReceiver(err).Get()); + result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, &err.GetReceiver()); if (result) { ChipLogProgress(DeviceLayer, "wpa_supplicant: save config succeeded!"); @@ -1335,8 +1330,7 @@ CHIP_ERROR ConnectivityManagerImpl::CommitConfig() ChipLogProgress(DeviceLayer, "wpa_supplicant: save config"); - result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, - &MakeUniquePointerReceiver(err).Get()); + result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, &err.GetReceiver()); if (!result) { @@ -1486,8 +1480,7 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N } GAutoPtr networkInfo(wpa_fi_w1_wpa_supplicant1_network_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, networkPath, nullptr, - &MakeUniquePointerReceiver(err).Get())); + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, networkPath, nullptr, &err.GetReceiver())); if (networkInfo == nullptr) { return CHIP_ERROR_INTERNAL; @@ -1518,7 +1511,7 @@ CHIP_ERROR ConnectivityManagerImpl::StopAutoScan() ChipLogDetail(DeviceLayer, "wpa_supplicant: disabling auto scan"); result = wpa_fi_w1_wpa_supplicant1_interface_call_auto_scan_sync( - mWpaSupplicant.iface, "" /* empty string means disabling auto scan */, nullptr, &MakeUniquePointerReceiver(err).Get()); + mWpaSupplicant.iface, "" /* empty string means disabling auto scan */, nullptr, &err.GetReceiver()); if (!result) { ChipLogError(DeviceLayer, "wpa_supplicant: Failed to stop auto network scan: %s", err ? err->message : "unknown"); @@ -1548,8 +1541,7 @@ CHIP_ERROR ConnectivityManagerImpl::StartWiFiScan(ByteSpan ssid, WiFiDriver::Sca g_variant_builder_add(&builder, "{sv}", "Type", g_variant_new_string("active")); args = g_variant_builder_end(&builder); - result = wpa_fi_w1_wpa_supplicant1_interface_call_scan_sync(mWpaSupplicant.iface, args, nullptr, - &MakeUniquePointerReceiver(err).Get()); + result = wpa_fi_w1_wpa_supplicant1_interface_call_scan_sync(mWpaSupplicant.iface, args, nullptr, &err.GetReceiver()); if (result) { @@ -1676,9 +1668,8 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi // with the proxy object. GAutoPtr err; - GAutoPtr bss( - wpa_fi_w1_wpa_supplicant1_bss_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, - bssPath, nullptr, &MakeUniquePointerReceiver(err).Get())); + GAutoPtr bss(wpa_fi_w1_wpa_supplicant1_bss_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, bssPath, nullptr, &err.GetReceiver())); if (bss == nullptr) { diff --git a/src/platform/Linux/NetworkCommissioningWiFiDriver.cpp b/src/platform/Linux/NetworkCommissioningWiFiDriver.cpp index 4b5b3c0b6b5e7d..16e4b7f0d7fbde 100644 --- a/src/platform/Linux/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/Linux/NetworkCommissioningWiFiDriver.cpp @@ -44,12 +44,12 @@ constexpr char kWiFiCredentialsKeyName[] = "wifi-pass"; constexpr char kWifiNetworkIdentityKeyName[] = "wifi-ni"; constexpr char kWifiClientIdentityKeyName[] = "wifi-ci"; constexpr char kWifiClientIdentityKeypairKeyName[] = "wifi-cik"; +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC inline CHIP_ERROR IgnoreNotFound(CHIP_ERROR err) { return (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) ? CHIP_NO_ERROR : err; } -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC } // namespace // NOTE: For WiFiDriver, we uses two network configs, one is mSavedNetwork, and another is mStagingNetwork, during init, it will diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index a8f6c23f1e5a24..5fd865df5485ad 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -85,7 +85,7 @@ CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextInitThreadStack(ThreadStackM GAutoPtr err; self->mProxy.reset(openthread_io_openthread_border_router_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kDBusOpenThreadService, kDBusOpenThreadObjectPath, nullptr, - &MakeUniquePointerReceiver(err).Get())); + &err.GetReceiver())); VerifyOrReturnError( self->mProxy != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "openthread: failed to create openthread dbus proxy %s", err ? err->message : "unknown error")); @@ -123,7 +123,7 @@ void ThreadStackManagerImpl::OnDbusPropertiesChanged(OpenthreadIoOpenthreadBorde GVariant * value; GAutoPtr iter; - g_variant_get(changed_properties, "a{sv}", &MakeUniquePointerReceiver(iter).Get()); + g_variant_get(changed_properties, "a{sv}", &iter.GetReceiver()); if (!iter) return; while (g_variant_iter_loop(iter.get(), "{&sv}", &key, &value)) @@ -193,7 +193,7 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd if (g_variant_n_children(routes.get()) > 0) { GAutoPtr iter; - g_variant_get(routes.get(), "av", &MakeUniquePointerReceiver(iter).Get()); + g_variant_get(routes.get(), "av", &iter.GetReceiver()); if (!iter) return false; @@ -207,14 +207,13 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd guchar preference; gboolean stable; gboolean nextHopIsThisDevice; - g_variant_get(route, "(&vqybb)", &MakeUniquePointerReceiver(prefix).Get(), &rloc16, &preference, &stable, - &nextHopIsThisDevice); + g_variant_get(route, "(&vqybb)", &prefix.GetReceiver(), &rloc16, &preference, &stable, &nextHopIsThisDevice); if (!prefix) continue; GAutoPtr address; guchar prefixLength; - g_variant_get(prefix.get(), "(&vy)", &MakeUniquePointerReceiver(address).Get(), &prefixLength); + g_variant_get(prefix.get(), "(&vy)", &address.GetReceiver(), &prefixLength); if (!address) continue; @@ -273,8 +272,7 @@ CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(Thread::OperationalDatase GAutoPtr err; GAutoPtr response(g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", g_variant_new("(ss)", "io.openthread.BorderRouter", "ActiveDatasetTlvs"), - G_DBUS_CALL_FLAGS_NONE, -1, nullptr, - &MakeUniquePointerReceiver(err).Get())); + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &err.GetReceiver())); if (err) { @@ -330,7 +328,7 @@ bool ThreadStackManagerImpl::_IsThreadEnabled() GAutoPtr err; GAutoPtr response(g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", g_variant_new("(ss)", "io.openthread.BorderRouter", "DeviceRole"), - G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &MakeUniquePointerReceiver(err).Get())); + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &err.GetReceiver())); if (err) { @@ -390,8 +388,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) else { GAutoPtr err; - gboolean result = - openthread_io_openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &MakeUniquePointerReceiver(err).Get()); + gboolean result = openthread_io_openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &err.GetReceiver()); if (err) { ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Reset", err->message); @@ -413,8 +410,7 @@ void ThreadStackManagerImpl::_OnThreadBrAttachFinished(GObject * source_object, GAutoPtr attachRes; GAutoPtr err; { - gboolean result = openthread_io_openthread_border_router_call_attach_finish(this_->mProxy.get(), res, - &MakeUniquePointerReceiver(err).Get()); + gboolean result = openthread_io_openthread_border_router_call_attach_finish(this_->mProxy.get(), res, &err.GetReceiver()); if (!result) { ChipLogError(DeviceLayer, "Failed to perform finish Thread network scan: %s", @@ -612,8 +608,8 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) GAutoPtr scan_result; GAutoPtr err; { - gboolean result = openthread_io_openthread_border_router_call_scan_finish( - mProxy.get(), &MakeUniquePointerReceiver(scan_result).Get(), res, &MakeUniquePointerReceiver(err).Get()); + gboolean result = openthread_io_openthread_border_router_call_scan_finish(mProxy.get(), &scan_result.GetReceiver(), res, + &err.GetReceiver()); if (!result) { ChipLogError(DeviceLayer, "Failed to perform finish Thread network scan: %s", @@ -635,7 +631,7 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) if (g_variant_n_children(scan_result.get()) > 0) { GAutoPtr iter; - g_variant_get(scan_result.get(), "a(tstayqqynyybb)", &MakeUniquePointerReceiver(iter).Get()); + g_variant_get(scan_result.get(), "a(tstayqqynyybb)", &iter.GetReceiver()); if (!iter) { delete scanResult; diff --git a/src/platform/Linux/bluez/AdapterIterator.cpp b/src/platform/Linux/bluez/AdapterIterator.cpp index 3197be4e73e175..e69c473f52bbfe 100644 --- a/src/platform/Linux/bluez/AdapterIterator.cpp +++ b/src/platform/Linux/bluez/AdapterIterator.cpp @@ -57,7 +57,7 @@ CHIP_ERROR AdapterIterator::Initialize(AdapterIterator * self) self->mManager = g_dbus_object_manager_client_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, nullptr /* unused user data in the Proxy Type Func */, - nullptr /*destroy notify */, nullptr /* cancellable */, &MakeUniquePointerReceiver(error).Get()); + nullptr /* destroy notify */, nullptr /* cancellable */, &error.GetReceiver()); VerifyOrExit(self->mManager != nullptr, ChipLogError(DeviceLayer, "Failed to get DBUS object manager for listing adapters."); err = CHIP_ERROR_INTERNAL); diff --git a/src/platform/Linux/bluez/BluezAdvertisement.cpp b/src/platform/Linux/bluez/BluezAdvertisement.cpp index 1b95aae41a4f11..196529816b59ab 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.cpp +++ b/src/platform/Linux/bluez/BluezAdvertisement.cpp @@ -118,7 +118,7 @@ CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, const char mpRoot = reinterpret_cast(g_object_ref(aEndpoint.GetGattApplicationObjectManager())); mpAdapter = reinterpret_cast(g_object_ref(aEndpoint.GetAdapter())); - g_object_get(G_OBJECT(mpRoot), "object-path", &MakeUniquePointerReceiver(rootPath).Get(), nullptr); + g_object_get(G_OBJECT(mpRoot), "object-path", &rootPath.GetReceiver(), nullptr); mpAdvPath = g_strdup_printf("%s/advertising", rootPath.get()); mpAdvUUID = g_strdup(aAdvUUID); @@ -241,8 +241,7 @@ void BluezAdvertisement::StartDone(GObject * aObject, GAsyncResult * aResult) GAutoPtr error; gboolean success = FALSE; - success = - bluez_leadvertising_manager1_call_register_advertisement_finish(advMgr, aResult, &MakeUniquePointerReceiver(error).Get()); + success = bluez_leadvertising_manager1_call_register_advertisement_finish(advMgr, aResult, &error.GetReceiver()); if (success == FALSE) { g_dbus_object_manager_server_unexport(mpRoot, mpAdvPath); @@ -304,8 +303,7 @@ void BluezAdvertisement::StopDone(GObject * aObject, GAsyncResult * aResult) GAutoPtr error; gboolean success = FALSE; - success = - bluez_leadvertising_manager1_call_unregister_advertisement_finish(advMgr, aResult, &MakeUniquePointerReceiver(error).Get()); + success = bluez_leadvertising_manager1_call_unregister_advertisement_finish(advMgr, aResult, &error.GetReceiver()); if (success == FALSE) { diff --git a/src/platform/Linux/bluez/BluezConnection.cpp b/src/platform/Linux/bluez/BluezConnection.cpp index 39b5bb0bdb8ba6..d2d5745a4c37c2 100644 --- a/src/platform/Linux/bluez/BluezConnection.cpp +++ b/src/platform/Linux/bluez/BluezConnection.cpp @@ -180,7 +180,7 @@ CHIP_ERROR BluezConnection::BluezDisconnect(BluezConnection * conn) ChipLogDetail(DeviceLayer, "%s peer=%s", __func__, conn->GetPeerAddress()); - success = bluez_device1_call_disconnect_sync(conn->mpDevice, nullptr, &MakeUniquePointerReceiver(error).Get()); + success = bluez_device1_call_disconnect_sync(conn->mpDevice, nullptr, &error.GetReceiver()); VerifyOrExit(success == TRUE, ChipLogError(DeviceLayer, "FAIL: Disconnect: %s", error->message)); exit: @@ -284,7 +284,7 @@ CHIP_ERROR BluezConnection::SendIndicationImpl(ConnectionDataBundle * data) VerifyOrExit(len <= static_cast(std::numeric_limits::max()), ChipLogError(DeviceLayer, "FAIL: buffer too large in %s", __func__)); auto status = g_io_channel_write_chars(data->mConn.mC2Channel.mChannel.get(), buf, static_cast(len), &written, - &MakeUniquePointerReceiver(error).Get()); + &error.GetReceiver()); VerifyOrExit(status == G_IO_STATUS_NORMAL, ChipLogError(DeviceLayer, "FAIL: C2 Indicate: %s", error->message)); } else @@ -311,7 +311,7 @@ void BluezConnection::SendWriteRequestDone(GObject * aObject, GAsyncResult * aRe { BluezGattCharacteristic1 * c1 = BLUEZ_GATT_CHARACTERISTIC1(aObject); GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c1, aResult, &MakeUniquePointerReceiver(error).Get()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c1, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: SendWriteRequest : %s", error->message)); BLEManagerImpl::HandleWriteComplete(static_cast(apConnection)); @@ -360,7 +360,7 @@ void BluezConnection::SubscribeCharacteristicDone(GObject * aObject, GAsyncResul { BluezGattCharacteristic1 * c2 = BLUEZ_GATT_CHARACTERISTIC1(aObject); GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &MakeUniquePointerReceiver(error).Get()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: SubscribeCharacteristic : %s", error->message)); @@ -392,7 +392,7 @@ void BluezConnection::UnsubscribeCharacteristicDone(GObject * aObject, GAsyncRes { BluezGattCharacteristic1 * c2 = BLUEZ_GATT_CHARACTERISTIC1(aObject); GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &MakeUniquePointerReceiver(error).Get()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: UnsubscribeCharacteristic : %s", error->message)); diff --git a/src/platform/Linux/bluez/BluezEndpoint.cpp b/src/platform/Linux/bluez/BluezEndpoint.cpp index 3baca7d127f20a..e68b28b8f421a8 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.cpp +++ b/src/platform/Linux/bluez/BluezEndpoint.cpp @@ -264,8 +264,7 @@ void BluezEndpoint::RegisterGattApplicationDone(GObject * aObject, GAsyncResult GAutoPtr error; BluezGattManager1 * gattMgr = BLUEZ_GATT_MANAGER1(aObject); - gboolean success = - bluez_gatt_manager1_call_register_application_finish(gattMgr, aResult, &MakeUniquePointerReceiver(error).Get()); + gboolean success = bluez_gatt_manager1_call_register_application_finish(gattMgr, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, { ChipLogError(DeviceLayer, "FAIL: RegisterApplication : %s", error->message); @@ -614,16 +613,16 @@ void BluezEndpoint::SetupGattServer(GDBusConnection * aConn) CHIP_ERROR BluezEndpoint::StartupEndpointBindings() { GAutoPtr err; - GAutoPtr conn(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &MakeUniquePointerReceiver(err).Get())); + GAutoPtr conn(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &err.GetReceiver())); VerifyOrReturnError(conn != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "FAIL: get bus sync in %s, error: %s", __func__, err->message)); SetupGattServer(conn.get()); - mpObjMgr = g_dbus_object_manager_client_new_sync( - conn.get(), G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, - nullptr /* unused user data in the Proxy Type Func */, nullptr /*destroy notify */, nullptr /* cancellable */, - &MakeUniquePointerReceiver(err).Get()); + mpObjMgr = g_dbus_object_manager_client_new_sync(conn.get(), G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", + bluez_object_manager_client_get_proxy_type, + nullptr /* unused user data in the Proxy Type Func */, + nullptr /*destroy notify */, nullptr /* cancellable */, &err.GetReceiver()); VerifyOrReturnError(mpObjMgr != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "FAIL: Error getting object manager client: %s", err->message)); @@ -729,7 +728,7 @@ CHIP_ERROR BluezEndpoint::ConnectDeviceImpl(BluezDevice1 & aDevice) for (uint16_t i = 0; i < kMaxConnectRetries; i++) { GAutoPtr error; - if (bluez_device1_call_connect_sync(&aDevice, mConnectCancellable.get(), &MakeUniquePointerReceiver(error).Get())) + if (bluez_device1_call_connect_sync(&aDevice, mConnectCancellable.get(), &error.GetReceiver())) { ChipLogDetail(DeviceLayer, "ConnectDevice complete"); return CHIP_NO_ERROR; diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.cpp b/src/platform/Linux/bluez/ChipDeviceScanner.cpp index 5d9cbf25c9028b..03b26aa08e3dc7 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.cpp +++ b/src/platform/Linux/bluez/ChipDeviceScanner.cpp @@ -72,7 +72,7 @@ CHIP_ERROR ChipDeviceScanner::Init(BluezAdapter1 * adapter, ChipDeviceScannerDel self->mManager = g_dbus_object_manager_client_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, nullptr /* unused user data in the Proxy Type Func */, - nullptr /* destroy notify */, nullptr /* cancellable */, &MakeUniquePointerReceiver(err).Get()); + nullptr /* destroy notify */, nullptr /* cancellable */, &err.GetReceiver()); VerifyOrReturnError(self->mManager != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(Ble, "Failed to get D-Bus object manager for device scanning: %s", err->message)); return CHIP_NO_ERROR; @@ -205,8 +205,7 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStopScan(ChipDeviceScanner * self) self->mInterfaceChangedSignal = 0; } - if (!bluez_adapter1_call_stop_discovery_sync(self->mAdapter, nullptr /* not cancellable */, - &MakeUniquePointerReceiver(error).Get())) + if (!bluez_adapter1_call_stop_discovery_sync(self->mAdapter, nullptr /* not cancellable */, &error.GetReceiver())) { ChipLogError(Ble, "Failed to stop discovery %s", error->message); return CHIP_ERROR_INTERNAL; @@ -268,7 +267,7 @@ void ChipDeviceScanner::RemoveDevice(BluezDevice1 & device) const auto devicePath = g_dbus_proxy_get_object_path(G_DBUS_PROXY(&device)); GAutoPtr error; - if (!bluez_adapter1_call_remove_device_sync(mAdapter, devicePath, nullptr, &MakeUniquePointerReceiver(error).Get())) + if (!bluez_adapter1_call_remove_device_sync(mAdapter, devicePath, nullptr, &error.GetReceiver())) { ChipLogDetail(Ble, "Failed to remove device %s: %s", StringOrNullMarker(devicePath), error->message); } @@ -303,17 +302,15 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self) g_variant_builder_add(&filterBuilder, "{sv}", "Transport", g_variant_new_string("le")); GVariant * filter = g_variant_builder_end(&filterBuilder); - if (!bluez_adapter1_call_set_discovery_filter_sync(self->mAdapter, filter, self->mCancellable.get(), - &MakeUniquePointerReceiver(error).Get())) + if (!bluez_adapter1_call_set_discovery_filter_sync(self->mAdapter, filter, self->mCancellable.get(), &error.GetReceiver())) { // Not critical: ignore if fails ChipLogError(Ble, "Failed to set discovery filters: %s", error->message); - g_clear_error(&MakeUniquePointerReceiver(error).Get()); + error.reset(); } ChipLogProgress(Ble, "BLE initiating scan."); - if (!bluez_adapter1_call_start_discovery_sync(self->mAdapter, self->mCancellable.get(), - &MakeUniquePointerReceiver(error).Get())) + if (!bluez_adapter1_call_start_discovery_sync(self->mAdapter, self->mCancellable.get(), &error.GetReceiver())) { ChipLogError(Ble, "Failed to start discovery: %s", error->message); return CHIP_ERROR_INTERNAL; diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 0a1a9468d00b06..4d4c3e77316fc7 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -208,11 +208,11 @@ void BLEManagerImpl::ReadValueRequestedCb(const char * remoteAddress, int reques GAutoPtr uuid; GAutoPtr value; - VerifyOrReturn(__GetAttInfo(gattHandle, &MakeUniquePointerReceiver(uuid).Get(), &type) == BT_ERROR_NONE, + VerifyOrReturn(__GetAttInfo(gattHandle, &uuid.GetReceiver(), &type) == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from GATT handle")); ChipLogProgress(DeviceLayer, "Gatt read requested on %s: uuid=%s", __ConvertAttTypeToStr(type), StringOrNullMarker(uuid.get())); - ret = bt_gatt_get_value(gattHandle, &MakeUniquePointerReceiver(value).Get(), &len); + ret = bt_gatt_get_value(gattHandle, &value.GetReceiver(), &len); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_get_value() failed: %s", get_error_message(ret))); ChipLogByteSpan(DeviceLayer, ByteSpan(Uint8::from_const_char(value.get()), len)); @@ -233,7 +233,7 @@ void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int reque conn = static_cast(g_hash_table_lookup(mConnectionMap, remoteAddress)); VerifyOrReturn(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); - VerifyOrReturn(__GetAttInfo(gattHandle, &MakeUniquePointerReceiver(uuid).Get(), &type) == BT_ERROR_NONE, + VerifyOrReturn(__GetAttInfo(gattHandle, &uuid.GetReceiver(), &type) == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from GATT handle")); ChipLogProgress(DeviceLayer, "Gatt write requested on %s: uuid=%s len=%d", __ConvertAttTypeToStr(type), StringOrNullMarker(uuid.get()), len); @@ -268,7 +268,7 @@ void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h se VerifyOrReturn(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); - int ret = __GetAttInfo(charHandle, &MakeUniquePointerReceiver(uuid).Get(), &type); + int ret = __GetAttInfo(charHandle, &uuid.GetReceiver(), &type); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from CHAR handle: %s", get_error_message(ret))); @@ -776,7 +776,7 @@ static bool __GattClientForeachCharCb(int total, int index, bt_gatt_h charHandle GAutoPtr uuid; auto conn = static_cast(data); - int ret = __GetAttInfo(charHandle, &MakeUniquePointerReceiver(uuid).Get(), &type); + int ret = __GetAttInfo(charHandle, &uuid.GetReceiver(), &type); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from CHAR handle: %s", get_error_message(ret))); @@ -803,7 +803,7 @@ static bool __GattClientForeachServiceCb(int total, int index, bt_gatt_h svcHand auto conn = static_cast(data); ChipLogProgress(DeviceLayer, "__GattClientForeachServiceCb"); - int ret = __GetAttInfo(svcHandle, &MakeUniquePointerReceiver(uuid).Get(), &type); + int ret = __GetAttInfo(svcHandle, &uuid.GetReceiver(), &type); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from SVC handle: %s", get_error_message(ret))); diff --git a/src/platform/Tizen/BUILD.gn b/src/platform/Tizen/BUILD.gn index 0d0f329be1bd5e..f2f972635a054d 100644 --- a/src/platform/Tizen/BUILD.gn +++ b/src/platform/Tizen/BUILD.gn @@ -31,6 +31,7 @@ static_library("Tizen") { sources = [ "../DeviceSafeQueue.cpp", "../DeviceSafeQueue.h", + "../GLibTypeDeleter.h", "../SingletonConfigurationManager.cpp", "AppPreference.cpp", "AppPreference.h", diff --git a/src/platform/Tizen/DnssdImpl.cpp b/src/platform/Tizen/DnssdImpl.cpp index 8d383ac48f5d13..cc3e5a1e8f76a6 100644 --- a/src/platform/Tizen/DnssdImpl.cpp +++ b/src/platform/Tizen/DnssdImpl.cpp @@ -181,13 +181,13 @@ void OnBrowse(dnssd_service_state_e state, dnssd_service_h service, void * data) chip::GAutoPtr ifaceName; uint32_t interfaceId = 0; - ret = dnssd_service_get_type(service, &MakeUniquePointerReceiver(type).Get()); + ret = dnssd_service_get_type(service, &type.GetReceiver()); VerifyOrExit(ret == DNSSD_ERROR_NONE, ChipLogError(DeviceLayer, "dnssd_service_get_type() failed: %s", get_error_message(ret))); - ret = dnssd_service_get_name(service, &MakeUniquePointerReceiver(name).Get()); + ret = dnssd_service_get_name(service, &name.GetReceiver()); VerifyOrExit(ret == DNSSD_ERROR_NONE, ChipLogError(DeviceLayer, "dnssd_service_get_name() failed: %s", get_error_message(ret))); - ret = dnssd_service_get_interface(service, &MakeUniquePointerReceiver(ifaceName).Get()); + ret = dnssd_service_get_interface(service, &ifaceName.GetReceiver()); VerifyOrExit(ret == DNSSD_ERROR_NONE, ChipLogError(DeviceLayer, "dnssd_service_get_interface() failed: %s", get_error_message(ret))); @@ -305,12 +305,12 @@ void OnResolve(dnssd_error_e result, dnssd_service_h service, void * userData) chip::Inet::IPAddress ipAddr; CHIP_ERROR err = CHIP_NO_ERROR; - int ret = dnssd_service_get_name(service, &MakeUniquePointerReceiver(name).Get()); + int ret = dnssd_service_get_name(service, &name.GetReceiver()); VerifyOrExit(ret == DNSSD_ERROR_NONE, ChipLogError(DeviceLayer, "dnssd_service_get_name() failed: %s", get_error_message(ret))); chip::Platform::CopyString(rCtx->mResult.mName, name.get()); - ret = dnssd_service_get_ip(service, &MakeUniquePointerReceiver(ipv4).Get(), &MakeUniquePointerReceiver(ipv6).Get()); + ret = dnssd_service_get_ip(service, &ipv4.GetReceiver(), &ipv6.GetReceiver()); VerifyOrExit(ret == DNSSD_ERROR_NONE, ChipLogError(DeviceLayer, "dnssd_service_get_ip() failed: %s", get_error_message(ret))); // If both IPv4 and IPv6 are set, IPv6 address has higher priority. diff --git a/src/platform/Tizen/WiFiManager.cpp b/src/platform/Tizen/WiFiManager.cpp index ed43377e5e0142..50e8b9206401d7 100644 --- a/src/platform/Tizen/WiFiManager.cpp +++ b/src/platform/Tizen/WiFiManager.cpp @@ -400,14 +400,14 @@ bool WiFiManager::_FoundAPOnScanCb(wifi_manager_ap_h ap, void * userData) wifi_manager_security_type_e type; WiFiScanResponse scannedAP; - wifiErr = wifi_manager_ap_get_essid(ap, &MakeUniquePointerReceiver(essid).Get()); + wifiErr = wifi_manager_ap_get_essid(ap, &essid.GetReceiver()); VerifyOrExit(wifiErr == WIFI_MANAGER_ERROR_NONE, ChipLogError(DeviceLayer, "FAIL: get AP essid [%s]", get_error_message(wifiErr))); ChipLogProgress(DeviceLayer, "Essid Found: %s\n", essid.get()); scannedAP.ssidLen = static_cast(std::min(strlen(essid.get()), sizeof(scannedAP.ssid))); memcpy(scannedAP.ssid, essid.get(), scannedAP.ssidLen); - wifiErr = wifi_manager_ap_get_bssid(ap, &MakeUniquePointerReceiver(bssid).Get()); + wifiErr = wifi_manager_ap_get_bssid(ap, &bssid.GetReceiver()); VerifyOrExit(wifiErr == WIFI_MANAGER_ERROR_NONE, ChipLogError(DeviceLayer, "Fail: get AP bssid [%s]", get_error_message(wifiErr))); memcpy(scannedAP.bssid, bssid.get(), std::min(strlen(bssid.get()), sizeof(scannedAP.bssid))); @@ -443,7 +443,7 @@ bool WiFiManager::_FoundAPCb(wifi_manager_ap_h ap, void * userData) bool isPassphraseRequired = false; auto clonedAp = reinterpret_cast(userData); - wifiErr = wifi_manager_ap_get_essid(ap, &MakeUniquePointerReceiver(essid).Get()); + wifiErr = wifi_manager_ap_get_essid(ap, &essid.GetReceiver()); VerifyOrExit(wifiErr == WIFI_MANAGER_ERROR_NONE, ChipLogError(DeviceLayer, "FAIL: get AP essid [%s]", get_error_message(wifiErr))); @@ -503,7 +503,7 @@ bool WiFiManager::_ConfigListCb(const wifi_manager_config_h config, void * userD GAutoPtr name; wifi_manager_security_type_e securityType = WIFI_MANAGER_SECURITY_TYPE_NONE; - wifi_manager_config_get_name(config, &MakeUniquePointerReceiver(name).Get()); + wifi_manager_config_get_name(config, &name.GetReceiver()); wifi_manager_config_get_security_type(config, &securityType); wifiErr = wifi_manager_config_remove(sInstance.mWiFiManagerHandle, config); @@ -1155,7 +1155,7 @@ CHIP_ERROR WiFiManager::GetConfiguredNetwork(NetworkCommissioning::Network & net return CHIP_ERROR_INCORRECT_STATE; } GAutoPtr essid; - int wifiErr = wifi_manager_ap_get_essid(connectedAp, &MakeUniquePointerReceiver(essid).Get()); + int wifiErr = wifi_manager_ap_get_essid(connectedAp, &essid.GetReceiver()); VerifyOrReturnError(wifiErr == WIFI_MANAGER_ERROR_NONE, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "FAIL: get essid [%s]", get_error_message(wifiErr))); network.networkIDLen = static_cast(std::min(strlen(essid.get()), sizeof(network.networkID)));