43#include "aes/aescpp.h"
52 class ApplicationStatus;
56 class ControllerReplication;
57 class ManufacturerSpecific;
58 class MultiChannelAssociation;
61 class SceneActivation;
76 class ManufacturerSpecificDB;
105 friend class TimerThread;
113 ControllerInterface_Unknown = 0,
115 ControllerInterface_Hid
125 Driver(
string const& _controllerPath, ControllerInterface
const& _interface);
172 bool Init(
uint32 _attempts);
178 void RemoveQueues(
uint8 const _nodeId);
186 bool m_awakeNodesQueried;
187 bool m_allNodesQueried;
188 bool m_notifytransactions;
195 void RequestConfig();
219 ControllerCaps_Secondary = 0x01,
220 ControllerCaps_OnOtherNetwork = 0x02,
221 ControllerCaps_SIS = 0x04,
222 ControllerCaps_RealPrimary = 0x08,
223 ControllerCaps_SUC = 0x10
229 InitCaps_Slave = 0x01,
230 InitCaps_TimerSupport = 0x02,
231 InitCaps_Secondary = 0x04,
235 bool IsPrimaryController()
const
237 return ((m_initCaps & InitCaps_Secondary) == 0);
239 bool IsStaticUpdateController()
const
241 return ((m_initCaps & InitCaps_SUC) != 0);
243 bool IsBridgeController()
const
245 return (m_libraryType == 7);
247 bool IsInclusionController()
const
249 return ((m_controllerCaps & ControllerCaps_SIS) != 0);
252 bool HasExtendedTxStatus()
const
254 return m_hasExtendedTxStatus;
261 uint8 GetControllerNodeId()
const
263 return m_Controller_nodeId;
265 uint8 GetSUCNodeId()
const
269 uint16 GetManufacturerId()
const
271 return m_manufacturerId;
273 uint16 GetProductType()
const
275 return m_productType;
277 uint16 GetProductId()
const
281 string GetControllerPath()
const
283 return m_controllerPath;
285 ControllerInterface GetControllerInterfaceType()
const
287 return m_controllerInterfaceType;
289 string GetLibraryVersion()
const
291 return m_libraryVersion;
293 string GetLibraryTypeName()
const
295 return m_libraryTypeName;
297 int32 GetSendQueueCount()
const
300 for (
int32 i = 0; i < MsgQueue_Count; ++i)
302 count += (
int32) (m_msgQueue[i].size());
316 Node* GetNodeUnsafe(
uint8 _nodeId);
325 Node* GetNode(
uint8 _nodeId);
327 ControllerInterface m_controllerInterfaceType;
328 string m_controllerPath;
329 Internal::Platform::Controller* m_controller;
331 string m_libraryVersion;
332 string m_libraryTypeName;
335 uint8 m_serialAPIVersion[2];
343 uint8 m_controllerCaps;
344 bool m_hasExtendedTxStatus;
345 uint8 m_Controller_nodeId;
347 Internal::Platform::Mutex* m_nodeMutex;
349 Internal::CC::ControllerReplication* m_controllerReplication;
351 uint8 m_transmitOptions;
360 void HandleGetVersionResponse(
uint8* _data);
361 void HandleGetRandomResponse(
uint8* _data);
362 void HandleSerialAPISetupResponse(
uint8* _data);
363 void HandleGetControllerCapabilitiesResponse(
uint8* _data);
364 void HandleGetSerialAPICapabilitiesResponse(
uint8* _data);
365 void HandleSerialAPISoftResetResponse(
uint8* _data);
366 void HandleEnableSUCResponse(
uint8* _data);
367 void HandleSetSUCNodeIdResponse(
uint8* _data);
368 void HandleGetSUCNodeIdResponse(
uint8* _data);
369 void HandleMemoryGetIdResponse(
uint8* _data);
382 void HandleSerialAPIGetInitDataResponse(
uint8* _data);
383 void HandleGetNodeProtocolInfoResponse(
uint8* _data);
384 bool HandleRemoveFailedNodeResponse(
uint8* _data);
385 void HandleIsFailedNodeResponse(
uint8* _data);
386 bool HandleReplaceFailedNodeResponse(
uint8* _data);
387 bool HandleAssignReturnRouteResponse(
uint8* _data);
388 bool HandleDeleteReturnRouteResponse(
uint8* _data);
389 void HandleSendNodeInformationRequest(
uint8* _data);
390 void HandleSendDataResponse(
uint8* _data,
bool _replication);
391 bool HandleNetworkUpdateResponse(
uint8* _data);
392 void HandleGetRoutingInfoResponse(
uint8* _data);
394 void HandleSendDataRequest(
uint8* _data,
uint8 _length,
bool _replication);
395 void HandleAddNodeToNetworkRequest(
uint8* _data);
396 void HandleCreateNewPrimaryRequest(
uint8* _data);
397 void HandleControllerChangeRequest(
uint8* _data);
398 void HandleSetLearnModeRequest(
uint8* _data);
399 void HandleRemoveFailedNodeRequest(
uint8* _data);
400 void HandleReplaceFailedNodeRequest(
uint8* _data);
401 void HandleRemoveNodeFromNetworkRequest(
uint8* _data);
402 void HandleApplicationCommandHandlerRequest(
uint8* _data,
bool encrypted);
403 void HandlePromiscuousApplicationCommandHandlerRequest(
uint8* _data);
404 void HandleAssignReturnRouteRequest(
uint8* _data);
405 void HandleDeleteReturnRouteRequest(
uint8* _data);
406 void HandleNodeNeighborUpdateRequest(
uint8* _data);
407 void HandleNetworkUpdateRequest(
uint8* _data);
408 bool HandleApplicationUpdateRequest(
uint8* _data);
409 bool HandleRfPowerLevelSetResponse(
uint8* _data);
410 bool HandleSerialApiSetTimeoutsResponse(
uint8* _data);
411 bool HandleMemoryGetByteResponse(
uint8* _data);
412 bool HandleReadMemoryResponse(
uint8* _data);
413 void HandleGetVirtualNodesResponse(
uint8* _data);
414 bool HandleSetSlaveLearnModeResponse(
uint8* _data);
415 void HandleSetSlaveLearnModeRequest(
uint8* _data);
416 bool HandleSendSlaveNodeInfoResponse(
uint8* _data);
417 void HandleSendSlaveNodeInfoRequest(
uint8* _data);
418 void HandleApplicationSlaveCommandRequest(
uint8* _data);
419 void HandleSerialAPIResetRequest(
uint8* _data);
421 void CommonAddNodeStatusRequestHandler(
uint8 _funcId,
uint8* _data);
423 bool m_waitingForAck;
424 uint8 m_expectedCallbackId;
425 uint8 m_expectedReply;
426 uint8 m_expectedCommandClassId;
427 uint8 m_expectedNodeId;
433 int32 GetPollInterval()
435 return m_pollInterval;
437 void SetPollInterval(
int32 _milliseconds,
bool _bIntervalBetweenPolls)
439 m_pollInterval = _milliseconds;
440 m_bIntervalBetweenPolls = _bIntervalBetweenPolls;
442 bool EnablePoll(
const ValueID &_valueId,
uint8 _intensity = 1);
443 bool DisablePoll(
const ValueID &_valueId);
444 bool isPolled(
const ValueID &_valueId);
445 void SetPollIntensity(
const ValueID &_valueId,
uint8 _intensity);
446 static void PollThreadEntryPoint(Internal::Platform::Event* _exitEvent,
void* _context);
447 void PollThreadProc(Internal::Platform::Event* _exitEvent);
449 Internal::Platform::Thread* m_pollThread;
455 list<PollEntry> m_pollList;
456 Internal::Platform::Mutex* m_pollMutex;
457 int32 m_pollInterval;
458 bool m_bIntervalBetweenPolls;
481 void InitNode(
uint8 const _nodeId,
bool newNode =
false,
bool secure =
false,
uint8 const *_protocolInfo =
NULL,
uint8 const _length = 0);
485 bool IsNodeListeningDevice(
uint8 const _nodeId);
486 bool IsNodeFrequentListeningDevice(
uint8 const _nodeId);
487 bool IsNodeBeamingDevice(
uint8 const _nodeId);
488 bool IsNodeRoutingDevice(
uint8 const _nodeId);
489 bool IsNodeSecurityDevice(
uint8 const _nodeId);
494 string GetNodeBasicString(
uint8 const _nodeId);
496 string GetNodeGenericString(
uint8 const _nodeId,
uint8 _instance);
498 string GetNodeSpecificString(
uint8 const _nodeId,
uint8 _instance);
499 string GetNodeType(
uint8 const _nodeId);
502 string GetNodeManufacturerName(
uint8 const _nodeId);
503 string GetNodeProductName(
uint8 const _nodeId);
504 string GetNodeName(
uint8 const _nodeId);
505 string GetNodeLocation(
uint8 const _nodeId);
507 string GetNodeDeviceTypeString(
uint8 const _nodeId);
509 string GetNodeRoleString(
uint8 const _nodeId);
511 string GetNodePlusTypeString(
uint8 const _nodeId);
512 bool IsNodeZWavePlus(
uint8 const _nodeId);
517 void SetNodeManufacturerName(
uint8 const _nodeId,
string const& _manufacturerName);
518 void SetNodeProductName(
uint8 const _nodeId,
string const& _productName);
519 void SetNodeName(
uint8 const _nodeId,
string const& _nodeName);
520 void SetNodeLocation(
uint8 const _nodeId,
string const& _location);
521 void SetNodeLevel(
uint8 const _nodeId,
uint8 const _level);
522 void SetNodeOn(
uint8 const _nodeId);
523 void SetNodeOff(
uint8 const _nodeId);
527 bool IsAPICallSupported(
uint8 const _apinum)
const
529 return ((m_apiMask[(_apinum - 1) >> 3] & (1 << ((_apinum - 1) & 0x07))) != 0);
531 void SetAPICall(
uint8 const _apinum,
bool _toSet)
535 m_apiMask[(_apinum - 1) >> 3] |= (1 << ((_apinum - 1) & 0x07));
539 m_apiMask[(_apinum - 1) >> 3] &= ~(1 << ((_apinum - 1) & 0x07));
555 ControllerCommand_None = 0,
571 ControllerCommand_DeleteButton
581 ControllerState_Normal = 0,
591 ControllerState_NodeFailed
600 ControllerError_None = 0,
612 ControllerError_Overflow
621 void RequestNodeNeighbors(
uint8 const _nodeId,
uint32 const _requestFlags);
623 bool BeginControllerCommand(
ControllerCommand _command, pfnControllerCallback_t _callback,
void* _context,
bool _highPower,
uint8 _nodeId,
uint8 _arg);
624 bool CancelControllerCommand();
625 void AddNodeStop(
uint8 const _funcId);
627 struct ControllerCommandItem
630 bool m_controllerStateChanged;
631 bool m_controllerCommandDone;
633 pfnControllerCallback_t m_controllerCallback;
635 void* m_controllerCallbackContext;
637 bool m_controllerAdded;
638 uint8 m_controllerCommandNode;
639 uint8 m_controllerCommandArg;
640 uint8 m_controllerDeviceProtocolInfo[254];
641 uint8 m_controllerDeviceProtocolInfoLength;
644 ControllerCommandItem* m_currentControllerCommand;
646 void DoControllerCommand();
647 void UpdateControllerState(ControllerState
const _state, ControllerError
const _error = ControllerError_None);
651 void UpdateNodeRoutes(
uint8 const_nodeId,
bool _doUpdate =
false);
661 MsgQueue_Command = 0,
678 return m_transmitOptions;
699 bool WriteNextMsg(MsgQueue
const _queue);
700 bool WriteMsg(
string const &str);
701 void RemoveCurrentMsg();
702 bool MoveMessagesToWakeUpQueue(
uint8 const _targetNodeId,
bool const _move);
703 bool HandleErrorResponse(
uint8 const _error,
uint8 const _nodeId,
char const* _funcStr,
bool _sleepCheck =
false);
704 bool IsExpectedReply(
uint8 const _nodeId);
707 void CheckCompletedNodeQueries();
745 MsgQueueCmd_SendMsg = 0,
746 MsgQueueCmd_QueryStageComplete,
747 MsgQueueCmd_Controller,
748 MsgQueueCmd_ReloadNode
755 m_msg(
NULL), m_nodeId(0), m_queryStage(Node::QueryStage_None), m_retry(false), m_cci(
NULL)
759 bool operator ==(MsgQueueItem
const& _other)
const
761 if (_other.m_command == m_command)
763 if (m_command == MsgQueueCmd_SendMsg)
765 return ((*_other.m_msg) == (*m_msg));
767 else if (m_command == MsgQueueCmd_QueryStageComplete)
769 return ((_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage));
771 else if (m_command == MsgQueueCmd_Controller)
773 return ((_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback));
775 else if (m_command == MsgQueueCmd_ReloadNode)
777 return (_other.m_nodeId == m_nodeId);
785 MsgQueueCmd m_command;
786 Internal::Msg* m_msg;
790 ControllerCommandItem* m_cci;
793 list<MsgQueueItem> m_msgQueue[MsgQueue_Count];
794 Internal::Platform::Event* m_queueEvent[MsgQueue_Count];
795 Internal::Platform::Mutex* m_sendMutex;
796 Internal::Msg* m_currentMsg;
797 MsgQueue m_currentMsgQueueSource;
798 Internal::Platform::TimeStamp m_resendTimeStamp;
804 void TestNetwork(
uint8 const _nodeId,
uint32 const _count);
816 void RequestVirtualNeighbors(MsgQueue
const _queue);
817 bool IsVirtualNode(
uint8 const _nodeId)
const
819 return ((m_virtualNeighbors[(_nodeId - 1) >> 3] & 1 << ((_nodeId - 1) & 0x07)) != 0);
821 void SendVirtualNodeInfo(
uint8 const _fromNodeId,
uint8 const _ToNodeId);
822 void SendSlaveLearnModeOff();
824 void ReadButtons(
uint8 const _nodeId);
826 bool m_virtualNeighborsReceived;
843 void RequestConfigParam(
uint8 const _nodeId,
uint8 const _param);
854 bool IsMultiInstance(
uint8 const _nodeId,
uint8 const _groupIdx);
855 string GetGroupLabel(
uint8 const _nodeId,
uint8 const _groupIdx);
856 void AddAssociation(
uint8 const _nodeId,
uint8 const _groupIdx,
uint8 const _targetNodeId,
uint8 const _instance = 0x00);
857 void RemoveAssociation(
uint8 const _nodeId,
uint8 const _groupIdx,
uint8 const _targetNodeId,
uint8 const _instance = 0x00);
863 void QueueNotification(Notification* _notification);
864 void NotifyWatchers();
865 list<Notification*> m_notifications;
866 Internal::Platform::Event* m_notificationsEvent;
897 void LogDriverStatistics();
923 uint32 m_broadcastReadCnt;
924 uint32 m_broadcastWriteCnt;
932 aes_encrypt_ctx *GetAuthKey();
933 aes_encrypt_ctx *GetEncKey();
934 bool isNetworkKeySet();
937 bool initNetworkKeys(
bool newnode);
938 uint8 *GetNetworkKey();
939 bool SendEncryptedMessage();
940 bool SendNonceRequest(
string logmsg);
941 void SendNonceKey(
uint8 nodeId,
uint8 *nonce);
942 aes_encrypt_ctx *AuthKey;
943 aes_encrypt_ctx *EncryptKey;
944 uint8 m_nonceReportSent;
945 uint8 m_nonceReportSentAttempt;
946 bool m_inclusionkeySet;
967 void SubmitEventMsg(EventMsg *);
968 void ProcessEventMsg();
969 list<EventMsg *> m_eventQueueMsg;
970 Internal::Platform::Event* m_queueMsgEvent;
971 Internal::Platform::Mutex* m_eventMutex;
978 bool CheckNodeConfigRevision(Node *);
979 bool CheckMFSConfigRevision();
980 void ReloadNode(
uint8 const _nodeId);
983 void processConfigRevision(Internal::DNSLookup *);
990 bool setHttpClient(Internal::i_HttpClient *client);
992 bool startConfigDownload(
uint16 _manufacturerId,
uint16 _productType,
uint16 _productId,
string configfile,
uint8 node = 0);
993 bool startDownload(
string target,
string file);
994 bool startMFSDownload(
string configfile);
995 bool refreshNodeConfig(
uint8 node);
996 void processDownload(Internal::HttpDownload *);
997 Internal::i_HttpClient *m_httpClient;
1005 Node::ChangeLogEntry
const GetChangeLog(
uint8 const _nodeId, uint32_t revision);
1012 Internal::ManufacturerSpecificDB *GetManufacturerSpecificDB();
1013 bool downloadConfigRevision(Node *);
1014 bool downloadMFSRevision();
1016 Internal::ManufacturerSpecificDB *m_mfs;
unsigned short uint16
Definition: Defs.h:88
#define NULL
Definition: Defs.h:81
unsigned int uint32
Definition: Defs.h:91
signed int int32
Definition: Defs.h:90
#define NUM_NODE_BITFIELD_BYTES
Definition: Defs.h:236
#define OPENZWAVE_EXPORT
Definition: Defs.h:52
unsigned char uint8
Definition: Defs.h:85
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:85
ControllerError
Definition: Driver.h:599
@ ControllerError_Busy
Definition: Driver.h:609
@ ControllerError_Disabled
Definition: Driver.h:611
@ ControllerError_NotSecondary
Definition: Driver.h:605
@ ControllerError_NotPrimary
Definition: Driver.h:606
@ ControllerError_IsPrimary
Definition: Driver.h:607
@ ControllerError_Failed
Definition: Driver.h:610
@ ControllerError_NodeNotFound
Definition: Driver.h:602
@ ControllerError_NotBridge
Definition: Driver.h:603
@ ControllerError_NotSUC
Definition: Driver.h:604
@ ControllerError_ButtonNotFound
Definition: Driver.h:601
@ ControllerError_NotFound
Definition: Driver.h:608
uint8 GetTransmitOptions() const
Definition: Driver.h:676
ControllerState
Definition: Driver.h:580
@ ControllerState_Failed
Definition: Driver.h:589
@ ControllerState_NodeOK
Definition: Driver.h:590
@ ControllerState_Completed
Definition: Driver.h:588
@ ControllerState_Waiting
Definition: Driver.h:585
@ ControllerState_InProgress
Definition: Driver.h:587
@ ControllerState_Cancel
Definition: Driver.h:583
@ ControllerState_Sleeping
Definition: Driver.h:586
@ ControllerState_Starting
Definition: Driver.h:582
@ ControllerState_Error
Definition: Driver.h:584
MsgQueue
Definition: Driver.h:660
@ MsgQueue_Query
Definition: Driver.h:666
@ MsgQueue_Send
Definition: Driver.h:665
@ MsgQueue_Controller
Definition: Driver.h:663
@ MsgQueue_NoOp
Definition: Driver.h:662
@ MsgQueue_Poll
Definition: Driver.h:667
@ MsgQueue_WakeUp
Definition: Driver.h:664
uint8 GetNodeNumber(Internal::Msg const *_msg) const
Definition: Driver.h:464
ControllerInterface
Definition: Driver.h:112
@ ControllerInterface_Serial
Definition: Driver.h:114
ControllerCommand
Definition: Driver.h:554
@ ControllerCommand_RemoveFailedNode
Definition: Driver.h:560
@ ControllerCommand_AssignReturnRoute
Definition: Driver.h:566
@ ControllerCommand_RequestNetworkUpdate
Definition: Driver.h:564
@ ControllerCommand_RemoveDevice
Definition: Driver.h:559
@ ControllerCommand_ReplicationSend
Definition: Driver.h:569
@ ControllerCommand_RequestNodeNeighborUpdate
Definition: Driver.h:565
@ ControllerCommand_TransferPrimaryRole
Definition: Driver.h:563
@ ControllerCommand_ReplaceFailedNode
Definition: Driver.h:562
@ ControllerCommand_CreateNewPrimary
Definition: Driver.h:557
@ ControllerCommand_DeleteAllReturnRoutes
Definition: Driver.h:567
@ ControllerCommand_SendNodeInformation
Definition: Driver.h:568
@ ControllerCommand_ReceiveConfiguration
Definition: Driver.h:558
@ ControllerCommand_CreateButton
Definition: Driver.h:570
@ ControllerCommand_HasNodeFailed
Definition: Driver.h:561
@ ControllerCommand_AddDevice
Definition: Driver.h:556
Internal::TimerThread * GetTimer()
Definition: Driver.h:207
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:72
Implements COMMAND_CLASS_APPLICATION_STATUS (0x22), a Z-Wave device command class.
Definition: ApplicationStatus.h:43
Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class.
Definition: Basic.h:43
Base class for all Z-Wave command classes.
Definition: CommandClass.h:61
Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class.
Definition: ControllerReplication.h:44
Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class.
Definition: ManufacturerSpecific.h:45
Implements COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION (0x8E), a Z-Wave device command class.
Definition: MultiChannelAssociation.h:46
Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
Definition: NodeNaming.h:57
Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class.
Definition: SceneActivation.h:45
Implements COMMAND_CLASS_SECURITY (0x98), a Z-Wave device command class.
Definition: Security.h:67
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:52
the DNSThread provides Async DNS lookups for checking revision numbers of Config Files against the of...
Definition: DNSThread.h:72
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices.
Definition: ManufacturerSpecificDB.h:117
Message object to be passed to and from devices on the Z-Wave network.
Definition: Msg.h:51
uint8 GetTargetNodeId() const
Identifies the Node ID of the "target" node (if any) for this function.
Definition: Msg.h:75
The TimerThread class makes it possible to schedule events to happen at a certain time in the future.
Definition: TimerThread.h:56
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:50
Base class for values associated with a node.
Definition: Value.h:55
The main public interface to OpenZWave.
Definition: Manager.h:109
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:82
QueryStage
Definition: Node.h:126
MetaDataFields
Definition: Node.h:879
Provides a unique ID for a value reported by a Z-Wave device.
Definition: ValueID.h:77
Definition: Bitfield.cpp:31
struct OpenZWave::InstanceAssociation InstanceAssociation
uint32 m_noack
Definition: Driver.h:888
uint32 m_retries
Definition: Driver.h:885
uint32 m_badroutes
Definition: Driver.h:887
uint32 m_netbusy
Definition: Driver.h:889
uint32 m_readAborts
Definition: Driver.h:876
uint32 m_CANCnt
Definition: Driver.h:880
uint32 m_broadcastWriteCnt
Definition: Driver.h:895
uint32 m_nondelivery
Definition: Driver.h:892
uint32 m_writeCnt
Definition: Driver.h:879
uint32 m_callbacks
Definition: Driver.h:886
uint32 m_routedbusy
Definition: Driver.h:893
uint32 m_dropped
Definition: Driver.h:884
uint32 m_ACKCnt
Definition: Driver.h:882
uint32 m_SOFCnt
Definition: Driver.h:874
uint32 m_badChecksum
Definition: Driver.h:877
uint32 m_OOFCnt
Definition: Driver.h:883
uint32 m_broadcastReadCnt
Definition: Driver.h:894
uint32 m_readCnt
Definition: Driver.h:878
uint32 m_ACKWaiting
Definition: Driver.h:875
uint32 m_notidle
Definition: Driver.h:890
uint32 m_txverified
Definition: Driver.h:891
uint32 m_NAKCnt
Definition: Driver.h:881
Definition: DNSThread.h:59