Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// <Alarm::HandleMsg>
// Handle a message from the Z-Wave network
//-----------------------------------------------------------------------------
bool Alarm::HandleMsg
(
	uint8 const* _data,
	uint32 const _length,
	uint32 const _instance	// = 1
)
{
	if (AlarmCmd_Report == (AlarmCmd)_data[0])
	{
		// We have received a report from the Z-Wave device
		Log::Write( LogLevel_Info, GetNodeId(), "Received Alarm report: type=%d, level=%d", _data[1], _data[2] );

		ValueByte* value;
		if( (value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Type ) )) )
		{
			value->OnValueRefreshed( _data[1] );
			value->Release();
		}
		if( (value = static_cast<ValueByte*>( GetValue( _instance, AlarmIndex_Level ) )) )
		{
			value->OnValueRefreshed( _data[2] );
			value->Release();
		}
		return true;
	}

	return false;
}
//-----------------------------------------------------------------------------
// <ManufacturerProprietary::HandleMsg>
// Handle a message from the Z-Wave network
//-----------------------------------------------------------------------------
bool ManufacturerProprietary::HandleMsg
(
    uint8 const* _data,
    uint32 const _length,
    uint32 const _instance    // = 1
)
{
    uint8 const* payload = _data+2;
    if( MANUFACTURER_ID_FIBARO[0] == _data[0] &&
        MANUFACTURER_ID_FIBARO[1] == _data[1] )
    {

        if( FIBARO_VENETIEN_BLINDS_REPORT_ID[0] == payload[0] &&
            FIBARO_VENETIEN_BLINDS_REPORT_ID[1] == payload[1] &&
            FIBARO_VENETIEN_BLINDS_REPORT_ID[2] == payload[2] )
        {
        ValueByte* blindsValue = static_cast<ValueByte*>( GetValue( _instance, FibaroVenetianBlindsValueIds_Blinds ) );
        ValueByte* tiltValue   = static_cast<ValueByte*>( GetValue( _instance, FibaroVenetianBlindsValueIds_Tilt ) );

        if( NULL != blindsValue && NULL != tiltValue)
        {
            Log::Write( LogLevel_Info, GetNodeId(), "Received Fibaro proprietary blind/slat position for node %d: Blinds: %d Slats: %d",
                        GetNodeId(), payload[3], payload[4] );
            blindsValue->OnValueRefreshed( payload[3] );
            tiltValue->OnValueRefreshed( payload[4] );
            blindsValue->Release();
            tiltValue->Release();
        }
        else
        {
            Log::Write( LogLevel_Warning, GetNodeId(), "Error setting Fibaro blind/slat position. Values were not found." );      
        }
            return true;
        }
        else
        {
            Log::Write( LogLevel_Warning, GetNodeId(), "Received unknown Fibaro proprietary message for node %d.",
                        GetNodeId());
            return false;
        }
    }
    Log::Write( LogLevel_Warning, GetNodeId(), "Received unknown manufacturer proprietary message for node %d.",
                GetNodeId());
    return false;
}
//-----------------------------------------------------------------------------
// <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;
	}
Exemplo n.º 4
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;
}