@@ -88,15 +88,15 @@ SimpleSerialProtocol::SimpleSerialProtocol(
88
88
Serial_& usbapiSerialRef,
89
89
const unsigned long baudrate,
90
90
const unsigned long waitForByteTimeout,
91
- const ErrorCallbackPointer _standaloneErrorCallbackPointer ,
91
+ const ErrorCallbackPointer _errorCallbackPointer ,
92
92
const byte _commandCallbackRangeFrom,
93
93
const byte _commandCallbackRangeTo) :
94
94
SimpleSerialProtocol{
95
95
static_cast <Stream&>(usbapiSerialRef),
96
96
false ,
97
97
baudrate,
98
98
waitForByteTimeout,
99
- _standaloneErrorCallbackPointer ,
99
+ _errorCallbackPointer ,
100
100
_commandCallbackRangeFrom,
101
101
_commandCallbackRangeTo
102
102
}
@@ -107,15 +107,15 @@ SimpleSerialProtocol::SimpleSerialProtocol(
107
107
Serial_* usbapiSerialPtr,
108
108
const unsigned long baudrate,
109
109
const unsigned long waitForByteTimeout,
110
- const ErrorCallbackPointer _standaloneErrorCallbackPointer ,
110
+ const ErrorCallbackPointer _errorCallbackPointer ,
111
111
const byte _commandCallbackRangeFrom,
112
112
const byte _commandCallbackRangeTo) :
113
113
SimpleSerialProtocol{
114
114
static_cast <Stream*>(usbapiSerialPtr),
115
115
false ,
116
116
baudrate,
117
117
waitForByteTimeout,
118
- _standaloneErrorCallbackPointer ,
118
+ _errorCallbackPointer ,
119
119
_commandCallbackRangeFrom,
120
120
_commandCallbackRangeTo
121
121
}
@@ -141,7 +141,7 @@ SimpleSerialProtocol::SimpleSerialProtocol(
141
141
},
142
142
_commandCallbackRangeFrom{commandCallbackRangeFrom},
143
143
_commandCallbackRangeTo{commandCallbackRangeTo},
144
- _standaloneErrorCallbackPointer {errorCallbackPointer}
144
+ _errorCallbackPointer {errorCallbackPointer}
145
145
{
146
146
_afterConstructor ();
147
147
}
@@ -163,24 +163,24 @@ SimpleSerialProtocol::SimpleSerialProtocol(
163
163
},
164
164
_commandCallbackRangeFrom{commandCallbackRangeFrom},
165
165
_commandCallbackRangeTo{commandCallbackRangeTo},
166
- _standaloneErrorCallbackPointer {errorCallbackPointer}
166
+ _errorCallbackPointer {errorCallbackPointer}
167
167
{
168
168
_afterConstructor ();
169
169
}
170
170
171
171
SimpleSerialProtocol::~SimpleSerialProtocol ()
172
172
{
173
- delete[] this ->_standaloneCommandCallbackPointers ;
173
+ delete[] this ->_commandCallbackPointers ;
174
174
}
175
175
176
176
void SimpleSerialProtocol::_afterConstructor ()
177
177
{
178
178
const byte commandCallbackPointerBufferMaxIndex = abs (_commandCallbackRangeTo - _commandCallbackRangeFrom);
179
179
const uint16_t commandCallbackPointerBufferSize = static_cast <uint16_t >(commandCallbackPointerBufferMaxIndex) + 1 ;
180
- this ->_standaloneCommandCallbackPointers = new CallbackPointer[commandCallbackPointerBufferSize];
180
+ this ->_commandCallbackPointers = new CallbackPointer[commandCallbackPointerBufferSize];
181
181
for (uint16_t i = 0 ; i <= commandCallbackPointerBufferMaxIndex; i++)
182
182
{
183
- this ->_standaloneCommandCallbackPointers [i] = nullptr ;
183
+ this ->_commandCallbackPointers [i] = nullptr ;
184
184
}
185
185
}
186
186
@@ -256,12 +256,12 @@ void SimpleSerialProtocol::writeEot() const
256
256
this ->writeByte (CHAR_EOT);
257
257
}
258
258
259
- void SimpleSerialProtocol::setDieInstantlyOnNotRegisteredCommand (const bool die)
259
+ void SimpleSerialProtocol::setDieImmediatelyOnNotRegisteredCommand (const bool die)
260
260
{
261
261
this ->_dieImmediatelyOnNotRegisteredCommand = die;
262
262
}
263
263
264
- void SimpleSerialProtocol::registerCommand (const byte command, const CallbackPointer callbackPointer )
264
+ void SimpleSerialProtocol::registerCommand (const byte command, const CallbackPointer commandCallbackPointer )
265
265
{
266
266
// Serial.println(F("SimpleSerialProtocol::registerCommand"));
267
267
@@ -283,7 +283,7 @@ void SimpleSerialProtocol::registerCommand(const byte command, const CallbackPoi
283
283
return ;
284
284
}
285
285
286
- this ->_registerCommandCallback (command, callbackPointer );
286
+ this ->_registerCommandCallback (command, commandCallbackPointer );
287
287
}
288
288
289
289
void SimpleSerialProtocol::unregisterCommand (const byte command)
@@ -357,13 +357,13 @@ void SimpleSerialProtocol::_registerCommandCallback(
357
357
) const
358
358
{
359
359
const uint8_t commandIndex = this ->_getCommandIndex (command);
360
- this ->_standaloneCommandCallbackPointers [commandIndex] = commandCallbackPointer;
360
+ this ->_commandCallbackPointers [commandIndex] = commandCallbackPointer;
361
361
}
362
362
363
363
void SimpleSerialProtocol::_unregisterCommandCallback (const byte command) const
364
364
{
365
365
const uint8_t commandIndex = this ->_getCommandIndex (command);
366
- this ->_standaloneCommandCallbackPointers [commandIndex] = nullptr ;
366
+ this ->_commandCallbackPointers [commandIndex] = nullptr ;
367
367
}
368
368
369
369
bool SimpleSerialProtocol::_isCommandRangeValid () const
@@ -384,7 +384,7 @@ bool SimpleSerialProtocol::_isCommandInReservedRange(const byte command) const
384
384
bool SimpleSerialProtocol::_isCommandRegistered (const byte command) const
385
385
{
386
386
const uint8_t commandIndex = this ->_getCommandIndex (command);
387
- return this ->_standaloneCommandCallbackPointers [commandIndex] != nullptr ;
387
+ return this ->_commandCallbackPointers [commandIndex] != nullptr ;
388
388
}
389
389
390
390
uint8_t SimpleSerialProtocol::_getCommandIndex (const byte command) const
@@ -395,13 +395,13 @@ uint8_t SimpleSerialProtocol::_getCommandIndex(const byte command) const
395
395
void SimpleSerialProtocol::_callCommandCallback (const byte command) const
396
396
{
397
397
const uint8_t commandIndex = this ->_getCommandIndex (command);
398
- const CallbackPointer commandCallbackPointer = this ->_standaloneCommandCallbackPointers [commandIndex];
398
+ const CallbackPointer commandCallbackPointer = this ->_commandCallbackPointers [commandIndex];
399
399
commandCallbackPointer ();
400
400
}
401
401
402
402
void SimpleSerialProtocol::_error (const uint8_t errorNum, const bool dieImmediately)
403
403
{
404
- this ->_standaloneErrorCallbackPointer (errorNum);
404
+ this ->_errorCallbackPointer (errorNum);
405
405
if (dieImmediately) this ->_die ();
406
406
}
407
407
@@ -435,5 +435,5 @@ void SimpleSerialProtocol::_flushCommand()
435
435
void SimpleSerialProtocol::_die ()
436
436
{
437
437
this ->_isDead = true ;
438
- this ->_standaloneErrorCallbackPointer (ERROR_IS_DEAD);
438
+ this ->_errorCallbackPointer (ERROR_IS_DEAD);
439
439
}
0 commit comments