OpenZWave Library 1.4.0
Loading...
Searching...
No Matches
Driver.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// Driver.h
4//
5// Communicates with a Z-Wave network
6//
7// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
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#ifndef _Driver_H
29#define _Driver_H
30
31#include <string>
32#include <map>
33#include <list>
34
35#include "Defs.h"
36#include "Group.h"
38#include "Node.h"
39#include "platform/Event.h"
40#include "platform/Mutex.h"
41#include "platform/TimeStamp.h"
42#include "aes/aescpp.h"
43
44namespace OpenZWave
45{
46 class Msg;
47 class Value;
48 class Event;
49 class Mutex;
50 class Controller;
51 class Thread;
53 class Notification;
54
58 class OPENZWAVE_EXPORT Driver
59 {
60 friend class Manager;
61 friend class Node;
62 friend class Group;
63 friend class CommandClass;
65 friend class Value;
66 friend class ValueStore;
67 friend class ValueButton;
68 friend class Association;
69 friend class Basic;
72 friend class NodeNaming;
73 friend class NoOperation;
74 friend class SceneActivation;
75 friend class WakeUp;
76 friend class Security;
77 friend class Msg;
78
79 //-----------------------------------------------------------------------------
80 // Controller Interfaces
81 //-----------------------------------------------------------------------------
82 public:
89
90 //-----------------------------------------------------------------------------
91 // Construction / Destruction
92 //-----------------------------------------------------------------------------
93 private:
97 Driver( string const& _controllerPath, ControllerInterface const& _interface );
102 virtual ~Driver();
103
107 void Start();
111 static void DriverThreadEntryPoint( Event* _exitEvent, void* _context );
130 void DriverThreadProc( Event* _exitEvent );
144 bool Init( uint32 _attempts );
145
150 void RemoveQueues( uint8 const _nodeId );
151
152 Thread* m_driverThread;
153 Mutex* m_initMutex;
154 bool m_exit;
155 bool m_init;
156 bool m_awakeNodesQueried;
157 bool m_allNodesQueried;
158 bool m_notifytransactions;
159 TimeStamp m_startTime;
160
161 //-----------------------------------------------------------------------------
162 // Configuration
163 //-----------------------------------------------------------------------------
164 private:
165 void RequestConfig(); // Get the network configuration from the Z-Wave network
166 bool ReadConfig(); // Read the configuration from a file
167 void WriteConfig(); // Save the configuration to a file
168
169 //-----------------------------------------------------------------------------
170 // Controller
171 //-----------------------------------------------------------------------------
172 private:
173 // Controller Capabilities (return in FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES)
174 enum
175 {
176 ControllerCaps_Secondary = 0x01,
177 ControllerCaps_OnOtherNetwork = 0x02,
178 ControllerCaps_SIS = 0x04,
179 ControllerCaps_RealPrimary = 0x08,
180 ControllerCaps_SUC = 0x10
181 };
182
183 // Init Capabilities (return in FUNC_ID_SERIAL_API_GET_INIT_DATA)
184 enum
185 {
186 InitCaps_Slave = 0x01,
187 InitCaps_TimerSupport = 0x02,
188 InitCaps_Secondary = 0x04,
189 InitCaps_SUC = 0x08
190 };
191
192 bool IsPrimaryController()const{ return ((m_initCaps & InitCaps_Secondary) == 0); }
193 bool IsStaticUpdateController()const{ return ((m_initCaps & InitCaps_SUC) != 0); }
194 bool IsBridgeController()const{ return (m_libraryType == 7); }
195 bool IsInclusionController()const{ return ((m_controllerCaps & ControllerCaps_SIS) != 0); }
196
197
198 uint32 GetHomeId()const{ return m_homeId; }
199 uint8 GetControllerNodeId()const{ return m_Controller_nodeId; }
200 uint8 GetSUCNodeId()const{ return m_SUCNodeId; }
201 uint16 GetManufacturerId()const{ return m_manufacturerId; }
202 uint16 GetProductType()const{ return m_productType; }
203 uint16 GetProductId()const{ return m_productId; }
204 string GetControllerPath()const{ return m_controllerPath; }
205 ControllerInterface GetControllerInterfaceType()const{ return m_controllerInterfaceType; }
206 string GetLibraryVersion()const{ return m_libraryVersion; }
207 string GetLibraryTypeName()const{ return m_libraryTypeName; }
208 int32 GetSendQueueCount()const
209 {
210 int32 count = 0;
211 for( int32 i=0; i<MsgQueue_Count; ++i )
212 {
213 count += (int32) (m_msgQueue[i].size());
214 }
215 return count;
216 }
217
227 Node* GetNodeUnsafe( uint8 _nodeId );
237 Node* GetNode( uint8 _nodeId );
241 //void LockNodes();
245 //void ReleaseNodes();
246
247 ControllerInterface m_controllerInterfaceType; // Specifies the controller's hardware interface
248 string m_controllerPath; // name or path used to open the controller hardware.
249 Controller* m_controller; // Handles communications with the controller hardware.
250 uint32 m_homeId; // Home ID of the Z-Wave controller. Not valid until the DriverReady notification has been received.
251
252 string m_libraryVersion; // Version of the Z-Wave Library used by the controller.
253 string m_libraryTypeName; // Name describing the library type.
254 uint8 m_libraryType; // Type of library used by the controller.
255
256 uint8 m_serialAPIVersion[2];
257 uint16 m_manufacturerId;
258 uint16 m_productType;
259 uint16 m_productId;
260 uint8 m_apiMask[32];
261
262 uint8 m_initVersion; // Version of the Serial API used by the controller.
263 uint8 m_initCaps; // Set of flags indicating the serial API capabilities (See IsSlave, HasTimerSupport, IsPrimaryController and IsStaticUpdateController above).
264 uint8 m_controllerCaps; // Set of flags indicating the controller's capabilities (See IsInclusionController above).
265 uint8 m_Controller_nodeId; // Z-Wave Controller's own node ID.
266 Node* m_nodes[256]; // Array containing all the node objects.
267 Mutex* m_nodeMutex; // Serializes access to node data
268
269 ControllerReplication* m_controllerReplication; // Controller replication is handled separately from the other command classes, due to older hand-held controllers using invalid node IDs.
270
271 uint8 m_transmitOptions;
272
273 //-----------------------------------------------------------------------------
274 // Receiving Z-Wave messages
275 //-----------------------------------------------------------------------------
276 private:
277 bool ReadMsg();
278 void ProcessMsg( uint8* _data );
279
280 void HandleGetVersionResponse( uint8* _data );
281 void HandleGetRandomResponse( uint8* _data );
282 void HandleGetControllerCapabilitiesResponse( uint8* _data );
283 void HandleGetSerialAPICapabilitiesResponse( uint8* _data );
284 void HandleSerialAPISoftResetResponse( uint8* _data );
285 void HandleEnableSUCResponse( uint8* _data );
286 void HandleSetSUCNodeIdResponse( uint8* _data );
287 void HandleGetSUCNodeIdResponse( uint8* _data );
288 void HandleMemoryGetIdResponse( uint8* _data );
301 void HandleSerialAPIGetInitDataResponse( uint8* _data );
302 void HandleGetNodeProtocolInfoResponse( uint8* _data );
303 bool HandleRemoveFailedNodeResponse( uint8* _data );
304 void HandleIsFailedNodeResponse( uint8* _data );
305 bool HandleReplaceFailedNodeResponse( uint8* _data );
306 bool HandleAssignReturnRouteResponse( uint8* _data );
307 bool HandleDeleteReturnRouteResponse( uint8* _data );
308 void HandleSendNodeInformationRequest( uint8* _data );
309 void HandleSendDataResponse( uint8* _data, bool _replication );
310 bool HandleNetworkUpdateResponse( uint8* _data );
311 void HandleGetRoutingInfoResponse( uint8* _data );
312
313 void HandleSendDataRequest( uint8* _data, bool _replication );
314 void HandleAddNodeToNetworkRequest( uint8* _data );
315 void HandleCreateNewPrimaryRequest( uint8* _data );
316 void HandleControllerChangeRequest( uint8* _data );
317 void HandleSetLearnModeRequest( uint8* _data );
318 void HandleRemoveFailedNodeRequest( uint8* _data );
319 void HandleReplaceFailedNodeRequest( uint8* _data );
320 void HandleRemoveNodeFromNetworkRequest( uint8* _data );
321 void HandleApplicationCommandHandlerRequest( uint8* _data, bool encrypted );
322 void HandlePromiscuousApplicationCommandHandlerRequest( uint8* _data );
323 void HandleAssignReturnRouteRequest( uint8* _data );
324 void HandleDeleteReturnRouteRequest( uint8* _data );
325 void HandleNodeNeighborUpdateRequest( uint8* _data );
326 void HandleNetworkUpdateRequest( uint8* _data );
327 bool HandleApplicationUpdateRequest( uint8* _data );
328 bool HandleRfPowerLevelSetResponse( uint8* _data );
329 bool HandleSerialApiSetTimeoutsResponse( uint8* _data );
330 bool HandleMemoryGetByteResponse( uint8* _data );
331 bool HandleReadMemoryResponse( uint8* _data );
332 void HandleGetVirtualNodesResponse( uint8* _data );
333 bool HandleSetSlaveLearnModeResponse( uint8* _data );
334 void HandleSetSlaveLearnModeRequest( uint8* _data );
335 bool HandleSendSlaveNodeInfoResponse( uint8* _data );
336 void HandleSendSlaveNodeInfoRequest( uint8* _data );
337 void HandleApplicationSlaveCommandRequest( uint8* _data );
338 void HandleSerialAPIResetRequest( uint8* _data );
339
340 void CommonAddNodeStatusRequestHandler( uint8 _funcId, uint8* _data );
341
342 bool m_waitingForAck; // True when we are waiting for an ACK from the dongle
343 uint8 m_expectedCallbackId; // If non-zero, we wait for a message with this callback Id
344 uint8 m_expectedReply; // If non-zero, we wait for a message with this function Id
345 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
346 uint8 m_expectedNodeId; // If we are waiting for a FUNC_ID_APPLICATION_COMMAND_HANDLER, make sure we only accept it from this node.
347
348 //-----------------------------------------------------------------------------
349 // Polling Z-Wave devices
350 //-----------------------------------------------------------------------------
351 private:
352 int32 GetPollInterval(){ return m_pollInterval ; }
353 void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls ){ m_pollInterval = _milliseconds; m_bIntervalBetweenPolls = _bIntervalBetweenPolls; }
354 bool EnablePoll( const ValueID &_valueId, uint8 _intensity = 1 );
355 bool DisablePoll( const ValueID &_valueId );
356 bool isPolled( const ValueID &_valueId );
357 void SetPollIntensity( const ValueID &_valueId, uint8 _intensity );
358 static void PollThreadEntryPoint( Event* _exitEvent, void* _context );
359 void PollThreadProc( Event* _exitEvent );
360
361 Thread* m_pollThread; // Thread for polling devices on the Z-Wave network
362 struct PollEntry
363 {
364 ValueID m_id;
365 uint8 m_pollCounter;
366 };
368 list<PollEntry> m_pollList; // List of nodes that need to be polled
370 Mutex* m_pollMutex; // Serialize access to the polling list
371 int32 m_pollInterval; // Time interval during which all nodes must be polled
372 bool m_bIntervalBetweenPolls; // if true, the library intersperses m_pollInterval between polls; if false, the library attempts to complete all polls within m_pollInterval
373
374 //-----------------------------------------------------------------------------
375 // Retrieving Node information
376 //-----------------------------------------------------------------------------
377 public:
378 uint8 GetNodeNumber( Msg const* _msg )const{ return ( _msg == NULL ? 0 : _msg->GetTargetNodeId() ); }
379
380 private:
392 void InitNode( uint8 const _nodeId, bool newNode = false, bool secure = false, uint8 const *_protocolInfo = NULL, uint8 const _length = 0);
393
394 void InitAllNodes(); // Delete all nodes and fetch the data from the Z-Wave network again.
395
396 bool IsNodeListeningDevice( uint8 const _nodeId );
397 bool IsNodeFrequentListeningDevice( uint8 const _nodeId );
398 bool IsNodeBeamingDevice( uint8 const _nodeId );
399 bool IsNodeRoutingDevice( uint8 const _nodeId );
400 bool IsNodeSecurityDevice( uint8 const _nodeId );
401 uint32 GetNodeMaxBaudRate( uint8 const _nodeId );
402 uint8 GetNodeVersion( uint8 const _nodeId );
403 uint8 GetNodeSecurity( uint8 const _nodeId );
404 uint8 GetNodeBasic( uint8 const _nodeId );
405 uint8 GetNodeGeneric( uint8 const _nodeId );
406 uint8 GetNodeSpecific( uint8 const _nodeId );
407 string GetNodeType( uint8 const _nodeId );
408 uint32 GetNodeNeighbors( uint8 const _nodeId, uint8** o_neighbors );
409
410 string GetNodeManufacturerName( uint8 const _nodeId );
411 string GetNodeProductName( uint8 const _nodeId );
412 string GetNodeName( uint8 const _nodeId );
413 string GetNodeLocation( uint8 const _nodeId );
414 uint16 GetNodeDeviceType( uint8 const _nodeId );
415 string GetNodeDeviceTypeString( uint8 const _nodeId );
416 uint8 GetNodeRole( uint8 const _nodeId );
417 string GetNodeRoleString( uint8 const _nodeId );
418 uint8 GetNodePlusType( uint8 const _nodeId );
419 string GetNodePlusTypeString ( uint8 const _nodeId );
420 bool IsNodeZWavePlus( uint8 const _nodeId );
421
422
423 uint16 GetNodeManufacturerId( uint8 const _nodeId );
424 uint16 GetNodeProductType( uint8 const _nodeId );
425 uint16 GetNodeProductId( uint8 const _nodeId );
426 void SetNodeManufacturerName( uint8 const _nodeId, string const& _manufacturerName );
427 void SetNodeProductName( uint8 const _nodeId, string const& _productName );
428 void SetNodeName( uint8 const _nodeId, string const& _nodeName );
429 void SetNodeLocation( uint8 const _nodeId, string const& _location );
430 void SetNodeLevel( uint8 const _nodeId, uint8 const _level );
431 void SetNodeOn( uint8 const _nodeId );
432 void SetNodeOff( uint8 const _nodeId );
433
434 Value* GetValue( ValueID const& _id );
435
436 bool IsAPICallSupported( uint8 const _apinum )const{ return (( m_apiMask[( _apinum - 1 ) >> 3] & ( 1 << (( _apinum - 1 ) & 0x07 ))) != 0 ); }
437 void SetAPICall( uint8 const _apinum, bool _toSet )
438 {
439 if( _toSet )
440 {
441 m_apiMask[( _apinum - 1 ) >> 3] |= ( 1 << (( _apinum - 1 ) & 0x07 ));
442 }
443 else
444 {
445 m_apiMask[( _apinum - 1 ) >> 3] &= ~( 1 << (( _apinum - 1 ) & 0x07 ));
446 }
447 }
448 uint8 NodeFromMessage( uint8 const* buffer );
449
450 //-----------------------------------------------------------------------------
451 // Controller commands
452 //-----------------------------------------------------------------------------
453 public:
479
499
520
521 typedef void (*pfnControllerCallback_t)( ControllerState _state, ControllerError _err, void* _context );
522
523 private:
524 // The public interface is provided via the wrappers in the Manager class
525 void ResetController( Event* _evt );
526 void SoftReset();
527 void RequestNodeNeighbors( uint8 const _nodeId, uint32 const _requestFlags );
528
529 bool BeginControllerCommand( ControllerCommand _command, pfnControllerCallback_t _callback, void* _context, bool _highPower, uint8 _nodeId, uint8 _arg );
530 bool CancelControllerCommand();
531 void AddNodeStop( uint8 const _funcId ); // Handle different controller behaviors
532
533 struct ControllerCommandItem
534 {
535 ControllerState m_controllerState;
536 bool m_controllerStateChanged;
537 bool m_controllerCommandDone;
538 ControllerCommand m_controllerCommand;
539 pfnControllerCallback_t m_controllerCallback;
540 ControllerError m_controllerReturnError;
541 void* m_controllerCallbackContext;
542 bool m_highPower;
543 bool m_controllerAdded;
544 uint8 m_controllerCommandNode;
545 uint8 m_controllerCommandArg;
546 uint8 m_controllerDeviceProtocolInfo[254];
547 uint8 m_controllerDeviceProtocolInfoLength;
548 };
549
550 ControllerCommandItem* m_currentControllerCommand;
551
552 void DoControllerCommand();
553 void UpdateControllerState( ControllerState const _state, ControllerError const _error = ControllerError_None );
554
555 uint8 m_SUCNodeId;
556
557 void UpdateNodeRoutes( uint8 const_nodeId, bool _doUpdate = false );
558
559 Event* m_controllerResetEvent;
560
561 //-----------------------------------------------------------------------------
562 // Sending Z-Wave messages
563 //-----------------------------------------------------------------------------
564 public:
577
578 void SendMsg( Msg* _msg, MsgQueue const _queue );
579
583 uint8 GetTransmitOptions()const{ return m_transmitOptions; }
584
585 private:
603 bool WriteNextMsg( MsgQueue const _queue ); // Extracts the first message from the queue, and makes it the current one.
604 bool WriteMsg( string const &str); // Sends the current message to the Z-Wave network
605 void RemoveCurrentMsg(); // Deletes the current message and cleans up the callback etc states
606 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.
607 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.
608 bool IsExpectedReply( uint8 const _nodeId ); // Determine if reply message is the one we are expecting
609 void SendQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage );
610 void RetryQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage );
611 void CheckCompletedNodeQueries(); // Send notifications if all awake and/or sleeping nodes have completed their queries
612
613 // Requests to be sent to nodes are assigned to one of five queues.
614 // From highest to lowest priority, these are
615 //
616 // 0) The security queue, for handling encrypted messages. This is the
617 // highest priority send queue, because the security process inserts
618 // messages to handle the encryption process that must be sent before
619 // a new message can be wrapped.
620 //
621 // 1) The command queue, for controller commands. This is the 2nd highest
622 // priority send queue, because the controller command processes are not
623 // permitted to be interrupted by other requests.
624 //
625 // 2) The controller queue exists to handle multi-step controller commands. These
626 // typically require user interaction or affect the network in some way.
627 //
628 // 3) The No Operation command class queue. This is used for device probing
629 // at startup as well as network diagnostics.
630 //
631 // 4) The wakeup queue. This holds messages that have been held for a
632 // sleeping device that has now woken up. These get a high priority
633 // because such devices do not stay awake for very long.
634 //
635 // 5) The send queue. This is for normal messages, usually triggered by
636 // a user interaction with the application.
637 //
638 // 6) The query queue. For node query messages sent when a new node is
639 // discovered. The query process generates a large number of requests,
640 // so the query queue has a low priority to avoid making the system
641 // unresponsive.
642 //
643 // 7) The poll queue. Requests to devices that need their state polling
644 // at regular intervals. These are of the lowest priority, and are only
645 // sent when nothing else is going on
646 //
647 enum MsgQueueCmd
648 {
649 MsgQueueCmd_SendMsg = 0,
650 MsgQueueCmd_QueryStageComplete,
651 MsgQueueCmd_Controller
652 };
653
654 class MsgQueueItem
655 {
656 public:
657 MsgQueueItem() :
658 m_msg(NULL),
659 m_nodeId(0),
660 m_queryStage(Node::QueryStage_None),
661 m_retry(false),
662 m_cci(NULL)
663 {}
664
665 bool operator == ( MsgQueueItem const& _other )const
666 {
667 if( _other.m_command == m_command )
668 {
669 if( m_command == MsgQueueCmd_SendMsg )
670 {
671 return( (*_other.m_msg) == (*m_msg) );
672 }
673 else if( m_command == MsgQueueCmd_QueryStageComplete )
674 {
675 return( (_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage) );
676 }
677 else if( m_command == MsgQueueCmd_Controller )
678 {
679 return( (_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback) );
680 }
681 }
682
683 return false;
684 }
685
686 MsgQueueCmd m_command;
687 Msg* m_msg;
688 uint8 m_nodeId;
689 Node::QueryStage m_queryStage;
690 bool m_retry;
691 ControllerCommandItem* m_cci;
692 };
693
695 list<MsgQueueItem> m_msgQueue[MsgQueue_Count];
697 Event* m_queueEvent[MsgQueue_Count]; // Events for each queue, which are signaled when the queue is not empty
698 Mutex* m_sendMutex; // Serialize access to the queues
699 Msg* m_currentMsg;
700 MsgQueue m_currentMsgQueueSource; // identifies which queue held m_currentMsg
701 TimeStamp m_resendTimeStamp;
702
703 //-----------------------------------------------------------------------------
704 // Network functions
705 //-----------------------------------------------------------------------------
706 private:
707 void TestNetwork( uint8 const _nodeId, uint32 const _count );
708
709 //-----------------------------------------------------------------------------
710 // Virtual Node commands
711 //-----------------------------------------------------------------------------
712 public:
717 private:
718 uint32 GetVirtualNeighbors( uint8** o_neighbors );
719 void RequestVirtualNeighbors( MsgQueue const _queue );
720 bool IsVirtualNode( uint8 const _nodeId )const{ return (( m_virtualNeighbors[( _nodeId - 1 ) >> 3] & 1 << (( _nodeId - 1 ) & 0x07 )) != 0 ); }
721 void SendVirtualNodeInfo( uint8 const _fromNodeId, uint8 const _ToNodeId );
722 void SendSlaveLearnModeOff();
723 void SaveButtons();
724 void ReadButtons( uint8 const _nodeId );
725
726 bool m_virtualNeighborsReceived;
727 uint8 m_virtualNeighbors[NUM_NODE_BITFIELD_BYTES]; // Bitmask containing virtual neighbors
728
729 //-----------------------------------------------------------------------------
730 // SwitchAll
731 //-----------------------------------------------------------------------------
732 private:
733 // The public interface is provided via the wrappers in the Manager class
734 void SwitchAllOn();
735 void SwitchAllOff();
736
737 //-----------------------------------------------------------------------------
738 // Configuration Parameters (wrappers for the Node methods)
739 //-----------------------------------------------------------------------------
740 private:
741 // The public interface is provided via the wrappers in the Manager class
742 bool SetConfigParam( uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size );
743 void RequestConfigParam( uint8 const _nodeId, uint8 const _param );
744
745 //-----------------------------------------------------------------------------
746 // Groups (wrappers for the Node methods)
747 //-----------------------------------------------------------------------------
748 private:
749 // The public interface is provided via the wrappers in the Manager class
750 uint8 GetNumGroups( uint8 const _nodeId );
751 uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations );
752 uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, InstanceAssociation** o_associations );
753 uint8 GetMaxAssociations( uint8 const _nodeId, uint8 const _groupIdx );
754 string GetGroupLabel( uint8 const _nodeId, uint8 const _groupIdx );
755 void AddAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
756 void RemoveAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
757
758 //-----------------------------------------------------------------------------
759 // Notifications
760 //-----------------------------------------------------------------------------
761 private:
762 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.
763 void NotifyWatchers(); // Passes the notifications to all the registered watcher callbacks in turn.
764
766 list<Notification*> m_notifications;
768 Event* m_notificationsEvent;
769
770 //-----------------------------------------------------------------------------
771 // Statistics
772 //-----------------------------------------------------------------------------
773 public:
775 {
776 uint32 m_SOFCnt; // Number of SOF bytes received
777 uint32 m_ACKWaiting; // Number of unsolicited messages while waiting for an ACK
778 uint32 m_readAborts; // Number of times read were aborted due to timeouts
779 uint32 m_badChecksum; // Number of bad checksums
780 uint32 m_readCnt; // Number of messages successfully read
781 uint32 m_writeCnt; // Number of messages successfully sent
782 uint32 m_CANCnt; // Number of CAN bytes received
783 uint32 m_NAKCnt; // Number of NAK bytes received
784 uint32 m_ACKCnt; // Number of ACK bytes received
785 uint32 m_OOFCnt; // Number of bytes out of framing
786 uint32 m_dropped; // Number of messages dropped & not delivered
787 uint32 m_retries; // Number of messages retransmitted
788 uint32 m_callbacks; // Number of unexpected callbacks
789 uint32 m_badroutes; // Number of failed messages due to bad route response
790 uint32 m_noack; // Number of no ACK returned errors
791 uint32 m_netbusy; // Number of network busy/failure messages
793 uint32 m_nondelivery; // Number of messages not delivered to network
794 uint32 m_routedbusy; // Number of messages received with routed busy status
795 uint32 m_broadcastReadCnt; // Number of broadcasts read
796 uint32 m_broadcastWriteCnt; // Number of broadcasts sent
797 };
798
799 void LogDriverStatistics();
800
801 private:
802 void GetDriverStatistics( DriverData* _data );
803 void GetNodeStatistics( uint8 const _nodeId, Node::NodeData* _data );
804
805 uint32 m_SOFCnt; // Number of SOF bytes received
806 uint32 m_ACKWaiting; // Number of unsolicited messages while waiting for an ACK
807 uint32 m_readAborts; // Number of times read were aborted due to timeouts
808 uint32 m_badChecksum; // Number of bad checksums
809 uint32 m_readCnt; // Number of messages successfully read
810 uint32 m_writeCnt; // Number of messages successfully sent
811 uint32 m_CANCnt; // Number of CAN bytes received
812 uint32 m_NAKCnt; // Number of NAK bytes received
813 uint32 m_ACKCnt; // Number of ACK bytes received
814 uint32 m_OOFCnt; // Number of bytes out of framing
815 uint32 m_dropped; // Number of messages dropped & not delivered
816 uint32 m_retries; // Number of retransmitted messages
817 uint32 m_callbacks; // Number of unexpected callbacks
818 uint32 m_badroutes; // Number of failed messages due to bad route response
819 uint32 m_noack; // Number of no ACK returned errors
820 uint32 m_netbusy; // Number of network busy/failure messages
821 uint32 m_notidle; // Number of not idle messages
822 uint32 m_nondelivery; // Number of messages not delivered to network
823 uint32 m_routedbusy; // Number of messages received with routed busy status
824 uint32 m_broadcastReadCnt; // Number of broadcasts read
825 uint32 m_broadcastWriteCnt; // Number of broadcasts sent
826 //time_t m_commandStart; // Start time of last command
827 //time_t m_timeoutLost; // Cumulative time lost to timeouts
828
829
830 //-----------------------------------------------------------------------------
831 // Security Command Class Related (Version 1.1)
832 //-----------------------------------------------------------------------------
833 public:
836 bool isNetworkKeySet();
837
838 private:
839 bool initNetworkKeys(bool newnode);
840 uint8 *GetNetworkKey();
841 bool SendEncryptedMessage();
842 bool SendNonceRequest(string logmsg);
843 void SendNonceKey(uint8 nodeId, uint8 *nonce);
844 aes_encrypt_ctx *AuthKey;
845 aes_encrypt_ctx *EncryptKey;
846 uint8 m_nonceReportSent;
847 uint8 m_nonceReportSentAttempt;
848 bool m_inclusionkeySet;
849
850 };
851
852} // namespace OpenZWave
853
854#endif // _Driver_H
unsigned short uint16
Definition Defs.h:77
#define NULL
Definition Defs.h:70
unsigned int uint32
Definition Defs.h:80
signed int int32
Definition Defs.h:79
#define NUM_NODE_BITFIELD_BYTES
Definition Defs.h:225
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition Defs.h:54
#define OPENZWAVE_EXPORT
Definition Defs.h:52
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition Defs.h:53
unsigned char uint8
Definition Defs.h:74
Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class.
Definition ControllerReplication.h:38
Definition Controller.h:42
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition Driver.h:59
friend class SceneActivation
Definition Driver.h:74
uint8 GetNodeNumber(Msg const *_msg) const
Definition Driver.h:378
ControllerError
Definition Driver.h:505
@ ControllerError_Busy
Definition Driver.h:515
@ ControllerError_Disabled
Definition Driver.h:517
@ ControllerError_NotSecondary
Definition Driver.h:511
@ ControllerError_NotPrimary
Definition Driver.h:512
@ ControllerError_IsPrimary
Definition Driver.h:513
@ ControllerError_None
Definition Driver.h:506
@ ControllerError_Failed
Definition Driver.h:516
@ ControllerError_NodeNotFound
Definition Driver.h:508
@ ControllerError_NotBridge
Definition Driver.h:509
@ ControllerError_Overflow
Definition Driver.h:518
@ ControllerError_NotSUC
Definition Driver.h:510
@ ControllerError_ButtonNotFound
Definition Driver.h:507
@ ControllerError_NotFound
Definition Driver.h:514
friend class CommandClass
Definition Driver.h:63
aes_encrypt_ctx * GetAuthKey()
Definition Driver.cpp:6945
friend class NoOperation
Definition Driver.h:73
friend class Group
Definition Driver.h:62
uint8 GetTransmitOptions() const
Definition Driver.h:583
friend class Association
Definition Driver.h:68
friend class MultiChannelAssociation
Definition Driver.h:71
ControllerState
Definition Driver.h:486
@ ControllerState_Failed
Definition Driver.h:495
@ ControllerState_NodeOK
Definition Driver.h:496
@ ControllerState_Completed
Definition Driver.h:494
@ ControllerState_Waiting
Definition Driver.h:491
@ ControllerState_InProgress
Definition Driver.h:493
@ ControllerState_Cancel
Definition Driver.h:489
@ ControllerState_Normal
Definition Driver.h:487
@ ControllerState_Sleeping
Definition Driver.h:492
@ ControllerState_Starting
Definition Driver.h:488
@ ControllerState_Error
Definition Driver.h:490
@ ControllerState_NodeFailed
Definition Driver.h:497
friend class Basic
Definition Driver.h:69
MsgQueue
Definition Driver.h:566
@ MsgQueue_Query
Definition Driver.h:573
@ MsgQueue_Count
Definition Driver.h:575
@ MsgQueue_Send
Definition Driver.h:572
@ MsgQueue_Controller
Definition Driver.h:570
@ MsgQueue_NoOp
Definition Driver.h:569
@ MsgQueue_Command
Definition Driver.h:567
@ MsgQueue_Poll
Definition Driver.h:574
@ MsgQueue_Security
Definition Driver.h:568
@ MsgQueue_WakeUp
Definition Driver.h:571
friend class ManufacturerSpecific
Definition Driver.h:70
bool isNetworkKeySet()
Definition Driver.cpp:6974
friend class Node
Definition Driver.h:61
void(* pfnControllerCallback_t)(ControllerState _state, ControllerError _err, void *_context)
Definition Driver.h:521
friend class NodeNaming
Definition Driver.h:72
friend class ControllerReplication
Definition Driver.h:64
friend class Msg
Definition Driver.h:77
friend class Security
Definition Driver.h:76
ControllerInterface
Definition Driver.h:84
@ ControllerInterface_Unknown
Definition Driver.h:85
@ ControllerInterface_Hid
Definition Driver.h:87
@ ControllerInterface_Serial
Definition Driver.h:86
friend class ValueStore
Definition Driver.h:66
friend class WakeUp
Definition Driver.h:75
ControllerCommand
Definition Driver.h:460
@ ControllerCommand_None
Definition Driver.h:461
@ ControllerCommand_RemoveFailedNode
Definition Driver.h:466
@ ControllerCommand_AssignReturnRoute
Definition Driver.h:472
@ ControllerCommand_RequestNetworkUpdate
Definition Driver.h:470
@ ControllerCommand_RemoveDevice
Definition Driver.h:465
@ ControllerCommand_ReplicationSend
Definition Driver.h:475
@ ControllerCommand_RequestNodeNeighborUpdate
Definition Driver.h:471
@ ControllerCommand_TransferPrimaryRole
Definition Driver.h:469
@ ControllerCommand_ReplaceFailedNode
Definition Driver.h:468
@ ControllerCommand_CreateNewPrimary
Definition Driver.h:463
@ ControllerCommand_DeleteAllReturnRoutes
Definition Driver.h:473
@ ControllerCommand_SendNodeInformation
Definition Driver.h:474
@ ControllerCommand_DeleteButton
Definition Driver.h:477
@ ControllerCommand_ReceiveConfiguration
Definition Driver.h:464
@ ControllerCommand_CreateButton
Definition Driver.h:476
@ ControllerCommand_HasNodeFailed
Definition Driver.h:467
@ ControllerCommand_AddDevice
Definition Driver.h:462
aes_encrypt_ctx * GetEncKey()
Definition Driver.cpp:6959
friend class Manager
Definition Driver.h:60
friend class Value
Definition Driver.h:65
friend class ValueButton
Definition Driver.h:67
void LogDriverStatistics()
Definition Driver.cpp:6721
Platform-independent definition of event objects.
Definition Event.h:40
Message object to be passed to and from devices on the Z-Wave network.
Definition Msg.h:45
uint8 GetTargetNodeId() const
Identifies the Node ID of the "target" node (if any) for this function.
Definition Msg.h:66
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition Mutex.h:40
QueryStage
Definition Node.h:135
Provides a container for data sent via the notification callback handler installed by a call to Manag...
Definition Notification.h:43
Implements a platform-independent thread management class.
Definition Thread.h:43
Implements a platform-independent TimeStamp.
Definition TimeStamp.h:40
Provides a unique ID for a value reported by a Z-Wave device.
Definition ValueID.h:54
Base class for values associated with a node.
Definition Value.h:48
Definition Bitfield.h:35
Definition Driver.h:775
uint32 m_noack
Definition Driver.h:790
uint32 m_retries
Definition Driver.h:787
uint32 m_badroutes
Definition Driver.h:789
uint32 m_netbusy
Definition Driver.h:791
uint32 m_readAborts
Definition Driver.h:778
uint32 m_CANCnt
Definition Driver.h:782
uint32 m_broadcastWriteCnt
Definition Driver.h:796
uint32 m_nondelivery
Definition Driver.h:793
uint32 m_writeCnt
Definition Driver.h:781
uint32 m_callbacks
Definition Driver.h:788
uint32 m_routedbusy
Definition Driver.h:794
uint32 m_dropped
Definition Driver.h:786
uint32 m_ACKCnt
Definition Driver.h:784
uint32 m_SOFCnt
Definition Driver.h:776
uint32 m_badChecksum
Definition Driver.h:779
uint32 m_OOFCnt
Definition Driver.h:785
uint32 m_broadcastReadCnt
Definition Driver.h:795
uint32 m_readCnt
Definition Driver.h:780
uint32 m_ACKWaiting
Definition Driver.h:777
uint32 m_notidle
Definition Driver.h:792
uint32 m_NAKCnt
Definition Driver.h:783
Definition Node.h:577
Definition aes.h:83