Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Sickeroni authored Jun 5, 2023
2 parents 640e1fb + cd898c4 commit 290c672
Show file tree
Hide file tree
Showing 151 changed files with 52,867 additions and 12,792 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/content-launch-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/descriptor-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-select-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/fan-control-cluster.xml \
Expand All @@ -154,6 +155,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/identify-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/illuminance-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/keypad-input-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/laundry-washer-mode-select-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/level-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/low-power-cluster.xml \
Expand All @@ -173,8 +175,11 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/proxy-valid-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/pump-configuration-and-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/pwm-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/refrigerator-and-temperature-controlled-cabinet-mode-select-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml \
src/app/zap-templates/zcl/data-model/chip/relative-humidity-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-select-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-select-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/scene.xml \
src/app/zap-templates/zcl/data-model/chip/software-diagnostics-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/switch-cluster.xml \
Expand Down
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
deps += [
"${chip_root}/src/app/server/java",
"${chip_root}/src/controller/java",
"${chip_root}/src/controller/java:onboarding_payload",
"${chip_root}/src/platform/android:java",
"${chip_root}/src/setup_payload/java",
]
}

Expand Down
7 changes: 7 additions & 0 deletions config/nrfconnect/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ config CHIP_FACTORY_DATA_VERSION
this value in the factory data provider implementation to verify that the
factory data saved in the flash memory has the expected version.

config CHIP_FACTORY_DATA_ROTATING_DEVICE_UID_MAX_LEN
int "Maximum length of rotating device ID unique ID in bytes"
default 16
depends on CHIP_FACTORY_DATA
help
Maximum acceptable length of rotating device ID unique ID in bytes.

if CHIP_FACTORY_DATA_BUILD

# Factory data definitions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// This IDL was generated automatically by ZAP.
// It is for view/code review purposes only.

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
optional char_string<64> tagName = 2;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

struct ApplicationStruct {
int16u catalogVendorID = 0;
char_string applicationID = 1;
Expand Down Expand Up @@ -2296,22 +2308,43 @@ server cluster IcdManagement = 70 {

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster ModeSelect = 80 {
enum ModeTag : ENUM16 {
kAuto = 0;
kQuick = 1;
kQuiet = 2;
kLowNoise = 3;
kLowEnergy = 4;
kVacation = 5;
kMin = 6;
kMax = 7;
kNight = 8;
kDay = 9;
}

enum StatusCode : ENUM8 {
kSuccess = 0;
kUnsupportedMode = 1;
kGenericFailure = 2;
}

bitmap Feature : BITMAP32 {
kDeponoff = 0x1;
kOnOff = 0x1;
kExtendedStatus = 0x2;
}

struct SemanticTagStruct {
vendor_id mfgCode = 0;
struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
optional char_string<64> tagName = 2;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
SemanticTagStruct semanticTags[] = 2;
ModeTagStruct modeTags[] = 2;
}

readonly attribute char_string<32> description = 0;
readonly attribute char_string<64> description = 0;
readonly attribute nullable enum16 standardNamespace = 1;
readonly attribute ModeOptionStruct supportedModes[] = 2;
readonly attribute int8u currentMode = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,30 @@ using namespace chip::app::Clusters::ModeSelect;
using chip::Protocols::InteractionModel::Status;

using ModeOptionStructType = Structs::ModeOptionStruct::Type;
using SemanticTag = Structs::SemanticTagStruct::Type;
using ModeTagType = Structs::ModeTagStruct::Type;
template <typename T>
using List = app::DataModel::List<T>;
using storage_value_type = const ModeOptionStructType;
namespace {
Structs::ModeOptionStruct::Type buildModeOptionStruct(const char * label, uint8_t mode,
const List<const SemanticTag> & semanticTags)
Structs::ModeOptionStruct::Type buildModeOptionStruct(const char * label, uint8_t mode, const List<const ModeTagType> & modeTags)
{
Structs::ModeOptionStruct::Type option;
option.label = CharSpan::fromCharString(label);
option.mode = mode;
option.semanticTags = semanticTags;
option.label = CharSpan::fromCharString(label);
option.mode = mode;
option.modeTags = modeTags;
return option;
}
} // namespace

constexpr SemanticTag semanticTagsBlack[] = { { .value = 0 } };
constexpr SemanticTag semanticTagsCappucino[] = { { .value = 0 } };
constexpr SemanticTag semanticTagsEspresso[] = { { .value = 0 } };
ModeTagType modeTagsBlack[] = { detail::Structs::ModeTagStruct::Type{ .value = 0 } };
ModeTagType modeTagsCappucino[] = { detail::Structs::ModeTagStruct::Type{ .value = 0 } };
ModeTagType modeTagsEspresso[] = { detail::Structs::ModeTagStruct::Type{ .value = 0 } };

// TODO: Configure your options for each endpoint
storage_value_type StaticSupportedModesManager::coffeeOptions[] = {
buildModeOptionStruct("Black", 0, List<const SemanticTag>(semanticTagsBlack)),
buildModeOptionStruct("Cappuccino", 4, List<const SemanticTag>(semanticTagsCappucino)),
buildModeOptionStruct("Espresso", 7, List<const SemanticTag>(semanticTagsEspresso))
buildModeOptionStruct("Black", 0, List<const ModeTagType>(modeTagsBlack)),
buildModeOptionStruct("Cappuccino", 4, List<const ModeTagType>(modeTagsCappucino)),
buildModeOptionStruct("Espresso", 7, List<const ModeTagType>(modeTagsEspresso))
};
const StaticSupportedModesManager::EndpointSpanPair
StaticSupportedModesManager::supportedOptionsByEndpoints[EMBER_AF_MODE_SELECT_CLUSTER_SERVER_ENDPOINT_COUNT] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// This IDL was generated automatically by ZAP.
// It is for view/code review purposes only.

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
optional char_string<64> tagName = 2;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

struct ApplicationStruct {
int16u catalogVendorID = 0;
char_string applicationID = 1;
Expand Down Expand Up @@ -2029,22 +2041,43 @@ server cluster BooleanState = 69 {

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster ModeSelect = 80 {
enum ModeTag : ENUM16 {
kAuto = 0;
kQuick = 1;
kQuiet = 2;
kLowNoise = 3;
kLowEnergy = 4;
kVacation = 5;
kMin = 6;
kMax = 7;
kNight = 8;
kDay = 9;
}

enum StatusCode : ENUM8 {
kSuccess = 0;
kUnsupportedMode = 1;
kGenericFailure = 2;
}

bitmap Feature : BITMAP32 {
kDeponoff = 0x1;
kOnOff = 0x1;
kExtendedStatus = 0x2;
}

struct SemanticTagStruct {
vendor_id mfgCode = 0;
struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
optional char_string<64> tagName = 2;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
SemanticTagStruct semanticTags[] = 2;
ModeTagStruct modeTags[] = 2;
}

readonly attribute char_string<32> description = 0;
readonly attribute char_string<64> description = 0;
readonly attribute nullable enum16 standardNamespace = 1;
readonly attribute ModeOptionStruct supportedModes[] = 2;
readonly attribute int8u currentMode = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import chip.setuppayload.SetupPayload
import chip.setuppayload.SetupPayloadParser
import chip.setuppayload.SetupPayloadParser.UnrecognizedQrCodeException
import chip.onboardingpayload.OnboardingPayload
import chip.onboardingpayload.OnboardingPayloadParser
import chip.onboardingpayload.UnrecognizedQrCodeException
import com.google.chip.chiptool.provisioning.AddressCommissioningFragment
import com.google.chip.chiptool.provisioning.DeviceProvisioningFragment
import com.google.chip.chiptool.provisioning.EnterNetworkFragment
Expand Down Expand Up @@ -151,10 +151,10 @@ class CHIPToolActivity :
val uri = records[0].toUri()
if (!uri?.scheme.equals("mt", true)) return

lateinit var setupPayload: SetupPayload
lateinit var setupPayload: OnboardingPayload
try {
setupPayload =
SetupPayloadParser().parseQrCode(uri.toString().toUpperCase())
OnboardingPayloadParser().parseQrCode(uri.toString().toUpperCase())
} catch (ex: UnrecognizedQrCodeException) {
Log.e(TAG, "Unrecognized QR Code", ex)
Toast.makeText(this, "Unrecognized QR Code", Toast.LENGTH_SHORT).show()
Expand Down Expand Up @@ -208,10 +208,10 @@ class CHIPToolActivity :
val payload = JSONObject(payloadString)

// parse payload from JSON
val setupPayload = SetupPayload()
val setupPayload = OnboardingPayload()
// set defaults
setupPayload.discoveryCapabilities = setOf()
setupPayload.optionalQRCodeInfo = mapOf()
setupPayload.optionalQRCodeInfo = HashMap()

// read from payload
setupPayload.version = payload.getInt("version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.checkSelfPermission
import androidx.fragment.app.Fragment
import chip.setuppayload.SetupPayload
import chip.setuppayload.SetupPayloadParser
import chip.setuppayload.SetupPayloadParser.SetupPayloadException
import chip.setuppayload.SetupPayloadParser.InvalidEntryCodeFormatException
import chip.setuppayload.SetupPayloadParser.UnrecognizedQrCodeException
import chip.onboardingpayload.OnboardingPayload
import chip.onboardingpayload.OnboardingPayloadException
import chip.onboardingpayload.OnboardingPayloadParser
import chip.onboardingpayload.UnrecognizedQrCodeException
import com.google.chip.chiptool.R
import com.google.chip.chiptool.SelectActionFragment
import com.google.chip.chiptool.databinding.BarcodeFragmentBinding
Expand Down Expand Up @@ -182,14 +181,12 @@ class BarcodeFragment : Fragment() {
}

private fun handleInputQrCode(qrCode: String) {
lateinit var payload: SetupPayload
var isShortDiscriminator = false
lateinit var payload: OnboardingPayload
try {
payload = SetupPayloadParser().parseQrCode(qrCode)
} catch (ex: SetupPayloadException) {
payload = OnboardingPayloadParser().parseQrCode(qrCode)
} catch (ex: OnboardingPayloadException) {
try {
payload = SetupPayloadParser().parseManualEntryCode(qrCode)
isShortDiscriminator = true
payload = OnboardingPayloadParser().parseManualPairingCode(qrCode)
} catch (ex: Exception) {
Log.e(TAG, "Unrecognized Manual Pairing Code", ex)
Toast.makeText(requireContext(), "Unrecognized Manual Pairing Code", Toast.LENGTH_SHORT).show()
Expand All @@ -199,14 +196,14 @@ class BarcodeFragment : Fragment() {
Toast.makeText(requireContext(), "Unrecognized QR Code", Toast.LENGTH_SHORT).show()
}
FragmentUtil.getHost(this@BarcodeFragment, Callback::class.java)
?.onCHIPDeviceInfoReceived(CHIPDeviceInfo.fromSetupPayload(payload, isShortDiscriminator))
?.onCHIPDeviceInfoReceived(CHIPDeviceInfo.fromSetupPayload(payload))
}

private fun handleScannedQrCode(barcode: Barcode) {
Handler(Looper.getMainLooper()).post {
lateinit var payload: SetupPayload
lateinit var payload: OnboardingPayload
try {
payload = SetupPayloadParser().parseQrCode(barcode.displayValue)
payload = barcode.displayValue?.let { OnboardingPayloadParser().parseQrCode(it) } ?: return@post
} catch (ex: UnrecognizedQrCodeException) {
Log.e(TAG, "Unrecognized QR Code", ex)
Toast.makeText(requireContext(), "Unrecognized QR Code", Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package com.google.chip.chiptool.setuppayloadscanner

import android.os.Parcelable
import chip.setuppayload.DiscoveryCapability
import chip.setuppayload.SetupPayload
import chip.onboardingpayload.DiscoveryCapability
import chip.onboardingpayload.OnboardingPayload
import kotlinx.parcelize.Parcelize

/** Class to hold the CHIP device information. */
Expand All @@ -36,16 +36,15 @@ data class CHIPDeviceInfo(
val discoveryCapabilities: Set<DiscoveryCapability> = setOf(),
val isShortDiscriminator: Boolean = false,
val ipAddress: String? = null,

) : Parcelable {

companion object {
fun fromSetupPayload(setupPayload: SetupPayload, isShortDiscriminator: Boolean = false): CHIPDeviceInfo {
fun fromSetupPayload(setupPayload: OnboardingPayload): CHIPDeviceInfo {
return CHIPDeviceInfo(
setupPayload.version,
setupPayload.vendorId,
setupPayload.productId,
setupPayload.discriminator,
setupPayload.getLongDiscriminatorValue(),
setupPayload.setupPinCode,
setupPayload.commissioningFlow,
setupPayload.optionalQRCodeInfo.mapValues { (_, info) ->
Expand All @@ -57,7 +56,7 @@ data class CHIPDeviceInfo(
)
},
setupPayload.discoveryCapabilities,
isShortDiscriminator
setupPayload.hasShortDiscriminator
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.google.chip.chiptool.setuppayloadscanner

import android.os.Parcelable
import chip.setuppayload.OptionalQRCodeInfo.OptionalQRCodeInfoType
import chip.onboardingpayload.OptionalQRCodeInfo.OptionalQRCodeInfoType
import kotlinx.parcelize.Parcelize

@Parcelize
data class QrCodeInfo(
val tag: Int,
val type: OptionalQRCodeInfoType,
val data: String,
val data: String?,
val intDataValue: Int
) : Parcelable
12 changes: 12 additions & 0 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// This IDL was generated automatically by ZAP.
// It is for view/code review purposes only.

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
optional char_string<64> tagName = 2;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

struct ApplicationStruct {
int16u catalogVendorID = 0;
char_string applicationID = 1;
Expand Down
Loading

0 comments on commit 290c672

Please sign in to comment.