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

Method HandleMsg

cpp/src/command_classes/WakeUp.cpp:200–282  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

198// Handle a message from the Z-Wave network
199//-----------------------------------------------------------------------------
200bool WakeUp::HandleMsg
201(
202 uint8 const* _data,
203 uint32 const _length,
204 uint32 const _instance // = 1
205)
206{
207 if( WakeUpCmd_IntervalReport == (WakeUpCmd)_data[0] )
208 {
209 if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, 0 ) ) )
210 {
211 // some interval reports received are validly formatted (proper checksum, etc.) but only have length
212 // of 3 (0x84 (classid), 0x06 (IntervalReport), 0x00). Not sure what this means
213 if( _length < 6 )
214 {
215 Log::Write( LogLevel_Warning, "" );
216 Log::Write( LogLevel_Warning, GetNodeId(), "Unusual response: WakeUpCmd_IntervalReport with len = %d. Ignored.", _length );
217 value->Release();
218 return false;
219 }
220
221 uint32 interval = ((uint32)_data[1]) << 16;
222 interval |= (((uint32)_data[2]) << 8);
223 interval |= (uint32)_data[3];
224
225 uint8 targetNodeId = _data[4];
226
227 Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval report from node %d: Interval=%d, Target Node=%d", GetNodeId(), interval, targetNodeId );
228
229 value->OnValueRefreshed( (int32)interval );
230
231 // Ensure that the target node for wake-up notifications is the controller
232 // but only if node is not a listening device. Hybrid devices that can be
233 // powered by other then batteries shouldn't do this.
234 Node *node = GetNodeUnsafe();
235 if( GetDriver()->GetControllerNodeId() != targetNodeId && ((node) && (!node->IsListeningDevice())) )
236 {
237 SetValue( *value );
238 }
239 value->Release();
240 }
241 return true;
242 }
243 else if( WakeUpCmd_Notification == (WakeUpCmd)_data[0] )
244 {
245 // The device is awake.
246 Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Notification from node %d", GetNodeId() );
247 SetAwake( true );
248 return true;
249 }
250 else if( WakeUpCmd_IntervalCapabilitiesReport == (WakeUpCmd)_data[0] )
251 {
252 uint32 mininterval = (((uint32)_data[1]) << 16) | (((uint32)_data[2]) << 8) | ((uint32)_data[3]);
253 uint32 maxinterval = (((uint32)_data[4]) << 16) | (((uint32)_data[5]) << 8) | ((uint32)_data[6]);
254 uint32 definterval = (((uint32)_data[7]) << 16) | (((uint32)_data[8]) << 8) | ((uint32)_data[9]);
255 uint32 stepinterval = (((uint32)_data[10]) << 16) | (((uint32)_data[11]) << 8) | ((uint32)_data[12]);
256 Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval Capability report from node %d: Min Interval=%d, Max Interval=%d, Default Interval=%d, Interval Step=%d", GetNodeId(), mininterval, maxinterval, definterval, stepinterval );
257 if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, 1 ) ) )

Callers

nothing calls this directly

Calls 7

WriteFunction · 0.85
SetValueFunction · 0.85
GetControllerNodeIdMethod · 0.80
IsListeningDeviceMethod · 0.80
GetNodeIdFunction · 0.70
ReleaseMethod · 0.45
OnValueRefreshedMethod · 0.45

Tested by

no test coverage detected