-
-
Notifications
You must be signed in to change notification settings - Fork 876
Expand file tree
/
Copy pathNode.h
More file actions
925 lines (845 loc) · 34.9 KB
/
Copy pathNode.h
File metadata and controls
925 lines (845 loc) · 34.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
//-----------------------------------------------------------------------------
//
// Node.h
//
// A node in the Z-Wave network
//
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Node_H
#define _Node_H
#include <string>
#include <vector>
#include <list>
#include <map>
#include "Defs.h"
#include "value_classes/ValueID.h"
#include "value_classes/ValueList.h"
#include "Msg.h"
#include "platform/TimeStamp.h"
#include "Group.h"
class TiXmlElement;
class TiXmlNode;
namespace OpenZWave
{
namespace Internal
{
namespace CC
{
class CommandClass;
class Association;
class AssociationCommandConfiguration;
class ControllerReplication;
class Hail;
class ManufacturerSpecific;
class MultiChannelAssociation;
class MultiInstance;
class NodeNaming;
class Version;
class ZWavePlusInfo;
}
namespace VC
{
class Value;
class ValueStore;
}
namespace Platform
{
class Mutex;
}
class ProductDescriptor;
class ManufacturerSpecificDB;
}
namespace Testing
{
class TestHelper;
}
class Driver;
class Group;
/** \brief The Node class describes a Z-Wave node object...typically a device on the
* Z-Wave network.
*/
class Node
{
friend class Manager;
friend class Driver;
friend class Group;
friend class Internal::VC::Value;
friend class ValueButton;
friend class Internal::CC::Association;
friend class Internal::CC::AssociationCommandConfiguration;
friend class Internal::CC::CommandClass;
friend class Internal::CC::ControllerReplication;
friend class Internal::CC::Hail;
friend class Internal::CC::ManufacturerSpecific;
friend class Internal::CC::MultiInstance;
friend class Internal::CC::MultiChannelAssociation;
friend class Internal::CC::NodeNaming;
friend class Internal::CC::Version;
friend class Internal::CC::ZWavePlusInfo;
friend class Internal::ManufacturerSpecificDB;
friend class Testing::TestHelper;
//-----------------------------------------------------------------------------
// Construction
//-----------------------------------------------------------------------------
public:
/** Constructor initializes the node object, associating it with a specific
* network (_homeId) and network node (_nodeId).
* \param _homeId The homeId of the network to which this node is connected.
* \param _nodeId The nodeId of this node.
*/
Node(uint32 const _homeId, uint8 const _nodeId);
/** Destructor cleans up memory allocated to node and its child objects.
*/
virtual ~Node();
private:
/** Returns a pointer to the driver (interface with a Z-Wave controller)
* associated with this node.
*/
Driver* GetDriver() const;
//-----------------------------------------------------------------------------
// Initialization
//-----------------------------------------------------------------------------
public:
enum QueryStage
{
QueryStage_None, /**< Query process hasn't started for this node */
QueryStage_ProtocolInfo, /**< Retrieve protocol information */
QueryStage_Probe, /**< Ping device to see if alive */
QueryStage_WakeUp, /**< Start wake up process if a sleeping node */
QueryStage_ManufacturerSpecific1, /**< Retrieve manufacturer name and product ids if ProtocolInfo lets us */
QueryStage_NodeInfo, /**< Retrieve info about supported, controlled command classes */
QueryStage_NodePlusInfo, /**< Retrieve ZWave+ info and update device classes */
QueryStage_SecurityReport, /**< Retrieve a list of Command Classes that require Security */
QueryStage_ManufacturerSpecific2, /**< Retrieve manufacturer name and product ids */
QueryStage_Versions, /**< Retrieve version information */
QueryStage_Instances, /**< Retrieve information about multiple command class instances */
QueryStage_Static, /**< Retrieve static information (doesn't change) */
QueryStage_CacheLoad, /**< Ping a device upon restarting with cached config for the device */
QueryStage_Probe1 = QueryStage_CacheLoad, /** < Depreciated name. /todo Remove in 2.0 timeframe */
QueryStage_Associations, /**< Retrieve information about associations */
QueryStage_Neighbors, /**< Retrieve node neighbor list */
QueryStage_Session, /**< Retrieve session information (changes infrequently) */
QueryStage_Dynamic, /**< Retrieve dynamic information (changes frequently) */
QueryStage_Configuration, /**< Retrieve configurable parameter information (only done on request) */
QueryStage_Complete /**< Query process is completed for this node */
};
/**
* This function advances the query process (see Remarks below for more detail on the
* process). It iterates through the various query stages enumerated in Node::QueryStage.
*
* \remark
* For OpenZWave to discover everything about a node, we have to follow a certain
* order of queries, because the results of one stage may affect what is requested
* in the next stage. The stage is saved with the node data, so that any incomplete
* queries can be restarted the next time the application runs.
* <p>
* The individual command classes also store some state information as to whether
* they have had a response to certain queries. This state information is
* initialized by the SetStaticRequests call in QueryStage_None. It is also saved,
* so we do not need to request state from every command class if some have previously
* responded.
*/
void AdvanceQueries();
/**
* Signal that a specific query stage has been completed for this node. This will
* only work if the query process for this node is indeed at the specified stage.
* Otherwise, the function returns with no action.
* \param _stage The current stage of the query process.
*/
void QueryStageComplete(QueryStage const _stage);
/**
* Retry the specified query stage (up to _maxAttempts retries). This will
* only work if the query process for this node is indeed at the specified stage.
* Otherwise, the function returns with no action.
* \param _stage The query stage to retry.
* \param _maxAttempts
*/
void QueryStageRetry(QueryStage const _stage, uint8 const _maxAttempts = 0); // maxAttempts of zero means no limit
/**
* This function sets the query stage for the node (but only to an earlier stage).
* If a later stage is specified than the current one, it is ignored.
* \param _stage The desired query stage.
* \see m_queryStage, m_queryPending
*/
void SetQueryStage(QueryStage const _stage, bool const _advance = true);
/**
* Returns the current query stage enum.
* \return Enum value with the current query stage.
* \see m_queryStage
*/
Node::QueryStage GetCurrentQueryStage()
{
return m_queryStage;
}
/**
* Returns the specified query stage string.
* \param _stage The query stage.
* \return Specified query stage string.
* \see m_queryStage, m_queryPending
*/
string GetQueryStageName(QueryStage const _stage);
/**
* Returns whether the library thinks a node is functioning properly
* \return boolean status of node.
*/
bool IsNodeAlive() const
{
return m_nodeAlive;
}
/**
* This function handles a response to the FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO
* command for this node. If protocol information has already been retrieved
* for the node, the function simply returns. Otherwise, it populates several
* member variables about the device at this node:
* - m_routing (whether it is a routing node (capable of passing commands along to other nodes in the network) or not
* - m_maxBaudRate (the maximum baud rate at which this device can communicate)
* - m_version (TODO)
* - m_security (whether device supports security features)
* - m_listening (device is powered and listening constantly)
* - m_frequentListening (device can be woken up with a beam)
* - m_beaming (device is beam capable)
*/
void UpdateProtocolInfo(uint8 const* _data);
/**
* this function is called when the Node is added via a AddNode request. the ProtocolInfo field contains the
* devices classes and the CommandClasses that the node supports, so we can build a pretty good Node out of that
* info.
* @param _protocolInfo Byte 0 - Basic Device Class Byte 1 - Generic Device Class, Byte 2 - Specific Device Classes Remaining Bytes - Supported Command Classes
* @param _length length of the _protocolInfo field.
*/
void SetProtocolInfo(uint8 const* _protocolInfo, uint8 const _length);
void UpdateNodeInfo(uint8 const* _data, uint8 const _length);
bool ProtocolInfoReceived() const
{
return m_protocolInfoReceived;
}
bool NodeInfoReceived() const
{
return m_nodeInfoReceived;
}
bool IsNodeZWavePlus() const
{
return m_nodePlusInfoReceived;
}
bool AllQueriesCompleted() const
{
return (QueryStage_Complete == m_queryStage);
}
void SetNodePlusInfoReceived(const bool _received)
{
m_nodePlusInfoReceived = _received;
}
/**
* Handle dead node detection tracking.
* Use this routine to set state of nodes.
* Tracks state as well as send notifications.
*/
void SetNodeAlive(bool const _isAlive);
private:
void SetStaticRequests();
QueryStage m_queryStage;
bool m_queryPending;
bool m_queryConfiguration;
uint8 m_queryRetries;
bool m_protocolInfoReceived;
bool m_basicprotocolInfoReceived;
bool m_nodeInfoReceived;
bool m_nodePlusInfoReceived;
bool m_manufacturerSpecificClassReceived;
bool m_nodeInfoSupported;
bool m_refreshonNodeInfoFrame;
bool m_nodeAlive;
//-----------------------------------------------------------------------------
// Capabilities
//-----------------------------------------------------------------------------
public:
// Security flags
enum
{
SecurityFlag_Security = 0x01,
SecurityFlag_Controller = 0x02,
SecurityFlag_SpecificDevice = 0x04,
SecurityFlag_RoutingSlave = 0x08,
SecurityFlag_BeamCapability = 0x10,
SecurityFlag_Sensor250ms = 0x20,
SecurityFlag_Sensor1000ms = 0x40,
SecurityFlag_OptionalFunctionality = 0x80
};
// Node Ids
enum
{
NodeBroadcast = 0xff
};
bool IsListeningDevice() const
{
return m_listening;
}
bool IsFrequentListeningDevice() const
{
return m_frequentListening;
}
bool IsBeamingDevice() const
{
return m_beaming;
}
bool IsRoutingDevice() const
{
return m_routing;
}
bool IsSecurityDevice() const
{
return m_security;
}
uint32 GetMaxBaudRate() const
{
return m_maxBaudRate;
}
uint8 GetVersion() const
{
return m_version;
}
uint8 GetSecurity() const
{
return m_security;
}
uint8 GetNodeId() const
{
return m_nodeId;
}
uint8 GetBasic() const
{
return m_basic;
}
string GetBasicString();
uint8 GetGeneric(uint8 const _instance) const;
string GetGenericString(uint8 const _instance);
uint8 GetSpecific(uint8 const _instance) const;
string GetSpecificString(uint8 const _instance);
string GetEndPointDeviceClassLabel(uint8 const _generic, uint8 const _specific);
string const& GetType() const
{
return m_type;
}
uint32 GetNeighbors(uint8** o_neighbors);
bool IsController() const
{
return (m_basic == 0x01 || m_basic == 0x02) && (m_generic == 0x01 || m_generic == 0x02);
}
bool IsAddingNode() const
{
return m_addingNode;
} /* These three *AddingNode functions are used to tell if we this node is just being discovered. Currently used by the Security CC to initiate the Network Key Exchange */
void SetAddingNode()
{
m_addingNode = true;
}
void ClearAddingNode()
{
m_addingNode = false;
}
bool IsNodeReset();
private:
bool m_listening;
bool m_frequentListening;
bool m_beaming;
bool m_routing;
uint32 m_maxBaudRate;
uint8 m_version;
bool m_security;
uint32 m_homeId;
uint8 m_nodeId;
uint8 m_basic; //*< Basic device class (0x01-Controller, 0x02-Static Controller, 0x03-Slave, 0x04-Routing Slave
uint8 m_generic;
uint8 m_specific;
string m_type; // Label representing the specific/generic/basic value
uint8 m_neighbors[29]; // Bitmask containing the neighboring nodes
uint8 m_numRouteNodes; // number of node routes
uint8 m_routeNodes[5]; // nodes to route to
map<uint8, uint8> m_buttonMap; // Map button IDs into virtual node numbers
bool m_addingNode;
//-----------------------------------------------------------------------------
// Device Naming
//-----------------------------------------------------------------------------
private:
// Manufacturer, Product and Name are stored here so they can be set by the
// user even if the device does not support the relevant command classes.
string GetManufacturerName() const
{
return m_manufacturerName;
}
string GetProductName() const
{
return m_productName;
}
string GetNodeName() const
{
return m_nodeName;
}
string GetLocation() const
{
return m_location;
}
// string GetManufacturerId()const{ return std::to_string(m_manufacturerId); }
uint16 GetManufacturerId() const
{
return m_manufacturerId;
}
// string GetProductType()const{ return string(m_productType); }
uint16 GetProductType() const
{
return m_productType;
}
// string GetProductId()const{ return string(m_productId); }
uint16 GetProductId() const
{
return m_productId;
}
void SetManufacturerName(string const& _manufacturerName)
{
m_manufacturerName = _manufacturerName;
}
void SetProductName(string const& _productName)
{
m_productName = _productName;
}
void SetNodeName(string const& _nodeName);
void SetLocation(string const& _location);
void SetManufacturerId(uint16 const& _manufacturerId)
{
m_manufacturerId = _manufacturerId;
}
void SetProductType(uint16 const& _productType)
{
m_productType = _productType;
}
void SetProductId(uint16 const& _productId)
{
m_productId = _productId;
}
string m_manufacturerName;
string m_productName;
string m_nodeName;
string m_location;
uint16 m_manufacturerId;
uint16 m_productType;
uint16 m_productId;
// zwave+ info
uint16 GetDeviceType() const
{
return m_deviceType;
}
string GetDeviceTypeString();
uint8 GetRoleType() const
{
return m_role;
}
string GetRoleTypeString();
uint8 GetNodeType() const
{
return m_nodeType;
}
string GetNodeTypeString();
uint16 m_deviceType;
uint8 m_role;
uint8 m_nodeType;
//-----------------------------------------------------------------------------
// Command Classes
//-----------------------------------------------------------------------------
public:
/**
* This function retrieves a pointer to the requested command class object (if supported by this node).
* \param _commandClassId Class ID (a single byte value) identifying the command class requested.
* \return Pointer to the requested CommandClass object if supported, otherwise NULL.
* \see CommandClass, m_commandClassMap
*/
Internal::CC::CommandClass* GetCommandClass(uint8 const _commandClassId) const;
void ApplicationCommandHandler(uint8 const* _data, bool encrypted);
/**
* This function sets up Secured Command Classes. It iterates over the existing command classes marking them
* as Secured if they exist, and if they don't, it creates new Command Classes and sets them up as Secured
* @param _data a list of Command Classes that are Secured by the Device
* @param _length the length of the _data string
* @param _instance the instance of the Class thats Secured.
*/
void SetSecuredClasses(uint8 const* _data, uint8 const _length, uint32 const _instance = 1);
void SetSecured(bool secure);
bool IsSecured();
/**
* This function sets a Global Instance Label for all CommandClasses that don't define their
* own labels
*/
void SetInstanceLabel(uint8 const _instance, char *label);
/** This function gets a Instance Label for a ValueID. It either users the Global Instance Label
* above, or a Label for a Specific CC
*/
string GetInstanceLabel(uint8 const _ccid, uint8 const _instance);
/** Get The Number of Instances on this node
*
*/
uint8 GetNumInstances(uint8 const _ccid);
private:
/**
* Creates the specified command class object and adds it to the node (via the
* m_commandClassMap) if it doesn't exist.
* No new object is created if it already exists for this node.
* \param _commandClassId Class ID (a single byte value) identifying the command class requested.
* \return Pointer to the CommandClass object just added to the map (NULL if the object
* was already there or if the CommandClass object creation failed).
* \see CommandClass, CommandClasses::CreateCommandClass, m_commandClassMap
*/
Internal::CC::CommandClass* AddCommandClass(uint8 const _commandClassId);
/**
* Removes a command class object from the node (via the m_commandClassMap). Before removing the
* object, this function also removes any values stored in the object's ValueStore.
* \param _commandClassId Class ID (a single byte value) identifying the command class to be removed.
* \see m_commandClassMap, ValueStore, GetValueStore, ValueStore::RemoveCommandClassValues
*/
void RemoveCommandClass(uint8 const _commandClassId);
void ReadXML(TiXmlElement const* _nodeElement);
void ReadDeviceProtocolXML(TiXmlElement const* _ccsElement);
void ReadCommandClassesXML(TiXmlElement const* _ccsElement);
void WriteXML(TiXmlElement* _nodeElement);
map<uint8, Internal::CC::CommandClass*> m_commandClassMap; /**< Map of command class ids and pointers to associated command class objects */
bool m_secured; /**< Is this Node added Securely */
map<uint8, string> m_globalInstanceLabel; /** < The Global Labels for Instances for CC that dont define their own labels */
TiXmlNode *m_nodeCache;
//-----------------------------------------------------------------------------
// Configuration Revision Related Classes
//-----------------------------------------------------------------------------
public:
void SetProductDetails(std::shared_ptr<Internal::ProductDescriptor> product);
/** Get a path to the config file for this device
*
* @return a path relative to the config directory for the config file. returns a empty string if a config file is not present.
*/
string getConfigPath();
/** Get the latest local revision of the config file for this node
*
* @return a revision number
*/
uint32 getFileConfigRevision()
{
return m_fileConfigRevision;
}
;
/** Get the Revision number of the config that is laoded for this Node
*
* @return the revision number currently loaded.
*/
uint32 getLoadedConfigRevision()
{
return m_loadedConfigRevision;
}
;
/** Get the Latest Config File revision available at openzwave.com
*
* @return The latest revision number available
*/
uint32 getLatestConfigRevision()
{
return m_latestConfigRevision;
}
;
/** Set the revision number of the Config File for this device
*
* @param rev the revision number
*/
void setFileConfigRevision(uint32 rev);
/** Set the revision number of the config that is loaded for this device
*
* @param rev the revision number
*/
void setLoadedConfigRevision(uint32 rev);
/** Set the revision number of the latest available config file for this device
*
* @param rev the revision number
*/
void setLatestConfigRevision(uint32 rev);
/** Check the latest available revision number for this device.
*
*/
void checkLatestConfigRevision();
private:
std::shared_ptr<Internal::ProductDescriptor> m_Product;
uint32 m_fileConfigRevision;
uint32 m_loadedConfigRevision;
uint32 m_latestConfigRevision;
//-----------------------------------------------------------------------------
// Basic commands (helpers that go through the basic command class)
//-----------------------------------------------------------------------------
public:
void SetLevel(uint8 const _level);
//-----------------------------------------------------------------------------
// On/Off commands (helpers that go through the basic or switchall command class)
//-----------------------------------------------------------------------------
public:
void SetNodeOn();
void SetNodeOff();
//-----------------------------------------------------------------------------
// Values (handled by the command classes)
//-----------------------------------------------------------------------------
public:
ValueID CreateValueID(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, ValueID::ValueType const _type);
Internal::VC::Value* GetValue(ValueID const& _id);
Internal::VC::Value* GetValue(uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex);
bool RemoveValue(uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex);
// Helpers for creating values
bool CreateValueBitSet(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int32 const _default, uint8 const _pollIntensity);
bool CreateValueBool(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, bool const _default, uint8 const _pollIntensity);
bool CreateValueButton(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, uint8 const _pollIntensity);
bool CreateValueByte(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _default, uint8 const _pollIntensity);
bool CreateValueDecimal(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _default, uint8 const _pollIntensity);
bool CreateValueInt(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int32 const _default, uint8 const _pollIntensity);
bool CreateValueList(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _size, vector<Internal::VC::ValueList::Item> const& _items, int32 const _default, uint8 const _pollIntensity);
bool CreateValueRaw(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const* _default, uint8 const _length, uint8 const _pollIntensity);
bool CreateValueSchedule(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, uint8 const _pollIntensity);
bool CreateValueShort(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, int16 const _default, uint8 const _pollIntensity);
bool CreateValueString(ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _default, uint8 const _pollIntensity);
// helpers for removing values
void RemoveValueList(Internal::VC::ValueList* _value);
void ReadValueFromXML(uint8 const _commandClassId, TiXmlElement const* _valueElement);
bool CreateValueFromXML(uint8 const _commandClassId, TiXmlElement const* _valueElement);
private:
Internal::VC::ValueStore* GetValueStore() const
{
return m_values;
}
Internal::VC::ValueStore* m_values; // Values reported via command classes
//-----------------------------------------------------------------------------
// Configuration Parameters (handled by the Configuration command class)
//-----------------------------------------------------------------------------
private:
bool SetConfigParam(uint8 const _param, int32 _value, uint8 const _size);
void RequestConfigParam(uint8 const _param);
bool RequestAllConfigParams(uint32 const _requestFlags);
//-----------------------------------------------------------------------------
// Dynamic Values (used by query and other command classes for updating)
//-----------------------------------------------------------------------------
private:
bool RequestDynamicValues();
public:
//-----------------------------------------------------------------------------
// Refresh Dynamic Values from CommandClasses on Wakeup
//-----------------------------------------------------------------------------
void RefreshValuesOnWakeup();
//-----------------------------------------------------------------------------
// Groups
//-----------------------------------------------------------------------------
private:
// The public interface is provided via the wrappers in the Manager class
uint8 GetNumGroups();
uint32 GetAssociations(uint8 const _groupIdx, uint8** o_associations);
uint32 GetAssociations(uint8 const _groupIdx, InstanceAssociation** o_associations);
uint8 GetMaxAssociations(uint8 const _groupIdx);
bool IsMultiInstance(uint8 const _groupIdx);
string GetGroupLabel(uint8 const _groupIdx);
void AddAssociation(uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00);
void RemoveAssociation(uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00);
void AutoAssociate();
// The following methods are not exposed
Group* GetGroup(uint8 const _groupIdx); // Get a pointer to a Group object. This must only be called while holding the node Lock.
void AddGroup(Group* _group); // The groups are fixed properties of a device, so there is no need for a matching RemoveGroup.
void WriteGroups(TiXmlElement* _associationsElement); // Write the group data out to XNL
map<uint8, Group*> m_groups; // Maps group indices to Group objects.
//-----------------------------------------------------------------------------
// Device Classes (static data read from the device_classes.xml file)
//-----------------------------------------------------------------------------
private:
// Container for device class info
class DeviceClass
{
public:
DeviceClass(TiXmlElement const* _el);
~DeviceClass()
{
delete[] m_mandatoryCommandClasses;
}
uint8 const* GetMandatoryCommandClasses()
{
return m_mandatoryCommandClasses;
}
uint8 GetBasicMapping()
{
return m_basicMapping;
}
string const& GetLabel()
{
return m_label;
}
private:
uint8* m_mandatoryCommandClasses; // Zero terminated array of mandatory command classes for this device type.
uint8 m_basicMapping; // Command class that COMMAND_CLASS_BASIC maps on to, or zero if there is no mapping.
string m_label; // Descriptive label for the device.
};
// Container for generic device class info
class GenericDeviceClass: public DeviceClass
{
public:
GenericDeviceClass(TiXmlElement const* _el);
~GenericDeviceClass();
DeviceClass* GetSpecificDeviceClass(uint8 const& _specific);
private:
map<uint8, DeviceClass*> m_specificDeviceClasses;
};
bool SetDeviceClasses(uint8 const _basic, uint8 const _generic, uint8 const _specific); // Set the device class data for the node
bool SetPlusDeviceClasses(uint8 const _role, uint8 const _nodeType, uint16 const _deviceType); // Set the device class data for the node based on the Zwave+ info report
bool AddMandatoryCommandClasses(uint8 const* _commandClasses); // Add mandatory command classes as specified in the device_classes.xml to the node.
void ReadDeviceClasses(); // Read the static device class data from the device_classes.xml file
static bool s_deviceClassesLoaded; // True if the xml file has already been loaded
static map<uint8, string> s_basicDeviceClasses; // Map of basic device classes.
static map<uint8, GenericDeviceClass*> s_genericDeviceClasses; // Map of generic device classes.
static map<uint8, DeviceClass*> s_roleDeviceClasses; // Map of Zwave+ role device classes.
static map<uint16, DeviceClass*> s_deviceTypeClasses; // Map of Zwave+ device type device classes.
static map<uint8, DeviceClass*> s_nodeTypes; // Map of ZWave+ Node Types
//-----------------------------------------------------------------------------
// Statistics
//-----------------------------------------------------------------------------
public:
struct CommandClassData
{
uint8 m_commandClassId;
uint32 m_sentCnt;
uint32 m_receivedCnt;
};
struct NodeData
{
uint32 m_sentCnt;
uint32 m_sentFailed;
uint32 m_retries;
uint32 m_receivedCnt;
uint32 m_receivedDups;
uint32 m_receivedUnsolicited;
string m_sentTS;
string m_receivedTS;
uint32 m_lastRequestRTT;
uint32 m_averageRequestRTT; // ms
uint32 m_lastResponseRTT;
uint32 m_averageResponseRTT;
uint8 m_quality; // Node quality measure
uint8 m_lastReceivedMessage[254];
list<CommandClassData> m_ccData;
bool m_txStatusReportSupported;
uint16 m_txTime;
uint8 m_hops;
char m_rssi_1[8];
char m_rssi_2[8];
char m_rssi_3[8];
char m_rssi_4[8];
char m_rssi_5[8];
uint8 m_ackChannel;
uint8 m_lastTxChannel;
TXSTATUS_ROUTING_SCHEME m_routeScheme;
char m_routeUsed[9];
TXSTATUS_ROUTE_SPEED m_routeSpeed;
uint8 m_routeTries;
uint8 m_lastFailedLinkFrom;
uint8 m_lastFailedLinkTo;
};
private:
void GetNodeStatistics(NodeData* _data);
uint32 m_sentCnt; // Number of messages sent from this node.
uint32 m_sentFailed; // Number of sent messages failed
uint32 m_retries; // Number of message retries
uint32 m_receivedCnt; // Number of messages received from this node.
uint32 m_receivedDups; // Number of duplicated messages received;
uint32 m_receivedUnsolicited; // Number of messages received unsolicited
uint32 m_lastRequestRTT; // Last message request RTT
uint32 m_lastResponseRTT; // Last message response RTT
Internal::Platform::TimeStamp m_sentTS; // Last message sent time
Internal::Platform::TimeStamp m_receivedTS; // Last message received time
uint32 m_averageRequestRTT; // Average Request round trip time.
uint32 m_averageResponseRTT; // Average Response round trip time.
uint8 m_quality; // Node quality measure
uint8 m_lastReceivedMessage[254]; // Place to hold last received message
uint8 m_errors;
bool m_txStatusReportSupported; // if Extended Status Reports are available
uint16 m_txTime; // Time Taken to Transmit the last frame
uint8 m_hops; // Hops taken in transmitting last frame
char m_rssi_1[8]; // RSSI Level of last transmission
char m_rssi_2[8]; // RSSI Level of last transmission
char m_rssi_3[8]; // RSSI Level of last transmission
char m_rssi_4[8]; // RSSI Level of last transmission
char m_rssi_5[8]; // RSSI Level of last transmission
uint8 m_ackChannel; // Channel we received the last ACK on
uint8 m_lastTxChannel; // Channel we transmitted the last frame on
TXSTATUS_ROUTING_SCHEME m_routeScheme; // The Scheme used to route the last frame
uint8 m_routeUsed[4]; // The Route Taken in the last frame
TXSTATUS_ROUTE_SPEED m_routeSpeed; // Baud Rate of the last frame
uint8 m_routeTries; // The number of attempts to route the last frame
uint8 m_lastFailedLinkFrom; // The last failed link from
uint8 m_lastFailedLinkTo; // The last failed link to
//-----------------------------------------------------------------------------
// Encryption Related
//-----------------------------------------------------------------------------
public:
uint8 *GenerateNonceKey();
uint8 *GetNonceKey(uint32 nonceid);
private:
uint8 m_lastnonce;
uint8 m_nonces[8][8];
//-----------------------------------------------------------------------------
// MetaData Related
//-----------------------------------------------------------------------------
public:
/**
* MetaData Fields.
* Available Fields that contain metadata about a device.
* \see Manager::AddWatcher
* \see Manager::BeginControllerCommand
*/
enum MetaDataFields
{
MetaData_OzwInfoPage_URL,
MetaData_ZWProductPage_URL,
MetaData_ProductPic,
MetaData_Description,
MetaData_ProductManual_URL,
MetaData_ProductPage_URL,
MetaData_InclusionHelp,
MetaData_ExclusionHelp,
MetaData_ResetHelp,
MetaData_WakeupHelp,
MetaData_ProductSupport_URL,
MetaData_Frequency,
MetaData_Name,
MetaData_Identifier,
MetaData_Invalid = 255
};
struct ChangeLogEntry
{
string author;
string date;
int revision;
string description;
};
string const GetMetaData(MetaDataFields);
MetaDataFields GetMetaDataId(string);
string const GetMetaDataString(MetaDataFields);
ChangeLogEntry const GetChangeLog(uint32_t);
private:
void ReadMetaDataFromXML(TiXmlElement const* _valueElement);
void WriteMetaDataXML(TiXmlElement*);
map<MetaDataFields, string> m_metadata;
map<uint32_t, ChangeLogEntry> m_changeLog;
};
} //namespace OpenZWave
#endif //_Node_H