Skip to content

ESP32 Matter Arduino not resuming session #11378

Open
@theonlytechnohead

Description

@theonlytechnohead

Board

ESP32 Dev Module

Device Description

Plain module connected with jumpers

Hardware Configuration

GPIO 12 & 13 are connected to LED strips with 60 SK6812 LEDs per strip
LEDs are powered externally

Version

v3.2.0

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

921600

Description

Hello,
Thank you for such an excellent experience setting up a Matter device!
I followed the ColorLight example to get started, however when the device reboots, I see some errors in the console.
The errors seem to appear roughly when Matter.begin() or ColorLight.updateAccessory() is called.

The device also produces errors when responding to some commands sent by routines in the Google Home app:
(317140) chip[DMG]: Endpoint=1 Cluster=0x0000_0300 Command=0x0000_000A status 0x81 (no additional context)
The Google Home app reports that an action failed.

Please let me know if there's anything else I can do to help debug these issues!

Sketch

#include <Matter.h>
#include <WiFi.h>

const char *ssid = "ssid ";
const char *password = "password ";

MatterColorLight ColorLight;

#include <FastLED.h>

#define LEFT_PIN 12
#define RIGHT_PIN 13

#define NUM_LEDS 60

CRGB left[NUM_LEDS];
CRGB right[NUM_LEDS];

TaskHandle_t matterTask;

bool state = true;
espHsvColor_t colour = { 0, 0, 0 };
espHsvColor_t target = { 140, 254, 127 };

void setup() {
  Serial.begin(115200);

  FastLED.addLeds<WS2812, LEFT_PIN, GRB>(left, NUM_LEDS).setRgbw(RgbwDefault());
  FastLED.addLeds<WS2812, RIGHT_PIN, GRB>(right, NUM_LEDS).setRgbw(RgbwDefault());

  // clear to black
  set_all(CRGB::Black);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    centre_wipe(CRGB::Yellow);
    delay(500);
    centre_wipe(CRGB::Black);
  }

  ColorLight.begin(state, target);

  ColorLight.onChange(update);

  xTaskCreatePinnedToCore(
    matter,        // Function to implement the task
    "matterTask",  // Name of the task
    8192,          // Stack size in words (causes stack overflow (DUH!!!!) if too low
    NULL,          // Task input parameter
    0,             // Priority of the task, 0 is lowest
    &matterTask,   // Task handle
    0);            // Core where the task should run, code runs on core 1 by default
}

void matter(void *parameter) {
  Matter.begin();
  vTaskDelay(500);
  // this may be a restart of an already commissioned Matter accessory
  if (Matter.isDeviceCommissioned()) {
    while (!Matter.isDeviceConnected()) {
      vTaskDelay(500);
      centre_wipe(CRGB::Orange);
      vTaskDelay(500);
      centre_wipe(CRGB::Black);
    }
    // configure the light based on initial state and colour
    ColorLight.updateAccessory();
  }

  for (;;) {
    vTaskDelay(10);
    if (!Matter.isDeviceCommissioned()) {
      Serial.println("");
      Serial.println("Matter Node is not commissioned yet.");
      Serial.println("Initiate the device discovery in your Matter environment.");
      Serial.println("Commission it to your Matter hub with the manual pairing code or QR code");
      Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
      Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
      // wait for Matter Light Commissioning.
      uint32_t timeCount = 0;
      while (!Matter.isDeviceCommissioned()) {
        while (WiFi.status() != WL_CONNECTED) {
          vTaskDelay(500);
          centre_wipe(CRGB::Yellow);
          vTaskDelay(500);
          centre_wipe(CRGB::Black);
        }
        vTaskDelay(500);
        centre_wipe(CRGB::Blue);
        vTaskDelay(500);
        centre_wipe(CRGB::Black);
        if ((timeCount++ % 50) == 0) {  // 50*100ms = 5 sec
          Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
          Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
          Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
        }
      }
    }
  }
}

void loop() {
  if (colour.h != target.h || colour.s != target.s || colour.v != target.v) {
    colour = { target.h, target.s, target.v };
    set_all(CHSV(colour.h, colour.s, colour.v));
    Serial.printf("loop colour changed to hsv(%d, %d, %d)\n", colour.h, colour.s, colour.v);
  }
}

bool update(bool s, espHsvColor_t c) {
  if (state != s) {
    Serial.printf("update state changed to %s\n", s ? "ON" : "OFF");
    state = s;
    if (state && 1 < c.v)
      target = { c.h, c.s, c.v };
    if (!state) {
      target = { 0, 0, 0 };
    }
    return true;
  }
  if (colour.h != c.h || colour.s != c.s || colour.v != c.v) {
    Serial.printf("update colour changed to hsv(%d, %d, %d)\n", c.h, c.s, c.v);
    if (state && 1 < c.v)
      target = { c.h, c.s, c.v };
    else
      target = { 0, 0, 0 };
    return true;
  }
  // This callback must return the success state to Matter
  return true;
}

void set_all(CRGB c) {
  for (int i = 0; i < NUM_LEDS; i++) {
    left[i] = c;
    right[i] = c;
  }
  FastLED.show();
}

void centre_wipe(CRGB c) {
  for (int i = 0; i < NUM_LEDS; i++) {
    left[i] = c;
    right[i] = c;
    FastLED.show();
  }
}

Debug Message

E (11114) chip[DMG]: Endpoint 0, Cluster 0x0000_0031 not found in IncreaseClusterDataVersion!
E (11115) chip[DMG]: Endpoint 0, Cluster 0x0000_0031 not found in IncreaseClusterDataVersion!
update color changed to hsl(0, 0, 0)
E (12611) chip[IN]: SendMessage() to UDP:[REDACTED-IPV6-ADDRESS]:5540 failed: 3000004
E (12612) chip[-]: Error LwIP:0x03000004 at ./managed_components/espressif__esp_matter/connectedhomeip/connectedhomeip/src/app/OperationalSessionSetup.cpp:254
E (12623) chip[DMG]: Failed to establish CASE for subscription-resumption with error '3000004'
E (12648) chip[DMG]: Failed to establish CASE for subscription-resumption with error '3000004'

Other Steps to Reproduce

The device is provisioned within Google Home via a Google Nest Mini

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Area: MatterIssues and Feature Request about Matter ProtocolStatus: Awaiting triageIssue is waiting for triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions