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