Skip to content

Commit adf2bb3

Browse files
committed
Changes to support few more missing attributes
1 parent 7084a0c commit adf2bb3

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

scripts/tools/generate_esp32_chip_factory_bin.py

+25
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ class Product_Color_Enum(Enum):
194194
'encoding': 'u32',
195195
'value': None,
196196
},
197+
'part-number': {
198+
'type': 'data',
199+
'encoding': 'string',
200+
'value': None,
201+
},
202+
'product-label': {
203+
'type': 'data',
204+
'encoding': 'string',
205+
'value': None,
206+
},
207+
'product-url': {
208+
'type': 'data',
209+
'encoding': 'string',
210+
'value': None,
211+
},
197212
}
198213

199214

@@ -350,6 +365,12 @@ def populate_factory_data(args, spake2p_params):
350365
FACTORY_DATA['product-finish']['value'] = Product_Finish_Enum[args.product_finish].value
351366
if args.product_color:
352367
FACTORY_DATA['product-color']['value'] = Product_Color_Enum[args.product_color].value
368+
if args.part_number:
369+
FACTORY_DATA['part-number']['value'] = args.part_number
370+
if args.product_url:
371+
FACTORY_DATA['product-url']['value'] = args.product_url
372+
if args.product_label:
373+
FACTORY_DATA['product-label']['value'] = args.product_label
353374

354375
# SupportedModes are stored as multiple entries
355376
# - sm-sz/<ep> : number of supported modes for the endpoint
@@ -528,6 +549,10 @@ def any_base_int(s): return int(s, 0)
528549
parser.add_argument("--product-color", type=str, choices=product_color_choices,
529550
help='Product colors choices for product appearance')
530551

552+
parser.add_argument("--part-number", type=str, help='human readable product number')
553+
parser.add_argument("--product-label", type=str, help='human readable product label')
554+
parser.add_argument("--product-url", type=str, help='link to product specific web page')
555+
531556
parser.add_argument('-s', '--size', type=any_base_int, default=0x6000,
532557
help='The size of the partition.bin, default: 0x6000')
533558
parser.add_argument('--target', default='esp32',

src/platform/ESP32/ESP32Config.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const ESP32Config::Key ESP32Config::kConfigKey_SupportedLocaleSize = { kConfig
7979
const ESP32Config::Key ESP32Config::kConfigKey_RotatingDevIdUniqueId = { kConfigNamespace_ChipFactory, "rd-id-uid" };
8080
const ESP32Config::Key ESP32Config::kConfigKey_ProductFinish = { kConfigNamespace_ChipFactory, "product-finish" };
8181
const ESP32Config::Key ESP32Config::kConfigKey_ProductColor = { kConfigNamespace_ChipFactory, "product-color" };
82+
const ESP32Config::Key ESP32Config::kConfigKey_PartNumber = { kConfigNamespace_ChipFactory, "part-number" };
8283
const ESP32Config::Key ESP32Config::kConfigKey_LocationCapability = { kConfigNamespace_ChipFactory, "loc-capability" };
8384

8485
// Keys stored in the chip-config namespace

src/platform/ESP32/ESP32Config.h

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class ESP32Config
7575
static const Key kConfigKey_ProductId;
7676
static const Key kConfigKey_ProductName;
7777
static const Key kConfigKey_ProductLabel;
78+
static const Key kConfigKey_PartNumber;
7879
static const Key kConfigKey_ProductURL;
7980
static const Key kConfigKey_SupportedCalTypes;
8081
static const Key kConfigKey_SupportedLocaleSize;

src/platform/ESP32/ESP32FactoryDataProvider.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ CHIP_ERROR ESP32FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersi
278278

279279
CHIP_ERROR ESP32FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize)
280280
{
281-
return GenericDeviceInstanceInfoProvider<ESP32Config>::GetPartNumber(buf, bufSize);
281+
CHIP_ERROR err = ESP32Config::ReadConfigValueStr(ESP32Config::kConfigKey_PartNumber, buf, bufSize, bufSize);
282+
if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND)
283+
{
284+
return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
285+
}
286+
return err;
282287
}
283288
#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER
284289

0 commit comments

Comments
 (0)