Skip to content

Commit

Permalink
using schedulework
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak-Shaha committed Sep 25, 2024
1 parent c6f6c8d commit c65feae
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions examples/air-quality-sensor-app/silabs/src/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ AirQualityEnum classifyAirQuality(int32_t value)

CHIP_ERROR SensorManager::Init()
{

PlatformMgr().LockChipStack();
ChipLogDetail(AppServer, "Int instnace");
AirQualitySensorManager::InitInstance();
PlatformMgr().UnlockChipStack();
ChipLogDetail(AppServer, "Int instnace success");
DeviceLayer::PlatformMgr().ScheduleWork(AirQualitySensorManager::InitInstance);
// Create cmsisos sw timer for air quality sensor timer.
mSensorTimer = osTimerNew(SensorTimerEventHandler, osTimerPeriodic, nullptr, nullptr);
if (mSensorTimer == NULL)
Expand Down Expand Up @@ -165,12 +160,14 @@ void SensorManager::SensorTimerEventHandler(void * arg)
}
#endif // USE_AIR_QUALITY_SENSOR

DeviceLayer::PlatformMgr().ScheduleWork(AirQualitySensorManager::GetInstance()->OnAirQualityChangeHandler,
classifyAirQuality(air_quality));

PlatformMgr().LockChipStack();
AirQualitySensorManager::GetInstance()->OnAirQualityChangeHandler(classifyAirQuality(air_quality));
ChipLogDetail(AppServer, "RAW AirQuality value: %ld and corresponding Enum value : %d", air_quality,
chip::to_underlying(AirQualitySensorManager::GetInstance()->GetAirQuality()));
PlatformMgr().UnlockChipStack();

AppTask::GetAppTask().UpdateAirQualitySensorUI();

ChipLogDetail(AppServer, "RAW AirQuality value: %ld and corresponding Enum value : %d", air_quality,
chip::to_underlying(AirQualitySensorManager::GetInstance()->GetAirQuality()));
AppTask::GetAppTask().UpdateAirQualitySensorUI();
}

0 comments on commit c65feae

Please sign in to comment.