Skip to content

Commit

Permalink
Update ESP32 board to 2.0.6, esp-matter to 65e1ed1 and Matter to V1.0…
Browse files Browse the repository at this point in the history
….0.2 (#10)

* Update SDK

* Update readme and version
  • Loading branch information
Yacubane authored Jan 5, 2023
1 parent 67177c5 commit 419a030
Show file tree
Hide file tree
Showing 524 changed files with 81,221 additions and 51,553 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
> :warning: This library is currently meant to be used only for research purposes. Please read limitations section before using it.
# ESP32 Arduino Matter
This projects aims at possibility to easily launch Matter internet-of-things protocol on ESP32 with Arduino. Project contains precompiled and ready to use components from two projects: [Espressif's SDK for Matter](https://github.com/espressif/esp-matter) and [Matter](https://github.com/project-chip/connectedhomeip).
This projects aims at possibility to easily launch Matter internet-of-things protocol on ESP32 with Arduino. Repository contains precompiled and ready to use components from two projects: [Espressif's SDK for Matter](https://github.com/espressif/esp-matter) and [Matter](https://github.com/project-chip/connectedhomeip).

## Installing on Arduino IDE
1. Make sure that ESP32 board version is 2.0.5
1. Make sure that ESP32 board version is 2.0.6
2. [Turn on C++17 support for Arduino](#enabling-c17-on-arduino-ide)
3. Download this repository and [import library into Arduino IDE](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
3. [Download](https://github.com/jakubdybczak/esp32-arduino-matter/releases) and [import library into Arduino IDE](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
4. Choose larger partition scheme, for example `Minimal SPIFFS`
5. To prevent some issues related to old data, enable `Erase Flash Before Sketch Upload` option
6. Run example sketch

## Installing on PlatformIO
1. Use espressif32 platform at version 5.2.0
1. Use espressif32 platform at version 5.3.0
2. Turn on C++17 support, by setting `build_unflags=-std=gnu++11` and `build_flags=-std=gnu++17`.
3. Add this library: `lib_deps=https://github.com/jakubdybczak/esp32-arduino-matter.git`
4. Choose larger partition scheme, for example `board_build.partitions=min_spiffs.csv`
Expand All @@ -21,35 +19,37 @@ This projects aims at possibility to easily launch Matter internet-of-things pro
## Example usage
Please look at [examples](https://github.com/jakubdybczak/esp32-arduino-matter/tree/master/examples).

## Compatibility
This project contains precompiled libraries based on specific version of ESP32 SDK and this library does not guarantee support for other versions. Current build is based on `esp-idf` at version 4.4.3 and will work with:
* Arduino IDE with [ESP32 board](https://github.com/espressif/arduino-esp32) at version 2.0.6
* PlatformIO with [PlatformIO espressif32 platform](https://github.com/platformio/platform-espressif32) at version 5.3.0

## Limitations
* Library only works on base ESP32 (with experimental support for ESP32-S3, ESP32-C3).
* Library only works on ESP32, ESP32-S3 and ESP32-C3.
* There is no possibility to change vendor/product ID as this value is pre-compiled.
* There is no known possibility to change setup PIN.
* This library comes with precompiled NimBLE, because default Bluedroid shipped with arduino-esp32 takes too much RAM memory.
* Matter Controllers such as Apple Home, Google Home, Smarthings and other might not have full support of all device types.
* Matter Controllers such as Apple Home, Google Home, SmartThings and others might not have full support of all device types.

## Versions
This project is currently build based on these projects:

| Project | Tag/Commit Hash |
| Project | Tag / Commit hash |
| ------------- | ------------- |
| [Espressif's esp-idf](https://github.com/espressif/esp-idf) | 4.4.2</br>Arduino IDE ESP32 board @ 2.0.5</br>PlatformIO espressif platform @ 5.2.0 |
| [Espressif's SDK for Matter](https://github.com/espressif/esp-matter) | a0f13786 |
| [Matter](https://github.com/project-chip/connectedhomeip) | 7c2353bb |
| [Matter](https://github.com/project-chip/connectedhomeip) | V1.0.0.2 |
| [esp-matter](https://github.com/espressif/esp-matter) | 65e1ed1 |
| [esp-idf](https://github.com/espressif/esp-idf) | 4.4.3 |

## Enabling C++17 on Arduino IDE
1. Find `platform.txt` for ESP32 board. Location of this file is platform depended.

MacOS: `~/Library/Arduino15/packages/esp32/hardware/esp32/2.0.5/platform.txt`
MacOS: `~/Library/Arduino15/packages/esp32/hardware/esp32/2.0.6/platform.txt`

Windows: `C:\Users\<USER>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\platform.txt`
Windows: `C:\Users\<USER>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\platform.txt`

2. Inside `platform.txt` find `ESP32 Support Start` section and it's `compiler.cpp.flags.esp32` key. Change `-std=gnu++11` to ` -std=gnu++17`. Do the same thing for `ESP32S3` and `ESP32C3` `Support Start` section if you are using ESP32S3/ESP32C3.
2. Inside `platform.txt` find `ESP32 Support Start` section and it's `compiler.cpp.flags.esp32` key. Change `-std=gnu++11` to `-std=gnu++17`. Do the same thing for `ESP32S3` and `ESP32C3` `Support Start` section if you are using ESP32-S3/ESP32-C3.

3. Restart Arduino IDE.

## Building custom version of this library
Please look [here](https://github.com/jakubdybczak/esp32-arduino-matter-builder).

## Future and possibilities
* Creating more user-friendly wrapper API.
Please look [here](https://github.com/jakubdybczak/esp32-arduino-matter-builder).
13 changes: 10 additions & 3 deletions examples/Debug/Debug.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ using namespace esp_matter;
using namespace esp_matter::endpoint;

/**
This program presents example many Matter devices and should be used only
for debug purposes (for example checking which devices types are supported)
This program presents many Matter devices and should be used only
for debug purposes (for example checking which devices types are supported
in Matter controller).
Keep in mind that it IS NOT POSSIBLE to run all those endpoints due to
out of memory. There is need to manually comment out endpoints!
Running about 4-5 endpoints at the same time should work.
Running about 4 endpoints at the same time should work.
*/

static void on_device_event(const ChipDeviceEvent *event, intptr_t arg) {}
Expand Down Expand Up @@ -53,6 +54,7 @@ void setup() {

// !!!
// USE ONLY ABOUT 4 ENDPOINTS TO AVOID OUT OF MEMORY ERRORS
// MANUALLY COMMENT REST OF ENDPOINTS
// !!!

on_off_light::config_t light_config;
Expand All @@ -65,6 +67,10 @@ void setup() {

color_temperature_light::config_t color_temperature_light_config;
endpoint = color_temperature_light::create(node, &color_temperature_light_config, ENDPOINT_FLAG_NONE, NULL);
/* Add color control cluster */
cluster = cluster::get(endpoint, ColorControl::Id);
cluster::color_control::feature::hue_saturation::config_t hue_saturation_config;
cluster::color_control::feature::hue_saturation::add(cluster, &hue_saturation_config);
print_endpoint_info("color_temperature_light", endpoint);

extended_color_light::config_t extended_color_light_config;
Expand Down Expand Up @@ -102,6 +108,7 @@ void setup() {

window_covering_device::config_t window_covering_device_config;
endpoint = window_covering_device::create(node, &window_covering_device_config, ENDPOINT_FLAG_NONE, NULL);
/* Add additional control clusters */
cluster = cluster::get(endpoint, WindowCovering::Id);
cluster::window_covering::feature::lift::config_t lift;
cluster::window_covering::feature::tilt::config_t tilt;
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32 Arduino Matter
version=0.0.1
version=1.0.0
author=Jakub Dybczak <[email protected]>
maintainer=Jakub Dybczak <[email protected]>
sentence=Matter for ESP32 on Arduino
Expand Down
7 changes: 0 additions & 7 deletions src/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,16 @@
#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN
#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX
#define CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION CONFIG_CHIPOBLE_SINGLE_CONNECTION
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
#define CHIP_DEVICE_CONFIG_CHIP_TIME_SERVICE_ENDPOINT_ID CONFIG_CHIP_TIME_SERVICE_ENDPOINT_ID
#define CHIP_DEVICE_CONFIG_DEFAULT_TIME_SYNC_INTERVAL CONFIG_DEFAULT_TIME_SYNC_INTERVAL
#define CHIP_DEVICE_CONFIG_TIME_SYNC_TIMEOUT CONFIG_TIME_SYNC_TIMEOUT
#define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_ENDPOINT_ID CONFIG_SERVICE_PROVISIONING_ENDPOINT_ID
#define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_CONNECTIVITY_TIMEOUT CONFIG_SERVICE_PROVISIONING_CONNECTIVITY_TIMEOUT
#define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT
#define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS CONFIG_ENABLE_TEST_SETUP_PARAMS
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER CONFIG_USE_TEST_SERIAL_NUMBER
#define CHIP_DEVICE_CONFIG_ENABLE_TRAIT_MANAGER CONFIG_ENABLE_TRAIT_MANAGER
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY CONFIG_ENABLE_THREAD_TELEMETRY
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL CONFIG_ENABLE_THREAD_TELEMETRY_FULL
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_PROD_BUFFER_SIZE CONFIG_EVENT_LOGGING_PROD_BUFFER_SIZE
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
#define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH CONFIG_LOG_PROVISIONING_HASH
#define CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL
#define CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION_LABEL
#define CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION_LABEL
Expand Down
1 change: 0 additions & 1 deletion src/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

#define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS
#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS
#define CHIP_CONFIG_MAX_SESSION_KEYS CONFIG_MAX_SESSION_KEYS
#define CHIP_CONFIG_MAX_FABRICS CONFIG_MAX_FABRICS
#define CHIP_CONFIG_SECURITY_TEST_MODE CONFIG_SECURITY_TEST_MODE

Expand Down
2 changes: 0 additions & 2 deletions src/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
CHIP_ERROR StoreRebootCount(uint32_t rebootCount) override;
CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override;
CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override;
CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override;
CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;
CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize);
CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override;
CHIP_ERROR GetLocationCapability(uint8_t & location) override;
Expand Down
43 changes: 0 additions & 43 deletions src/DeviceNetworkProvisioningDelegateImpl.h

This file was deleted.

34 changes: 15 additions & 19 deletions src/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include <lib/dnssd/platform/Dnssd.h>
#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
#include <mdns.h>

Expand Down Expand Up @@ -49,8 +50,7 @@ struct BrowseContext : public GenericContext
Inet::IPAddressType addrType, DnssdBrowseCallback cb, void * cbCtx)

{
memset(mType, 0, sizeof(mType));
strncpy(mType, type, strnlen(type, kDnssdTypeMaxSize));
Platform::CopyString(mType, type);
mContextType = ContextType::Browse;
mAddressType = addrType;
mProtocol = protocol;
Expand Down Expand Up @@ -104,23 +104,19 @@ struct ResolveContext : public GenericContext
ResolveContext(DnssdService * service, Inet::InterfaceId ifId, mdns_search_once_t * searchHandle, DnssdResolveCallback cb,
void * cbCtx)
{
memset(mType, 0, sizeof(mType));
memset(mInstanceName, 0, sizeof(mInstanceName));
strncpy(mType, service->mType, strnlen(service->mType, kDnssdTypeMaxSize));
mType[kDnssdTypeMaxSize] = 0;
strncpy(mInstanceName, service->mName, strnlen(service->mName, Common::kInstanceNameMaxLength));
mInstanceName[Common::kInstanceNameMaxLength] = 0;
mContextType = ContextType::Resolve;
mProtocol = service->mProtocol;
mResolveCb = cb;
mCbContext = cbCtx;
mInterfaceId = ifId;
mSearchHandle = searchHandle;
mResolveState = ResolveState::QuerySrv;
mResult = nullptr;
mService = nullptr;
mAddresses = nullptr;
mAddressCount = 0;
Platform::CopyString(mType, type);
Platform::CopyString(mInstanceName, service->mName);
mContextType = ContextType::Resolve;
mProtocol = service->mProtocol;
mResolveCb = cb;
mCbContext = cbCtx;
mInterfaceId = ifId;
mSearchHandle = searchHandle;
mResolveState = ResolveState::QuerySrv;
mResult = nullptr;
mService = nullptr;
mAddresses = nullptr;
mAddressCount = 0;
}

~ResolveContext()
Expand Down
2 changes: 2 additions & 0 deletions src/ESP32FactoryDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class ESP32FactoryDataProvider : public CommissionableDataProvider,
CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
CHIP_ERROR GetProductName(char * buf, size_t bufSize) override;
CHIP_ERROR GetProductId(uint16_t & productId) override;
CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override;
CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;
CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override;
CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override;
#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER
Expand Down
2 changes: 1 addition & 1 deletion src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ void SetAccessControl(AccessControl & accessControl);
*
* Calls to this function must be synchronized externally.
*/
void ResetAccessControl();
void ResetAccessControlToDefault();

} // namespace Access
} // namespace chip
17 changes: 16 additions & 1 deletion src/address_resolve/AddressResolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class NodeLookupRequest

private:
static constexpr uint32_t kMinLookupTimeMsDefault = 200;
static constexpr uint32_t kMaxLookupTimeMsDefault = 15000;
static constexpr uint32_t kMaxLookupTimeMsDefault = 45000;

PeerId mPeerId;
System::Clock::Milliseconds32 mMinLookupTimeMs{ kMinLookupTimeMsDefault };
Expand Down Expand Up @@ -204,6 +204,21 @@ class Resolver
/// in progress)
virtual CHIP_ERROR LookupNode(const NodeLookupRequest & request, Impl::NodeLookupHandle & handle) = 0;

/// Inform the Lookup handle that the previous node lookup was not sufficient
/// for the purpose of the caller (e.g establishing a session fails with the
/// result of the previous lookup), and that more data is needed.
///
/// If this returns CHIP_NO_ERROR, the following is expected:
/// - The listener OnNodeAddressResolved will be called with the additional data.
/// - handle must NOT be destroyed while the lookup is in progress (it
/// is part of an internal 'lookup list')
/// - handle must NOT be reused (the lookup is done on a per-node basis
/// and maintains lookup data internally while the operation is still
/// in progress)
///
/// If no additional data is available at the time of the request, it returns CHIP_ERROR_WELL_EMPTY.
virtual CHIP_ERROR TryNextResult(Impl::NodeLookupHandle & handle) = 0;

/// Stops an active lookup request.
///
/// Caller controlls weather the `fail` callback of the handle is invoked or not by using
Expand Down
Loading

0 comments on commit 419a030

Please sign in to comment.