From 92a9262b894d845cf74d148b7a79ac95e8830527 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 c1e105bc..31c30aa7 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 eb2f13bc..ff3c3487 100644 --- a/note.h +++ b/note.h @@ -289,6 +289,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 493e18d97ad9c64083ddf031a6669ea97ba201af 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 ff3c3487..88c89e4c 100644 --- a/note.h +++ b/note.h @@ -370,8 +370,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. @@ -446,9 +449,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 3cd5b94c3270e0f535ddba4385b51dad1f6e5228 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 31c30aa7..1abdaa12 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 88c89e4c..5aabf1e2 100644 --- a/note.h +++ b/note.h @@ -292,11 +292,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 165d709b97fa10022b11f5ec17ae4b189a7b642e 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 1abdaa12..edb5477e 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 14ad898ee9d9da2591ed2714b5e65509e651e08e 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 edb5477e..c16df573 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 3aab4970fda98f147a44804771ec977da66f9410 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 2cdb6505f9c2345b14fb85cb0038654dab0f086c 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 c16df573..b82d5eed 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 5aabf1e2..8f8b4b9f 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 3 +#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) @@ -294,11 +294,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.