From 164050840b576601145e126667fce6b4258aaa34 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 6 May 2022 11:06:04 -0400 Subject: [PATCH] Removed some methods that are unused from af-events.cpp (#18099) * 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 --- src/app/util/af-event.cpp | 81 --------------------------------------- src/app/util/af-event.h | 12 ------ src/app/util/af.h | 22 ----------- src/app/util/util.cpp | 3 -- 4 files changed, 118 deletions(-) diff --git a/src/app/util/af-event.cpp b/src/app/util/af-event.cpp index 9cc2b8495a71d4..31a87bae250fa5 100644 --- a/src/app/util/af-event.cpp +++ b/src/app/util/af-event.cpp @@ -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) @@ -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(delayM) << 16); - } - - return EMBER_BAD_ARGUMENT; -} - EmberStatus emberAfScheduleTickExtended(EndpointId endpoint, ClusterId clusterId, bool isClient, uint32_t delayMs, EmberAfEventPollControl pollControl, EmberAfEventSleepControl sleepControl) { @@ -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(duration)); - } - else if (units == EMBER_EVENT_MINUTE_TIME) - { - ms = MIN_TO_MS(static_cast(duration)); - } - else if (units == EMBER_EVENT_ZERO_DELAY) - { - ms = 0; - } - else - { - ms = UINT32_MAX; - } - return ms; -} diff --git a/src/app/util/af-event.h b/src/app/util/af-event.h index 655184af940da2..1b10e21b5887cd 100644 --- a/src/app/util/af-event.h +++ b/src/app/util/af-event.h @@ -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); diff --git a/src/app/util/af.h b/src/app/util/af.h index 2575116f71df13..1749168135e435 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -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. @@ -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 diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 16ec51717cbe0d..54239e8e55d9d0 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -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();