Skip to content

Commit

Permalink
Add ids/Events.h (#13689)
Browse files Browse the repository at this point in the history
* Add ids/Events.h

* Update generated code
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 9, 2022
1 parent 4650701 commit 2781021
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 173 deletions.
5 changes: 5 additions & 0 deletions src/app/common/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
"name": "Commands Ids header",
"output": "ids/Commands.h"
},
{
"path": "../../zap-templates/templates/app/ids/Events.zapt",
"name": "Events Ids header",
"output": "ids/Events.h"
},
{
"path": "../../zap-templates/templates/app/cluster-objects.zapt",
"name": "Cluster objects header for Interaction Model",
Expand Down
10 changes: 5 additions & 5 deletions src/app/zap-templates/templates/app/cluster-objects.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <lib/support/BitFlags.h>
#include <protocols/interaction_model/Constants.h>
#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <app-common/zap-generated/ids/Events.h>

namespace chip {
namespace app {
Expand Down Expand Up @@ -187,7 +188,6 @@ namespace Events {
{{/first}}
namespace {{asUpperCamelCase name}} {
static constexpr PriorityLevel kPriorityLevel = PriorityLevel::{{asUpperCamelCase priority}};
static constexpr EventId kEventId = {{asMEI manufacturerCode code}};

enum class Fields {
{{#zcl_event_fields}}
Expand All @@ -199,7 +199,7 @@ struct Type
{
public:
static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; }
static constexpr EventId GetEventId() { return kEventId; }
static constexpr EventId GetEventId() { return Events::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }

{{#zcl_event_fields}}
Expand All @@ -212,7 +212,7 @@ public:
struct DecodableType {
public:
static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; }
static constexpr EventId GetEventId() { return kEventId; }
static constexpr EventId GetEventId() { return Events::{{asUpperCamelCase name}}::Id; }
static constexpr ClusterId GetClusterId() { return Clusters::{{asUpperCamelCase parent.name}}::Id; }

{{#zcl_event_fields}}
Expand Down
32 changes: 32 additions & 0 deletions src/app/zap-templates/templates/app/ids/Events.zapt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{> header}}

#pragma once

#include <app/util/basic-types.h>

namespace chip {
namespace app {
namespace Clusters {

{{#zcl_clusters}}
{{#zcl_events}}
{{#first}}
namespace {{asUpperCamelCase parent.label}} {
namespace Events {

{{/first}}
namespace {{asUpperCamelCase name}} {
static constexpr EventId Id = {{asMEI manufacturerCode code}};
} // namespace {{asUpperCamelCase name}}

{{#last}}
} // namespace Events
} // namespace {{asUpperCamelCase parent.label}}

{{/last}}
{{/zcl_events}}
{{/zcl_clusters}}

} // namespace Clusters
} // namespace app
} // namespace chip
31 changes: 16 additions & 15 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/ids/Events.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceControlServer.h>
Expand Down Expand Up @@ -88,19 +89,19 @@ void SignalHandler(int signum)
err = CHIP_ERROR_REBOOT_SIGNAL_RECEIVED;
break;
case SIGTRAP:
PlatformMgrImpl().HandleSoftwareFault(SoftwareDiagnostics::Events::SoftwareFault::kEventId);
PlatformMgrImpl().HandleSoftwareFault(SoftwareDiagnostics::Events::SoftwareFault::Id);
break;
case SIGILL:
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::HardwareFaultChange::kEventId);
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::HardwareFaultChange::Id);
break;
case SIGALRM:
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::RadioFaultChange::kEventId);
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::RadioFaultChange::Id);
break;
case SIGVTALRM:
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::NetworkFaultChange::kEventId);
PlatformMgrImpl().HandleGeneralFault(GeneralDiagnostics::Events::NetworkFaultChange::Id);
break;
case SIGIO:
PlatformMgrImpl().HandleSwitchEvent(Switch::Events::SwitchLatched::kEventId);
PlatformMgrImpl().HandleSwitchEvent(Switch::Events::SwitchLatched::Id);
break;
default:
break;
Expand Down Expand Up @@ -385,7 +386,7 @@ void PlatformManagerImpl::HandleGeneralFault(uint32_t EventId)
return;
}

if (EventId == GeneralDiagnostics::Events::HardwareFaultChange::kEventId)
if (EventId == GeneralDiagnostics::Events::HardwareFaultChange::Id)
{
GeneralFaults<kMaxHardwareFaults> previous;
GeneralFaults<kMaxHardwareFaults> current;
Expand All @@ -402,7 +403,7 @@ void PlatformManagerImpl::HandleGeneralFault(uint32_t EventId)
#endif
delegate->OnHardwareFaultsDetected(previous, current);
}
else if (EventId == GeneralDiagnostics::Events::RadioFaultChange::kEventId)
else if (EventId == GeneralDiagnostics::Events::RadioFaultChange::Id)
{
GeneralFaults<kMaxRadioFaults> previous;
GeneralFaults<kMaxRadioFaults> current;
Expand All @@ -419,7 +420,7 @@ void PlatformManagerImpl::HandleGeneralFault(uint32_t EventId)
#endif
delegate->OnRadioFaultsDetected(previous, current);
}
else if (EventId == GeneralDiagnostics::Events::NetworkFaultChange::kEventId)
else if (EventId == GeneralDiagnostics::Events::NetworkFaultChange::Id)
{
GeneralFaults<kMaxNetworkFaults> previous;
GeneralFaults<kMaxNetworkFaults> current;
Expand Down Expand Up @@ -470,7 +471,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
return;
}

if (EventId == Switch::Events::SwitchLatched::kEventId)
if (EventId == Switch::Events::SwitchLatched::Id)
{
uint8_t newPosition = 0;

Expand All @@ -479,7 +480,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnSwitchLatched(newPosition);
}
else if (EventId == Switch::Events::InitialPress::kEventId)
else if (EventId == Switch::Events::InitialPress::Id)
{
uint8_t newPosition = 0;

Expand All @@ -488,7 +489,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnInitialPressed(newPosition);
}
else if (EventId == Switch::Events::LongPress::kEventId)
else if (EventId == Switch::Events::LongPress::Id)
{
uint8_t newPosition = 0;

Expand All @@ -497,7 +498,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnLongPressed(newPosition);
}
else if (EventId == Switch::Events::ShortRelease::kEventId)
else if (EventId == Switch::Events::ShortRelease::Id)
{
uint8_t previousPosition = 0;

Expand All @@ -506,7 +507,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnShortReleased(previousPosition);
}
else if (EventId == Switch::Events::LongRelease::kEventId)
else if (EventId == Switch::Events::LongRelease::Id)
{
uint8_t previousPosition = 0;

Expand All @@ -515,7 +516,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnLongReleased(previousPosition);
}
else if (EventId == Switch::Events::MultiPressOngoing::kEventId)
else if (EventId == Switch::Events::MultiPressOngoing::Id)
{
uint8_t newPosition = 0;
uint8_t currentNumberOfPressesCounted = 0;
Expand All @@ -526,7 +527,7 @@ void PlatformManagerImpl::HandleSwitchEvent(uint32_t EventId)
#endif
delegate->OnMultiPressOngoing(newPosition, currentNumberOfPressesCounted);
}
else if (EventId == Switch::Events::MultiPressComplete::kEventId)
else if (EventId == Switch::Events::MultiPressComplete::Id)
{
uint8_t newPosition = 0;
uint8_t totalNumberOfPressesCounted = 0;
Expand Down
Loading

0 comments on commit 2781021

Please sign in to comment.