|
| 1 | +## Providers Implemented for ESP32 Platform |
| 2 | + |
| 3 | +The ESP32 platform has implemented several providers that can be used with data |
| 4 | +stored in the factory or by setting fixed data. |
| 5 | + |
| 6 | +Below are the providers that have been implemented: |
| 7 | + |
| 8 | +- [Commissionable Data Provider](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32FactoryDataProvider.h#L47) |
| 9 | + This provider reads the discriminator and setup pincode related parameters |
| 10 | + from the factory partition. |
| 11 | +- [Device Attestation Credentials Provider](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32FactoryDataProvider.h#L56) |
| 12 | + This provider manages the attestation data. |
| 13 | +- [Device Instance Info Provider](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32FactoryDataProvider.h#L86) |
| 14 | + This provider reads basic device information from the factory partition. |
| 15 | +- [Device Info Provider](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32DeviceInfoProvider.h#L31) |
| 16 | + This provider provides fixed labels, supported calendar types, and supported |
| 17 | + locales from the factory partition. |
| 18 | +- [Supported Modes](https://github.com/project-chip/connectedhomeip/blob/master/examples/platform/esp32/mode-support/static-supported-modes-manager.h#L28) |
| 19 | + This provider offers the supported modes for the mode-select cluster. |
| 20 | + |
| 21 | +More information can be found in the [factory data guide](factory_data.md). |
| 22 | + |
| 23 | +### Device Info Provider |
| 24 | + |
| 25 | +Currently, there are two implementations for this provider: |
| 26 | + |
| 27 | +1. [Reads data stored in the factory partition](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ESP32FactoryDataProvider.h#L56) |
| 28 | + _(This will be deprecated in the future)_ |
| 29 | +2. [Provides APIs to set fixed data that gets read later](https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/StaticESP32DeviceInfoProvider.h) |
| 30 | + |
| 31 | +- New products should use the `StaticESP32DeviceInfoProvider`. Utilize the |
| 32 | + `Set...()` APIs to set the fixed data. |
| 33 | +- Existing products using the first implementation can continue to use it if |
| 34 | + they do not wish to change the data. |
| 35 | +- For products using the first implementation and wanting to change the fixed |
| 36 | + data via OTA, they should switch to the second implementation in the OTA |
| 37 | + image and use the `Set...()` APIs to set the fixed data. |
| 38 | + |
| 39 | +#### Example: |
| 40 | + |
| 41 | +```cpp |
| 42 | +#include <platform/ESP32/StaticESP32FactoryDataProvider.h> |
| 43 | + |
| 44 | +DeviceLayer::StaticESP32DeviceInfoProvider deviceInfoProvider; |
| 45 | + |
| 46 | +// Define array for Supported Calendar Types |
| 47 | +using namespace chip::app::Clusters::TimeFormatLocalization::CalendarTypeEnum; |
| 48 | +CalendarTypeEnum supportedCalendarTypes[] = { |
| 49 | + CalendarTypeEnum::kGregorian, CalendarTypeEnum::kCoptic, |
| 50 | + CalendarTypeEnum::kEthiopian, CalendarTypeEnum::kChinese, |
| 51 | +}; |
| 52 | + |
| 53 | +// Define array for Supported Locales |
| 54 | +const char* supportedLocales[] = { |
| 55 | + "en-US", |
| 56 | + "en-EU", |
| 57 | +}; |
| 58 | + |
| 59 | +// Define array for Fixed labels { EndpointId, Label, Value } |
| 60 | +struct StaticESP32DeviceInfoProvider::FixedLabelEntry fixedLabels[] = { |
| 61 | + { 0, "Room", "Bedroom 2" }, |
| 62 | + { 0, "Orientation", "North" }, |
| 63 | + { 0, "Direction", "Up" }, |
| 64 | +}; |
| 65 | + |
| 66 | +Span<CalendarTypeEnum> sSupportedCalendarTypes(supportedCalendarTypes); |
| 67 | +Span<const char*> sSupportedLocales(supportedLocales); |
| 68 | +Span<StaticESP32DeviceInfoProvider::FixedLabelEntry> sFixedLabels(fixedLabels); |
| 69 | + |
| 70 | +{ |
| 71 | + deviceInfoProvider.SetSupportedLocales(sSupportedLocales); |
| 72 | + deviceInfoProvider.SetSupportedCalendarTypes(sSupportedCalendarTypes); |
| 73 | + deviceInfoProvider.SetFixedLabels(sFixedLabels); |
| 74 | + DeviceLayer::SetDeviceInfoProvider(&deviceInfoProvider); |
| 75 | +} |
| 76 | +``` |
0 commit comments