//-----------------------------------------------------------------------------
// <AssociationCommandConfiguration::HandleMsg>
// Handle a message from the Z-Wave network
//-----------------------------------------------------------------------------
bool AssociationCommandConfiguration::HandleMsg
(
	uint8 const* _data,
	uint32 const _length,
	uint32 const _instance	// = 1
)
{
	if (AssociationCommandConfigurationCmd_SupportedRecordsReport == (AssociationCommandConfigurationCmd)_data[0])
	{
		uint8 maxCommandLength			=	 _data[1] >> 2;
		bool commandsAreValues			= ( (_data[1] & 0x02) != 0 );
		bool commandsAreConfigurable	= ( (_data[1] & 0x01) != 0 );
		int16 numFreeCommands			= (((int16)_data[2])<<16) | (int16)_data[3];
		int16 maxCommands				= (((int16)_data[4])<<16) | (int16)_data[5];

		Log::Write( LogLevel_Info, GetNodeId(), "Received AssociationCommandConfiguration Supported Records Report:" );
		Log::Write( LogLevel_Info, GetNodeId(), "    Maximum command length = %d bytes", maxCommandLength );
		Log::Write( LogLevel_Info, GetNodeId(), "    Maximum number of commands = %d", maxCommands );
		Log::Write( LogLevel_Info, GetNodeId(), "    Number of free commands = %d", numFreeCommands );
		Log::Write( LogLevel_Info, GetNodeId(), "    Commands are %s and are %s", commandsAreValues ? "values" : "not values", commandsAreConfigurable ? "configurable" : "not configurable" );

		ValueBool* valueBool;
		ValueByte* valueByte;
		ValueShort* valueShort;

		if( (valueByte = static_cast<ValueByte*>( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommandLength ) )) )
		{
			valueByte->OnValueRefreshed( maxCommandLength );
			valueByte->Release();
		}

		if( (valueBool = static_cast<ValueBool*>( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreValues ) )) )
		{
			valueBool->OnValueRefreshed( commandsAreValues );
			valueBool->Release();
		}

		if( (valueBool = static_cast<ValueBool*>( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreConfigurable ) )) )
		{
			valueBool->OnValueRefreshed( commandsAreConfigurable );
			valueBool->Release();
		}

		if( (valueShort = static_cast<ValueShort*>( GetValue( _instance, AssociationCommandConfigurationIndex_NumFreeCommands ) )) )
		{
			valueShort->OnValueRefreshed( numFreeCommands );
			valueShort->Release();
		}

		if( (valueShort = static_cast<ValueShort*>( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommands ) )) )
		{
			valueShort->OnValueRefreshed( maxCommands );
			valueShort->Release();
		}
		return true;
	}
예제 #2
0
//-----------------------------------------------------------------------------
// <ZWavePlusInfo::HandleMsg>
// Handle a message from the Z-Wave network
//-----------------------------------------------------------------------------
bool ZWavePlusInfo::HandleMsg
(
	uint8 const* _data,
	uint32 const _length,
	uint32 const _instance	// = 1
)
{
	if( ZWavePlusInfoCmd_Report == _data[0] )
	{
		uint8 version = _data[1];
		uint8 role    = _data[2];
		uint8 nodeType    = _data[3];
		uint16 installerIcon = (_data[4]<< 8) | _data[5];
		uint16 deviceType		 = (_data[6]<< 8) | _data[7];

		if( Node* node = GetNodeUnsafe() )
		{
			node->SetPlusDeviceClasses(	role, nodeType, deviceType );
		}
		ClearStaticRequest( StaticRequest_Values );

		ValueByte* value;
		if( (value = static_cast<ValueByte*>( GetValue( _instance, ZWavePlusInfoIndex_Version ) )) )
		{
			value->OnValueRefreshed( version );
			value->Release();
		}

		ValueShort* svalue;
		if( (svalue = static_cast<ValueShort*>( GetValue( _instance, ZWavePlusInfoIndex_InstallerIcon ) )) )
		{
			svalue->OnValueRefreshed( installerIcon );
			svalue->Release();
		}

		if( (svalue = static_cast<ValueShort*>( GetValue( _instance, ZWavePlusInfoIndex_UserIcon ) )) )
		{
			svalue->OnValueRefreshed( deviceType );
			svalue->Release();
		}




		return true;
	}
	return false;
}