MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / HandleMsg

Method HandleMsg

cpp/src/command_classes/ClimateControlSchedule.cpp:142–293  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

140// Handle a message from the Z-Wave network
141//-----------------------------------------------------------------------------
142bool ClimateControlSchedule::HandleMsg
143(
144 uint8 const* _data,
145 uint32 const _length,
146 uint32 const _instance // = 1
147)
148{
149 if( ClimateControlScheduleCmd_Report == (ClimateControlScheduleCmd)_data[0] )
150 {
151 uint8 day = _data[1] & 0x07;
152
153 if (day > 7) /* size of c_dayNames */
154 {
155 Log::Write (LogLevel_Warning, GetNodeId(), "Day Value was greater than range. Setting to Invalid");
156 day = 0;
157 }
158
159 Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule report for %s", c_dayNames[day] );
160
161 if( ValueSchedule* value = static_cast<ValueSchedule*>( GetValue( _instance, day ) ) )
162 {
163 // Remove any existing data
164 value->ClearSwitchPoints();
165
166 // Parse the switch point data
167 for( uint8 i=2; i<29; i+=3 )
168 {
169 uint8 setback = _data[i+2];
170 if( setback == 0x7f )
171 {
172 // Switch point is unused, so we stop parsing here
173 break;
174 }
175
176 uint8 hours = _data[i] & 0x1f;
177 uint8 minutes = _data[i+1] & 0x3f;
178
179 if( setback == 0x79 )
180 {
181 Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Frost Protection Mode", hours, minutes, c_dayNames[day] );
182 }
183 else if( setback == 0x7a )
184 {
185 Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Energy Saving Mode", hours, minutes, c_dayNames[day] );
186 }
187 else
188 {
189 Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Setback %+.1fC", hours, minutes, ((float)setback)*0.1f );
190 }
191
192 value->SetSwitchPoint( hours, minutes, setback );
193 }
194
195 if( !value->GetNumSwitchPoints() )
196 {
197 Log::Write( LogLevel_Info, GetNodeId(), " No Switch points have been set" );
198 }
199

Callers

nothing calls this directly

Calls 12

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
GetFlagByteMethod · 0.80
SetFlagByteMethod · 0.80
SendMsgMethod · 0.80
GetNodeIdFunction · 0.70
ClearSwitchPointsMethod · 0.45
SetSwitchPointMethod · 0.45
GetNumSwitchPointsMethod · 0.45
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected