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

Method HandleMsg

cpp/src/command_classes/NodeNaming.cpp:286–328  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

284// Handle a message from the Z-Wave network
285//-----------------------------------------------------------------------------
286bool NodeNaming::HandleMsg
287(
288 uint8 const* _data,
289 uint32 const _length,
290 uint32 const _instance // = 1
291)
292{
293 bool updated = false;
294 if( Node* node = GetNodeUnsafe() )
295 {
296 if( NodeNamingCmd_Report == (NodeNamingCmd)_data[0] )
297 {
298 string name = ExtractString( _data, _length );
299 if( node->m_nodeName == "" )
300 {
301 // We only overwrite the name if it is empty
302 node->m_nodeName = name;
303 Log::Write( LogLevel_Info, GetNodeId(), "Received the name: %s.", name.c_str() );
304 updated = true;
305 }
306 }
307 else if( NodeNamingCmd_LocationReport == (NodeNamingCmd)_data[0] )
308 {
309 string location = ExtractString( _data, _length );
310 if( node->m_location == "" )
311 {
312 // We only overwrite the location if it is empty
313 node->m_location = location;
314 Log::Write( LogLevel_Info, GetNodeId(), "Received the location: %s.", location.c_str() );
315 updated = true;
316 }
317 }
318 }
319
320 if( updated )
321 {
322 Notification* notification = new Notification( Notification::Type_NodeNaming );
323 notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() );
324 GetDriver()->QueueNotification( notification );
325 }
326
327 return true;
328}
329
330//-----------------------------------------------------------------------------
331// <NodeNaming::SetName>

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.85
QueueNotificationMethod · 0.80
GetNodeIdFunction · 0.70
GetHomeIdFunction · 0.70
c_strMethod · 0.45

Tested by

no test coverage detected