@@ -186,9 +186,9 @@ void noteTransactionStop (void) {
186
186
The TwoWire implementation to use for I2C communication.
187
187
*/
188
188
/* *************************************************************************/
189
- void Notecard::platformInit (bool assignCallbacks)
189
+ void Notecard::platformInit (bool assignCallbacks) const
190
190
{
191
- NoteSetUserAgent ((char *)" note-arduino" );
191
+ NoteSetUserAgent ((char *) ( " note-arduino " NOTE_ARDUINO_VERSION) );
192
192
if (assignCallbacks) {
193
193
NoteSetFnDefault (malloc, free, noteDelay, noteMillis);
194
194
} else {
@@ -225,7 +225,7 @@ Notecard::~Notecard (void)
225
225
appropriately for the host.
226
226
*/
227
227
/* *************************************************************************/
228
- void Notecard::begin (NoteI2c * noteI2c_, uint32_t i2cAddress_, uint32_t i2cMax_)
228
+ void Notecard::begin (NoteI2c * noteI2c_, uint32_t i2cAddress_, uint32_t i2cMax_) const
229
229
{
230
230
noteI2c = noteI2c_;
231
231
platformInit (noteI2c);
@@ -247,7 +247,7 @@ void Notecard::begin(NoteI2c * noteI2c_, uint32_t i2cAddress_, uint32_t i2cMax_)
247
247
communicating with the Notecard from the host.
248
248
*/
249
249
/* *************************************************************************/
250
- void Notecard::begin (NoteSerial * noteSerial_)
250
+ void Notecard::begin (NoteSerial * noteSerial_) const
251
251
{
252
252
noteSerial = noteSerial_;
253
253
platformInit (noteSerial);
@@ -273,7 +273,7 @@ void Notecard::begin(NoteSerial * noteSerial_)
273
273
@brief Clear the debug output source.
274
274
*/
275
275
/* *************************************************************************/
276
- void Notecard::clearDebugOutputStream (void )
276
+ void Notecard::clearDebugOutputStream (void ) const
277
277
{
278
278
setDebugOutputStream (nullptr );
279
279
}
@@ -290,7 +290,7 @@ void Notecard::clearDebugOutputStream(void)
290
290
@return `True` if a pending response was displayed to the debug stream.
291
291
*/
292
292
/* *************************************************************************/
293
- bool Notecard::debugSyncStatus (int pollFrequencyMs, int maxLevel)
293
+ bool Notecard::debugSyncStatus (int pollFrequencyMs, int maxLevel) const
294
294
{
295
295
return NoteDebugSyncStatus (pollFrequencyMs, maxLevel);
296
296
}
@@ -302,11 +302,32 @@ bool Notecard::debugSyncStatus(int pollFrequencyMs, int maxLevel)
302
302
A `J` JSON response object.
303
303
*/
304
304
/* *************************************************************************/
305
- void Notecard::deleteResponse (J *rsp)
305
+ void Notecard::deleteResponse (J *rsp) const
306
306
{
307
307
NoteDeleteResponse (rsp);
308
308
}
309
309
310
+ /* *************************************************************************/
311
+ /* !
312
+ @brief Deinitialize the Notecard object communication.
313
+ This function clears the Notecard object's communication
314
+ interfaces, and frees all associated memory.
315
+ */
316
+ /* *************************************************************************/
317
+ void Notecard::end (void ) const
318
+ {
319
+ // Clear Communication Interfaces
320
+ NoteSetFnI2C (0 , 0 , nullptr , nullptr , nullptr );
321
+ NoteSetFnSerial (nullptr , nullptr , nullptr , nullptr );
322
+
323
+ // Clear Platform Callbacks
324
+ platformInit (false );
325
+
326
+ // Delete Singletons
327
+ noteI2c = make_note_i2c (nullptr );
328
+ noteSerial = make_note_serial (nullptr );
329
+ }
330
+
310
331
/* *************************************************************************/
311
332
/* !
312
333
@deprecated NoteDebug, which this function wraps, should be treated as an
@@ -317,7 +338,7 @@ void Notecard::deleteResponse(J *rsp)
317
338
A string to log to the serial debug stream.
318
339
*/
319
340
/* *************************************************************************/
320
- NOTE_ARDUINO_DEPRECATED void Notecard::logDebug (const char *message)
341
+ NOTE_ARDUINO_DEPRECATED void Notecard::logDebug (const char *message) const
321
342
{
322
343
#ifdef NOTE_ARDUINO_NO_DEPRECATED_ATTR
323
344
NOTE_C_LOG_WARN (" logDebug is deprecated." )
@@ -336,7 +357,7 @@ NOTE_ARDUINO_DEPRECATED void Notecard::logDebug(const char *message)
336
357
@param ... one or more values to interpolate into the format string.
337
358
*/
338
359
/* *************************************************************************/
339
- NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf (const char *format, ...)
360
+ NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf (const char *format, ...) const
340
361
{
341
362
char message[256 ];
342
363
va_list args;
@@ -360,7 +381,7 @@ NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf(const char *format, ...)
360
381
@return A `J` JSON Object populated with the request name.
361
382
*/
362
383
/* *************************************************************************/
363
- J *Notecard::newCommand (const char *request)
384
+ J *Notecard::newCommand (const char *request) const
364
385
{
365
386
return NoteNewCommand (request);
366
387
}
@@ -375,7 +396,7 @@ J *Notecard::newCommand(const char *request)
375
396
@return A `J` JSON Object populated with the request name.
376
397
*/
377
398
/* *************************************************************************/
378
- J *Notecard::newRequest (const char *request)
399
+ J *Notecard::newRequest (const char *request) const
379
400
{
380
401
return NoteNewRequest (request);
381
402
}
@@ -390,7 +411,7 @@ J *Notecard::newRequest(const char *request)
390
411
@return `J` JSON Object with the response from the Notecard.
391
412
*/
392
413
/* *************************************************************************/
393
- J *Notecard::requestAndResponse (J *req)
414
+ J *Notecard::requestAndResponse (J *req) const
394
415
{
395
416
return NoteRequestResponse (req);
396
417
}
@@ -406,7 +427,7 @@ J *Notecard::requestAndResponse(J *req)
406
427
@return `J` JSON Object with the response from the Notecard.
407
428
*/
408
429
/* *************************************************************************/
409
- J *Notecard::requestAndResponseWithRetry (J *req, uint32_t timeoutSeconds)
430
+ J *Notecard::requestAndResponseWithRetry (J *req, uint32_t timeoutSeconds) const
410
431
{
411
432
return NoteRequestResponseWithRetry (req, timeoutSeconds);
412
433
}
@@ -419,7 +440,7 @@ J *Notecard::requestAndResponseWithRetry(J *req, uint32_t timeoutSeconds)
419
440
@return `true` if the response object contains an error.
420
441
*/
421
442
/* *************************************************************************/
422
- bool Notecard::responseError (J *rsp)
443
+ bool Notecard::responseError (J *rsp) const
423
444
{
424
445
return NoteResponseError (rsp);
425
446
}
@@ -435,7 +456,7 @@ bool Notecard::responseError(J *rsp)
435
456
`False` if there was an error.
436
457
*/
437
458
/* *************************************************************************/
438
- bool Notecard::sendRequest (J *req)
459
+ bool Notecard::sendRequest (J *req) const
439
460
{
440
461
return NoteRequest (req);
441
462
}
@@ -452,7 +473,7 @@ bool Notecard::sendRequest(J *req)
452
473
`False` if the message couldn't be sent.
453
474
*/
454
475
/* *************************************************************************/
455
- bool Notecard::sendRequestWithRetry (J *req, uint32_t timeoutSeconds)
476
+ bool Notecard::sendRequestWithRetry (J *req, uint32_t timeoutSeconds) const
456
477
{
457
478
return NoteRequestWithRetry (req, timeoutSeconds);
458
479
}
@@ -469,7 +490,7 @@ bool Notecard::sendRequestWithRetry(J *req, uint32_t timeoutSeconds)
469
490
debug output.
470
491
*/
471
492
/* *************************************************************************/
472
- void Notecard::setDebugOutputStream (NoteLog * noteLog_)
493
+ void Notecard::setDebugOutputStream (NoteLog * noteLog_) const
473
494
{
474
495
noteLog = noteLog_;
475
496
if (noteLog) {
@@ -492,7 +513,7 @@ void Notecard::setDebugOutputStream(NoteLog * noteLog_)
492
513
I2C bus taken during the call to `lockI2cFn()`.
493
514
*/
494
515
/* *************************************************************************/
495
- void Notecard::setFnI2cMutex (mutexFn lockI2cFn_, mutexFn unlockI2cFn_) {
516
+ void Notecard::setFnI2cMutex (mutexFn lockI2cFn_, mutexFn unlockI2cFn_) const {
496
517
NoteSetFnI2CMutex (lockI2cFn_, unlockI2cFn_);
497
518
}
498
519
@@ -509,7 +530,7 @@ void Notecard::setFnI2cMutex(mutexFn lockI2cFn_, mutexFn unlockI2cFn_) {
509
530
Notecard transaction taken during the call to `lockNoteFn()`.
510
531
*/
511
532
/* *************************************************************************/
512
- void Notecard::setFnNoteMutex (mutexFn lockNoteFn_, mutexFn unlockNoteFn_) {
533
+ void Notecard::setFnNoteMutex (mutexFn lockNoteFn_, mutexFn unlockNoteFn_) const {
513
534
NoteSetFnNoteMutex (lockNoteFn_, unlockNoteFn_);
514
535
}
515
536
@@ -528,7 +549,7 @@ void Notecard::setFnNoteMutex(mutexFn lockNoteFn_, mutexFn unlockNoteFn_) {
528
549
A platform specific tuple of digital I/O pins.
529
550
*/
530
551
/* *************************************************************************/
531
- void Notecard::setTransactionPins (NoteTxn * noteTxn_) {
552
+ void Notecard::setTransactionPins (NoteTxn * noteTxn_) const {
532
553
noteTxn = noteTxn_; // Set global interface
533
554
if (noteTxn_) {
534
555
NoteSetFnTransaction (noteTransactionStart, noteTransactionStop);
0 commit comments