From 7884ad8f8e2aed0d90bcdadbe8714530b61f3c57 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Mon, 12 Jan 2026 15:21:54 -0600 Subject: [PATCH 1/7] feat: NoteConnect --- n_request.c | 8 ++++---- note.h | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/n_request.c b/n_request.c index c774720a..42f88d02 100644 --- a/n_request.c +++ b/n_request.c @@ -758,11 +758,11 @@ void NoteResetRequired(void) resetRequired = true; } -/*! - @brief Initialize or re-initialize the I/O inferface (I2C/UART). +bool NoteConnect(void) +{ + return NoteReset(); +} - @returns True if the reset was successful and false if not. - */ bool NoteReset(void) { _LockNote(); diff --git a/note.h b/note.h index b9997ebd..ab20c0b5 100644 --- a/note.h +++ b/note.h @@ -290,6 +290,15 @@ typedef void (*txnStopFn) (void); // External API +/*! + @brief Connect to the Notecard + + This function is used to establish the Notecard connection. + + @returns `true` when connection has been established, `false` otherwise. + */ +bool NoteConnect(void); + /*! @brief Reset the Notecard, clearing any error state. From f0b6ce341414ada4fa4fdd4aa0a38ca8a89e1692 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Thu, 15 Jan 2026 22:03:34 +0000 Subject: [PATCH 2/7] deprecate: *WithRetry() APIs --- note.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/note.h b/note.h index ab20c0b5..89962263 100644 --- a/note.h +++ b/note.h @@ -371,8 +371,11 @@ J *NoteRequestResponse(J *req); contains an I/O error. @see NoteResponseError to check the response for errors. + + @deprecated This function is deprecated. Please use `NoteConnect()` followed by + the standard `NoteRequestResponse()` function instead. */ -J *NoteRequestResponseWithRetry(J *req, uint32_t timeoutSeconds); +NOTE_C_DEPRECATED J *NoteRequestResponseWithRetry(J *req, uint32_t timeoutSeconds); /*! @brief Send a request to the Notecard and return the response as JSON string. @@ -447,9 +450,10 @@ bool NoteRequest(J *req); @returns `true` if successful and `false` if an error occurs (e.g. out of memory or the response from the Notecard has an "err" field). - @see NoteRequestResponseWithRetry if you need to work with the response. + @deprecated This function is deprecated. Please use `NoteConnect()` followed by + the standard `NoteRequest()` function instead. */ -bool NoteRequestWithRetry(J *req, uint32_t timeoutSeconds); +NOTE_C_DEPRECATED bool NoteRequestWithRetry(J *req, uint32_t timeoutSeconds); /*! @brief Set the request timeout for Notecard transactions. From 15fcf9eb45c07b55fa867d3849c925769335b32d Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Thu, 15 Jan 2026 22:18:40 +0000 Subject: [PATCH 3/7] chore: improve NoteConnect logic --- n_request.c | 15 +++++++++++++-- note.h | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/n_request.c b/n_request.c index 42f88d02..c9278955 100644 --- a/n_request.c +++ b/n_request.c @@ -758,9 +758,20 @@ void NoteResetRequired(void) resetRequired = true; } -bool NoteConnect(void) +bool NoteConnect(uint32_t timeoutSeconds_) { - return NoteReset(); + bool result = false; + uint32_t startMs = _GetMs(); + uint32_t timeoutMs = timeoutSeconds_ * 1000; + + do { + if ((result = NoteReset())) { // Let the reset function manage locking + break; + } + _DelayMs(RETRY_DELAY_MS); + } while ((_GetMs() - startMs) < timeoutMs); + + return result; } bool NoteReset(void) diff --git a/note.h b/note.h index 89962263..91b694e1 100644 --- a/note.h +++ b/note.h @@ -293,11 +293,13 @@ typedef void (*txnStopFn) (void); /*! @brief Connect to the Notecard - This function is used to establish the Notecard connection. + This blocking, thread-safe function is used to establish the Notecard connection. + + @param timeoutSeconds Time limit for connection attempts, in seconds. @returns `true` when connection has been established, `false` otherwise. */ -bool NoteConnect(void); +bool NoteConnect(uint32_t timeoutSeconds); /*! @brief Reset the Notecard, clearing any error state. From 7c673b736dd0792fe6119d7906a83f3160c51671 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Thu, 15 Jan 2026 22:36:57 +0000 Subject: [PATCH 4/7] chore: improve timeout logic --- n_request.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/n_request.c b/n_request.c index c9278955..3d1b34c7 100644 --- a/n_request.c +++ b/n_request.c @@ -758,18 +758,15 @@ void NoteResetRequired(void) resetRequired = true; } -bool NoteConnect(uint32_t timeoutSeconds_) +bool NoteConnect(uint32_t timeoutSeconds) { bool result = false; - uint32_t startMs = _GetMs(); - uint32_t timeoutMs = timeoutSeconds_ * 1000; - do { - if ((result = NoteReset())) { // Let the reset function manage locking - break; - } - _DelayMs(RETRY_DELAY_MS); - } while ((_GetMs() - startMs) < timeoutMs); + for ( + uint32_t startMs = _GetMs(), timeoutMs = (timeoutSeconds * 1000) ; + (result = NoteReset()) && ((_GetMs() - startMs) < timeoutMs) ; + _DelayMs(RETRY_DELAY_MS) + ); return result; } From df53021e13c093a5b71e20b08ceef2418fe30047 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Thu, 15 Jan 2026 22:55:22 +0000 Subject: [PATCH 5/7] fix; ignore known deprecation messages --- n_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/n_request.c b/n_request.c index 3d1b34c7..a7929b4c 100644 --- a/n_request.c +++ b/n_request.c @@ -204,7 +204,10 @@ bool NoteRequest(J *req) bool NoteRequestWithRetry(J *req, uint32_t timeoutSeconds) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" J *rsp = NoteRequestResponseWithRetry(req, timeoutSeconds); +#pragma GCC diagnostic pop // If there is no response return false if (rsp == NULL) { return false; From 39452da99a8e5a361650307dc05775ba80f0f313 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Thu, 15 Jan 2026 17:15:52 -0600 Subject: [PATCH 6/7] fix: Remove deprecated APIs from API reference --- docs/api_reference.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 8316ea84..930725fe 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -114,12 +114,8 @@ Functions .. doxygenfunction:: NoteRequestResponse -.. doxygenfunction:: NoteRequestResponseWithRetry - .. doxygenfunction:: NoteRequest -.. doxygenfunction:: NoteRequestWithRetry - .. doxygendefine:: NoteResponseError .. doxygendefine:: NoteDeleteResponse From f3497eb952bda7562d55845be970833879bfd7ab Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Fri, 16 Jan 2026 14:44:44 +0000 Subject: [PATCH 7/7] Change NoteConnect timeout to milliseconds --- n_request.c | 4 ++-- note.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/n_request.c b/n_request.c index a7929b4c..be27e5d6 100644 --- a/n_request.c +++ b/n_request.c @@ -761,12 +761,12 @@ void NoteResetRequired(void) resetRequired = true; } -bool NoteConnect(uint32_t timeoutSeconds) +bool NoteConnect(uint32_t timeoutMs) { bool result = false; for ( - uint32_t startMs = _GetMs(), timeoutMs = (timeoutSeconds * 1000) ; + uint32_t startMs = _GetMs() ; (result = NoteReset()) && ((_GetMs() - startMs) < timeoutMs) ; _DelayMs(RETRY_DELAY_MS) ); diff --git a/note.h b/note.h index 91b694e1..ec9d36d6 100644 --- a/note.h +++ b/note.h @@ -40,8 +40,8 @@ enum { #define NOTE_C_STRINGIZE(x) _NOTE_C_STRINGIZE(x) #define NOTE_C_VERSION_MAJOR 2 -#define NOTE_C_VERSION_MINOR 5 -#define NOTE_C_VERSION_PATCH 5 +#define NOTE_C_VERSION_MINOR 6 +#define NOTE_C_VERSION_PATCH 1 #define NOTE_C_VERSION NOTE_C_STRINGIZE(NOTE_C_VERSION_MAJOR) "." NOTE_C_STRINGIZE(NOTE_C_VERSION_MINOR) "." NOTE_C_STRINGIZE(NOTE_C_VERSION_PATCH) @@ -295,11 +295,11 @@ typedef void (*txnStopFn) (void); This blocking, thread-safe function is used to establish the Notecard connection. - @param timeoutSeconds Time limit for connection attempts, in seconds. + @param timeoutMs Time limit for connection attempts, in milliseconds. @returns `true` when connection has been established, `false` otherwise. */ -bool NoteConnect(uint32_t timeoutSeconds); +bool NoteConnect(uint32_t timeoutMs); /*! @brief Reset the Notecard, clearing any error state.