Skip to content

Commit 67177c5

Browse files
authored
Update esp-matter, Matter SDK and add debug example (#7)
* Update esp-matter and Matter SDK, add new examples * Update README.md
1 parent ee0fb90 commit 67177c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1442
-1955
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ This projects aims at possibility to easily launch Matter internet-of-things pro
1919
5. Run example sketch
2020

2121
## Example usage
22-
Please look at [examples](https://github.com/jakubdybczak/esp32-arduino-matter/tree/master/examples). You can test integration with Android and Matter controller by downloading compiled [CHIPTool](https://drive.google.com/drive/folders/1NXqfbRzBQRWCH4VWJQwQSO6KKYeIH7VK) for Android.
22+
Please look at [examples](https://github.com/jakubdybczak/esp32-arduino-matter/tree/master/examples).
2323

2424
## Limitations
2525
* Library only works on base ESP32 (with experimental support for ESP32-S3, ESP32-C3).
2626
* There is no possibility to change vendor/product ID as this value is pre-compiled.
2727
* There is no known possibility to change setup PIN.
2828
* This library comes with precompiled NimBLE, because default Bluedroid shipped with arduino-esp32 takes too much RAM memory.
29-
* As of 06 Nov 2022, this library does not work with Google Home as this app is compatible with older version of Matter. You can test this library with CHIPTool.
29+
* Matter Controllers such as Apple Home, Google Home, Smarthings and other might not have full support of all device types.
3030

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

3434
| Project | Tag/Commit Hash |
3535
| ------------- | ------------- |
3636
| [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 |
37-
| [Espressif's SDK for Matter](https://github.com/espressif/esp-matter) | e7c70721 |
38-
| [Matter](https://github.com/project-chip/connectedhomeip) | 87bee4de |
37+
| [Espressif's SDK for Matter](https://github.com/espressif/esp-matter) | a0f13786 |
38+
| [Matter](https://github.com/project-chip/connectedhomeip) | 7c2353bb |
3939

4040
## Enabling C++17 on Arduino IDE
4141
1. Find `platform.txt` for ESP32 board. Location of this file is platform depended.
@@ -52,4 +52,4 @@ This project is currently build based on these projects:
5252
Please look [here](https://github.com/jakubdybczak/esp32-arduino-matter-builder).
5353

5454
## Future and possibilities
55-
* Creating more user-friendly wrapper API.
55+
* Creating more user-friendly wrapper API.

examples/Debug/Debug.ino

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#include "Matter.h"
2+
#include <app/server/OnboardingCodesUtil.h>
3+
using namespace chip;
4+
using namespace chip::app::Clusters;
5+
using namespace esp_matter;
6+
using namespace esp_matter::endpoint;
7+
8+
/**
9+
This program presents example many Matter devices and should be used only
10+
for debug purposes (for example checking which devices types are supported)
11+
12+
Keep in mind that it IS NOT POSSIBLE to run all those endpoints due to
13+
out of memory. There is need to manually comment out endpoints!
14+
Running about 4-5 endpoints at the same time should work.
15+
*/
16+
17+
static void on_device_event(const ChipDeviceEvent *event, intptr_t arg) {}
18+
static esp_err_t on_identification(identification::callback_type_t type, uint16_t endpoint_id,
19+
uint8_t effect_id, void *priv_data) {
20+
return ESP_OK;
21+
}
22+
23+
static esp_err_t on_attribute_update(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
24+
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data) {
25+
if (type == attribute::PRE_UPDATE) {
26+
Serial.print("Update on endpoint: ");
27+
Serial.print(endpoint_id);
28+
Serial.print(" cluster: ");
29+
Serial.print(cluster_id);
30+
Serial.print(" attribute: ");
31+
Serial.println(attribute_id);
32+
}
33+
return ESP_OK;
34+
}
35+
36+
void print_endpoint_info(String clusterName, endpoint_t *endpoint) {
37+
uint16_t endpoint_id = endpoint::get_id(endpoint);
38+
Serial.print(clusterName);
39+
Serial.print(" has endpoint: ");
40+
Serial.println(endpoint_id);
41+
}
42+
43+
void setup() {
44+
Serial.begin(115200);
45+
46+
esp_log_level_set("*", ESP_LOG_DEBUG);
47+
48+
node::config_t node_config;
49+
node_t *node = node::create(&node_config, on_attribute_update, on_identification);
50+
51+
endpoint_t *endpoint;
52+
cluster_t *cluster;
53+
54+
// !!!
55+
// USE ONLY ABOUT 4 ENDPOINTS TO AVOID OUT OF MEMORY ERRORS
56+
// !!!
57+
58+
on_off_light::config_t light_config;
59+
endpoint = on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL);
60+
print_endpoint_info("on_off_light", endpoint);
61+
62+
dimmable_light::config_t dimmable_light_config;
63+
endpoint = dimmable_light::create(node, &dimmable_light_config, ENDPOINT_FLAG_NONE, NULL);
64+
print_endpoint_info("dimmable_light", endpoint);
65+
66+
color_temperature_light::config_t color_temperature_light_config;
67+
endpoint = color_temperature_light::create(node, &color_temperature_light_config, ENDPOINT_FLAG_NONE, NULL);
68+
print_endpoint_info("color_temperature_light", endpoint);
69+
70+
extended_color_light::config_t extended_color_light_config;
71+
endpoint = extended_color_light::create(node, &extended_color_light_config, ENDPOINT_FLAG_NONE, NULL);
72+
print_endpoint_info("extended_color_light", endpoint);
73+
74+
generic_switch::config_t generic_switch_config;
75+
generic_switch_config.switch_cluster.current_position = 1;
76+
generic_switch_config.switch_cluster.number_of_positions = 3;
77+
endpoint = generic_switch::create(node, &generic_switch_config, ENDPOINT_FLAG_NONE, NULL);
78+
print_endpoint_info("generic_switch", endpoint);
79+
80+
on_off_plugin_unit::config_t on_off_plugin_unit_config;
81+
on_off_plugin_unit_config.on_off.on_off = true;
82+
endpoint = on_off_plugin_unit::create(node, &on_off_plugin_unit_config, ENDPOINT_FLAG_NONE, NULL);
83+
print_endpoint_info("on_off_plugin_unit", endpoint);
84+
85+
dimmable_plugin_unit::config_t dimmable_plugin_unit_config;
86+
endpoint = dimmable_plugin_unit::create(node, &dimmable_plugin_unit_config, ENDPOINT_FLAG_NONE, NULL);
87+
print_endpoint_info("dimmable_plugin_unit", endpoint);
88+
89+
fan::config_t fan_config;
90+
endpoint = fan::create(node, &fan_config, ENDPOINT_FLAG_NONE, NULL);
91+
print_endpoint_info("fan", endpoint);
92+
93+
thermostat::config_t thermostat_config;
94+
thermostat_config.thermostat.local_temperature = 19;
95+
endpoint = thermostat::create(node, &thermostat_config, ENDPOINT_FLAG_NONE, NULL);
96+
print_endpoint_info("thermostat", endpoint);
97+
98+
door_lock::config_t door_lock_config;
99+
door_lock_config.door_lock.lock_state = 1;
100+
endpoint = door_lock::create(node, &door_lock_config, ENDPOINT_FLAG_NONE, NULL);
101+
print_endpoint_info("door_lock", endpoint);
102+
103+
window_covering_device::config_t window_covering_device_config;
104+
endpoint = window_covering_device::create(node, &window_covering_device_config, ENDPOINT_FLAG_NONE, NULL);
105+
cluster = cluster::get(endpoint, WindowCovering::Id);
106+
cluster::window_covering::feature::lift::config_t lift;
107+
cluster::window_covering::feature::tilt::config_t tilt;
108+
cluster::window_covering::feature::position_aware_lift::config_t position_aware_lift;
109+
cluster::window_covering::feature::position_aware_tilt::config_t position_aware_tilt;
110+
cluster::window_covering::feature::absolute_position::config_t absolute_position;
111+
cluster::window_covering::feature::lift::add(cluster, &lift);
112+
cluster::window_covering::feature::tilt::add(cluster, &tilt);
113+
cluster::window_covering::feature::position_aware_lift::add(cluster, &position_aware_lift);
114+
cluster::window_covering::feature::position_aware_tilt::add(cluster, &position_aware_tilt);
115+
cluster::window_covering::feature::absolute_position::add(cluster, &absolute_position);
116+
print_endpoint_info("window_covering_device", endpoint);
117+
118+
temperature_sensor::config_t temperature_sensor_config;
119+
temperature_sensor_config.temperature_measurement.measured_value = 22;
120+
endpoint = temperature_sensor::create(node, &temperature_sensor_config, ENDPOINT_FLAG_NONE, NULL);
121+
print_endpoint_info("temperature_sensor", endpoint);
122+
123+
occupancy_sensor::config_t occupancy_sensor_config;
124+
occupancy_sensor_config.occupancy_sensing.occupancy = 1;
125+
endpoint = occupancy_sensor::create(node, &occupancy_sensor_config, ENDPOINT_FLAG_NONE, NULL);
126+
print_endpoint_info("occupancy_sensor", endpoint);
127+
128+
contact_sensor::config_t contact_sensor_config;
129+
contact_sensor_config.boolean_state.state_value = true;
130+
endpoint = contact_sensor::create(node, &contact_sensor_config, ENDPOINT_FLAG_NONE, NULL);
131+
print_endpoint_info("contact_sensor", endpoint);
132+
133+
esp_matter::start(on_device_event);
134+
135+
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));
136+
}
137+
138+
void loop() {
139+
140+
}

examples/Two_endpoints_plugin_unit/Two_endpoints_plugin_unit.ino renamed to examples/TwoEndpointsPluginUnit/TwoEndpointsPluginUnit.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ attribute_t *attribute_ref_1;
3535
attribute_t *attribute_ref_2;
3636

3737
// There is possibility to listen for various device events, related for example
38-
// to setup process Leaved as empty for simplicity
38+
// to setup process. Leaved as empty for simplicity.
3939
static void on_device_event(const ChipDeviceEvent *event, intptr_t arg) {}
4040
static esp_err_t on_identification(identification::callback_type_t type,
4141
uint16_t endpoint_id, uint8_t effect_id,
@@ -88,8 +88,7 @@ void setup() {
8888
endpoint_t *endpoint_2 = on_off_plugin_unit::create(node, &plugin_unit_config,
8989
ENDPOINT_FLAG_NONE, NULL);
9090

91-
// Save on/off attribute reference. It will be used to read attribute value
92-
// later.
91+
// Save on/off attribute reference. It will be used to read attribute value later.
9392
attribute_ref_1 =
9493
attribute::get(cluster::get(endpoint_1, CLUSTER_ID), ATTRIBUTE_ID);
9594
attribute_ref_2 =
@@ -139,4 +138,4 @@ void loop() {
139138
set_onoff_attribute_value(&onoff_value, plugin_unit_endpoint_id_2);
140139
}
141140
}
142-
}
141+
}

src/ConfigurationManagerImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
5757
CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;
5858
CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize);
5959
CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override;
60+
CHIP_ERROR GetLocationCapability(uint8_t & location) override;
6061
static ConfigurationManagerImpl & GetDefaultInstance();
6162

6263
private:

src/ESP32Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class ESP32Config
7979
static const Key kConfigKey_SupportedCalTypes;
8080
static const Key kConfigKey_SupportedLocaleSize;
8181
static const Key kConfigKey_RotatingDevIdUniqueId;
82+
static const Key kConfigKey_LocationCapability;
8283

8384
// CHIP Config keys
8485
static const Key kConfigKey_ServiceConfig;

0 commit comments

Comments
 (0)