Skip to content

Commit

Permalink
Merge branch 'master' into esp32/enable_extended_ble_adv
Browse files Browse the repository at this point in the history
  • Loading branch information
sayondeep authored Mar 26, 2024
2 parents 21f72d5 + 72bd295 commit b8d886a
Show file tree
Hide file tree
Showing 59 changed files with 680 additions and 475 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
--known-failure app/CommandHandler.h \
--known-failure app/CommandHandlerInterface.h \
--known-failure app/CommandSenderLegacyCallback.h \
--known-failure app/data-model/ListLargeSystemExtensions.h \
--known-failure app/ReadHandler.h \
--known-failure app/reporting/reporting.cpp \
--known-failure app/reporting/tests/MockReportScheduler.cpp \
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/spell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ on:
- ".github/.wordlist.txt"

jobs:
# Seems redundant; removed as pyspelling is customized while this is not
# check-reviewdog:
# name: Check Spelling - reviewdog
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - uses: reviewdog/action-misspell@v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
check-spellcheck:
name: Check Spelling - pyspelling
runs-on: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions docs/ci-cd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@ Work In Progress
## Tools

- [Daily Fail Summary](tools/daily_fail_summary.md)
- Spellcheck
- Uses
[`rojopolis`/spellcheck-github-actions](https://github.com/marketplace/actions/github-spellcheck-action#configuration),
a PySpelling-based spellchecker
- This tool utilizes the definitions in .spellcheck.yml and
.github/`.wordlist.txt` to check all documentation files.
.spellcheck.yml defines the settings while `.wordlist.txt` is a
dictionary of words to skip checking (brand names, technical jargon,
acronyms)

## General Improvement Ideas
3 changes: 1 addition & 2 deletions examples/chef/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@

#include "AppEvent.h"
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "timers.h" // provides FreeRTOS timer support
#include <ble/BLEEndPoint.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

Expand Down
7 changes: 3 additions & 4 deletions examples/chef/silabs/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

#include "AppEvent.h"

#include "FreeRTOS.h"
#include "timers.h" // provides FreeRTOS timer support

#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>

class LightingManager
Expand Down Expand Up @@ -68,11 +66,12 @@ class LightingManager
bool mAutoTurnOff;
uint32_t mAutoTurnOffDuration;
bool mAutoTurnOffTimerArmed;
osTimerId_t mLightTimer;

void CancelTimer(void);
void StartTimer(uint32_t aTimeoutMs);

static void TimerEventHandler(TimerHandle_t xTimer);
static void TimerEventHandler(void * timerCbArg);
static void AutoTurnOffTimerEventHandler(AppEvent * aEvent);
static void ActuatorMovementTimerEventHandler(AppEvent * aEvent);

Expand Down
8 changes: 4 additions & 4 deletions examples/chef/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ CHIP_ERROR AppTask::StartAppTask()
void AppTask::AppTaskMain(void * pvParameter)
{
AppEvent event;
QueueHandle_t sAppEventQueue = *(static_cast<QueueHandle_t *>(pvParameter));
osMessageQueueId_t sAppEventQueue = *(static_cast<osMessageQueueId_t *>(pvParameter));

CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
Expand All @@ -94,11 +94,11 @@ void AppTask::AppTaskMain(void * pvParameter)

while (true)
{
BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10));
while (eventReceived == pdTRUE)
osStatus_t eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, osWaitForever);
while (eventReceived == osOK)
{
sAppTask.DispatchEvent(&event);
eventReceived = xQueueReceive(sAppEventQueue, &event, 0);
eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, 0);
}
}
}
Expand Down
47 changes: 17 additions & 30 deletions examples/chef/silabs/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,20 @@

#include "AppConfig.h"
#include "AppTask.h"
#include <FreeRTOS.h>

LightingManager LightingManager::sLight;

TimerHandle_t sLightTimer;

CHIP_ERROR LightingManager::Init()
{
// Create FreeRTOS sw timer for light timer.
sLightTimer = xTimerCreate("lightTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = light obj context
TimerEventHandler // timer callback handler
);

if (sLightTimer == NULL)
// Create cmsis os sw timer for light timer.
mLightTimer = osTimerNew(TimerEventHandler, // timer callback handler
osTimerOnce, // no timer reload (one-shot timer)
(void *) this, // pass the app task obj context
NULL // No osTimerAttr_t to provide.

if (mLightTimer == NULL)
{
SILABS_LOG("sLightTimer timer create failed");
SILABS_LOG("mLightTimer timer create failed");
return APP_ERROR_CREATE_TIMER_FAILED;
}

Expand Down Expand Up @@ -123,38 +118,30 @@ bool LightingManager::InitiateAction(int32_t aActor, Action_t aAction)

void LightingManager::StartTimer(uint32_t aTimeoutMs)
{
if (xTimerIsTimerActive(sLightTimer))
{
SILABS_LOG("app timer already started!");
CancelTimer();
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
// Starts or restarts the function timer
if (osTimerStart(mLightTimer, pdMS_TO_TICKS(aTimeoutMs)) != osOK)
{
SILABS_LOG("sLightTimer timer start() failed");
SILABS_LOG("mLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
}
}

void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, 0) == pdFAIL)
if (osTimerStop(mLightTimer) == osError)
{
SILABS_LOG("sLightTimer stop() failed");
SILABS_LOG("mLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
}
}

void LightingManager::TimerEventHandler(TimerHandle_t xTimer)
void LightingManager::TimerEventHandler(void * timerCbArg)
{
// Get light obj context from timer id.
LightingManager * light = static_cast<LightingManager *>(pvTimerGetTimerID(xTimer));
// The callback argument is the light obj context assigned at timer creation.
LightingManager * light = static_cast<LightingManager *>(timerCbArg);

// The timer event handler will be called in the context of the timer task
// once sLightTimer expires. Post an event to apptask queue with the actual handler
// once mLightTimer expires. Post an event to apptask queue with the actual handler
// so that the event can be handled in the context of the apptask.
AppEvent event;
event.Type = AppEvent::kEventType_Timer;
Expand Down
3 changes: 1 addition & 2 deletions examples/light-switch-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@

#include "AppEvent.h"
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "timers.h" // provides FreeRTOS timer support
#include <ble/BLEEndPoint.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

Expand Down
8 changes: 4 additions & 4 deletions examples/light-switch-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ CHIP_ERROR AppTask::StartAppTask()
void AppTask::AppTaskMain(void * pvParameter)
{
AppEvent event;
QueueHandle_t sAppEventQueue = *(static_cast<QueueHandle_t *>(pvParameter));
osMessageQueueId_t sAppEventQueue = *(static_cast<osMessageQueueId_t *>(pvParameter));

CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
Expand All @@ -121,11 +121,11 @@ void AppTask::AppTaskMain(void * pvParameter)
SILABS_LOG("App Task started");
while (true)
{
BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY);
while (eventReceived == pdTRUE)
osStatus_t eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, osWaitForever);
while (eventReceived == osOK)
{
sAppTask.DispatchEvent(&event);
eventReceived = xQueueReceive(sAppEventQueue, &event, 0);
eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, 0);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions examples/lighting-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@

#include "AppEvent.h"
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "LightingManager.h"
#include "timers.h" // provides FreeRTOS timer support
#include <ble/BLEEndPoint.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

Expand Down
7 changes: 3 additions & 4 deletions examples/lighting-app/silabs/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@

#include "AppEvent.h"

#include "FreeRTOS.h"
#include "timers.h" // provides FreeRTOS timer support
#include <app/clusters/on-off-server/on-off-server.h>

#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>

class LightingManager
Expand Down Expand Up @@ -72,11 +70,12 @@ class LightingManager
uint32_t mAutoTurnOffDuration;
bool mAutoTurnOffTimerArmed;
bool mOffEffectArmed;
osTimerId_t mLightTimer;

void CancelTimer(void);
void StartTimer(uint32_t aTimeoutMs);

static void TimerEventHandler(TimerHandle_t xTimer);
static void TimerEventHandler(void * timerCbArg);
static void AutoTurnOffTimerEventHandler(AppEvent * aEvent);
static void ActuatorMovementTimerEventHandler(AppEvent * aEvent);
static void OffEffectTimerEventHandler(AppEvent * aEvent);
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ CHIP_ERROR AppTask::StartAppTask()
void AppTask::AppTaskMain(void * pvParameter)
{
AppEvent event;
QueueHandle_t sAppEventQueue = *(static_cast<QueueHandle_t *>(pvParameter));
osMessageQueueId_t sAppEventQueue = *(static_cast<osMessageQueueId_t *>(pvParameter));

CHIP_ERROR err = sAppTask.Init();
if (err != CHIP_NO_ERROR)
Expand All @@ -134,11 +134,11 @@ void AppTask::AppTaskMain(void * pvParameter)

while (true)
{
BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY);
while (eventReceived == pdTRUE)
osStatus_t eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, osWaitForever);
while (eventReceived == osOK)
{
sAppTask.DispatchEvent(&event);
eventReceived = xQueueReceive(sAppEventQueue, &event, 0);
eventReceived = osMessageQueueGet(sAppEventQueue, &event, NULL, 0);
}
}
}
Expand Down
45 changes: 16 additions & 29 deletions examples/lighting-app/silabs/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "AppConfig.h"
#include "AppTask.h"
#include <FreeRTOS.h>

#include <lib/support/TypeTraits.h>

Expand All @@ -30,9 +29,6 @@ using namespace ::chip::app::Clusters::OnOff;
using namespace ::chip::DeviceLayer;

LightingManager LightingManager::sLight;

TimerHandle_t sLightTimer;

namespace {

/**********************************************************
Expand All @@ -50,17 +46,16 @@ OnOffEffect gEffect = {

CHIP_ERROR LightingManager::Init()
{
// Create FreeRTOS sw timer for light timer.
sLightTimer = xTimerCreate("lightTmr", // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(1), // == default timer period
false, // no timer reload (==one-shot)
(void *) this, // init timer id = light obj context
TimerEventHandler // timer callback handler
// Create cmsis os sw timer for light timer.
mLightTimer = osTimerNew(TimerEventHandler, // timer callback handler
osTimerOnce, // no timer reload (one-shot timer)
(void *) this, // pass the app task obj context
NULL // No osTimerAttr_t to provide.
);

if (sLightTimer == NULL)
if (mLightTimer == NULL)
{
SILABS_LOG("sLightTimer timer create failed");
SILABS_LOG("mLightTimer timer create failed");
return APP_ERROR_CREATE_TIMER_FAILED;
}

Expand Down Expand Up @@ -157,38 +152,30 @@ bool LightingManager::InitiateAction(int32_t aActor, Action_t aAction)

void LightingManager::StartTimer(uint32_t aTimeoutMs)
{
if (xTimerIsTimerActive(sLightTimer))
{
SILABS_LOG("app timer already started!");
CancelTimer();
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS)
// Starts or restarts the function timer
if (osTimerStart(mLightTimer, pdMS_TO_TICKS(aTimeoutMs)) != osOK)
{
SILABS_LOG("sLightTimer timer start() failed");
SILABS_LOG("mLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
}
}

void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, pdMS_TO_TICKS(0)) == pdFAIL)
if (osTimerStop(mLightTimer) == osError)
{
SILABS_LOG("sLightTimer stop() failed");
SILABS_LOG("mLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
}
}

void LightingManager::TimerEventHandler(TimerHandle_t xTimer)
void LightingManager::TimerEventHandler(void * timerCbArg)
{
// Get light obj context from timer id.
LightingManager * light = static_cast<LightingManager *>(pvTimerGetTimerID(xTimer));
// The callback argument is the light obj context assigned at timer creation.
LightingManager * light = static_cast<LightingManager *>(timerCbArg);

// The timer event handler will be called in the context of the timer task
// once sLightTimer expires. Post an event to apptask queue with the actual handler
// once mLightTimer expires. Post an event to apptask queue with the actual handler
// so that the event can be handled in the context of the apptask.
AppEvent event;
event.Type = AppEvent::kEventType_Timer;
Expand Down
3 changes: 1 addition & 2 deletions examples/lit-icd-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@

#include "AppEvent.h"
#include "BaseApplication.h"
#include "FreeRTOS.h"
#include "timers.h" // provides FreeRTOS timer support
#include <ble/BLEEndPoint.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

Expand Down
Loading

0 comments on commit b8d886a

Please sign in to comment.