----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 284 | // Handle a message from the Z-Wave network |
| 285 | //----------------------------------------------------------------------------- |
| 286 | bool 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> |
nothing calls this directly
no test coverage detected