Skip to content

Commit

Permalink
Use serial number and manufacturing date in Basic Cluster
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markus-becker-tridonic-com committed Nov 11, 2021
1 parent d45cfaa commit b41c597
Show file tree
Hide file tree
Showing 35 changed files with 262 additions and 212 deletions.
2 changes: 1 addition & 1 deletion config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ menu "CHIP Device Layer"
string "Device Firmware Revision"
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
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 @@ -72,23 +72,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_REVISION;
}

uint32_t code;
if (DeviceLayer::ConfigurationMgr().GetSetupPinCode(code) == CHIP_NO_ERROR)
Expand All @@ -104,7 +117,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
14 changes: 7 additions & 7 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.
*/
#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_REVISION_STRING
*
* A string identifying the firmware revision running on the device.
* A string identifying the software version running on the device.
* CHIP service currently expects the firmware 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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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 @@ -125,7 +125,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_REVISION_STRING);
err = LightMgr().Init();
if (err != CHIP_NO_ERROR)
{
Expand Down
20 changes: 10 additions & 10 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.
*/
#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"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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_REVISION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION 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_REVISION_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.
*/
#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_REVISION_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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_STRING "1.0d1"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
14 changes: 7 additions & 7 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.
*/
#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_REVISION_STRING
*
* A string identifying the firmware revision running on the device.
* A string identifying the software version running on the device.
* CHIP service currently expects the firmware 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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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_REVISION_STRING);
CHIP_ERROR err = BoltLockMgr().Init();
if (err != CHIP_NO_ERROR)
{
Expand Down
20 changes: 10 additions & 10 deletions examples/lock-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.
*/
#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"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_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_REVISION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION 42020
#endif

#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME
Expand Down
6 changes: 3 additions & 3 deletions examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ 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");
Expand All @@ -153,7 +153,7 @@ CHIP_ERROR AppTask::Init()
PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0);
#endif

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

Expand Down
14 changes: 7 additions & 7 deletions examples/lock-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,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
* 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.
*/
#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_REVISION_STRING
*
* A string identifying the firmware revision running on the device.
* A string identifying the software version running on the device.
* CHIP service currently expects the firmware 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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ CHIP_ERROR AppTask::Init()
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

P6_LOG("Current Firmware Version: %d", CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION);
P6_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION);
err = BoltLockMgr().Init();
if (err != CHIP_NO_ERROR)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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_REVISION_STRING);

err = BoltLockMgr().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.
*/
#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_REVISION_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_REVISION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_REVISION_STRING "1.0d1"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
Loading

0 comments on commit b41c597

Please sign in to comment.