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

Method HandleMsg

cpp/src/command_classes/SwitchBinary.cpp:110–151  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

108// Handle a message from the Z-Wave network
109//-----------------------------------------------------------------------------
110bool SwitchBinary::HandleMsg
111(
112 uint8 const* _data,
113 uint32 const _length,
114 uint32 const _instance // = 1
115)
116{
117 if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0])
118 {
119 Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchBinary report from node %d: level=%s", GetNodeId(), _data[1] ? "On" : "Off" );
120
121 // data[1] => Switch state
122 if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, SwitchBinaryIndex_Level ) ) )
123 {
124 value->OnValueRefreshed( _data[1] != 0 );
125 value->Release();
126 }
127
128 if ( GetVersion() >= 2) {
129
130 // data[2] => target state
131 if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, SwitchBinaryIndex_TargetState ) ) )
132 {
133 value->OnValueRefreshed( _data[2] != 0 );
134 value->Release();
135 }
136
137 // data[3] might be duration
138 if (_length > 3) {
139 if ( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchBinaryIndex_Duration ) ) )
140 {
141 value->OnValueRefreshed( _data[3] );
142 value->Release();
143 }
144 }
145 }
146
147 return true;
148 }
149
150 return false;
151}
152
153//-----------------------------------------------------------------------------
154// <SwitchBinary::SetValue>

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.85
GetVersionFunction · 0.85
GetNodeIdFunction · 0.70
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected