Driver.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Driver.h
//
// Communicates with a Z-Wave network
//
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Driver_H
#define _Driver_H
#include <string>
#include <map>
#include <list>
#include "Defs.h"
#include "Group.h"
#include "value_classes/ValueID.h"
#include "Node.h"
#include "platform/Event.h"
#include "platform/Mutex.h"
#include "platform/TimeStamp.h"
#include "aes/aescpp.h"
namespace OpenZWave
{
class Msg;
class Value;
class Event;
class Mutex;
class Controller;
class Thread;
class ControllerReplication;
class Notification;
class OPENZWAVE_EXPORT Driver
{
friend class Manager;
friend class Node;
friend class Group;
friend class CommandClass;
friend class ControllerReplication;
friend class Value;
friend class ValueStore;
friend class ValueButton;
friend class Association;
friend class Basic;
friend class ManufacturerSpecific;
friend class MultiChannelAssociation;
friend class NodeNaming;
friend class NoOperation;
friend class SceneActivation;
friend class WakeUp;
friend class Security;
friend class Msg;
//-----------------------------------------------------------------------------
// Controller Interfaces
//-----------------------------------------------------------------------------
public:
enum ControllerInterface
{
ControllerInterface_Unknown = 0,
ControllerInterface_Serial,
ControllerInterface_Hid
};
//-----------------------------------------------------------------------------
// Construction / Destruction
//-----------------------------------------------------------------------------
private:
Driver( string const& _controllerPath, ControllerInterface const& _interface );
virtual ~Driver();
void Start();
static void DriverThreadEntryPoint( Event* _exitEvent, void* _context );
void DriverThreadProc( Event* _exitEvent );
bool Init( uint32 _attempts );
void RemoveQueues( uint8 const _nodeId );
Thread* m_driverThread;
Mutex* m_initMutex;
bool m_exit;
bool m_init;
bool m_awakeNodesQueried;
bool m_allNodesQueried;
bool m_notifytransactions;
TimeStamp m_startTime;
//-----------------------------------------------------------------------------
// Configuration
//-----------------------------------------------------------------------------
private:
void RequestConfig(); // Get the network configuration from the Z-Wave network
bool ReadConfig(); // Read the configuration from a file
void WriteConfig(); // Save the configuration to a file
//-----------------------------------------------------------------------------
// Controller
//-----------------------------------------------------------------------------
private:
// Controller Capabilities (return in FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES)
enum
{
ControllerCaps_Secondary = 0x01,
ControllerCaps_OnOtherNetwork = 0x02,
ControllerCaps_SIS = 0x04,
ControllerCaps_RealPrimary = 0x08,
ControllerCaps_SUC = 0x10
};
// Init Capabilities (return in FUNC_ID_SERIAL_API_GET_INIT_DATA)
enum
{
InitCaps_Slave = 0x01,
InitCaps_TimerSupport = 0x02,
InitCaps_Secondary = 0x04,
InitCaps_SUC = 0x08
};
bool IsPrimaryController()const{ return ((m_initCaps & InitCaps_Secondary) == 0); }
bool IsStaticUpdateController()const{ return ((m_initCaps & InitCaps_SUC) != 0); }
bool IsBridgeController()const{ return (m_libraryType == 7); }
bool IsInclusionController()const{ return ((m_controllerCaps & ControllerCaps_SIS) != 0); }
uint32 GetHomeId()const{ return m_homeId; }
uint8 GetControllerNodeId()const{ return m_Controller_nodeId; }
uint8 GetSUCNodeId()const{ return m_SUCNodeId; }
uint16 GetManufacturerId()const{ return m_manufacturerId; }
uint16 GetProductType()const{ return m_productType; }
uint16 GetProductId()const{ return m_productId; }
string GetControllerPath()const{ return m_controllerPath; }
ControllerInterface GetControllerInterfaceType()const{ return m_controllerInterfaceType; }
string GetLibraryVersion()const{ return m_libraryVersion; }
string GetLibraryTypeName()const{ return m_libraryTypeName; }
int32 GetSendQueueCount()const
{
int32 count = 0;
for( int32 i=0; i<MsgQueue_Count; ++i )
{
count += (int32) (m_msgQueue[i].size());
}
return count;
}
Node* GetNodeUnsafe( uint8 _nodeId );
Node* GetNode( uint8 _nodeId );
//void LockNodes();
//void ReleaseNodes();
ControllerInterface m_controllerInterfaceType; // Specifies the controller's hardware interface
string m_controllerPath; // name or path used to open the controller hardware.
Controller* m_controller; // Handles communications with the controller hardware.
uint32 m_homeId; // Home ID of the Z-Wave controller. Not valid until the DriverReady notification has been received.
string m_libraryVersion; // Version of the Z-Wave Library used by the controller.
string m_libraryTypeName; // Name describing the library type.
uint8 m_libraryType; // Type of library used by the controller.
uint8 m_serialAPIVersion[2];
uint16 m_manufacturerId;
uint16 m_productType;
uint16 m_productId;
uint8 m_apiMask[32];
uint8 m_initVersion; // Version of the Serial API used by the controller.
uint8 m_initCaps; // Set of flags indicating the serial API capabilities (See IsSlave, HasTimerSupport, IsPrimaryController and IsStaticUpdateController above).
uint8 m_controllerCaps; // Set of flags indicating the controller's capabilities (See IsInclusionController above).
uint8 m_Controller_nodeId; // Z-Wave Controller's own node ID.
Node* m_nodes[256]; // Array containing all the node objects.
Mutex* m_nodeMutex; // Serializes access to node data
ControllerReplication* m_controllerReplication; // Controller replication is handled separately from the other command classes, due to older hand-held controllers using invalid node IDs.
uint8 m_transmitOptions;
//-----------------------------------------------------------------------------
// Receiving Z-Wave messages
//-----------------------------------------------------------------------------
private:
bool ReadMsg();
void ProcessMsg( uint8* _data );
void HandleGetVersionResponse( uint8* _data );
void HandleGetRandomResponse( uint8* _data );
void HandleGetControllerCapabilitiesResponse( uint8* _data );
void HandleGetSerialAPICapabilitiesResponse( uint8* _data );
void HandleSerialAPISoftResetResponse( uint8* _data );
void HandleEnableSUCResponse( uint8* _data );
void HandleSetSUCNodeIdResponse( uint8* _data );
void HandleGetSUCNodeIdResponse( uint8* _data );
void HandleMemoryGetIdResponse( uint8* _data );
void HandleSerialAPIGetInitDataResponse( uint8* _data );
void HandleGetNodeProtocolInfoResponse( uint8* _data );
bool HandleRemoveFailedNodeResponse( uint8* _data );
void HandleIsFailedNodeResponse( uint8* _data );
bool HandleReplaceFailedNodeResponse( uint8* _data );
bool HandleAssignReturnRouteResponse( uint8* _data );
bool HandleDeleteReturnRouteResponse( uint8* _data );
void HandleSendNodeInformationRequest( uint8* _data );
void HandleSendDataResponse( uint8* _data, bool _replication );
bool HandleNetworkUpdateResponse( uint8* _data );
void HandleGetRoutingInfoResponse( uint8* _data );
void HandleSendDataRequest( uint8* _data, bool _replication );
void HandleAddNodeToNetworkRequest( uint8* _data );
void HandleCreateNewPrimaryRequest( uint8* _data );
void HandleControllerChangeRequest( uint8* _data );
void HandleSetLearnModeRequest( uint8* _data );
void HandleRemoveFailedNodeRequest( uint8* _data );
void HandleReplaceFailedNodeRequest( uint8* _data );
void HandleRemoveNodeFromNetworkRequest( uint8* _data );
void HandleApplicationCommandHandlerRequest( uint8* _data, bool encrypted );
void HandlePromiscuousApplicationCommandHandlerRequest( uint8* _data );
void HandleAssignReturnRouteRequest( uint8* _data );
void HandleDeleteReturnRouteRequest( uint8* _data );
void HandleNodeNeighborUpdateRequest( uint8* _data );
void HandleNetworkUpdateRequest( uint8* _data );
bool HandleApplicationUpdateRequest( uint8* _data );
bool HandleRfPowerLevelSetResponse( uint8* _data );
bool HandleSerialApiSetTimeoutsResponse( uint8* _data );
bool HandleMemoryGetByteResponse( uint8* _data );
bool HandleReadMemoryResponse( uint8* _data );
void HandleGetVirtualNodesResponse( uint8* _data );
bool HandleSetSlaveLearnModeResponse( uint8* _data );
void HandleSetSlaveLearnModeRequest( uint8* _data );
bool HandleSendSlaveNodeInfoResponse( uint8* _data );
void HandleSendSlaveNodeInfoRequest( uint8* _data );
void HandleApplicationSlaveCommandRequest( uint8* _data );
void HandleSerialAPIResetRequest( uint8* _data );
void CommonAddNodeStatusRequestHandler( uint8 _funcId, uint8* _data );
bool m_waitingForAck; // True when we are waiting for an ACK from the dongle
uint8 m_expectedCallbackId; // If non-zero, we wait for a message with this callback Id
uint8 m_expectedReply; // If non-zero, we wait for a message with this function Id
uint8 m_expectedCommandClassId; // If the expected reply is FUNC_ID_APPLICATION_COMMAND_HANDLER, this value stores the command class we're waiting to hear from
uint8 m_expectedNodeId; // If we are waiting for a FUNC_ID_APPLICATION_COMMAND_HANDLER, make sure we only accept it from this node.
//-----------------------------------------------------------------------------
// Polling Z-Wave devices
//-----------------------------------------------------------------------------
private:
int32 GetPollInterval(){ return m_pollInterval ; }
void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls ){ m_pollInterval = _milliseconds; m_bIntervalBetweenPolls = _bIntervalBetweenPolls; }
bool EnablePoll( const ValueID &_valueId, uint8 _intensity = 1 );
bool DisablePoll( const ValueID &_valueId );
bool isPolled( const ValueID &_valueId );
void SetPollIntensity( const ValueID &_valueId, uint8 _intensity );
static void PollThreadEntryPoint( Event* _exitEvent, void* _context );
void PollThreadProc( Event* _exitEvent );
Thread* m_pollThread; // Thread for polling devices on the Z-Wave network
struct PollEntry
{
ValueID m_id;
uint8 m_pollCounter;
};
OPENZWAVE_EXPORT_WARNINGS_OFF
list<PollEntry> m_pollList; // List of nodes that need to be polled
OPENZWAVE_EXPORT_WARNINGS_ON
Mutex* m_pollMutex; // Serialize access to the polling list
int32 m_pollInterval; // Time interval during which all nodes must be polled
bool m_bIntervalBetweenPolls; // if true, the library intersperses m_pollInterval between polls; if false, the library attempts to complete all polls within m_pollInterval
//-----------------------------------------------------------------------------
// Retrieving Node information
//-----------------------------------------------------------------------------
public:
uint8 GetNodeNumber( Msg const* _msg )const{ return ( _msg == NULL ? 0 : _msg->GetTargetNodeId() ); }
private:
void InitNode( uint8 const _nodeId, bool newNode = false, bool secure = false, uint8 const *_protocolInfo = NULL, uint8 const _length = 0);
void InitAllNodes(); // Delete all nodes and fetch the data from the Z-Wave network again.
bool IsNodeListeningDevice( uint8 const _nodeId );
bool IsNodeFrequentListeningDevice( uint8 const _nodeId );
bool IsNodeBeamingDevice( uint8 const _nodeId );
bool IsNodeRoutingDevice( uint8 const _nodeId );
bool IsNodeSecurityDevice( uint8 const _nodeId );
uint32 GetNodeMaxBaudRate( uint8 const _nodeId );
uint8 GetNodeVersion( uint8 const _nodeId );
uint8 GetNodeSecurity( uint8 const _nodeId );
uint8 GetNodeBasic( uint8 const _nodeId );
uint8 GetNodeGeneric( uint8 const _nodeId );
uint8 GetNodeSpecific( uint8 const _nodeId );
string GetNodeType( uint8 const _nodeId );
uint32 GetNodeNeighbors( uint8 const _nodeId, uint8** o_neighbors );
string GetNodeManufacturerName( uint8 const _nodeId );
string GetNodeProductName( uint8 const _nodeId );
string GetNodeName( uint8 const _nodeId );
string GetNodeLocation( uint8 const _nodeId );
uint16 GetNodeDeviceType( uint8 const _nodeId );
string GetNodeDeviceTypeString( uint8 const _nodeId );
uint8 GetNodeRole( uint8 const _nodeId );
string GetNodeRoleString( uint8 const _nodeId );
uint8 GetNodePlusType( uint8 const _nodeId );
string GetNodePlusTypeString ( uint8 const _nodeId );
bool IsNodeZWavePlus( uint8 const _nodeId );
uint16 GetNodeManufacturerId( uint8 const _nodeId );
uint16 GetNodeProductType( uint8 const _nodeId );
uint16 GetNodeProductId( uint8 const _nodeId );
void SetNodeManufacturerName( uint8 const _nodeId, string const& _manufacturerName );
void SetNodeProductName( uint8 const _nodeId, string const& _productName );
void SetNodeName( uint8 const _nodeId, string const& _nodeName );
void SetNodeLocation( uint8 const _nodeId, string const& _location );
void SetNodeLevel( uint8 const _nodeId, uint8 const _level );
void SetNodeOn( uint8 const _nodeId );
void SetNodeOff( uint8 const _nodeId );
Value* GetValue( ValueID const& _id );
bool IsAPICallSupported( uint8 const _apinum )const{ return (( m_apiMask[( _apinum - 1 ) >> 3] & ( 1 << (( _apinum - 1 ) & 0x07 ))) != 0 ); }
void SetAPICall( uint8 const _apinum, bool _toSet )
{
if( _toSet )
{
m_apiMask[( _apinum - 1 ) >> 3] |= ( 1 << (( _apinum - 1 ) & 0x07 ));
}
else
{
m_apiMask[( _apinum - 1 ) >> 3] &= ~( 1 << (( _apinum - 1 ) & 0x07 ));
}
}
uint8 NodeFromMessage( uint8 const* buffer );
//-----------------------------------------------------------------------------
// Controller commands
//-----------------------------------------------------------------------------
public:
enum ControllerCommand
{
ControllerCommand_None = 0,
ControllerCommand_AddDevice,
ControllerCommand_CreateNewPrimary,
ControllerCommand_ReceiveConfiguration,
ControllerCommand_RemoveDevice,
ControllerCommand_RemoveFailedNode,
ControllerCommand_HasNodeFailed,
ControllerCommand_ReplaceFailedNode,
ControllerCommand_TransferPrimaryRole,
ControllerCommand_RequestNetworkUpdate,
ControllerCommand_RequestNodeNeighborUpdate,
ControllerCommand_AssignReturnRoute,
ControllerCommand_DeleteAllReturnRoutes,
ControllerCommand_SendNodeInformation,
ControllerCommand_ReplicationSend,
ControllerCommand_CreateButton,
ControllerCommand_DeleteButton
};
enum ControllerState
{
ControllerState_Normal = 0,
ControllerState_Starting,
ControllerState_Cancel,
ControllerState_Error,
ControllerState_Waiting,
ControllerState_Sleeping,
ControllerState_InProgress,
ControllerState_Completed,
ControllerState_Failed,
ControllerState_NodeOK,
ControllerState_NodeFailed
};
enum ControllerError
{
ControllerError_None = 0,
ControllerError_ButtonNotFound,
ControllerError_NodeNotFound,
ControllerError_NotBridge,
ControllerError_NotSUC,
ControllerError_NotSecondary,
ControllerError_NotPrimary,
ControllerError_IsPrimary,
ControllerError_NotFound,
ControllerError_Busy,
ControllerError_Failed,
ControllerError_Disabled,
ControllerError_Overflow
};
typedef void (*pfnControllerCallback_t)( ControllerState _state, ControllerError _err, void* _context );
private:
// The public interface is provided via the wrappers in the Manager class
void ResetController( Event* _evt );
void SoftReset();
void RequestNodeNeighbors( uint8 const _nodeId, uint32 const _requestFlags );
bool BeginControllerCommand( ControllerCommand _command, pfnControllerCallback_t _callback, void* _context, bool _highPower, uint8 _nodeId, uint8 _arg );
bool CancelControllerCommand();
void AddNodeStop( uint8 const _funcId ); // Handle different controller behaviors
struct ControllerCommandItem
{
ControllerState m_controllerState;
bool m_controllerStateChanged;
bool m_controllerCommandDone;
ControllerCommand m_controllerCommand;
pfnControllerCallback_t m_controllerCallback;
ControllerError m_controllerReturnError;
void* m_controllerCallbackContext;
bool m_highPower;
bool m_controllerAdded;
uint8 m_controllerCommandNode;
uint8 m_controllerCommandArg;
uint8 m_controllerDeviceProtocolInfo[254];
uint8 m_controllerDeviceProtocolInfoLength;
};
ControllerCommandItem* m_currentControllerCommand;
void DoControllerCommand();
void UpdateControllerState( ControllerState const _state, ControllerError const _error = ControllerError_None );
uint8 m_SUCNodeId;
void UpdateNodeRoutes( uint8 const_nodeId, bool _doUpdate = false );
Event* m_controllerResetEvent;
//-----------------------------------------------------------------------------
// Sending Z-Wave messages
//-----------------------------------------------------------------------------
public:
enum MsgQueue
{
MsgQueue_Command = 0,
MsgQueue_Security,
MsgQueue_NoOp,
MsgQueue_Controller,
MsgQueue_WakeUp,
MsgQueue_Send,
MsgQueue_Query,
MsgQueue_Poll,
MsgQueue_Count // Number of message queues
};
void SendMsg( Msg* _msg, MsgQueue const _queue );
uint8 GetTransmitOptions()const{ return m_transmitOptions; }
private:
bool WriteNextMsg( MsgQueue const _queue ); // Extracts the first message from the queue, and makes it the current one.
bool WriteMsg( string const &str); // Sends the current message to the Z-Wave network
void RemoveCurrentMsg(); // Deletes the current message and cleans up the callback etc states
bool MoveMessagesToWakeUpQueue( uint8 const _targetNodeId, bool const _move ); // If a node does not respond, and is of a type that can sleep, this method is used to move all its pending messages to another queue ready for when it wakes up next.
bool HandleErrorResponse( uint8 const _error, uint8 const _nodeId, char const* _funcStr, bool _sleepCheck = false ); // Handle data errors and process consistently. If message is moved to wake-up queue, return true.
bool IsExpectedReply( uint8 const _nodeId ); // Determine if reply message is the one we are expecting
void SendQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage );
void RetryQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage );
void CheckCompletedNodeQueries(); // Send notifications if all awake and/or sleeping nodes have completed their queries
// Requests to be sent to nodes are assigned to one of five queues.
// From highest to lowest priority, these are
//
// 0) The security queue, for handling encrypted messages. This is the
// highest priority send queue, because the security process inserts
// messages to handle the encryption process that must be sent before
// a new message can be wrapped.
//
// 1) The command queue, for controller commands. This is the 2nd highest
// priority send queue, because the controller command processes are not
// permitted to be interrupted by other requests.
//
// 2) The controller queue exists to handle multi-step controller commands. These
// typically require user interaction or affect the network in some way.
//
// 3) The No Operation command class queue. This is used for device probing
// at startup as well as network diagnostics.
//
// 4) The wakeup queue. This holds messages that have been held for a
// sleeping device that has now woken up. These get a high priority
// because such devices do not stay awake for very long.
//
// 5) The send queue. This is for normal messages, usually triggered by
// a user interaction with the application.
//
// 6) The query queue. For node query messages sent when a new node is
// discovered. The query process generates a large number of requests,
// so the query queue has a low priority to avoid making the system
// unresponsive.
//
// 7) The poll queue. Requests to devices that need their state polling
// at regular intervals. These are of the lowest priority, and are only
// sent when nothing else is going on
//
enum MsgQueueCmd
{
MsgQueueCmd_SendMsg = 0,
MsgQueueCmd_QueryStageComplete,
MsgQueueCmd_Controller
};
class MsgQueueItem
{
public:
MsgQueueItem() :
m_msg(NULL),
m_nodeId(0),
m_queryStage(Node::QueryStage_None),
m_retry(false),
m_cci(NULL)
{}
bool operator == ( MsgQueueItem const& _other )const
{
if( _other.m_command == m_command )
{
if( m_command == MsgQueueCmd_SendMsg )
{
return( (*_other.m_msg) == (*m_msg) );
}
else if( m_command == MsgQueueCmd_QueryStageComplete )
{
return( (_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage) );
}
else if( m_command == MsgQueueCmd_Controller )
{
return( (_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback) );
}
}
return false;
}
MsgQueueCmd m_command;
Msg* m_msg;
uint8 m_nodeId;
Node::QueryStage m_queryStage;
bool m_retry;
ControllerCommandItem* m_cci;
};
OPENZWAVE_EXPORT_WARNINGS_OFF
list<MsgQueueItem> m_msgQueue[MsgQueue_Count];
OPENZWAVE_EXPORT_WARNINGS_ON
Event* m_queueEvent[MsgQueue_Count]; // Events for each queue, which are signaled when the queue is not empty
Mutex* m_sendMutex; // Serialize access to the queues
Msg* m_currentMsg;
MsgQueue m_currentMsgQueueSource; // identifies which queue held m_currentMsg
TimeStamp m_resendTimeStamp;
//-----------------------------------------------------------------------------
// Network functions
//-----------------------------------------------------------------------------
private:
void TestNetwork( uint8 const _nodeId, uint32 const _count );
//-----------------------------------------------------------------------------
// Virtual Node commands
//-----------------------------------------------------------------------------
public:
private:
uint32 GetVirtualNeighbors( uint8** o_neighbors );
void RequestVirtualNeighbors( MsgQueue const _queue );
bool IsVirtualNode( uint8 const _nodeId )const{ return (( m_virtualNeighbors[( _nodeId - 1 ) >> 3] & 1 << (( _nodeId - 1 ) & 0x07 )) != 0 ); }
void SendVirtualNodeInfo( uint8 const _fromNodeId, uint8 const _ToNodeId );
void SendSlaveLearnModeOff();
void SaveButtons();
void ReadButtons( uint8 const _nodeId );
bool m_virtualNeighborsReceived;
uint8 m_virtualNeighbors[NUM_NODE_BITFIELD_BYTES]; // Bitmask containing virtual neighbors
//-----------------------------------------------------------------------------
// SwitchAll
//-----------------------------------------------------------------------------
private:
// The public interface is provided via the wrappers in the Manager class
void SwitchAllOn();
void SwitchAllOff();
//-----------------------------------------------------------------------------
// Configuration Parameters (wrappers for the Node methods)
//-----------------------------------------------------------------------------
private:
// The public interface is provided via the wrappers in the Manager class
bool SetConfigParam( uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size );
void RequestConfigParam( uint8 const _nodeId, uint8 const _param );
//-----------------------------------------------------------------------------
// Groups (wrappers for the Node methods)
//-----------------------------------------------------------------------------
private:
// The public interface is provided via the wrappers in the Manager class
uint8 GetNumGroups( uint8 const _nodeId );
uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations );
uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, InstanceAssociation** o_associations );
uint8 GetMaxAssociations( uint8 const _nodeId, uint8 const _groupIdx );
string GetGroupLabel( uint8 const _nodeId, uint8 const _groupIdx );
void AddAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
void RemoveAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
//-----------------------------------------------------------------------------
// Notifications
//-----------------------------------------------------------------------------
private:
void QueueNotification( Notification* _notification ); // Adds a notification to the list. Notifications are queued until a point in the thread where we know we do not have any nodes locked.
void NotifyWatchers(); // Passes the notifications to all the registered watcher callbacks in turn.
OPENZWAVE_EXPORT_WARNINGS_OFF
list<Notification*> m_notifications;
OPENZWAVE_EXPORT_WARNINGS_ON
Event* m_notificationsEvent;
//-----------------------------------------------------------------------------
// Statistics
//-----------------------------------------------------------------------------
public:
struct DriverData
{
uint32 m_SOFCnt; // Number of SOF bytes received
uint32 m_ACKWaiting; // Number of unsolicited messages while waiting for an ACK
uint32 m_readAborts; // Number of times read were aborted due to timeouts
uint32 m_badChecksum; // Number of bad checksums
uint32 m_readCnt; // Number of messages successfully read
uint32 m_writeCnt; // Number of messages successfully sent
uint32 m_CANCnt; // Number of CAN bytes received
uint32 m_NAKCnt; // Number of NAK bytes received
uint32 m_ACKCnt; // Number of ACK bytes received
uint32 m_OOFCnt; // Number of bytes out of framing
uint32 m_dropped; // Number of messages dropped & not delivered
uint32 m_retries; // Number of messages retransmitted
uint32 m_callbacks; // Number of unexpected callbacks
uint32 m_badroutes; // Number of failed messages due to bad route response
uint32 m_noack; // Number of no ACK returned errors
uint32 m_netbusy; // Number of network busy/failure messages
uint32 m_notidle;
uint32 m_nondelivery; // Number of messages not delivered to network
uint32 m_routedbusy; // Number of messages received with routed busy status
uint32 m_broadcastReadCnt; // Number of broadcasts read
uint32 m_broadcastWriteCnt; // Number of broadcasts sent
};
void LogDriverStatistics();
private:
void GetDriverStatistics( DriverData* _data );
void GetNodeStatistics( uint8 const _nodeId, Node::NodeData* _data );
uint32 m_SOFCnt; // Number of SOF bytes received
uint32 m_ACKWaiting; // Number of unsolicited messages while waiting for an ACK
uint32 m_readAborts; // Number of times read were aborted due to timeouts
uint32 m_badChecksum; // Number of bad checksums
uint32 m_readCnt; // Number of messages successfully read
uint32 m_writeCnt; // Number of messages successfully sent
uint32 m_CANCnt; // Number of CAN bytes received
uint32 m_NAKCnt; // Number of NAK bytes received
uint32 m_ACKCnt; // Number of ACK bytes received
uint32 m_OOFCnt; // Number of bytes out of framing
uint32 m_dropped; // Number of messages dropped & not delivered
uint32 m_retries; // Number of retransmitted messages
uint32 m_callbacks; // Number of unexpected callbacks
uint32 m_badroutes; // Number of failed messages due to bad route response
uint32 m_noack; // Number of no ACK returned errors
uint32 m_netbusy; // Number of network busy/failure messages
uint32 m_notidle; // Number of not idle messages
uint32 m_nondelivery; // Number of messages not delivered to network
uint32 m_routedbusy; // Number of messages received with routed busy status
uint32 m_broadcastReadCnt; // Number of broadcasts read
uint32 m_broadcastWriteCnt; // Number of broadcasts sent
//time_t m_commandStart; // Start time of last command
//time_t m_timeoutLost; // Cumulative time lost to timeouts
//-----------------------------------------------------------------------------
// Security Command Class Related (Version 1.1)
//-----------------------------------------------------------------------------
public:
aes_encrypt_ctx *GetAuthKey();
aes_encrypt_ctx *GetEncKey();
bool isNetworkKeySet();
private:
bool initNetworkKeys(bool newnode);
uint8 *GetNetworkKey();
bool SendEncryptedMessage();
bool SendNonceRequest(string logmsg);
void SendNonceKey(uint8 nodeId, uint8 *nonce);
aes_encrypt_ctx *AuthKey;
aes_encrypt_ctx *EncryptKey;
uint8 m_nonceReportSent;
uint8 m_nonceReportSentAttempt;
bool m_inclusionkeySet;
};
} // namespace OpenZWave
#endif // _Driver_H
OpenZWave::Driver::MsgQueue_Security
Definition: Driver.h:568
OpenZWave::NoOperation
Implements COMMAND_CLASS_NO_OPERATION (0x00), a Z-Wave device command class.
Definition: NoOperation.h:37
OpenZWave::Driver::ControllerState_Completed
Definition: Driver.h:494
OpenZWave::Driver::DriverData::m_CANCnt
uint32 m_CANCnt
Definition: Driver.h:782
OpenZWave::Association
Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class.
Definition: Association.h:38
OpenZWave::Msg
Message object to be passed to and from devices on the Z-Wave network.
Definition: Msg.h:44
OpenZWave
Definition: Bitfield.h:34
OpenZWave::ValueStore
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:43
OpenZWave::Driver::MsgQueue
MsgQueue
Definition: Driver.h:565
OpenZWave::Security
Definition: Security.h:63
OpenZWave::Driver::ControllerError_Disabled
Definition: Driver.h:517
OpenZWave::Msg::GetTargetNodeId
uint8 GetTargetNodeId() const
Identifies the Node ID of the "target" node (if any) for this function.
Definition: Msg.h:66
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition: Defs.h:52
OpenZWave::ManufacturerSpecific
Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class.
Definition: ManufacturerSpecific.h:38
uint16
unsigned short uint16
Definition: Defs.h:77
OPENZWAVE_EXPORT_WARNINGS_ON
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition: Defs.h:54
OpenZWave::Driver::DriverData::m_routedbusy
uint32 m_routedbusy
Definition: Driver.h:794
OpenZWave::Controller
Definition: Controller.h:41
OpenZWave::Event
Platform-independent definition of event objects.
Definition: Event.h:39
Group.h
OpenZWave::Driver::ControllerCommand_RemoveFailedNode
Definition: Driver.h:466
OpenZWave::Driver::ControllerError_NodeNotFound
Definition: Driver.h:508
OpenZWave::Driver::DriverData::m_nondelivery
uint32 m_nondelivery
Definition: Driver.h:793
OpenZWave::Driver::GetTransmitOptions
uint8 GetTransmitOptions() const
Definition: Driver.h:583
OpenZWave::Driver::ControllerCommand_RequestNodeNeighborUpdate
Definition: Driver.h:471
Node.h
OpenZWave::Driver::DriverData::m_readAborts
uint32 m_readAborts
Definition: Driver.h:778
OpenZWave::Driver::ControllerError_NotSecondary
Definition: Driver.h:511
OpenZWave::WakeUp
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:43
OpenZWave::Manager
The main public interface to OpenZWave.
Definition: Manager.h:109
OpenZWave::Driver::DriverData::m_ACKWaiting
uint32 m_ACKWaiting
Definition: Driver.h:777
OpenZWave::Thread
Implements a platform-independent thread management class.
Definition: Thread.h:42
OpenZWave::Node::QueryStage
QueryStage
Definition: Node.h:134
OpenZWave::Driver::ControllerError_IsPrimary
Definition: Driver.h:513
OpenZWave::Driver::DriverData::m_badChecksum
uint32 m_badChecksum
Definition: Driver.h:779
OpenZWave::Driver::MsgQueue_NoOp
Definition: Driver.h:569
OpenZWave::Driver::DriverData::m_writeCnt
uint32 m_writeCnt
Definition: Driver.h:781
OPENZWAVE_EXPORT_WARNINGS_OFF
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition: Defs.h:53
OpenZWave::Driver::ControllerCommand_RequestNetworkUpdate
Definition: Driver.h:470
OpenZWave::InstanceAssociation
Definition: Group.h:42
OpenZWave::Node
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:64
OpenZWave::Driver::DriverData
Definition: Driver.h:774
NULL
#define NULL
Definition: Defs.h:70
Defs.h
OpenZWave::Driver::ControllerCommand
ControllerCommand
Definition: Driver.h:459
OpenZWave::Driver::DriverData::m_readCnt
uint32 m_readCnt
Definition: Driver.h:780
OpenZWave::CommandClass
Base class for all Z-Wave command classes.
Definition: CommandClass.h:46
ValueID.h
OpenZWave::Driver::ControllerError
ControllerError
Definition: Driver.h:504
OpenZWave::Driver::DriverData::m_OOFCnt
uint32 m_OOFCnt
Definition: Driver.h:785
OpenZWave::ValueButton
Button value ???.
Definition: ValueButton.h:45
OpenZWave::Driver::ControllerError_NotPrimary
Definition: Driver.h:512
OpenZWave::Driver::ControllerState
ControllerState
Definition: Driver.h:485
OpenZWave::Driver::DriverData::m_notidle
uint32 m_notidle
Definition: Driver.h:792
OpenZWave::Driver::ControllerState_Sleeping
Definition: Driver.h:492
OpenZWave::Driver::DriverData::m_SOFCnt
uint32 m_SOFCnt
Definition: Driver.h:776
OpenZWave::MultiChannelAssociation
Implements COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION (0x8E), a Z-Wave device command class...
Definition: MultiChannelAssociation.h:39
OpenZWave::Driver::ControllerInterface
ControllerInterface
Definition: Driver.h:83
OpenZWave::Driver::DriverData::m_broadcastReadCnt
uint32 m_broadcastReadCnt
Definition: Driver.h:795
OpenZWave::Driver
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:58
OpenZWave::Node::NodeData
Definition: Node.h:576
OpenZWave::SceneActivation
Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class.
Definition: SceneActivation.h:39
OpenZWave::Driver::DriverData::m_badroutes
uint32 m_badroutes
Definition: Driver.h:789
int32
signed int int32
Definition: Defs.h:79
OpenZWave::Driver::ControllerError_Failed
Definition: Driver.h:516
uint32
unsigned int uint32
Definition: Defs.h:80
OpenZWave::Driver::GetNodeNumber
uint8 GetNodeNumber(Msg const *_msg) const
Definition: Driver.h:378
OpenZWave::Driver::ControllerState_Error
Definition: Driver.h:490
OpenZWave::Driver::ControllerCommand_SendNodeInformation
Definition: Driver.h:474
OpenZWave::Group
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:49
OpenZWave::Notification
Provides a container for data sent via the notification callback handler installed by a call to Manag...
Definition: Notification.h:42
Mutex.h
OpenZWave::Driver::ControllerCommand_RemoveDevice
Definition: Driver.h:465
OpenZWave::Driver::DriverData::m_broadcastWriteCnt
uint32 m_broadcastWriteCnt
Definition: Driver.h:796
OpenZWave::Driver::ControllerState_Starting
Definition: Driver.h:488
OpenZWave::Driver::ControllerError_ButtonNotFound
Definition: Driver.h:507
OpenZWave::ValueID
Provides a unique ID for a value reported by a Z-Wave device.
Definition: ValueID.h:53
OpenZWave::Driver::ControllerCommand_HasNodeFailed
Definition: Driver.h:467
OpenZWave::Driver::MsgQueue_Query
Definition: Driver.h:573
OpenZWave::Driver::ControllerError_NotBridge
Definition: Driver.h:509
OpenZWave::Driver::ControllerState_Cancel
Definition: Driver.h:489
OpenZWave::Driver::DriverData::m_callbacks
uint32 m_callbacks
Definition: Driver.h:788
aes_encrypt_ctx
Definition: aes.h:82
OpenZWave::Driver::ControllerCommand_TransferPrimaryRole
Definition: Driver.h:469
OpenZWave::Driver::DriverData::m_netbusy
uint32 m_netbusy
Definition: Driver.h:791
Event.h
OpenZWave::Driver::ControllerCommand_ReplicationSend
Definition: Driver.h:475
OpenZWave::Driver::MsgQueue_Poll
Definition: Driver.h:574
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:39
OpenZWave::Driver::ControllerError_NotFound
Definition: Driver.h:514
OpenZWave::Driver::DriverData::m_retries
uint32 m_retries
Definition: Driver.h:787
OpenZWave::Driver::ControllerState_Failed
Definition: Driver.h:495
OpenZWave::Driver::ControllerCommand_AddDevice
Definition: Driver.h:462
OpenZWave::Driver::MsgQueue_Send
Definition: Driver.h:572
TimeStamp.h
OpenZWave::Driver::DriverData::m_noack
uint32 m_noack
Definition: Driver.h:790
OpenZWave::Driver::ControllerInterface_Serial
Definition: Driver.h:86
OpenZWave::TimeStamp
Implements a platform-independent TimeStamp.
Definition: TimeStamp.h:39
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:47
OpenZWave::Driver::ControllerState_InProgress
Definition: Driver.h:493
OpenZWave::Driver::DriverData::m_dropped
uint32 m_dropped
Definition: Driver.h:786
OpenZWave::Driver::DriverData::m_NAKCnt
uint32 m_NAKCnt
Definition: Driver.h:783
OpenZWave::NodeNaming
Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
Definition: NodeNaming.h:37
OpenZWave::ControllerReplication
Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class.
Definition: ControllerReplication.h:37
OpenZWave::Driver::DriverData::m_ACKCnt
uint32 m_ACKCnt
Definition: Driver.h:784
OpenZWave::Driver::ControllerState_Waiting
Definition: Driver.h:491
OpenZWave::Node::QueryStage_None
Definition: Node.h:136
OpenZWave::Driver::MsgQueue_WakeUp
Definition: Driver.h:571
OpenZWave::Driver::ControllerCommand_DeleteAllReturnRoutes
Definition: Driver.h:473
aescpp.h
OpenZWave::Driver::ControllerCommand_AssignReturnRoute
Definition: Driver.h:472
OpenZWave::Driver::MsgQueue_Controller
Definition: Driver.h:570
OpenZWave::Driver::ControllerError_NotSUC
Definition: Driver.h:510
OpenZWave::Driver::ControllerError_Busy
Definition: Driver.h:515
OpenZWave::Basic
Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class.
Definition: Basic.h:39
OpenZWave::Driver::ControllerState_NodeOK
Definition: Driver.h:496
OpenZWave::Driver::ControllerCommand_ReplaceFailedNode
Definition: Driver.h:468
OpenZWave::Driver::ControllerCommand_CreateNewPrimary
Definition: Driver.h:463
OpenZWave::Driver::ControllerCommand_ReceiveConfiguration
Definition: Driver.h:464
NUM_NODE_BITFIELD_BYTES
#define NUM_NODE_BITFIELD_BYTES
Definition: Defs.h:224
OpenZWave::Driver::ControllerCommand_CreateButton
Definition: Driver.h:476
uint8
unsigned char uint8
Definition: Defs.h:74