1 //-----------------------------------------------------------------------------
2 //
3 // NoOperation.cpp
4 //
5 // Implementation of the Z-Wave COMMAND_CLASS_NO_OPERATION
6 //
7 // Copyright (c) 2012 Greg Satz <satz@iranger.com>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27
28 #include "command_classes/CommandClasses.h"
29 #include "command_classes/NoOperation.h"
30 #include "Defs.h"
31 #include "Msg.h"
32 #include "Node.h"
33 #include "Driver.h"
34 #include "platform/Log.h"
35
36 using namespace OpenZWave;
37
38 //-----------------------------------------------------------------------------
39 // <NoOperation::HandleMsg>
40 // Handle a message from the Z-Wave network
41 //-----------------------------------------------------------------------------
HandleMsg(uint8 const * _data,uint32 const _length,uint32 const _instance)42 bool NoOperation::HandleMsg
43 (
44 uint8 const* _data,
45 uint32 const _length,
46 uint32 const _instance // = 1
47 )
48 {
49 // We have received a no operation from the Z-Wave device.
50 Log::Write( LogLevel_Info, GetNodeId(), "Received NoOperation command from node %d", GetNodeId() );
51 return true;
52 }
53
54 //-----------------------------------------------------------------------------
55 // <NoOperation::Set>
56 // Send a No Operation message class.
57 //-----------------------------------------------------------------------------
Set(bool const _route,Driver::MsgQueue _queue)58 void NoOperation::Set
59 (
60 bool const _route,
61 Driver::MsgQueue _queue // = Driver::MsgQueue_NoOp
62 )
63 {
64 Log::Write( LogLevel_Info, GetNodeId(), "NoOperation::Set - Routing=%s", _route ? "true" : "false" );
65
66 Msg* msg = new Msg( "NoOperation_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
67 msg->Append( GetNodeId() );
68 msg->Append( 2 );
69 msg->Append( GetCommandClassId() );
70 msg->Append( 0 );
71 if( _route )
72 msg->Append( GetDriver()->GetTransmitOptions() );
73 else
74 msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_NO_ROUTE );
75 GetDriver()->SendMsg( msg, _queue );
76 }
77