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 using the values from the zap file.

At least Serial Number and Manufacturing Date should be taken from
ConfigurationMgr.
  • Loading branch information
markus-becker-tridonic-com committed Oct 27, 2021
1 parent b03b897 commit f8133a4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/clusters/basic/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,26 @@ void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint)
status = Attributes::HardwareVersion::Set(endpoint, firmwareRevision);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Software Version: 0x%02x", status));
}

char serialNumberString[33];
size_t serialNumberLen;
if (ConfigurationMgr().GetSerialNumber(serialNumberString, sizeof(serialNumberString), serialNumberLen) == CHIP_NO_ERROR)
{
status = Attributes::SerialNumber::Set(endpoint, chip::CharSpan(serialNumberString, strlen(serialNumberString)));
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Serial Number String: 0x%02x", status));
}

char manufacturingDateString[17];
uint16_t manufacturingYear;
uint8_t manufacturingMonth;
uint8_t manufacturingDayOfMonth;
if (ConfigurationMgr().GetManufacturingDate(manufacturingYear, manufacturingMonth, manufacturingDayOfMonth) == CHIP_NO_ERROR)
{
snprintf(manufacturingDateString, sizeof(manufacturingDateString), "%04" PRIu16 "-%02" PRIu16 "-%02" PRIu16,
manufacturingYear, manufacturingMonth, manufacturingDayOfMonth);
status =
Attributes::ManufacturingDate::Set(endpoint, chip::CharSpan(manufacturingDateString, strlen(manufacturingDateString)));
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(Zcl, "Error setting Manufacturing Date String: 0x%02x", status));
}
}

0 comments on commit f8133a4

Please sign in to comment.