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

Method HandleMsg

cpp/src/command_classes/UserCode.cpp:425–535  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

423// Handle a message from the Z-Wave network
424//-----------------------------------------------------------------------------
425bool UserCode::HandleMsg
426(
427 uint8 const* _data,
428 uint32 const _length,
429 uint32 const _instance // = 1
430)
431{
432 if( UserNumberCmd_Report == (UserCodeCmd)_data[0] )
433 {
434 m_dom.SetFlagByte(STATE_FLAG_USERCODE_COUNT, _data[1]);
435 ClearStaticRequest( StaticRequest_Values );
436 if( _data[1] == 0 )
437 {
438 Log::Write( LogLevel_Info, GetNodeId(), "Received User Number report from node %d: Not supported", GetNodeId() );
439 }
440 else
441 {
442 Log::Write( LogLevel_Info, GetNodeId(), "Received User Number report from node %d: Supported Codes %d (%d)", GetNodeId(), _data[1], _data[1] );
443 }
444
445 if( ValueShort* value = static_cast<ValueShort*>( GetValue( _instance, UserCodeIndex_Count ) ) )
446 {
447 value->OnValueRefreshed( _data[1] );
448 value->Release();
449 }
450
451 if( Node* node = GetNodeUnsafe() )
452 {
453 string data;
454
455 for( uint16 i = 0; i <= m_dom.GetFlagByte(STATE_FLAG_USERCODE_COUNT); i++ )
456 {
457 char str[16];
458 if (i == 0)
459 {
460 snprintf( str, sizeof(str), "Enrollment Code");
461 node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i, str, "", true, false, data, 0 );
462 }
463 else
464 {
465 snprintf( str, sizeof(str), "Code %d:", i);
466 node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i, str, "", false, false, data, 0 );
467 }
468 m_userCode[i].status = UserCode_Available;
469 memcpy(&m_userCode[i].usercode, 0, 10);
470 }
471 if (m_com.GetFlagBool(COMPAT_FLAG_UC_EXPOSERAWVALUE)) {
472 node->CreateValueRaw( ValueID::ValueGenre_User, GetCommandClassId(), _instance, UserCodeIndex_RawValue, "Raw UserCode", "", false, false, 0, 0, 0);
473 node->CreateValueShort( ValueID::ValueGenre_User, GetCommandClassId(), _instance, UserCodeIndex_RawValueIndex, "Raw UserCode Index", "", false, false, 0, 0);
474 }
475 }
476 return true;
477 }
478 else if( UserCodeCmd_Report == (UserCodeCmd)_data[0] )
479 {
480 int i = _data[1];
481 Log::Write( LogLevel_Info, GetNodeId(), "Received User Code Report from node %d for User Code %d (%s)", GetNodeId(), i, CodeStatus( _data[2] ).c_str() );
482

Callers

nothing calls this directly

Calls 15

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
RequestValueFunction · 0.85
SetFlagByteMethod · 0.80
GetFlagByteMethod · 0.80
CreateValueStringMethod · 0.80
GetFlagBoolMethod · 0.80
CreateValueRawMethod · 0.80
CreateValueShortMethod · 0.80
GetOptionAsBoolMethod · 0.80
GetNodeIdFunction · 0.70
GetFunction · 0.50

Tested by

no test coverage detected