Skip to content

Commit

Permalink
Removed some methods that are unused from af-events.cpp (#18099)
Browse files Browse the repository at this point in the history
* Start removing some unused methods from af-event

* Remove also emAfGetTimerDurationAndUnitFromMS

* Remove emberAfEventControlSetDelayMinutes

* Remove emberAfEventControlSetDelayQS

* Remove emAfInitEvents as it seems to be completely empty

* Restyle

* Remove emAfStackEventString
  • Loading branch information
andy31415 authored and pull[bot] committed Aug 30, 2023
1 parent 0ae9767 commit 1640508
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 118 deletions.
81 changes: 0 additions & 81 deletions src/app/util/af-event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,9 @@ void EventControlHandler(chip::System::Layer * systemLayer, void * appState)
}
}

const char emAfStackEventString[] = "Stack";

// *****************************************************************************
// Functions

// A function used to initialize events for idling
void emAfInitEvents(void) {}

const char * emberAfGetEventString(uint8_t index)
{
return (index == 0XFF ? emAfStackEventString : emAfEventStrings[index]);
}

static EmberAfEventContext * findEventContext(EndpointId endpoint, ClusterId clusterId, bool isClient)
{
#if defined(EMBER_AF_GENERATED_EVENT_CONTEXT)
Expand Down Expand Up @@ -189,26 +179,6 @@ void emberEventControlSetActive(EmberEventControl * control)
#endif
}

EmberStatus emberAfEventControlSetDelayQS(EmberEventControl * control, uint32_t delayQs)
{
if (delayQs <= EMBER_MAX_EVENT_CONTROL_DELAY_QS)
{
return emberEventControlSetDelayMS(control, delayQs << 8);
}

return EMBER_BAD_ARGUMENT;
}

EmberStatus emberAfEventControlSetDelayMinutes(EmberEventControl * control, uint16_t delayM)
{
if (delayM <= EMBER_MAX_EVENT_CONTROL_DELAY_MINUTES)
{
return emberEventControlSetDelayMS(control, static_cast<uint32_t>(delayM) << 16);
}

return EMBER_BAD_ARGUMENT;
}

EmberStatus emberAfScheduleTickExtended(EndpointId endpoint, ClusterId clusterId, bool isClient, uint32_t delayMs,
EmberAfEventPollControl pollControl, EmberAfEventSleepControl sleepControl)
{
Expand Down Expand Up @@ -278,54 +248,3 @@ EmberStatus emberAfDeactivateServerTick(EndpointId endpoint, ClusterId clusterId
{
return emberAfDeactivateClusterTick(endpoint, clusterId, EMBER_AF_SERVER_CLUSTER_TICK);
}

#define MS_TO_QS(ms) ((ms) >> 8)
#define MS_TO_MIN(ms) ((ms) >> 16)
#define QS_TO_MS(qs) ((qs) << 8)
#define MIN_TO_MS(min) ((min) << 16)

// Used to calculate the duration and unit used by the host to set the sleep timer
void emAfGetTimerDurationAndUnitFromMS(uint32_t durationMs, uint16_t * duration, EmberEventUnits * units)
{
if (durationMs <= MAX_TIMER_UNITS_HOST)
{
*duration = (uint16_t) durationMs;
*units = EMBER_EVENT_MS_TIME;
}
else if (MS_TO_QS(durationMs) <= MAX_TIMER_UNITS_HOST)
{
*duration = (uint16_t)(MS_TO_QS(durationMs));
*units = EMBER_EVENT_QS_TIME;
}
else
{
*duration = (MS_TO_MIN(durationMs) <= MAX_TIMER_UNITS_HOST ? (uint16_t)(MS_TO_MIN(durationMs)) : MAX_TIMER_UNITS_HOST);
*units = EMBER_EVENT_MINUTE_TIME;
}
}

uint32_t emAfGetMSFromTimerDurationAndUnit(uint16_t duration, EmberEventUnits units)
{
uint32_t ms;
if (units == EMBER_EVENT_MS_TIME)
{
ms = duration;
}
else if (units == EMBER_EVENT_QS_TIME)
{
ms = QS_TO_MS(static_cast<uint32_t>(duration));
}
else if (units == EMBER_EVENT_MINUTE_TIME)
{
ms = MIN_TO_MS(static_cast<uint32_t>(duration));
}
else if (units == EMBER_EVENT_ZERO_DELAY)
{
ms = 0;
}
else
{
ms = UINT32_MAX;
}
return ms;
}
12 changes: 0 additions & 12 deletions src/app/util/af-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@
*/
typedef struct EmberEventData EmberEventData;

// A function used to retrieve the proper NCP timer duration and unit based on a given
// passed number of milliseconds.
void emAfGetTimerDurationAndUnitFromMS(uint32_t durationMs, uint16_t * duration, EmberEventUnits * units);

// A function (inverse of the above) to retrieve the number of milliseconds
// represented by a given timer duration and unit.
uint32_t emAfGetMSFromTimerDurationAndUnit(uint16_t duration, EmberEventUnits units);

const char * emberAfGetEventString(uint8_t index);

void emAfInitEvents(void);

/** @brief Sets this ::EmberEventControl as inactive (no pending event).
*/
void emberEventControlSetInactive(EmberEventControl * control);
Expand Down
22 changes: 0 additions & 22 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,22 +808,6 @@ EmberStatus emberEventControlSetDelayMS(EmberEventControl * control, uint32_t de
*/
EmberStatus emberAfEventControlSetDelayQS(EmberEventControl * control, uint32_t delayQs);

/**
* @brief Sets the ::EmberEventControl to run "delayM" minutes in the future.
* The 'minutes' are actually 65536 (0x10000) milliseconds long. This function
* first verifies that the delay is within the acceptable range before
* scheduling the event.
*
* @param control a pointer to the event control.
* @param delayM the number of minutes until the next event.
*
* @return If delayM is less than or equal to
::EMBER_MAX_EVENT_CONTROL_DELAY_MINUTES, this function will schedule
the event and return ::EMBER_SUCCESS. Otherwise it will return
::EMBER_BAD_ARGUMENT.
*/
EmberStatus emberAfEventControlSetDelayMinutes(EmberEventControl * control, uint16_t delayM);

/**
* @brief Sets the ::EmberEventControl for the current network, and only
* the current network, as inactive. See ::emberEventControlSetInactive.
Expand Down Expand Up @@ -856,12 +840,6 @@ EmberStatus emberAfNetworkEventControlSetDelay(EmberEventControl * controls, uin
#else
#define emberAfNetworkEventControlSetDelay(controls, delayMs) emberAfNetworkEventControlSetDelayMS(controls, delayMs);
#endif
/**
* @brief Sets the ::EmberEventControl for the current network, and only the
* current network, to run "delayQs" quarter seconds in the future. See
* ::emberAfEventControlSetDelayQS.
*/
EmberStatus emberAfNetworkEventControlSetDelayQS(EmberEventControl * controls, uint32_t delayQs);
/**
* @brief Sets the ::EmberEventControl for the current network, and only the
* current network, to run "delayM" minutes in the future. See
Expand Down
3 changes: 0 additions & 3 deletions src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ void emberAfInit(chip::Messaging::ExchangeManager * exchangeMgr)
// Set up client API buffer.
emberAfSetExternalBuffer(appResponseData, EMBER_AF_RESPONSE_BUFFER_LEN, &appResponseLength, &emberAfResponseApsFrame);

// initialize event management system
emAfInitEvents();

MATTER_PLUGINS_INIT

emAfCallInits();
Expand Down

0 comments on commit 1640508

Please sign in to comment.