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

Method HandleMsg

cpp/src/command_classes/ThermostatSetpoint.cpp:194–314  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

192// Handle a message from the Z-Wave network
193//-----------------------------------------------------------------------------
194bool ThermostatSetpoint::HandleMsg
195(
196 uint8 const* _data,
197 uint32 const _length,
198 uint32 const _instance // = 1
199)
200{
201 if( ThermostatSetpointCmd_Report == (ThermostatSetpointCmd)_data[0] )
202 {
203 // We have received a thermostat setpoint value from the Z-Wave device
204 if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, _data[1] ) ) )
205 {
206 uint8 scale;
207 uint8 precision = 0;
208 string temperature = ExtractValue( &_data[2], &scale, &precision );
209
210 value->SetUnits( scale ? "F" : "C" );
211 value->OnValueRefreshed( temperature );
212 if( value->GetPrecision() != precision )
213 {
214 value->SetPrecision( precision );
215 }
216 value->Release();
217
218 Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat setpoint report: Setpoint %s = %s%s", value->GetLabel().c_str(), value->GetValue().c_str(), value->GetUnits().c_str() );
219 }
220 return true;
221 }
222
223 else if( ThermostatSetpointCmd_SupportedReport == (ThermostatSetpointCmd)_data[0] )
224 {
225 if( Node* node = GetNodeUnsafe() )
226 {
227 // We have received the supported thermostat setpoints from the Z-Wave device
228 Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat setpoints" );
229
230 // Parse the data for the supported setpoints
231 for( uint32 i=1; i<_length-1; ++i )
232 {
233 for( int32 bit=0; bit<8; ++bit )
234 {
235 if( ( _data[i] & (1<<bit) ) != 0 )
236 {
237 if ( GetVersion() >= 3)
238 {
239 // Request the supported setpoints
240 Msg* msg = new Msg( "ThermostatSetpointCmd_CapabilitesGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
241 msg->SetInstance( this, _instance );
242 msg->Append( GetNodeId() );
243 msg->Append( 3 );
244 msg->Append( GetCommandClassId() );
245 msg->Append( ThermostatSetpointCmd_CapabilitiesGet );
246 uint8 type = ((i-1)<<3) + bit;
247 if ( m_com.GetFlagBool(COMPAT_FLAG_TSSP_ALTTYPEINTERPRETATION) == false )
248 {
249 // for interpretation A the setpoint identifier makes a jump of 4 after the 2nd bit ... wtf @ zensys
250 if ( type > 2 )
251 {

Callers

nothing calls this directly

Calls 15

WriteFunction · 0.85
GetVersionFunction · 0.85
GetCommandClassIdFunction · 0.85
SetUnitsMethod · 0.80
GetPrecisionMethod · 0.80
SetPrecisionMethod · 0.80
GetFlagBoolMethod · 0.80
SendMsgMethod · 0.80
GetFlagByteMethod · 0.80
CreateValueDecimalMethod · 0.80
GetNodeIdFunction · 0.70
OnValueRefreshedMethod · 0.45

Tested by

no test coverage detected