File tree 2 files changed +17
-3
lines changed
examples/thermostat/silabs
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,14 @@ class SensorManager
31
31
{
32
32
public:
33
33
CHIP_ERROR Init ();
34
+ struct AttributeUpdateInfo
35
+ {
36
+ int16_t temperature;
37
+ uint16_t endPoint;
38
+ };
34
39
35
40
private:
41
+ static void UpdateClusterState (intptr_t context);
36
42
friend SensorManager & SensorMgr ();
37
43
38
44
osTimerId_t mSensorTimer ;
Original file line number Diff line number Diff line change @@ -116,11 +116,19 @@ void SensorManager::SensorTimerEventHandler(void * arg)
116
116
if ((temperature >= (lastTemperature + kMinTemperatureDelta )) || temperature <= (lastTemperature - kMinTemperatureDelta ))
117
117
{
118
118
lastTemperature = temperature;
119
- PlatformMgr ().LockChipStack ();
119
+ AttributeUpdateInfo * data = chip::Platform::New<AttributeUpdateInfo>();
120
+ data->endPoint = kThermostatEndpoint ;
121
+ data->temperature = temperature;
120
122
// The SensorMagager shouldn't be aware of the Endpoint ID TODO Fix this.
121
123
// TODO Per Spec we should also apply the Offset stored in the same cluster before saving the temp
122
124
123
- app::Clusters::Thermostat::Attributes::LocalTemperature::Set (kThermostatEndpoint , temperature);
124
- PlatformMgr ().UnlockChipStack ();
125
+ chip::DeviceLayer::PlatformMgr ().ScheduleWork (UpdateClusterState, reinterpret_cast <intptr_t >(data));
125
126
}
126
127
}
128
+
129
+ void SensorManager::UpdateClusterState (intptr_t context)
130
+ {
131
+ SensorManager::AttributeUpdateInfo * data = reinterpret_cast <SensorManager::AttributeUpdateInfo *> (context);
132
+ app::Clusters::Thermostat::Attributes::LocalTemperature::Set (data->endPoint , data->temperature );
133
+ chip::Platform::Delete (data);
134
+ }
You can’t perform that action at this time.
0 commit comments