esp-matter
esp-matter copied to clipboard
Mode Select and mfg_tool (CON-1198)
If the labels for mode select aren't set correctly you get an obscure error.... This is because I altered the ep order and now the ep in flash on mode select doesn't match my actual ep. This scheme of ep number being stored in flash also does not work for a bridged device. These label need to be set from code.
Not sure what is wrong. I am putting the labels on EP2 from mfg_tool. And you can see that I am reading them on EP2.
esp-matter-mfg-tool -cn "Test" -v 0xFFF2 -p 0x8001 --pai \
-k $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Key.pem \
-c $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Cert.pem \
-cd $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/credentials/test/certification-declaration/Chip-Test-CD-FFF2-8001.der \
--vendor-name "Lowpan" --product-name "Dimmer" --serial-num "12345678" \
--hw-ver-str "1.0.0" \
--passcode 20202021 --discriminator 3840 \
--fixed-labels "1/name/Main" "2/name/BTN-2" "3/name/BTN-3" "4/name/BTN-4" "5/name/BTN-5" "6/name/BTN-6" "7/name/BTN-7" "8/name/BTN-8" \
--supported-modes "0/Switch/2" "1/Dimmer/2" "2/ELV Dimmer/2" "3/Smartbulb/2" "4/No load/2"
I (7258) esp_matter_attribute: ********** R : Endpoint 0x0002's Cluster 0x00000062's Attribute 0x00000001 is 16 **********
I (7262) esp_matter_attribute: ********** R : Endpoint 0x0002's Cluster 0x00000050's Attribute 0x0000FFFC is 0 **********
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x420d76e0 PS : 0x00060130 A0 : 0x820d9cfe A1 : 0x3fcd2ec0
0x420d76e0: chip::app::DataModel::Encode(chip::TLV::TLVWriter&, chip::TLV::Tag, chip::Span<char const>) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/app/data-model/Encode.h:95
(inlined by) void chip::app::DataModel::WrappedStructEncoder::Encode<chip::Span<char const> const&>(unsigned char, chip::Span<char const> const&) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/app/data-model/WrappedStructEncoder.h:45
(inlined by) void chip::app::DataModel::WrappedStructEncoder::Encode<chip::Span<char const> const&>(unsigned char, chip::Span<char const> const&) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/app/data-model/WrappedStructEncoder.h:42
A2 : 0x3fcd2f00 A3 : 0x00000000 A4 : 0xbaad5678 A5 : 0x00000000
A6 : 0x00000016 A7 : 0x3fcd313c A8 : 0x00000000 A9 : 0x3fcd2eb0
A10 : 0x00000000 A11 : 0x3fcd313c A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000015 A15 : 0x3fcd2f08 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0xbaad5678 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000000
Backtrace: 0x420d76dd:0x3fcd2ec0 0x420d9cfb:0x3fcd2ef0 0x42083d7d:0x3fcd2f30 0x420757bd:0x3fcd2f90 0x42076680:0x3fcd3030 0x420767bb:0x3fcd3050 0x42076ea4:0x3fcd3130 0x420770f3:0x3fcd3250 0x42077178:0x3fcd3290 0x420c154d:0x3fcd32b0 0x420c155d:0x3fcd32d0 0x420dcdbd:0x3fcd32f0 0x420dd165:0x3fcd3310 0x420dd1ad:0x3fcd3380 0x40382cda:0x3fcd33a0
0x40056f5c: memcpy in ROM
0x40056f72: memcpy in ROM
0x420d76dd: void chip::app::DataModel::WrappedStructEncoder::Encode<chip::Span<char const> const&>(unsigned char, chip::Span<char const> const&) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/app/data-model/WrappedStructEncoder.h:44 (discriminator 2)
0x420d9cfb: chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type::Encode(chip::TLV::TLVWriter&, chip::TLV::Tag) const at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp:10500
0x42083d7d: chip::ChipError chip::app::DataModel::Encode<chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type, (chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type*)0>(chip::TLV::TLVWriter&, chip::TLV::Tag, chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/data-model/Encode.h:117
(inlined by) chip::ChipError chip::app::AttributeReportBuilder::EncodeValue<chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&, true>(chip::app::AttributeReportIBs::Builder&, chip::TLV::Tag, chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/AttributeAccessInterface.h:82
(inlined by) chip::ChipError chip::app::AttributeValueEncoder::EncodeListItem<chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&>(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/AttributeAccessInterface.h:278
(inlined by) chip::ChipError chip::app::AttributeValueEncoder::ListEncodeHelper::Encode<chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&, true>(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type const&) const at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/AttributeAccessInterface.h:127
(inlined by) operator()<chip::app::AttributeValueEncoder::ListEncodeHelper> at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/clusters/mode-select-server/mode-select-server.cpp:87
(inlined by) EncodeList<(anonymous namespace)::ModeSelectAttrAccess::Read(const chip::app::ConcreteReadAttributePath&, chip::app::AttributeValueEncoder&)::<lambda(const auto:5&)> > at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/AttributeAccessInterface.h:227
(inlined by) Read at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/clusters/mode-select-server/mode-select-server.cpp:82
0x420757bd: chip::app::ReadSingleClusterData(chip::Access::SubjectDescriptor const&, bool, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeReportIBs::Builder&, chip::app::AttributeValueEncoder::AttributeEncodeState*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/util/ember-compatibility-functions.cpp:436
(inlined by) chip::app::ReadSingleClusterData(chip::Access::SubjectDescriptor const&, bool, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeReportIBs::Builder&, chip::app::AttributeValueEncoder::AttributeEncodeState*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/util/ember-compatibility-functions.cpp:570
0x42076680: chip::app::reporting::Engine::RetrieveClusterData(chip::Access::SubjectDescriptor const&, bool, chip::app::AttributeReportIBs::Builder&, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeValueEncoder::AttributeEncodeState*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/reporting/Engine.cpp:93
0x420767bb: chip::app::reporting::Engine::BuildSingleReportDataAttributeReportIBs(chip::app::ReportDataMessage::Builder&, chip::app::ReadHandler*, bool*, bool*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/reporting/Engine.cpp:203 (discriminator 2)
0x42076ea4: chip::app::reporting::Engine::BuildAndSendSingleReportData(chip::app::ReadHandler*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/reporting/Engine.cpp:546
0x420770f3: chip::app::reporting::Engine::Run() at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/reporting/Engine.cpp:666
0x42077178: chip::app::reporting::Engine::Run(chip::System::Layer*, void*) at /home/jonsmirl/aosp/esp-matter/connectedhomeip/connectedhomeip/src/app/reporting/Engine.cpp:619
0x420c154d: chip::System::TimerData::Callback::Invoke() const at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/system/SystemTimer.h:61
(inlined by) chip::System::TimerPool<chip::System::TimerList::Node>::Invoke(chip::System::TimerList::Node*) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/system/SystemTimer.h:237
0x420c155d: chip::LambdaBridge::Initialize<chip::System::LayerImplFreeRTOS::ScheduleWork(void (*)(chip::System::Layer*, void*), void*)::{lambda()#1}>(chip::System::LayerImplFreeRTOS::ScheduleWork(void (*)(chip::System::Layer*, void*), void*)::{lambda()#1} const&)::{lambda(std::aligned_storage<24u, 4u>::type const&)#1}::_FUN(std::aligned_storage<24u, 4u>::type const&) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/system/SystemLayerImplFreeRTOS.cpp:143
(inlined by) operator() at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/lib/support/LambdaBridge.h:39
(inlined by) _FUN at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/lib/support/LambdaBridge.h:39
0x420dcdbd: chip::DeviceLayer::Internal::GenericPlatformManagerImpl<chip::DeviceLayer::PlatformManagerImpl>::_DispatchEvent(chip::DeviceLayer::ChipDeviceEvent const*) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/include/platform/internal/GenericPlatformManagerImpl.ipp:290
0x420dd165: chip::DeviceLayer::PlatformManager::DispatchEvent(chip::DeviceLayer::ChipDeviceEvent const*) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/include/platform/PlatformManager.h:503
(inlined by) chip::DeviceLayer::Internal::GenericPlatformManagerImpl_FreeRTOS<chip::DeviceLayer::PlatformManagerImpl>::_RunEventLoop() at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp:257
0x420dd1ad: chip::DeviceLayer::PlatformManager::RunEventLoop() at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/include/platform/PlatformManager.h:403
(inlined by) chip::DeviceLayer::Internal::GenericPlatformManagerImpl_FreeRTOS<chip::DeviceLayer::PlatformManagerImpl>::EventLoopTaskMain(void*) at /home/jonsmirl/l6/build/esp-idf/chip/../../../../aosp/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp:280
0x40382cda: vPortTaskWrapper at /home/jonsmirl/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
I just wrote my own ModeOptionsProvider, pretty simple to do. I did not figure out what is messed up with modes and mfg_tool. I will move these strings into an external file for translations. This also allows me to deal with the mode-select clusters ending up on different endpoints in my bridge.
const char *labels[] = {"Switch", "Dimmer", "ELV Dimmer", "Smartbulb", "No Load"};
const int modes[] = {0, 1, 2, 3, 4};
SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeOptionsProvider(EndpointId endpointId) const
{
int count = sizeof(modes) / sizeof(int);
ModeOptionStructType * modeOptionStructList = new ModeOptionStructType[count];
if (modeOptionStructList == nullptr)
{
return ModeOptionsProvider(nullptr, nullptr);
}
for (int i = 0; i < count; i++) {
Structs::ModeOptionStruct::Type option;
option.label = chip::CharSpan::fromCharString(labels[i]);
option.mode = static_cast<uint8_t>(modes[i]);
option.semanticTags = DataModel::List<const SemanticTag>((SemanticTag *)NULL, 0);
modeOptionStructList[i] = option;
}
return ModeOptionsProvider(modeOptionStructList, modeOptionStructList + count);
}
Can you please share your endpoint composition initially and after change?
~Till we remove mode_select from mfg-tool you can add it from the code. Here is the reference implementation that you will have to do in your example.~ Edit: You already did this :)
There really needs to a smart switch device type. With an official smart switch device type it would use ModeBase instead of ModeSelect.
I switched the EPs from fixed to being on an internal bridge. Doing that let me remove and reconfigure them. This model works on IOS but it does not work on Google Home due to Google not supporting Generic Swich.
For a smart switch (Keypads have 8 of these)
Bridge descriptor
Identify
Groups
Scenes
Mode Select
OnOff
LevelControl
ColorControl
GenericSwitch
OnOff Switch
Level control switch
Color control switch
Fixed label
User label
A better way to do this would be to let me pass in a ModeOptionStructType on the config when the ModeSelect cluster is made. Or just some constants like this, but reorganize them into a structure. This works for fixed label too.
const char *labels[] = {"Switch", "Dimmer", "ELV Dimmer", "Smartbulb", "No Load"};
const int modes[] = {0, 1, 2, 3, 4};
something like this, the nulls terminate the variable length lists.
const labels = {{"Switch", 0, {tag1, tag2, 0}}, {"Dimmer", 1, {tag1, tag2, 0}}, {"ELV Dimmer", 2, {tag1, tag2, 0}}, {"Smartbulb", 3, {tag1, tag2, 0}}, {NULL}}