Skip to content

Commit

Permalink
Update The message rx handling event naming. Move related ICD events …
Browse files Browse the repository at this point in the history
…to PublicEventTypes for the time being
  • Loading branch information
jmartinez-silabs committed Jul 4, 2023
1 parent 555f9a5 commit 7edbd32
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/app/icd/ICDEventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ void ICDEventManager::ICDEventHandler(const ChipDeviceEvent * event, intptr_t ar
pIcdManager->UpdateOperationState(ICDManager::OperationalState::ActiveMode);
}
break;
case DeviceEventType::kChipMsgHandledEvent:
if (event->MessageReceived.isExpectedResponse)
case DeviceEventType::kChipMsgRxEventHandled:
if (event->RxEventContext.clearsExpectedResponse)
{
if (expectedMsgCount > 0)
{
expectedMsgCount--;
}
else
{
// SHOULD we assert
// Should we assert
ChipLogError(DeviceLayer, "No response was expected by the ICD Manager");
}

Expand All @@ -91,7 +91,7 @@ void ICDEventManager::ICDEventHandler(const ChipDeviceEvent * event, intptr_t ar
pIcdManager->SetKeepActiveModeRequirements(ICDManager::KeepActiveFlags::kExpectingMsgResponse, false);
}
}
else if (event->MessageReceived.isReceived)
else if (event->RxEventContext.wasReceived)
{
pIcdManager->UpdateOperationState(ICDManager::OperationalState::ActiveMode);
}
Expand Down
40 changes: 33 additions & 7 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,35 @@ enum PublicEventTypes
* sending messages to other nodes.
*/
kServerReady,

/**
* TODO ICD: kChipMsgSentEvent and kChipMsgRxEventHandled should be InternalEventTypes.
* However the ICD manager leverages those events and its event handler is registered as an application
* event handler.
* ICDEventManager will have to expose 'ICDEventHandler' publicly to 'DispatchEventToDeviceLayer'.
*/

/**
* An Exchange Context sent a message.
* This event is coupled with MessageSent structure.
*/
kChipMsgSentEvent,

/**
* An Exchange Context handled a reception transaction.
* This event can occur by one of the 3 following scenarios:
* - A message was received.
* - An expected reception has timed out.
* - The exchange context was closed while an reception was expected.
*
* This event is coupled with RxEventContext structure.
*/
kChipMsgRxEventHandled,

/**
* An application event occurent that should wake up the system/device
*/
kAppWakeUpEvent,
};

/**
Expand All @@ -269,10 +298,7 @@ enum InternalEventTypes
kCHIPoBLEWriteReceived,
kCHIPoBLEIndicateConfirm,
kCHIPoBLEConnectionError,
kCHIPoBLENotifyConfirm,
kChipMsgSentEvent,
kChipMsgHandledEvent,
kAppWakeUpEvent,
kCHIPoBLENotifyConfirm
};

static_assert(kEventTypeNotSet == 0, "kEventTypeNotSet must be defined as 0");
Expand Down Expand Up @@ -547,9 +573,9 @@ struct ChipDeviceEvent final

struct
{
bool isReceived;
bool isExpectedResponse;
} MessageReceived;
bool wasReceived;
bool clearsExpectedResponse;
} RxEventContext;
};

void Clear() { memset(this, 0, sizeof(*this)); }
Expand Down
24 changes: 12 additions & 12 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ void ExchangeContext::DoClose(bool clearRetransTable)
CancelResponseTimer();
#if CONFIG_DEVICE_LAYER
DeviceLayer::ChipDeviceEvent event;
event.Type = DeviceLayer::DeviceEventType::kChipMsgHandledEvent;
event.MessageReceived.isReceived = false;
event.MessageReceived.isExpectedResponse = true;
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
event.Type = DeviceLayer::DeviceEventType::kChipMsgRxEventHandled;
event.RxEventContext.wasReceived = false;
event.RxEventContext.clearsExpectedResponse = true;
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post Msg Handled event at ExchangeContext closure %" CHIP_ERROR_FORMAT,
Expand Down Expand Up @@ -524,10 +524,10 @@ void ExchangeContext::NotifyResponseTimeout(bool aCloseIfNeeded)
{
#if CONFIG_DEVICE_LAYER
DeviceLayer::ChipDeviceEvent event;
event.Type = DeviceLayer::DeviceEventType::kChipMsgHandledEvent;
event.MessageReceived.isReceived = false;
event.MessageReceived.isExpectedResponse = true;
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
event.Type = DeviceLayer::DeviceEventType::kChipMsgRxEventHandled;
event.RxEventContext.wasReceived = false;
event.RxEventContext.clearsExpectedResponse = true;
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post Message Response Timeout event %" CHIP_ERROR_FORMAT, status.Format());
Expand Down Expand Up @@ -648,10 +648,10 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload

#if CONFIG_DEVICE_LAYER
DeviceLayer::ChipDeviceEvent event;
event.Type = DeviceLayer::DeviceEventType::kChipMsgHandledEvent;
event.MessageReceived.isReceived = true;
event.MessageReceived.isExpectedResponse = IsResponseExpected();
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
event.Type = DeviceLayer::DeviceEventType::kChipMsgRxEventHandled;
event.RxEventContext.wasReceived = true;
event.RxEventContext.clearsExpectedResponse = IsResponseExpected();
CHIP_ERROR status = DeviceLayer::PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post Message received event %" CHIP_ERROR_FORMAT, status.Format());
Expand Down

0 comments on commit 7edbd32

Please sign in to comment.