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;
332 string m_libraryVersion;
333 string m_libraryTypeName;
336 uint8 m_serialAPIVersion[2];
344 uint8 m_controllerCaps;
345 bool m_hasExtendedTxStatus;
346 uint8 m_Controller_nodeId;
348 Internal::Platform::Mutex* m_nodeMutex;
350 Internal::CC::ControllerReplication* m_controllerReplication;
352 uint8 m_transmitOptions;
361 void HandleGetVersionResponse(
uint8* _data);
362 void HandleGetRandomResponse(
uint8* _data);
363 void HandleSerialAPISetupResponse(
uint8* _data);
364 void HandleGetControllerCapabilitiesResponse(
uint8* _data);
365 void HandleGetSerialAPICapabilitiesResponse(
uint8* _data);
366 void HandleSerialAPISoftResetResponse(
uint8* _data);
367 void HandleEnableSUCResponse(
uint8* _data);
368 void HandleSetSUCNodeIdResponse(
uint8* _data);
369 void HandleGetSUCNodeIdResponse(
uint8* _data);
370 void HandleMemoryGetIdResponse(
uint8* _data);
383 void HandleSerialAPIGetInitDataResponse(
uint8* _data);
384 void HandleGetNodeProtocolInfoResponse(
uint8* _data);
385 bool HandleRemoveFailedNodeResponse(
uint8* _data);
386 void HandleIsFailedNodeResponse(
uint8* _data);
387 bool HandleReplaceFailedNodeResponse(
uint8* _data);
388 bool HandleAssignReturnRouteResponse(
uint8* _data);
389 bool HandleDeleteReturnRouteResponse(
uint8* _data);
390 void HandleSendNodeInformationRequest(
uint8* _data);
391 void HandleSendDataResponse(
uint8* _data,
bool _replication);
392 bool HandleNetworkUpdateResponse(
uint8* _data);
393 void HandleGetRoutingInfoResponse(
uint8* _data);
395 void HandleSendDataRequest(
uint8* _data,
uint8 _length,
bool _replication);
396 void HandleAddNodeToNetworkRequest(
uint8* _data);
397 void HandleCreateNewPrimaryRequest(
uint8* _data);
398 void HandleControllerChangeRequest(
uint8* _data);
399 void HandleSetLearnModeRequest(
uint8* _data);
400 void HandleRemoveFailedNodeRequest(
uint8* _data);
401 void HandleReplaceFailedNodeRequest(
uint8* _data);
402 void HandleRemoveNodeFromNetworkRequest(
uint8* _data);
403 void HandleApplicationCommandHandlerRequest(
uint8* _data,
bool encrypted);
404 void HandlePromiscuousApplicationCommandHandlerRequest(
uint8* _data);
405 void HandleAssignReturnRouteRequest(
uint8* _data);
406 void HandleDeleteReturnRouteRequest(
uint8* _data);
407 void HandleNodeNeighborUpdateRequest(
uint8* _data);
408 void HandleNetworkUpdateRequest(
uint8* _data);
409 bool HandleApplicationUpdateRequest(
uint8* _data);
410 bool HandleRfPowerLevelSetResponse(
uint8* _data);
411 bool HandleSerialApiSetTimeoutsResponse(
uint8* _data);
412 bool HandleMemoryGetByteResponse(
uint8* _data);
413 bool HandleReadMemoryResponse(
uint8* _data);
414 void HandleGetVirtualNodesResponse(
uint8* _data);
415 bool HandleSetSlaveLearnModeResponse(
uint8* _data);
416 void HandleSetSlaveLearnModeRequest(
uint8* _data);
417 bool HandleSendSlaveNodeInfoResponse(
uint8* _data);
418 void HandleSendSlaveNodeInfoRequest(
uint8* _data);
419 void HandleApplicationSlaveCommandRequest(
uint8* _data);
420 void HandleSerialAPIResetRequest(
uint8* _data);
422 void CommonAddNodeStatusRequestHandler(
uint8 _funcId,
uint8* _data);
424 bool m_waitingForAck;
425 uint8 m_expectedCallbackId;
426 uint8 m_expectedReply;
427 uint8 m_expectedCommandClassId;
428 uint8 m_expectedNodeId;
434 int32 GetPollInterval()
436 return m_pollInterval;
438 void SetPollInterval(
int32 _milliseconds,
bool _bIntervalBetweenPolls)
440 m_pollInterval = _milliseconds;
441 m_bIntervalBetweenPolls = _bIntervalBetweenPolls;
443 bool EnablePoll(
const ValueID &_valueId,
uint8 _intensity = 1);
444 bool DisablePoll(
const ValueID &_valueId);
445 bool isPolled(
const ValueID &_valueId);
446 void SetPollIntensity(
const ValueID &_valueId,
uint8 _intensity);
447 static void PollThreadEntryPoint(Internal::Platform::Event* _exitEvent,
void* _context);
448 void PollThreadProc(Internal::Platform::Event* _exitEvent);
450 Internal::Platform::Thread* m_pollThread;
456 list<PollEntry> m_pollList;
458 Internal::Platform::Mutex* m_pollMutex;
459 int32 m_pollInterval;
460 bool m_bIntervalBetweenPolls;
483 void InitNode(
uint8 const _nodeId,
bool newNode =
false,
bool secure =
false,
uint8 const *_protocolInfo =
NULL,
uint8 const _length = 0);
487 bool IsNodeListeningDevice(
uint8 const _nodeId);
488 bool IsNodeFrequentListeningDevice(
uint8 const _nodeId);
489 bool IsNodeBeamingDevice(
uint8 const _nodeId);
490 bool IsNodeRoutingDevice(
uint8 const _nodeId);
491 bool IsNodeSecurityDevice(
uint8 const _nodeId);
498 string GetNodeType(
uint8 const _nodeId);
501 string GetNodeManufacturerName(
uint8 const _nodeId);
502 string GetNodeProductName(
uint8 const _nodeId);
503 string GetNodeName(
uint8 const _nodeId);
504 string GetNodeLocation(
uint8 const _nodeId);
506 string GetNodeDeviceTypeString(
uint8 const _nodeId);
508 string GetNodeRoleString(
uint8 const _nodeId);
510 string GetNodePlusTypeString(
uint8 const _nodeId);
511 bool IsNodeZWavePlus(
uint8 const _nodeId);
516 void SetNodeManufacturerName(
uint8 const _nodeId,
string const& _manufacturerName);
517 void SetNodeProductName(
uint8 const _nodeId,
string const& _productName);
518 void SetNodeName(
uint8 const _nodeId,
string const& _nodeName);
519 void SetNodeLocation(
uint8 const _nodeId,
string const& _location);
520 void SetNodeLevel(
uint8 const _nodeId,
uint8 const _level);
521 void SetNodeOn(
uint8 const _nodeId);
522 void SetNodeOff(
uint8 const _nodeId);
526 bool IsAPICallSupported(
uint8 const _apinum)
const 528 return ((m_apiMask[(_apinum - 1) >> 3] & (1 << ((_apinum - 1) & 0x07))) != 0);
530 void SetAPICall(
uint8 const _apinum,
bool _toSet)
534 m_apiMask[(_apinum - 1) >> 3] |= (1 << ((_apinum - 1) & 0x07));
538 m_apiMask[(_apinum - 1) >> 3] &= ~(1 << ((_apinum - 1) & 0x07));
554 ControllerCommand_None = 0,
570 ControllerCommand_DeleteButton
580 ControllerState_Normal = 0,
590 ControllerState_NodeFailed
599 ControllerError_None = 0,
611 ControllerError_Overflow
620 void RequestNodeNeighbors(
uint8 const _nodeId,
uint32 const _requestFlags);
622 bool BeginControllerCommand(
ControllerCommand _command, pfnControllerCallback_t _callback,
void* _context,
bool _highPower,
uint8 _nodeId,
uint8 _arg);
623 bool CancelControllerCommand();
624 void AddNodeStop(
uint8 const _funcId);
626 struct ControllerCommandItem
629 bool m_controllerStateChanged;
630 bool m_controllerCommandDone;
632 pfnControllerCallback_t m_controllerCallback;
634 void* m_controllerCallbackContext;
636 bool m_controllerAdded;
637 uint8 m_controllerCommandNode;
638 uint8 m_controllerCommandArg;
639 uint8 m_controllerDeviceProtocolInfo[254];
640 uint8 m_controllerDeviceProtocolInfoLength;
643 ControllerCommandItem* m_currentControllerCommand;
645 void DoControllerCommand();
646 void UpdateControllerState(ControllerState
const _state, ControllerError
const _error = ControllerError_None);
650 void UpdateNodeRoutes(
uint8 const_nodeId,
bool _doUpdate =
false);
660 MsgQueue_Command = 0,
677 return m_transmitOptions;
698 bool WriteNextMsg(MsgQueue
const _queue);
699 bool WriteMsg(
string const &str);
700 void RemoveCurrentMsg();
701 bool MoveMessagesToWakeUpQueue(
uint8 const _targetNodeId,
bool const _move);
702 bool HandleErrorResponse(
uint8 const _error,
uint8 const _nodeId,
char const* _funcStr,
bool _sleepCheck =
false);
703 bool IsExpectedReply(
uint8 const _nodeId);
706 void CheckCompletedNodeQueries();
744 MsgQueueCmd_SendMsg = 0,
745 MsgQueueCmd_QueryStageComplete,
746 MsgQueueCmd_Controller,
747 MsgQueueCmd_ReloadNode
754 m_msg(
NULL), m_nodeId(0), m_queryStage(Node::QueryStage_None), m_retry(false), m_cci(
NULL)
758 bool operator ==(MsgQueueItem
const& _other)
const 760 if (_other.m_command == m_command)
762 if (m_command == MsgQueueCmd_SendMsg)
764 return ((*_other.m_msg) == (*m_msg));
766 else if (m_command == MsgQueueCmd_QueryStageComplete)
768 return ((_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage));
770 else if (m_command == MsgQueueCmd_Controller)
772 return ((_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback));
774 else if (m_command == MsgQueueCmd_ReloadNode)
776 return (_other.m_nodeId == m_nodeId);
784 MsgQueueCmd m_command;
785 Internal::Msg* m_msg;
789 ControllerCommandItem* m_cci;
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();
867 list<Notification*> m_notifications;
869 Internal::Platform::Event* m_notificationsEvent;
900 void LogDriverStatistics();
926 uint32 m_broadcastReadCnt;
927 uint32 m_broadcastWriteCnt;
935 aes_encrypt_ctx *GetAuthKey();
936 aes_encrypt_ctx *GetEncKey();
937 bool isNetworkKeySet();
940 bool initNetworkKeys(
bool newnode);
941 uint8 *GetNetworkKey();
942 bool SendEncryptedMessage();
943 bool SendNonceRequest(
string logmsg);
944 void SendNonceKey(
uint8 nodeId,
uint8 *nonce);
945 aes_encrypt_ctx *AuthKey;
946 aes_encrypt_ctx *EncryptKey;
947 uint8 m_nonceReportSent;
948 uint8 m_nonceReportSentAttempt;
949 bool m_inclusionkeySet;
970 void SubmitEventMsg(EventMsg *);
971 void ProcessEventMsg();
975 Internal::Platform::Event* m_queueMsgEvent;
976 Internal::Platform::Mutex* m_eventMutex;
983 bool CheckNodeConfigRevision(Node *);
984 bool CheckMFSConfigRevision();
985 void ReloadNode(
uint8 const _nodeId);
988 void processConfigRevision(Internal::DNSLookup *);
995 bool setHttpClient(Internal::i_HttpClient *client);
997 bool startConfigDownload(
uint16 _manufacturerId,
uint16 _productType,
uint16 _productId,
string configfile,
uint8 node = 0);
998 bool startMFSDownload(
string configfile);
999 bool refreshNodeConfig(
uint8 node);
1000 void processDownload(Internal::HttpDownload *);
1001 Internal::i_HttpClient *m_httpClient;
1009 Node::ChangeLogEntry
const GetChangeLog(
uint8 const _nodeId, uint32_t revision);
1016 Internal::ManufacturerSpecificDB *GetManufacturerSpecificDB();
1017 bool downloadConfigRevision(Node *);
1018 bool downloadMFSRevision();
1020 Internal::ManufacturerSpecificDB *m_mfs;
uint32 m_CANCnt
Definition: Driver.h:883
Definition: Bitfield.cpp:30
MsgQueue
Definition: Driver.h:658
Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class.
Definition: SceneActivation.h:44
#define OPENZWAVE_EXPORT
Definition: Defs.h:51
unsigned short uint16
Definition: Defs.h:89
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition: Defs.h:53
uint32 m_routedbusy
Definition: Driver.h:896
uint32 m_nondelivery
Definition: Driver.h:895
Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class.
Definition: ControllerReplication.h:43
uint8 GetTransmitOptions() const
Definition: Driver.h:675
uint32 m_readAborts
Definition: Driver.h:879
The main public interface to OpenZWave.
Definition: Manager.h:108
Implements COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION (0x8E), a Z-Wave device command class.
Definition: MultiChannelAssociation.h:45
MetaDataFields
Definition: Node.h:879
uint32 m_ACKWaiting
Definition: Driver.h:878
struct OpenZWave::InstanceAssociation InstanceAssociation
Internal::TimerThread * GetTimer()
Definition: Driver.h:207
QueryStage
Definition: Node.h:125
uint32 m_badChecksum
Definition: Driver.h:880
uint32 m_writeCnt
Definition: Driver.h:882
uint8 GetTargetNodeId() const
Identifies the Node ID of the "target" node (if any) for this function.
Definition: Msg.h:75
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition: Defs.h:52
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:49
Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class.
Definition: Basic.h:42
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:81
Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
Definition: NodeNaming.h:56
#define NULL
Definition: Defs.h:82
Base class for all Z-Wave command classes.
Definition: CommandClass.h:60
ControllerCommand
Definition: Driver.h:552
uint32 m_readCnt
Definition: Driver.h:881
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:51
ControllerError
Definition: Driver.h:597
uint32 m_OOFCnt
Definition: Driver.h:886
ControllerState
Definition: Driver.h:578
uint32 m_notidle
Definition: Driver.h:893
uint32 m_SOFCnt
Definition: Driver.h:877
ControllerInterface
Definition: Driver.h:111
uint32 m_broadcastReadCnt
Definition: Driver.h:897
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:84
uint32 m_badroutes
Definition: Driver.h:890
signed int int32
Definition: Defs.h:91
unsigned int uint32
Definition: Defs.h:92
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:59
uint32 m_broadcastWriteCnt
Definition: Driver.h:898
the DNSThread provides Async DNS lookups for checking revision numbers of Config Files against the of...
Definition: DNSThread.h:71
Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class.
Definition: ManufacturerSpecific.h:44
Provides a unique ID for a value reported by a Z-Wave device.The ValueID is used to uniquely identify...
Definition: ValueID.h:76
uint32 m_txverified
Definition: Driver.h:894
uint32 m_callbacks
Definition: Driver.h:889
uint32 m_netbusy
Definition: Driver.h:892
Implements COMMAND_CLASS_SECURITY (0x98), a Z-Wave device command class.
Definition: Security.h:66
Implements COMMAND_CLASS_APPLICATION_STATUS (0x22), a Z-Wave device command class.
Definition: ApplicationStatus.h:42
uint32 m_retries
Definition: Driver.h:888
uint32 m_noack
Definition: Driver.h:891
uint8 GetNodeNumber(Internal::Msg const *_msg) const
Definition: Driver.h:466
uint32 m_dropped
Definition: Driver.h:887
Definition: DNSThread.h:58
uint32 m_NAKCnt
Definition: Driver.h:884
uint32 m_ACKCnt
Definition: Driver.h:885
The TimerThread class makes it possible to schedule events to happen at a certain time in the future.
Definition: TimerThread.h:55
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices.
Definition: ManufacturerSpecificDB.h:116
Message object to be passed to and from devices on the Z-Wave network.
Definition: Msg.h:50
Base class for values associated with a node.
Definition: Value.h:53
#define NUM_NODE_BITFIELD_BYTES
Definition: Defs.h:237
unsigned char uint8
Definition: Defs.h:86