Skip to content

Commit

Permalink
Use serial number and manufacturing date in Basic Cluster (#10706)
Browse files Browse the repository at this point in the history
* Use serial number and manufacturing date in Basic Cluster

Basic Cluster is usually using the values from the zap file.

This means that all devices will have the same Serial Number and
ManufacturingDate. At least Serial Number and Manufacturing Date should be
taken from ConfigurationMgr.

Also:
* Use descriptive values for char arrays in basic cluster.
* Fix-up software and hardware version to match names in specification.

Co-authored-by: Boris Zbarsky <[email protected]>

* regenerated file

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 27, 2022
1 parent 8aa01b5 commit 4906757
Show file tree
Hide file tree
Showing 65 changed files with 356 additions and 310 deletions.
3 changes: 1 addition & 2 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ Gv
gz
hardcoded
hardknott
hardwarever
HardwareVersion
HardwareVersionString
hci
Expand Down Expand Up @@ -743,8 +744,6 @@ prj
ProductID
ProductLabel
ProductName
productrev
ProductRevision
ProductURL
proto
protobuf
Expand Down
20 changes: 10 additions & 10 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -400,26 +400,26 @@ menu "CHIP Device Layer"
The device product id (in hex). This is a unique id assigned by the device vendor to identify the product or device type.
Defaults to a CHIP-assigned id designating a non-production or test "product".

config DEFAULT_DEVICE_PRODUCT_REVISION
int "Default Device Product Revision"
config DEFAULT_DEVICE_HARDWARE_VERSION
int "Default Device Hardware Version"
range 0 65535
default 0
help
The default device product revision.
The default device hardware version.

Product revisions are specific to a particular device vendor and product id, and typically
correspond to a revision of the physical device, a change to its packaging, and/or a change
Hardware versions are specific to a particular device vendor and product id, and typically
correspond to a version of the physical device, a change to its packaging, and/or a change
to its marketing presentation. This value is generally *not* incremented for device software
revisions.
versions.

This is a default value which is used when a product revision has not been stored in device
This is a default value which is used when a hardware version has not been stored in device
persistent storage (e.g. by a factory provisioning process).

config DEVICE_FIRMWARE_REVISION
string "Device Firmware Revision"
config DEVICE_SOFTWARE_VERSION
string "Device Software Version"
default ""
help
A string identifying the firmware revision running on the device.
A string identifying the software version running on the device.

config DEVICE_TYPE
int "Default Device type"
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/nrfconnect_examples_cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ available configuration data or to add a specific subcommand.
```shell
VendorId: 9050 (0x235A)
ProductId: 20043 (0x4E4B)
ProductRevision: 1 (0x1)
HardwareVersion: 1 (0x1)
FabricId:
PinCode: 020202021
Discriminator: f00
Expand Down Expand Up @@ -208,12 +208,12 @@ uart:~$ matter config productid
20043 (0x4E4B)
```

#### productrev
#### hardwarever

Prints the product revision of the device. Takes no arguments.
Prints the hardware version of the device. Takes no arguments.

```shell
uart:~$ matter config productrev
uart:~$ matter config hardwarever
1 (0x1)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/python_chip_controller_building.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ I: 254 [DL]Device Configuration:
I: 257 [DL] Serial Number: TEST_SN
I: 260 [DL] Vendor Id: 9050 (0x235A)
I: 263 [DL] Product Id: 20043 (0x4E4B)
I: 267 [DL] Product Revision: 1
I: 267 [DL] Hardware Version: 1
I: 270 [DL] Setup Pin Code: 20202021
I: 273 [DL] Setup Discriminator: 3840 (0xF00)
I: 278 [DL] Manufacturing Date: (not set)
Expand Down
20 changes: 10 additions & 10 deletions examples/all-clusters-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@
#define CHIP_CONFIG_REQUIRE_AUTH 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The product revision number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a version of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software revisions.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the firmware revision running on the device.
* CHIP service currently expects the firmware version to be in the format
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "0.1ALPHA"
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ CHIP_ERROR AppTask::Init()
// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();

P6_LOG("Current Firmware Version: %s", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING);
P6_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);

// Initialize LEDs
sStatusLED.Init(SYSTEM_STATE_LED);
Expand Down
21 changes: 19 additions & 2 deletions examples/common/pigweed/rpc_services/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,36 @@ class Device : public generated::Device<Device>

virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{

uint16_t vendor_id;
if (DeviceLayer::ConfigurationMgr().GetVendorId(vendor_id) == CHIP_NO_ERROR)
{
response.vendor_id = static_cast<uint32_t>(vendor_id);
}
else
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
}

uint16_t product_id;
if (DeviceLayer::ConfigurationMgr().GetProductId(product_id) == CHIP_NO_ERROR)
{
response.product_id = static_cast<uint32_t>(product_id);
}
else
{
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
}

uint16_t software_version;
if (DeviceLayer::ConfigurationMgr().GetFirmwareRevision(software_version) == CHIP_NO_ERROR)
if (DeviceLayer::ConfigurationMgr().GetSoftwareVersion(software_version) == CHIP_NO_ERROR)
{
response.software_version = software_version;
}
else
{
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION;
}

uint32_t code;
if (DeviceLayer::ConfigurationMgr().GetSetupPinCode(code) == CHIP_NO_ERROR)
Expand All @@ -105,7 +118,11 @@ class Device : public generated::Device<Device>
response.has_pairing_info = true;
}

DeviceLayer::ConfigurationMgr().GetSerialNumber(response.serial_number, sizeof(response.serial_number));
if (DeviceLayer::ConfigurationMgr().GetSerialNumber(response.serial_number, sizeof(response.serial_number)) !=
CHIP_NO_ERROR)
{
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
}

return pw::OkStatus();
}
Expand Down
18 changes: 9 additions & 9 deletions examples/lighting-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x534C

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The product revision number assigned to device or product by the device vendor. This
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software revisions.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the firmware revision running on the device.
* CHIP service currently expects the firmware version to be in the format
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "0.1ALPHA"
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ CHIP_ERROR AppTask::Init()
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

EFR32_LOG("Current Firmware Version: %s", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING);
EFR32_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
err = LightMgr().Init();
if (err != CHIP_NO_ERROR)
{
Expand Down
26 changes: 13 additions & 13 deletions examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,32 @@
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x4B4C

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The product revision number assigned to device or product by the device vendor. This
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software revisions.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 100
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 100

#ifndef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION_STRING "v0.1.0"
#ifndef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "v0.1.0"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the firmware revision running on the device.
* CHIP currently expects the firmware version to be in the format
* A string identifying the software version running on the device.
* CHIP currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "04-2020-te2"
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "04-2020-te2"
#endif

#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION 42020
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 42020
#endif

#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME
Expand Down
6 changes: 3 additions & 3 deletions examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ CHIP_ERROR AppTask::Init()
}

// Print the current software version
char currentFirmwareRev[ConfigurationManager::kMaxFirmwareRevisionLength + 1] = { 0 };
err = ConfigurationMgr().GetFirmwareRevisionString(currentFirmwareRev, sizeof(currentFirmwareRev));
char currentSoftwareVer[ConfigurationManager::kMaxSoftwareVersionLength + 1] = { 0 };
err = ConfigurationMgr().GetSoftwareVersionString(currentSoftwareVer, sizeof(currentSoftwareVer));
if (err != CHIP_NO_ERROR)
{
K32W_LOG("Get version error");
assert(err == CHIP_NO_ERROR);
}

K32W_LOG("Current Firmware Version: %s", currentFirmwareRev);
K32W_LOG("Current Software Version: %s", currentSoftwareVer);

#if CONFIG_CHIP_NFC_COMMISSIONING
PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0);
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

ChipLogProgress(NotSpecified, "Current Firmware Version: %s", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING);
ChipLogProgress(NotSpecified, "Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);

err = LightingMgr().Init();
if (err != CHIP_NO_ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,24 @@
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x434B

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The product revision number assigned to device or product by the device vendor. This
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software revisions.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the firmware revision running on the device.
* CHIP currently expects the firmware version to be in the format
* A string identifying the software version running on the device.
* CHIP currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "1.0d1"
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0d1"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
18 changes: 9 additions & 9 deletions examples/lock-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x534B

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The product revision number assigned to device or product by the device vendor. This
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software revisions.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION 1
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the firmware revision running on the device.
* CHIP service currently expects the firmware version to be in the format
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "0.1ALPHA"
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ CHIP_ERROR AppTask::Init()
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

EFR32_LOG("Current Firmware Version: %s", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING);
EFR32_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
CHIP_ERROR err = BoltLockMgr().Init();
if (err != CHIP_NO_ERROR)
{
Expand Down
Loading

0 comments on commit 4906757

Please sign in to comment.