26
26
27
27
MyMessage::MyMessage (void )
28
28
{
29
- clear ();
29
+ this -> clear ();
30
30
}
31
31
32
32
MyMessage::MyMessage (const uint8_t _sensorId, const mysensors_data_t _dataType)
33
33
{
34
- clear ();
35
- (void )setSensor (_sensorId);
36
- (void )setType (static_cast <uint8_t >(_dataType));
34
+ this -> clear ();
35
+ (void )this -> setSensor (_sensorId);
36
+ (void )this -> setType (static_cast <uint8_t >(_dataType));
37
37
}
38
38
39
39
void MyMessage::clear (void )
@@ -45,10 +45,11 @@ void MyMessage::clear(void)
45
45
this ->command_echo_payload = 0u ;
46
46
this ->type = 0u ;
47
47
this ->sensor = 0u ;
48
+ // clear data buffer
48
49
(void )memset ((void *)this ->data , 0u , sizeof (this ->data ));
49
50
50
51
// set message protocol version
51
- (void )this ->setVersion (PROTOCOL_VERSION );
52
+ (void )this ->setVersion ();
52
53
}
53
54
54
55
uint8_t MyMessage::getHeaderSize (void ) const
@@ -68,17 +69,17 @@ uint8_t MyMessage::getExpectedMessageSize(void) const
68
69
69
70
bool MyMessage::isProtocolVersionValid (void ) const
70
71
{
71
- return (this ->getVersion () == PROTOCOL_VERSION );
72
+ return (this ->getVersion () == V2_MYS_HEADER_PROTOCOL_VERSION );
72
73
}
73
74
74
75
uint8_t MyMessage::getType (void ) const
75
76
{
76
77
return this ->type ;
77
78
}
78
79
79
- MyMessage& MyMessage::setType (const uint8_t _messageType )
80
+ MyMessage& MyMessage::setType (const uint8_t messageType )
80
81
{
81
- this ->type = _messageType ;
82
+ this ->type = messageType ;
82
83
return *this ;
83
84
}
84
85
@@ -87,9 +88,9 @@ uint8_t MyMessage::getLast(void) const
87
88
return this ->last ;
88
89
}
89
90
90
- MyMessage& MyMessage::setLast (const uint8_t _lastId )
91
+ MyMessage& MyMessage::setLast (const uint8_t lastId )
91
92
{
92
- this ->last = _lastId ;
93
+ this ->last = lastId ;
93
94
return *this ;
94
95
}
95
96
@@ -98,9 +99,9 @@ uint8_t MyMessage::getSender(void) const
98
99
return this ->sender ;
99
100
}
100
101
101
- MyMessage& MyMessage::setSender (const uint8_t _senderId )
102
+ MyMessage& MyMessage::setSender (const uint8_t senderId )
102
103
{
103
- this ->sender = _senderId ;
104
+ this ->sender = senderId ;
104
105
return *this ;
105
106
}
106
107
@@ -109,9 +110,9 @@ uint8_t MyMessage::getSensor(void) const
109
110
return this ->sensor ;
110
111
}
111
112
112
- MyMessage& MyMessage::setSensor (const uint8_t _sensorId )
113
+ MyMessage& MyMessage::setSensor (const uint8_t sensorId )
113
114
{
114
- this ->sensor = _sensorId ;
115
+ this ->sensor = sensorId ;
115
116
return *this ;
116
117
}
117
118
@@ -120,9 +121,9 @@ uint8_t MyMessage::getDestination(void) const
120
121
return this ->destination ;
121
122
}
122
123
123
- MyMessage& MyMessage::setDestination (const uint8_t _destinationId )
124
+ MyMessage& MyMessage::setDestination (const uint8_t destinationId )
124
125
{
125
- this ->destination = _destinationId ;
126
+ this ->destination = destinationId ;
126
127
return *this ;
127
128
}
128
129
@@ -138,9 +139,9 @@ bool MyMessage::isEcho(void) const
138
139
V2_MYS_HEADER_CEP_ECHOEQUEST_SIZE);
139
140
}
140
141
141
- MyMessage& MyMessage::setEcho (const bool _echo )
142
+ MyMessage& MyMessage::setEcho (const bool echo )
142
143
{
143
- BF_SET (this ->command_echo_payload , _echo , V2_MYS_HEADER_CEP_ECHOREQUEST_POS,
144
+ BF_SET (this ->command_echo_payload , echo , V2_MYS_HEADER_CEP_ECHOREQUEST_POS,
144
145
V2_MYS_HEADER_CEP_ECHOEQUEST_SIZE);
145
146
return *this ;
146
147
}
@@ -151,9 +152,9 @@ bool MyMessage::getRequestEcho(void) const
151
152
V2_MYS_HEADER_CEP_ECHO_SIZE);
152
153
}
153
154
154
- MyMessage& MyMessage::setRequestEcho (const bool _requestEcho )
155
+ MyMessage& MyMessage::setRequestEcho (const bool requestEcho )
155
156
{
156
- BF_SET (this ->command_echo_payload , _requestEcho , V2_MYS_HEADER_CEP_ECHO_POS,
157
+ BF_SET (this ->command_echo_payload , requestEcho , V2_MYS_HEADER_CEP_ECHO_POS,
157
158
V2_MYS_HEADER_CEP_ECHO_SIZE);
158
159
return *this ;
159
160
}
@@ -164,9 +165,9 @@ uint8_t MyMessage::getVersion(void) const
164
165
V2_MYS_HEADER_VSL_VERSION_SIZE);
165
166
}
166
167
167
- MyMessage& MyMessage::setVersion (const uint8_t _version )
168
+ MyMessage& MyMessage::setVersion (void )
168
169
{
169
- BF_SET (this ->version_length , _version , V2_MYS_HEADER_VSL_VERSION_POS,
170
+ BF_SET (this ->version_length , V2_MYS_HEADER_PROTOCOL_VERSION , V2_MYS_HEADER_VSL_VERSION_POS,
170
171
V2_MYS_HEADER_VSL_VERSION_SIZE);
171
172
return *this ;
172
173
}
@@ -177,9 +178,9 @@ mysensors_command_t MyMessage::getCommand(void) const
177
178
V2_MYS_HEADER_CEP_COMMAND_POS, V2_MYS_HEADER_CEP_COMMAND_SIZE));
178
179
}
179
180
180
- MyMessage& MyMessage::setCommand (const mysensors_command_t _command )
181
+ MyMessage& MyMessage::setCommand (const mysensors_command_t command )
181
182
{
182
- BF_SET (this ->command_echo_payload , static_cast <uint8_t >(_command ), V2_MYS_HEADER_CEP_COMMAND_POS,
183
+ BF_SET (this ->command_echo_payload , static_cast <uint8_t >(command ), V2_MYS_HEADER_CEP_COMMAND_POS,
183
184
V2_MYS_HEADER_CEP_COMMAND_SIZE);
184
185
return *this ;
185
186
}
@@ -190,9 +191,9 @@ mysensors_payload_t MyMessage::getPayloadType(void) const
190
191
V2_MYS_HEADER_CEP_PAYLOADTYPE_POS, V2_MYS_HEADER_CEP_PAYLOADTYPE_SIZE));
191
192
}
192
193
193
- MyMessage& MyMessage::setPayloadType (const mysensors_payload_t _payloadType )
194
+ MyMessage& MyMessage::setPayloadType (const mysensors_payload_t payloadType )
194
195
{
195
- BF_SET (this ->command_echo_payload , static_cast <uint8_t >(_payloadType ),
196
+ BF_SET (this ->command_echo_payload , static_cast <uint8_t >(payloadType ),
196
197
V2_MYS_HEADER_CEP_PAYLOADTYPE_POS, V2_MYS_HEADER_CEP_PAYLOADTYPE_SIZE);
197
198
return *this ;
198
199
}
@@ -203,9 +204,10 @@ bool MyMessage::getSigned(void) const
203
204
V2_MYS_HEADER_VSL_SIGNED_SIZE);
204
205
}
205
206
206
- MyMessage& MyMessage::setSigned (const bool _signed )
207
+ MyMessage& MyMessage::setSigned (const bool signedFlag )
207
208
{
208
- BF_SET (this ->version_length , _signed, V2_MYS_HEADER_VSL_SIGNED_POS, V2_MYS_HEADER_VSL_SIGNED_SIZE);
209
+ BF_SET (this ->version_length , signedFlag, V2_MYS_HEADER_VSL_SIGNED_POS,
210
+ V2_MYS_HEADER_VSL_SIGNED_SIZE);
209
211
return *this ;
210
212
}
211
213
@@ -220,15 +222,16 @@ uint8_t MyMessage::getLength(void) const
220
222
return length;
221
223
}
222
224
223
- MyMessage& MyMessage::setLength (const uint8_t _length )
225
+ MyMessage& MyMessage::setLength (const uint8_t length )
224
226
{
225
- uint8_t length = _length ;
227
+ uint8_t finalLength = length ;
226
228
// limit length
227
- if (length > MAX_PAYLOAD_SIZE) {
228
- length = MAX_PAYLOAD_SIZE;
229
+ if (finalLength > MAX_PAYLOAD_SIZE) {
230
+ finalLength = MAX_PAYLOAD_SIZE;
229
231
}
230
232
231
- BF_SET (this ->version_length , length, V2_MYS_HEADER_VSL_LENGTH_POS, V2_MYS_HEADER_VSL_LENGTH_SIZE);
233
+ BF_SET (this ->version_length , finalLength, V2_MYS_HEADER_VSL_LENGTH_POS,
234
+ V2_MYS_HEADER_VSL_LENGTH_SIZE);
232
235
return *this ;
233
236
}
234
237
0 commit comments