Skip to content

Commit

Permalink
update microwave oven app after reviewed
Browse files Browse the repository at this point in the history
  • Loading branch information
liangpy4 committed Dec 7, 2023
1 parent ad8e132 commit 6fce686
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 604 deletions.
3 changes: 0 additions & 3 deletions examples/microwave-oven-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;

extern void MatterMicrowaveOvenServerInit();
extern void MatterMicrowaveOvenServerShutdown();

void ApplicationInit()
{
MatterMicrowaveOvenServerInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate,
public:
/**
* This class is responsible for initialising all the microwave oven device clusters and managing the interactions between them
* as required by the specific "business logic". See the state machine diagram.
* as required by the specific "business logic".
* @param aClustersEndpoint The endpoint ID where all the microwave oven clusters exist.
*/
explicit ExampleMicrowaveOvenDevice(EndpointId aClustersEndpoint) :
mMicrowaveOvenControlInstance(this, aClustersEndpoint, MicrowaveOvenControl::Id, &mOperationalStateInstance,
&mMicrowaveOvenModeInstance),
mOperationalStateInstance(this, aClustersEndpoint, OperationalState::Id),
mMicrowaveOvenModeInstance(this, aClustersEndpoint, MicrowaveOvenMode::Id, 0)
mMicrowaveOvenModeInstance(this, aClustersEndpoint, MicrowaveOvenMode::Id, 0),
mMicrowaveOvenControlInstance(this, aClustersEndpoint, MicrowaveOvenControl::Id, mOperationalStateInstance,
mMicrowaveOvenModeInstance)
{}

/**
Expand Down Expand Up @@ -93,6 +93,7 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate,
uint8_t GetPowerStep() const override { return kDefaultPowerStep; }

// delegates from OperationalState cluster
using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
/**
* Get the countdown time.
* return actual cook time.
Expand Down Expand Up @@ -192,12 +193,12 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate,

private:
// define delegates and instances for Microwave Oven device
MicrowaveOvenControl::Instance mMicrowaveOvenControlInstance;
OperationalState::Instance mOperationalStateInstance;
ModeBase::Instance mMicrowaveOvenModeInstance;
MicrowaveOvenControl::Instance mMicrowaveOvenControlInstance;


// MicrowaveOvenMode types
using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
ModeTagStructType modeTagsNormal[1] = { { .value = to_underlying(MicrowaveOvenMode::ModeTag::kNormal) } };
ModeTagStructType modeTagsDefrost[1] = { { .value = to_underlying(MicrowaveOvenMode::ModeTag::kDefrost) } };

Expand All @@ -211,25 +212,31 @@ class ExampleMicrowaveOvenDevice : public MicrowaveOvenControl::Delegate,
};

// Operational States
const OperationalState::GenericOperationalState opStateList[4] = {
const OperationalState::GenericOperationalState mOpStateList[4] = {
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)),
};

app::DataModel::List<const OperationalState::GenericOperationalState> mOperationalStateList =
Span<const OperationalState::GenericOperationalState>(opStateList);
const app::DataModel::List<const OperationalState::GenericOperationalState> mOperationalStateList =
Span<const OperationalState::GenericOperationalState>(mOpStateList);

const OperationalState::GenericOperationalPhase opPhaseList[1] = {
const OperationalState::GenericOperationalPhase mOpPhaseList[1] = {
// Phase List is null
OperationalState::GenericOperationalPhase(DataModel::Nullable<CharSpan>()),
};

Span<const OperationalState::GenericOperationalPhase> mOperationalPhaseList =
Span<const OperationalState::GenericOperationalPhase>(opPhaseList);
Span<const OperationalState::GenericOperationalPhase>(mOpPhaseList);
};

} // namespace Clusters
} // namespace app
} // namespace chip



void MatterMicrowaveOvenServerInit();

void MatterMicrowaveOvenServerShutdown();
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,6 @@ cluster BasicInformation = 40 {
command MfgSpecificPing(): DefaultSuccess = 0;
}

/** Nodes should be expected to be deployed to any and all regions of the world. These global regions
may have differing common languages, units of measurements, and numerical formatting
standards. As such, Nodes that visually or audibly convey information need a mechanism by which
they can be configured to use a user’s preferred language, units, etc */
cluster LocalizationConfiguration = 43 {
revision 1; // NOTE: Default/not specifically set

attribute access(write: manage) char_string<35> activeLocale = 0;
readonly attribute char_string supportedLocales[] = 1;
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;
}

/** Nodes should be expected to be deployed to any and all regions of the world. These global regions
may have differing preferences for how dates and times are conveyed. As such, Nodes that visually
or audibly convey time information need a mechanism by which they can be configured to use a
Expand Down Expand Up @@ -315,32 +298,6 @@ cluster TimeFormatLocalization = 44 {
readonly attribute int16u clusterRevision = 65533;
}

/** Nodes should be expected to be deployed to any and all regions of the world. These global regions
may have differing preferences for the units in which values are conveyed in communication to a
user. As such, Nodes that visually or audibly convey measurable values to the user need a
mechanism by which they can be configured to use a user’s preferred unit. */
cluster UnitLocalization = 45 {
revision 1;

enum TempUnitEnum : enum8 {
kFahrenheit = 0;
kCelsius = 1;
kKelvin = 2;
}

bitmap Feature : bitmap32 {
kTemperatureUnit = 0x1;
}

attribute access(write: manage) optional TempUnitEnum temperatureUnit = 0;
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;
}

/** This cluster is used to manage global aspects of the Commissioning flow. */
cluster GeneralCommissioning = 48 {
revision 1; // NOTE: Default/not specifically set
Expand Down Expand Up @@ -1172,16 +1129,6 @@ endpoint 0 {
device type ma_rootdevice = 22, version 1;


server cluster Identify {
ram attribute identifyTime default = 0x0000;
ram attribute identifyType default = 0x00;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;

handle command Identify;
handle command TriggerEffect;
}

server cluster Descriptor {
callback attribute deviceTypeList;
callback attribute serverList;
Expand Down Expand Up @@ -1243,16 +1190,6 @@ endpoint 0 {
ram attribute clusterRevision default = 3;
}

server cluster LocalizationConfiguration {
persist attribute activeLocale default = "en-US";
callback attribute supportedLocales;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster TimeFormatLocalization {
persist attribute hourFormat default = 0;
callback attribute generatedCommandList;
Expand All @@ -1262,15 +1199,6 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}

server cluster UnitLocalization {
persist attribute temperatureUnit default = 0;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap default = 1;
ram attribute clusterRevision default = 1;
}

server cluster GeneralCommissioning {
ram attribute breadcrumb default = 0x0000000000000000;
callback attribute basicCommissioningInfo;
Expand Down
Loading

0 comments on commit 6fce686

Please sign in to comment.