@@ -186,9 +186,9 @@ void noteTransactionStop (void) {
186186 The TwoWire implementation to use for I2C communication.
187187*/
188188/* *************************************************************************/
189- void Notecard::platformInit (bool assignCallbacks)
189+ void Notecard::platformInit (bool assignCallbacks) const
190190{
191- NoteSetUserAgent ((char *)" note-arduino" );
191+ NoteSetUserAgent ((char *) ( " note-arduino " NOTE_ARDUINO_VERSION) );
192192 if (assignCallbacks) {
193193 NoteSetFnDefault (malloc, free, noteDelay, noteMillis);
194194 } else {
@@ -225,7 +225,7 @@ Notecard::~Notecard (void)
225225 appropriately for the host.
226226*/
227227/* *************************************************************************/
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
229229{
230230 noteI2c = noteI2c_;
231231 platformInit (noteI2c);
@@ -247,7 +247,7 @@ void Notecard::begin(NoteI2c * noteI2c_, uint32_t i2cAddress_, uint32_t i2cMax_)
247247 communicating with the Notecard from the host.
248248*/
249249/* *************************************************************************/
250- void Notecard::begin (NoteSerial * noteSerial_)
250+ void Notecard::begin (NoteSerial * noteSerial_) const
251251{
252252 noteSerial = noteSerial_;
253253 platformInit (noteSerial);
@@ -273,7 +273,7 @@ void Notecard::begin(NoteSerial * noteSerial_)
273273 @brief Clear the debug output source.
274274*/
275275/* *************************************************************************/
276- void Notecard::clearDebugOutputStream (void )
276+ void Notecard::clearDebugOutputStream (void ) const
277277{
278278 setDebugOutputStream (nullptr );
279279}
@@ -290,7 +290,7 @@ void Notecard::clearDebugOutputStream(void)
290290 @return `True` if a pending response was displayed to the debug stream.
291291*/
292292/* *************************************************************************/
293- bool Notecard::debugSyncStatus (int pollFrequencyMs, int maxLevel)
293+ bool Notecard::debugSyncStatus (int pollFrequencyMs, int maxLevel) const
294294{
295295 return NoteDebugSyncStatus (pollFrequencyMs, maxLevel);
296296}
@@ -302,11 +302,32 @@ bool Notecard::debugSyncStatus(int pollFrequencyMs, int maxLevel)
302302 A `J` JSON response object.
303303*/
304304/* *************************************************************************/
305- void Notecard::deleteResponse (J *rsp)
305+ void Notecard::deleteResponse (J *rsp) const
306306{
307307 NoteDeleteResponse (rsp);
308308}
309309
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+
310331/* *************************************************************************/
311332/* !
312333 @deprecated NoteDebug, which this function wraps, should be treated as an
@@ -317,7 +338,7 @@ void Notecard::deleteResponse(J *rsp)
317338 A string to log to the serial debug stream.
318339*/
319340/* *************************************************************************/
320- NOTE_ARDUINO_DEPRECATED void Notecard::logDebug (const char *message)
341+ NOTE_ARDUINO_DEPRECATED void Notecard::logDebug (const char *message) const
321342{
322343#ifdef NOTE_ARDUINO_NO_DEPRECATED_ATTR
323344 NOTE_C_LOG_WARN (" logDebug is deprecated." )
@@ -336,7 +357,7 @@ NOTE_ARDUINO_DEPRECATED void Notecard::logDebug(const char *message)
336357 @param ... one or more values to interpolate into the format string.
337358*/
338359/* *************************************************************************/
339- NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf (const char *format, ...)
360+ NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf (const char *format, ...) const
340361{
341362 char message[256 ];
342363 va_list args;
@@ -360,7 +381,7 @@ NOTE_ARDUINO_DEPRECATED void Notecard::logDebugf(const char *format, ...)
360381 @return A `J` JSON Object populated with the request name.
361382*/
362383/* *************************************************************************/
363- J *Notecard::newCommand (const char *request)
384+ J *Notecard::newCommand (const char *request) const
364385{
365386 return NoteNewCommand (request);
366387}
@@ -375,7 +396,7 @@ J *Notecard::newCommand(const char *request)
375396 @return A `J` JSON Object populated with the request name.
376397*/
377398/* *************************************************************************/
378- J *Notecard::newRequest (const char *request)
399+ J *Notecard::newRequest (const char *request) const
379400{
380401 return NoteNewRequest (request);
381402}
@@ -390,7 +411,7 @@ J *Notecard::newRequest(const char *request)
390411 @return `J` JSON Object with the response from the Notecard.
391412*/
392413/* *************************************************************************/
393- J *Notecard::requestAndResponse (J *req)
414+ J *Notecard::requestAndResponse (J *req) const
394415{
395416 return NoteRequestResponse (req);
396417}
@@ -406,7 +427,7 @@ J *Notecard::requestAndResponse(J *req)
406427 @return `J` JSON Object with the response from the Notecard.
407428*/
408429/* *************************************************************************/
409- J *Notecard::requestAndResponseWithRetry (J *req, uint32_t timeoutSeconds)
430+ J *Notecard::requestAndResponseWithRetry (J *req, uint32_t timeoutSeconds) const
410431{
411432 return NoteRequestResponseWithRetry (req, timeoutSeconds);
412433}
@@ -419,7 +440,7 @@ J *Notecard::requestAndResponseWithRetry(J *req, uint32_t timeoutSeconds)
419440 @return `true` if the response object contains an error.
420441*/
421442/* *************************************************************************/
422- bool Notecard::responseError (J *rsp)
443+ bool Notecard::responseError (J *rsp) const
423444{
424445 return NoteResponseError (rsp);
425446}
@@ -435,7 +456,7 @@ bool Notecard::responseError(J *rsp)
435456 `False` if there was an error.
436457*/
437458/* *************************************************************************/
438- bool Notecard::sendRequest (J *req)
459+ bool Notecard::sendRequest (J *req) const
439460{
440461 return NoteRequest (req);
441462}
@@ -452,7 +473,7 @@ bool Notecard::sendRequest(J *req)
452473 `False` if the message couldn't be sent.
453474*/
454475/* *************************************************************************/
455- bool Notecard::sendRequestWithRetry (J *req, uint32_t timeoutSeconds)
476+ bool Notecard::sendRequestWithRetry (J *req, uint32_t timeoutSeconds) const
456477{
457478 return NoteRequestWithRetry (req, timeoutSeconds);
458479}
@@ -469,7 +490,7 @@ bool Notecard::sendRequestWithRetry(J *req, uint32_t timeoutSeconds)
469490 debug output.
470491*/
471492/* *************************************************************************/
472- void Notecard::setDebugOutputStream (NoteLog * noteLog_)
493+ void Notecard::setDebugOutputStream (NoteLog * noteLog_) const
473494{
474495 noteLog = noteLog_;
475496 if (noteLog) {
@@ -492,7 +513,7 @@ void Notecard::setDebugOutputStream(NoteLog * noteLog_)
492513 I2C bus taken during the call to `lockI2cFn()`.
493514*/
494515/* *************************************************************************/
495- void Notecard::setFnI2cMutex (mutexFn lockI2cFn_, mutexFn unlockI2cFn_) {
516+ void Notecard::setFnI2cMutex (mutexFn lockI2cFn_, mutexFn unlockI2cFn_) const {
496517 NoteSetFnI2CMutex (lockI2cFn_, unlockI2cFn_);
497518}
498519
@@ -509,7 +530,7 @@ void Notecard::setFnI2cMutex(mutexFn lockI2cFn_, mutexFn unlockI2cFn_) {
509530 Notecard transaction taken during the call to `lockNoteFn()`.
510531*/
511532/* *************************************************************************/
512- void Notecard::setFnNoteMutex (mutexFn lockNoteFn_, mutexFn unlockNoteFn_) {
533+ void Notecard::setFnNoteMutex (mutexFn lockNoteFn_, mutexFn unlockNoteFn_) const {
513534 NoteSetFnNoteMutex (lockNoteFn_, unlockNoteFn_);
514535}
515536
@@ -528,7 +549,7 @@ void Notecard::setFnNoteMutex(mutexFn lockNoteFn_, mutexFn unlockNoteFn_) {
528549 A platform specific tuple of digital I/O pins.
529550*/
530551/* *************************************************************************/
531- void Notecard::setTransactionPins (NoteTxn * noteTxn_) {
552+ void Notecard::setTransactionPins (NoteTxn * noteTxn_) const {
532553 noteTxn = noteTxn_; // Set global interface
533554 if (noteTxn_) {
534555 NoteSetFnTransaction (noteTransactionStart, noteTransactionStop);
0 commit comments