Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the level control to light switch and changing to dimmer switch #37448

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 127 additions & 1 deletion examples/light-switch-app/light-switch-common/light-switch-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,131 @@ cluster OnOff = 6 {
command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66;
}

/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */
cluster LevelControl = 8 {
revision 6;

enum MoveModeEnum : enum8 {
kUp = 0;
kDown = 1;
}

enum StepModeEnum : enum8 {
kUp = 0;
kDown = 1;
}

bitmap Feature : bitmap32 {
kOnOff = 0x1;
kLighting = 0x2;
kFrequency = 0x4;
}

bitmap OptionsBitmap : bitmap8 {
kExecuteIfOff = 0x1;
kCoupleColorTempToLevel = 0x2;
}

readonly attribute nullable int8u currentLevel = 0;
readonly attribute optional int16u remainingTime = 1;
readonly attribute optional int8u minLevel = 2;
readonly attribute optional int8u maxLevel = 3;
readonly attribute optional int16u currentFrequency = 4;
readonly attribute optional int16u minFrequency = 5;
readonly attribute optional int16u maxFrequency = 6;
attribute OptionsBitmap options = 15;
attribute optional int16u onOffTransitionTime = 16;
attribute nullable int8u onLevel = 17;
attribute optional nullable int16u onTransitionTime = 18;
attribute optional nullable int16u offTransitionTime = 19;
attribute optional nullable int8u defaultMoveRate = 20;
attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct MoveToLevelRequest {
int8u level = 0;
nullable int16u transitionTime = 1;
OptionsBitmap optionsMask = 2;
OptionsBitmap optionsOverride = 3;
}

request struct MoveRequest {
MoveModeEnum moveMode = 0;
nullable int8u rate = 1;
OptionsBitmap optionsMask = 2;
OptionsBitmap optionsOverride = 3;
}

request struct StepRequest {
StepModeEnum stepMode = 0;
int8u stepSize = 1;
nullable int16u transitionTime = 2;
OptionsBitmap optionsMask = 3;
OptionsBitmap optionsOverride = 4;
}

request struct StopRequest {
OptionsBitmap optionsMask = 0;
OptionsBitmap optionsOverride = 1;
}

request struct MoveToLevelWithOnOffRequest {
int8u level = 0;
nullable int16u transitionTime = 1;
OptionsBitmap optionsMask = 2;
OptionsBitmap optionsOverride = 3;
}

request struct MoveWithOnOffRequest {
MoveModeEnum moveMode = 0;
nullable int8u rate = 1;
OptionsBitmap optionsMask = 2;
OptionsBitmap optionsOverride = 3;
}

request struct StepWithOnOffRequest {
StepModeEnum stepMode = 0;
int8u stepSize = 1;
nullable int16u transitionTime = 2;
OptionsBitmap optionsMask = 3;
OptionsBitmap optionsOverride = 4;
}

request struct StopWithOnOffRequest {
OptionsBitmap optionsMask = 0;
OptionsBitmap optionsOverride = 1;
}

request struct MoveToClosestFrequencyRequest {
int16u frequency = 0;
}

/** Command description for MoveToLevel */
command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0;
/** Command description for Move */
command Move(MoveRequest): DefaultSuccess = 1;
/** Command description for Step */
command Step(StepRequest): DefaultSuccess = 2;
/** Command description for Stop */
command Stop(StopRequest): DefaultSuccess = 3;
/** Command description for MoveToLevelWithOnOff */
command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4;
/** Command description for MoveWithOnOff */
command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5;
/** Command description for StepWithOnOff */
command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6;
/** Command description for StopWithOnOff */
command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7;
/** Change the currrent frequency to the provided one, or a close
approximation if the exact provided one is not possible. */
command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8;
}

/** The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters. */
cluster Descriptor = 29 {
revision 2;
Expand Down Expand Up @@ -3159,10 +3284,11 @@ endpoint 0 {
}
}
endpoint 1 {
device type ma_onofflightswitch = 259, version 1;
device type ma_dimmerswitch = 260, version 1;

binding cluster Identify;
binding cluster OnOff;
binding cluster LevelControl;
binding cluster ScenesManagement;
binding cluster ColorControl;

Expand Down
96 changes: 85 additions & 11 deletions examples/light-switch-app/light-switch-common/light-switch-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -4402,31 +4402,31 @@
},
{
"id": 2,
"name": "MA-onofflightswitch",
"name": "MA-dimmerswitch",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just raising attention that this is a common zap file for a few other platform light-switch app. They might be ok with this addition.
If not we can create zap file specific for silab's light-switch app.

"deviceTypeRef": {
"code": 259,
"code": 260,
"profileId": 259,
"label": "MA-onofflightswitch",
"name": "MA-onofflightswitch",
"label": "MA-dimmerswitch",
"name": "MA-dimmerswitch",
"deviceTypeOrder": 0
},
"deviceTypes": [
{
"code": 259,
"code": 260,
"profileId": 259,
"label": "MA-onofflightswitch",
"name": "MA-onofflightswitch",
"label": "MA-dimmerswitch",
"name": "MA-dimmerswitch",
"deviceTypeOrder": 0
}
],
"deviceVersions": [
1
],
"deviceIdentifiers": [
259
260
],
"deviceTypeName": "MA-onofflightswitch",
"deviceTypeCode": 259,
"deviceTypeName": "MA-dimmerswitch",
"deviceTypeCode": 260,
"deviceTypeProfileId": 259,
"clusters": [
{
Expand Down Expand Up @@ -4737,6 +4737,80 @@
}
]
},
{
"name": "Level Control",
"code": 8,
"mfgCode": null,
"define": "LEVEL_CONTROL_CLUSTER",
"side": "client",
"enabled": 1,
"commands": [
{
"name": "MoveToLevel",
"code": 0,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "Move",
"code": 1,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "Step",
"code": 2,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "Stop",
"code": 3,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "MoveToLevelWithOnOff",
"code": 4,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "MoveWithOnOff",
"code": 5,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "StepWithOnOff",
"code": 6,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "StopWithOnOff",
"code": 7,
"mfgCode": null,
"source": "client",
"isIncoming": 0,
"isEnabled": 1
}
]
},
{
"name": "Descriptor",
"code": 29,
Expand Down Expand Up @@ -5639,7 +5713,7 @@
"parentEndpointIdentifier": null
},
{
"endpointTypeName": "MA-onofflightswitch",
"endpointTypeName": "MA-dimmerswitch",
"endpointTypeIndex": 1,
"profileId": 259,
"endpointId": 1,
Expand Down
2 changes: 2 additions & 0 deletions examples/light-switch-app/silabs/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 10

#define LONG_PRESS_TIMEOUT 3000

// APP Logo, boolean only. must be 64x64
#define ON_DEMO_BITMAP \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
Expand Down
16 changes: 13 additions & 3 deletions examples/light-switch-app/silabs/include/AppEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#pragma once

#include <cstdint>

struct AppEvent;
typedef void (*EventHandler)(AppEvent *);

Expand All @@ -30,6 +32,15 @@ struct AppEvent
kEventType_Timer,
kEventType_Light,
kEventType_Install,
kEventType_ResetWarning,
kEventType_ResetCanceled,
// Button events
kEventType_ActionButtonPressed,
kEventType_ActionButtonReleased,
kEventType_FunctionButtonPressed,
kEventType_FunctionButtonReleased,
kEventType_TriggerLevelControlAction,
kEventType_TriggerToggle,
};

uint16_t Type;
Expand All @@ -46,9 +57,8 @@ struct AppEvent
} TimerEvent;
struct
{
uint8_t Action;
int32_t Actor;
} LightEvent;
void * Context;
} LightSwitchEvent;
};

EventHandler Handler;
Expand Down
27 changes: 0 additions & 27 deletions examples/light-switch-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ class AppTask : public BaseApplication

CHIP_ERROR StartAppTask();

/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
*
* @param buttonHandle APP_LIGHT_SWITCH or APP_FUNCTION_BUTTON
* @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
*/
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);

private:
static AppTask sAppTask;

Expand All @@ -85,21 +75,4 @@ class AppTask : public BaseApplication
* @return CHIP_ERROR
*/
CHIP_ERROR Init();

/**
* @brief PB0 Button event processing function
* Press and hold will trigger a factory reset timer start
* Press and release will restart BLEAdvertising if not commisionned
*
* @param aEvent button event being processed
*/
static void ButtonHandler(AppEvent * aEvent);

/**
* @brief PB1 Button event processing function
* Function triggers a switch action sent to the CHIP task
*
* @param aEvent button event being processed
*/
static void SwitchActionEventHandler(AppEvent * aEvent);
};
Loading
Loading