//-----------------------------------------------------------------------------
// <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( "Received AssociationCommandConfiguration Supported Records Report from node %d:", GetNodeId() );
		Log::Write( "    Maximum command length = %d bytes", maxCommandLength );
		Log::Write( "    Maximum number of commands = %d", maxCommands );
		Log::Write( "    Number of free commands = %d", numFreeCommands );
		Log::Write( "    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->OnValueChanged( maxCommandLength );
		}

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

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

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

		if( valueShort = static_cast<ValueShort*>( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommands ) ) )
		{
			valueShort->OnValueChanged( maxCommands );
		}
		return true;
	}