Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESP32] Add a configurable device type for commissionable advertising. #35344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scripts/tools/generate_esp32_chip_factory_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ class Product_Color_Enum(Enum):
'encoding': 'string',
'value': None,
},
'device-type': {
'type': 'data',
'encoding': 'u32',
'value': None,
},
}


Expand Down Expand Up @@ -372,6 +377,8 @@ def populate_factory_data(args, spake2p_params):
FACTORY_DATA['product-url']['value'] = args.product_url
if args.product_label:
FACTORY_DATA['product-label']['value'] = args.product_label
if args.device_type is not None:
FACTORY_DATA['device-type']['value'] = args.device_type

# SupportedModes are stored as multiple entries
# - sm-sz/<ep> : number of supported modes for the endpoint
Expand Down Expand Up @@ -554,6 +561,8 @@ def any_base_int(s): return int(s, 0)
parser.add_argument("--product-label", type=str, help='human readable product label')
parser.add_argument("--product-url", type=str, help='link to product specific web page')

parser.add_argument("--device-type", type=any_base_int, help='commissionable device type')

parser.add_argument('-s', '--size', type=any_base_int, default=0x6000,
help='The size of the partition.bin, default: 0x6000')
parser.add_argument('--target', default='esp32',
Expand Down
17 changes: 17 additions & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)
#endif // CONFIG_ENABLE_ESP32_LOCATIONCAPABILITY
}

CHIP_ERROR ConfigurationManagerImpl::GetDeviceTypeId(uint32_t & deviceType)
{
uint32_t value = 0;
CHIP_ERROR err = ReadConfigValue(ESP32Config::kConfigKey_PrimaryDeviceType, value);

if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
deviceType = CHIP_DEVICE_CONFIG_DEVICE_TYPE;
}
else
{
deviceType = value;
}

return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t codeLen)
{
// As per spec, codeLen has to be 2
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize);
CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override;
CHIP_ERROR GetLocationCapability(uint8_t & location) override;
CHIP_ERROR GetDeviceTypeId(uint32_t & deviceType) override;
static ConfigurationManagerImpl & GetDefaultInstance();

// Set the country code to esp_phy layer and also store it to NVS
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ESP32Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const ESP32Config::Key ESP32Config::kConfigKey_ProductFinish = { kConfig
const ESP32Config::Key ESP32Config::kConfigKey_ProductColor = { kConfigNamespace_ChipFactory, "product-color" };
const ESP32Config::Key ESP32Config::kConfigKey_PartNumber = { kConfigNamespace_ChipFactory, "part-number" };
const ESP32Config::Key ESP32Config::kConfigKey_LocationCapability = { kConfigNamespace_ChipFactory, "loc-capability" };
const ESP32Config::Key ESP32Config::kConfigKey_PrimaryDeviceType = { kConfigNamespace_ChipFactory, "device-type" };

// Keys stored in the chip-config namespace
const ESP32Config::Key ESP32Config::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" };
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ESP32Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ESP32Config
static const Key kConfigKey_ProductFinish;
static const Key kConfigKey_ProductColor;
static const Key kConfigKey_LocationCapability;
static const Key kConfigKey_PrimaryDeviceType;

// CHIP Config keys
static const Key kConfigKey_ServiceConfig;
Expand Down
Loading