96 ControllerInterface_Unknown = 0,
98 ControllerInterface_Hid
108 Driver(
string const& _controllerPath, ControllerInterface
const& _interface );
122 static void DriverThreadEntryPoint(
Event* _exitEvent,
void* _context );
141 void DriverThreadProc(
Event* _exitEvent );
155 bool Init(
uint32 _attempts );
161 void RemoveQueues(
uint8 const _nodeId );
169 bool m_awakeNodesQueried;
170 bool m_allNodesQueried;
171 bool m_notifytransactions;
178 void RequestConfig();
199 ControllerCaps_Secondary = 0x01,
200 ControllerCaps_OnOtherNetwork = 0x02,
201 ControllerCaps_SIS = 0x04,
202 ControllerCaps_RealPrimary = 0x08,
203 ControllerCaps_SUC = 0x10
209 InitCaps_Slave = 0x01,
210 InitCaps_TimerSupport = 0x02,
211 InitCaps_Secondary = 0x04,
215 bool IsPrimaryController()
const{
return ((m_initCaps & InitCaps_Secondary) == 0); }
216 bool IsStaticUpdateController()
const{
return ((m_initCaps & InitCaps_SUC) != 0); }
217 bool IsBridgeController()
const{
return (m_libraryType == 7); }
218 bool IsInclusionController()
const{
return ((m_controllerCaps & ControllerCaps_SIS) != 0); }
220 bool HasExtendedTxStatus()
const{
return m_hasExtendedTxStatus; }
222 uint32 GetHomeId()
const{
return m_homeId; }
223 uint8 GetControllerNodeId()
const{
return m_Controller_nodeId; }
224 uint8 GetSUCNodeId()
const{
return m_SUCNodeId; }
225 uint16 GetManufacturerId()
const{
return m_manufacturerId; }
226 uint16 GetProductType()
const{
return m_productType; }
227 uint16 GetProductId()
const{
return m_productId; }
228 string GetControllerPath()
const{
return m_controllerPath; }
229 ControllerInterface GetControllerInterfaceType()
const{
return m_controllerInterfaceType; }
230 string GetLibraryVersion()
const{
return m_libraryVersion; }
231 string GetLibraryTypeName()
const{
return m_libraryTypeName; }
232 int32 GetSendQueueCount()
const
235 for(
int32 i=0; i<MsgQueue_Count; ++i )
237 count += (
int32) (m_msgQueue[i].size());
251 Node* GetNodeUnsafe(
uint8 _nodeId );
261 Node* GetNode(
uint8 _nodeId );
271 ControllerInterface m_controllerInterfaceType;
272 string m_controllerPath;
273 Controller* m_controller;
276 string m_libraryVersion;
277 string m_libraryTypeName;
280 uint8 m_serialAPIVersion[2];
288 uint8 m_controllerCaps;
289 bool m_hasExtendedTxStatus;
290 uint8 m_Controller_nodeId;
294 ControllerReplication* m_controllerReplication;
296 uint8 m_transmitOptions;
303 void ProcessMsg(
uint8* _data,
uint8 _length );
305 void HandleGetVersionResponse(
uint8* _data );
306 void HandleGetRandomResponse(
uint8* _data );
307 void HandleSerialAPISetupResponse(
uint8* _data );
308 void HandleGetControllerCapabilitiesResponse(
uint8* _data );
309 void HandleGetSerialAPICapabilitiesResponse(
uint8* _data );
310 void HandleSerialAPISoftResetResponse(
uint8* _data );
311 void HandleEnableSUCResponse(
uint8* _data );
312 void HandleSetSUCNodeIdResponse(
uint8* _data );
313 void HandleGetSUCNodeIdResponse(
uint8* _data );
314 void HandleMemoryGetIdResponse(
uint8* _data );
327 void HandleSerialAPIGetInitDataResponse(
uint8* _data );
328 void HandleGetNodeProtocolInfoResponse(
uint8* _data );
329 bool HandleRemoveFailedNodeResponse(
uint8* _data );
330 void HandleIsFailedNodeResponse(
uint8* _data );
331 bool HandleReplaceFailedNodeResponse(
uint8* _data );
332 bool HandleAssignReturnRouteResponse(
uint8* _data );
333 bool HandleDeleteReturnRouteResponse(
uint8* _data );
334 void HandleSendNodeInformationRequest(
uint8* _data );
335 void HandleSendDataResponse(
uint8* _data,
bool _replication );
336 bool HandleNetworkUpdateResponse(
uint8* _data );
337 void HandleGetRoutingInfoResponse(
uint8* _data );
339 void HandleSendDataRequest(
uint8* _data,
uint8 _length,
bool _replication );
340 void HandleAddNodeToNetworkRequest(
uint8* _data );
341 void HandleCreateNewPrimaryRequest(
uint8* _data );
342 void HandleControllerChangeRequest(
uint8* _data );
343 void HandleSetLearnModeRequest(
uint8* _data );
344 void HandleRemoveFailedNodeRequest(
uint8* _data );
345 void HandleReplaceFailedNodeRequest(
uint8* _data );
346 void HandleRemoveNodeFromNetworkRequest(
uint8* _data );
347 void HandleApplicationCommandHandlerRequest(
uint8* _data,
bool encrypted );
348 void HandlePromiscuousApplicationCommandHandlerRequest(
uint8* _data );
349 void HandleAssignReturnRouteRequest(
uint8* _data );
350 void HandleDeleteReturnRouteRequest(
uint8* _data );
351 void HandleNodeNeighborUpdateRequest(
uint8* _data );
352 void HandleNetworkUpdateRequest(
uint8* _data );
353 bool HandleApplicationUpdateRequest(
uint8* _data );
354 bool HandleRfPowerLevelSetResponse(
uint8* _data );
355 bool HandleSerialApiSetTimeoutsResponse(
uint8* _data );
356 bool HandleMemoryGetByteResponse(
uint8* _data );
357 bool HandleReadMemoryResponse(
uint8* _data );
358 void HandleGetVirtualNodesResponse(
uint8* _data );
359 bool HandleSetSlaveLearnModeResponse(
uint8* _data );
360 void HandleSetSlaveLearnModeRequest(
uint8* _data );
361 bool HandleSendSlaveNodeInfoResponse(
uint8* _data );
362 void HandleSendSlaveNodeInfoRequest(
uint8* _data );
363 void HandleApplicationSlaveCommandRequest(
uint8* _data );
364 void HandleSerialAPIResetRequest(
uint8* _data );
366 void CommonAddNodeStatusRequestHandler(
uint8 _funcId,
uint8* _data );
368 bool m_waitingForAck;
369 uint8 m_expectedCallbackId;
370 uint8 m_expectedReply;
371 uint8 m_expectedCommandClassId;
372 uint8 m_expectedNodeId;
378 int32 GetPollInterval(){
return m_pollInterval ; }
379 void SetPollInterval(
int32 _milliseconds,
bool _bIntervalBetweenPolls ){ m_pollInterval = _milliseconds; m_bIntervalBetweenPolls = _bIntervalBetweenPolls; }
380 bool EnablePoll(
const ValueID &_valueId,
uint8 _intensity = 1 );
381 bool DisablePoll(
const ValueID &_valueId );
382 bool isPolled(
const ValueID &_valueId );
383 void SetPollIntensity(
const ValueID &_valueId,
uint8 _intensity );
384 static void PollThreadEntryPoint( Event* _exitEvent,
void* _context );
385 void PollThreadProc( Event* _exitEvent );
387 Thread* m_pollThread;
394 list<PollEntry> m_pollList;
397 int32 m_pollInterval;
398 bool m_bIntervalBetweenPolls;
418 void InitNode(
uint8 const _nodeId,
bool newNode =
false,
bool secure =
false,
uint8 const *_protocolInfo =
NULL,
uint8 const _length = 0);
422 bool IsNodeListeningDevice(
uint8 const _nodeId );
423 bool IsNodeFrequentListeningDevice(
uint8 const _nodeId );
424 bool IsNodeBeamingDevice(
uint8 const _nodeId );
425 bool IsNodeRoutingDevice(
uint8 const _nodeId );
426 bool IsNodeSecurityDevice(
uint8 const _nodeId );
433 string GetNodeType(
uint8 const _nodeId );
436 string GetNodeManufacturerName(
uint8 const _nodeId );
437 string GetNodeProductName(
uint8 const _nodeId );
438 string GetNodeName(
uint8 const _nodeId );
439 string GetNodeLocation(
uint8 const _nodeId );
441 string GetNodeDeviceTypeString(
uint8 const _nodeId );
443 string GetNodeRoleString(
uint8 const _nodeId );
445 string GetNodePlusTypeString (
uint8 const _nodeId );
446 bool IsNodeZWavePlus(
uint8 const _nodeId );
449 uint16 GetNodeManufacturerId(
uint8 const _nodeId );
452 void SetNodeManufacturerName(
uint8 const _nodeId,
string const& _manufacturerName );
453 void SetNodeProductName(
uint8 const _nodeId,
string const& _productName );
454 void SetNodeName(
uint8 const _nodeId,
string const& _nodeName );
455 void SetNodeLocation(
uint8 const _nodeId,
string const& _location );
456 void SetNodeLevel(
uint8 const _nodeId,
uint8 const _level );
457 void SetNodeOn(
uint8 const _nodeId );
458 void SetNodeOff(
uint8 const _nodeId );
462 bool IsAPICallSupported(
uint8 const _apinum )
const{
return (( m_apiMask[( _apinum - 1 ) >> 3] & ( 1 << (( _apinum - 1 ) & 0x07 ))) != 0 ); }
463 void SetAPICall(
uint8 const _apinum,
bool _toSet )
467 m_apiMask[( _apinum - 1 ) >> 3] |= ( 1 << (( _apinum - 1 ) & 0x07 ));
471 m_apiMask[( _apinum - 1 ) >> 3] &= ~( 1 << (( _apinum - 1 ) & 0x07 ));
487 ControllerCommand_None = 0,
503 ControllerCommand_DeleteButton
513 ControllerState_Normal = 0,
523 ControllerState_NodeFailed
532 ControllerError_None = 0,
544 ControllerError_Overflow
551 void ResetController(
Event* _evt );
553 void RequestNodeNeighbors(
uint8 const _nodeId,
uint32 const _requestFlags );
555 bool BeginControllerCommand(
ControllerCommand _command, pfnControllerCallback_t _callback,
void* _context,
bool _highPower,
uint8 _nodeId,
uint8 _arg );
556 bool CancelControllerCommand();
557 void AddNodeStop(
uint8 const _funcId );
559 struct ControllerCommandItem
562 bool m_controllerStateChanged;
563 bool m_controllerCommandDone;
565 pfnControllerCallback_t m_controllerCallback;
567 void* m_controllerCallbackContext;
569 bool m_controllerAdded;
570 uint8 m_controllerCommandNode;
571 uint8 m_controllerCommandArg;
572 uint8 m_controllerDeviceProtocolInfo[254];
573 uint8 m_controllerDeviceProtocolInfoLength;
576 ControllerCommandItem* m_currentControllerCommand;
578 void DoControllerCommand();
579 void UpdateControllerState( ControllerState
const _state, ControllerError
const _error = ControllerError_None );
583 void UpdateNodeRoutes(
uint8 const_nodeId,
bool _doUpdate =
false );
585 Event* m_controllerResetEvent;
593 MsgQueue_Command = 0,
603 void SendMsg(
Msg* _msg, MsgQueue
const _queue );
628 bool WriteNextMsg( MsgQueue
const _queue );
629 bool WriteMsg(
string const &str);
630 void RemoveCurrentMsg();
631 bool MoveMessagesToWakeUpQueue(
uint8 const _targetNodeId,
bool const _move );
632 bool HandleErrorResponse(
uint8 const _error,
uint8 const _nodeId,
char const* _funcStr,
bool _sleepCheck =
false );
633 bool IsExpectedReply(
uint8 const _nodeId );
636 void CheckCompletedNodeQueries();
674 MsgQueueCmd_SendMsg = 0,
675 MsgQueueCmd_QueryStageComplete,
676 MsgQueueCmd_Controller,
677 MsgQueueCmd_ReloadNode
686 m_queryStage(Node::QueryStage_None),
691 bool operator == ( MsgQueueItem
const& _other )
const
693 if( _other.m_command == m_command )
695 if( m_command == MsgQueueCmd_SendMsg )
697 return( (*_other.m_msg) == (*m_msg) );
699 else if( m_command == MsgQueueCmd_QueryStageComplete )
701 return( (_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage) );
703 else if( m_command == MsgQueueCmd_Controller )
705 return( (_other.m_cci->m_controllerCommand == m_cci->m_controllerCommand) && (_other.m_cci->m_controllerCallback == m_cci->m_controllerCallback) );
707 else if (m_command == MsgQueueCmd_ReloadNode )
709 return (_other.m_nodeId == m_nodeId);
717 MsgQueueCmd m_command;
720 Node::QueryStage m_queryStage;
722 ControllerCommandItem* m_cci;
726 list<MsgQueueItem> m_msgQueue[MsgQueue_Count];
728 Event* m_queueEvent[MsgQueue_Count];
731 MsgQueue m_currentMsgQueueSource;
732 TimeStamp m_resendTimeStamp;
738 void TestNetwork(
uint8 const _nodeId,
uint32 const _count );
750 void RequestVirtualNeighbors( MsgQueue
const _queue );
751 bool IsVirtualNode(
uint8 const _nodeId )
const{
return (( m_virtualNeighbors[( _nodeId - 1 ) >> 3] & 1 << (( _nodeId - 1 ) & 0x07 )) != 0 ); }
752 void SendVirtualNodeInfo(
uint8 const _fromNodeId,
uint8 const _ToNodeId );
753 void SendSlaveLearnModeOff();
755 void ReadButtons(
uint8 const _nodeId );
757 bool m_virtualNeighborsReceived;
773 bool SetConfigParam(
uint8 const _nodeId,
uint8 const _param,
int32 _value,
uint8 const _size );
774 void RequestConfigParam(
uint8 const _nodeId,
uint8 const _param );
783 uint32 GetAssociations(
uint8 const _nodeId,
uint8 const _groupIdx, InstanceAssociation** o_associations );
784 uint8 GetMaxAssociations(
uint8 const _nodeId,
uint8 const _groupIdx );
785 bool IsMultiInstance(
uint8 const _nodeId,
uint8 const _groupIdx );
786 string GetGroupLabel(
uint8 const _nodeId,
uint8 const _groupIdx );
787 void AddAssociation(
uint8 const _nodeId,
uint8 const _groupIdx,
uint8 const _targetNodeId,
uint8 const _instance = 0x00 );
788 void RemoveAssociation(
uint8 const _nodeId,
uint8 const _groupIdx,
uint8 const _targetNodeId,
uint8 const _instance = 0x00 );
794 void QueueNotification( Notification* _notification );
795 void NotifyWatchers();
798 list<Notification*> m_notifications;
800 Event* m_notificationsEvent;
831 void LogDriverStatistics();
834 void GetDriverStatistics(
DriverData* _data );
857 uint32 m_broadcastReadCnt;
858 uint32 m_broadcastWriteCnt;
867 aes_encrypt_ctx *GetAuthKey();
868 aes_encrypt_ctx *GetEncKey();
869 bool isNetworkKeySet();
872 bool initNetworkKeys(
bool newnode);
873 uint8 *GetNetworkKey();
874 bool SendEncryptedMessage();
875 bool SendNonceRequest(
string logmsg);
876 void SendNonceKey(
uint8 nodeId,
uint8 *nonce);
877 aes_encrypt_ctx *AuthKey;
878 aes_encrypt_ctx *EncryptKey;
879 uint8 m_nonceReportSent;
880 uint8 m_nonceReportSentAttempt;
881 bool m_inclusionkeySet;
899 void SubmitEventMsg(EventMsg *);
900 void ProcessEventMsg();
904 list<EventMsg *> m_eventQueueMsg;
906 Event* m_queueMsgEvent;
915 bool CheckNodeConfigRevision(Node *);
916 bool CheckMFSConfigRevision();
917 void ReloadNode(
uint8 const _nodeId);
920 void processConfigRevision(DNSLookup *);
927 bool setHttpClient(i_HttpClient *client);
929 bool startConfigDownload(
uint16 _manufacturerId,
uint16 _productType,
uint16 _productId,
string configfile,
uint8 node = 0);
930 bool startMFSDownload(
string configfile);
931 bool refreshNodeConfig(
uint8 node);
932 void processDownload(HttpDownload *);
933 i_HttpClient *m_httpClient;
940 string const GetMetaData(
uint8 const _nodeId, Node::MetaDataFields _metadata );
941 Node::ChangeLogEntry
const GetChangeLog(
uint8 const _nodeId, uint32_t revision);
949 ManufacturerSpecificDB *GetManufacturerSpecificDB();
950 bool downloadConfigRevision(Node *);
951 bool downloadMFSRevision();
953 ManufacturerSpecificDB *m_mfs;