2626
2727MyMessage::MyMessage (void )
2828{
29- clear ();
29+ this -> clear ();
3030}
3131
3232MyMessage::MyMessage (const uint8_t _sensorId, const mysensors_data_t _dataType)
3333{
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));
3737}
3838
3939void MyMessage::clear (void )
@@ -45,10 +45,11 @@ void MyMessage::clear(void)
4545 this ->command_echo_payload = 0u ;
4646 this ->type = 0u ;
4747 this ->sensor = 0u ;
48+ // clear data buffer
4849 (void )memset ((void *)this ->data , 0u , sizeof (this ->data ));
4950
5051 // set message protocol version
51- (void )this ->setVersion (PROTOCOL_VERSION );
52+ (void )this ->setVersion ();
5253}
5354
5455uint8_t MyMessage::getHeaderSize (void ) const
@@ -68,17 +69,17 @@ uint8_t MyMessage::getExpectedMessageSize(void) const
6869
6970bool MyMessage::isProtocolVersionValid (void ) const
7071{
71- return (this ->getVersion () == PROTOCOL_VERSION );
72+ return (this ->getVersion () == V2_MYS_HEADER_PROTOCOL_VERSION );
7273}
7374
7475uint8_t MyMessage::getType (void ) const
7576{
7677 return this ->type ;
7778}
7879
79- MyMessage& MyMessage::setType (const uint8_t _messageType )
80+ MyMessage& MyMessage::setType (const uint8_t messageType )
8081{
81- this ->type = _messageType ;
82+ this ->type = messageType ;
8283 return *this ;
8384}
8485
@@ -87,9 +88,9 @@ uint8_t MyMessage::getLast(void) const
8788 return this ->last ;
8889}
8990
90- MyMessage& MyMessage::setLast (const uint8_t _lastId )
91+ MyMessage& MyMessage::setLast (const uint8_t lastId )
9192{
92- this ->last = _lastId ;
93+ this ->last = lastId ;
9394 return *this ;
9495}
9596
@@ -98,9 +99,9 @@ uint8_t MyMessage::getSender(void) const
9899 return this ->sender ;
99100}
100101
101- MyMessage& MyMessage::setSender (const uint8_t _senderId )
102+ MyMessage& MyMessage::setSender (const uint8_t senderId )
102103{
103- this ->sender = _senderId ;
104+ this ->sender = senderId ;
104105 return *this ;
105106}
106107
@@ -109,9 +110,9 @@ uint8_t MyMessage::getSensor(void) const
109110 return this ->sensor ;
110111}
111112
112- MyMessage& MyMessage::setSensor (const uint8_t _sensorId )
113+ MyMessage& MyMessage::setSensor (const uint8_t sensorId )
113114{
114- this ->sensor = _sensorId ;
115+ this ->sensor = sensorId ;
115116 return *this ;
116117}
117118
@@ -120,9 +121,9 @@ uint8_t MyMessage::getDestination(void) const
120121 return this ->destination ;
121122}
122123
123- MyMessage& MyMessage::setDestination (const uint8_t _destinationId )
124+ MyMessage& MyMessage::setDestination (const uint8_t destinationId )
124125{
125- this ->destination = _destinationId ;
126+ this ->destination = destinationId ;
126127 return *this ;
127128}
128129
@@ -138,9 +139,9 @@ bool MyMessage::isEcho(void) const
138139 V2_MYS_HEADER_CEP_ECHOEQUEST_SIZE);
139140}
140141
141- MyMessage& MyMessage::setEcho (const bool _echo )
142+ MyMessage& MyMessage::setEcho (const bool echo )
142143{
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,
144145 V2_MYS_HEADER_CEP_ECHOEQUEST_SIZE);
145146 return *this ;
146147}
@@ -151,9 +152,9 @@ bool MyMessage::getRequestEcho(void) const
151152 V2_MYS_HEADER_CEP_ECHO_SIZE);
152153}
153154
154- MyMessage& MyMessage::setRequestEcho (const bool _requestEcho )
155+ MyMessage& MyMessage::setRequestEcho (const bool requestEcho )
155156{
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,
157158 V2_MYS_HEADER_CEP_ECHO_SIZE);
158159 return *this ;
159160}
@@ -164,9 +165,9 @@ uint8_t MyMessage::getVersion(void) const
164165 V2_MYS_HEADER_VSL_VERSION_SIZE);
165166}
166167
167- MyMessage& MyMessage::setVersion (const uint8_t _version )
168+ MyMessage& MyMessage::setVersion (void )
168169{
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,
170171 V2_MYS_HEADER_VSL_VERSION_SIZE);
171172 return *this ;
172173}
@@ -177,9 +178,9 @@ mysensors_command_t MyMessage::getCommand(void) const
177178 V2_MYS_HEADER_CEP_COMMAND_POS, V2_MYS_HEADER_CEP_COMMAND_SIZE));
178179}
179180
180- MyMessage& MyMessage::setCommand (const mysensors_command_t _command )
181+ MyMessage& MyMessage::setCommand (const mysensors_command_t command )
181182{
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,
183184 V2_MYS_HEADER_CEP_COMMAND_SIZE);
184185 return *this ;
185186}
@@ -190,9 +191,9 @@ mysensors_payload_t MyMessage::getPayloadType(void) const
190191 V2_MYS_HEADER_CEP_PAYLOADTYPE_POS, V2_MYS_HEADER_CEP_PAYLOADTYPE_SIZE));
191192}
192193
193- MyMessage& MyMessage::setPayloadType (const mysensors_payload_t _payloadType )
194+ MyMessage& MyMessage::setPayloadType (const mysensors_payload_t payloadType )
194195{
195- BF_SET (this ->command_echo_payload , static_cast <uint8_t >(_payloadType ),
196+ BF_SET (this ->command_echo_payload , static_cast <uint8_t >(payloadType ),
196197 V2_MYS_HEADER_CEP_PAYLOADTYPE_POS, V2_MYS_HEADER_CEP_PAYLOADTYPE_SIZE);
197198 return *this ;
198199}
@@ -203,9 +204,10 @@ bool MyMessage::getSigned(void) const
203204 V2_MYS_HEADER_VSL_SIGNED_SIZE);
204205}
205206
206- MyMessage& MyMessage::setSigned (const bool _signed )
207+ MyMessage& MyMessage::setSigned (const bool signedFlag )
207208{
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);
209211 return *this ;
210212}
211213
@@ -220,15 +222,16 @@ uint8_t MyMessage::getLength(void) const
220222 return length;
221223}
222224
223- MyMessage& MyMessage::setLength (const uint8_t _length )
225+ MyMessage& MyMessage::setLength (const uint8_t length )
224226{
225- uint8_t length = _length ;
227+ uint8_t finalLength = length ;
226228 // limit length
227- if (length > MAX_PAYLOAD_SIZE) {
228- length = MAX_PAYLOAD_SIZE;
229+ if (finalLength > MAX_PAYLOAD_SIZE) {
230+ finalLength = MAX_PAYLOAD_SIZE;
229231 }
230232
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);
232235 return *this ;
233236}
234237
0 commit comments