Skip to content

Commit 96a8a97

Browse files
authored
feat: v1.8.2 (#152)
* feat: v1.8.2 * Remove `note-c` before re-add * Squashed 'src/note-c/' content from commit 887edc75 git-subtree-dir: src/note-c git-subtree-split: 887edc756581ee1ee0e9957e4ed54e9f91943f6d * Remove unneeded directories from `note-c`
1 parent d139b22 commit 96a8a97

File tree

4 files changed

+32
-33
lines changed

4 files changed

+32
-33
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Blues Wireless Notecard
2-
version=1.8.1
2+
version=1.8.2
33
author=Blues
44
maintainer=Blues <[email protected]>
55
sentence=An easy to use Notecard Library for Arduino.

src/NoteDefines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Define the version of the `note-arduino` library
55
#define NOTE_ARDUINO_VERSION_MAJOR 1
66
#define NOTE_ARDUINO_VERSION_MINOR 8
7-
#define NOTE_ARDUINO_VERSION_PATCH 1
7+
#define NOTE_ARDUINO_VERSION_PATCH 2
88

99
#define NOTE_ARDUINO_VERSION NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MAJOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MINOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_PATCH)
1010

src/note-c/n_request.c

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void _noteSuspendTransactionDebug(void)
116116
*/
117117
NOTE_C_STATIC uint32_t _noteTransaction_calculateTimeoutMs(J *req, bool isReq)
118118
{
119-
uint32_t result = (CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000);
119+
uint32_t result = ((CARD_INTER_TRANSACTION_TIMEOUT_SEC - 1) * 1000);
120120

121121
// Interrogate the request
122122
if (JContainsString(req, (isReq ? "req" : "cmd"), "note.add")) {
@@ -137,13 +137,13 @@ NOTE_C_STATIC uint32_t _noteTransaction_calculateTimeoutMs(J *req, bool isReq)
137137
} else if (JIsPresent(req, "seconds")) {
138138
NOTE_C_LOG_DEBUG("Using `seconds` parameter value for timeout.");
139139
result = (JGetInt(req, "seconds") * 1000);
140-
} else {
141-
NOTE_C_LOG_DEBUG("No `milliseconds` or `seconds` parameter "
142-
"provided. Defaulting to 90-second timeout.");
143-
result = (90 * 1000);
144140
}
145141
}
146142

143+
// Add one second to the timeout, to provide time for the Notecard to
144+
// timeout first, then report the timeout to the host, when applicable.
145+
result += 1000;
146+
147147
return result;
148148
}
149149

@@ -436,9 +436,6 @@ J *_noteTransactionShouldLock(J *req, bool lockNotecard)
436436
// Serialize the JSON request
437437
char *json = JPrintUnformatted(req); // `json` allocated, must be freed
438438
if (json == NULL) {
439-
if (lockNotecard) {
440-
_UnlockNote();
441-
}
442439
_TransactionStop();
443440
NOTE_C_LOG_ERROR(ERRSTR("failed to serialize JSON request", c_mem));
444441
return NULL;
@@ -492,28 +489,6 @@ J *_noteTransactionShouldLock(J *req, bool lockNotecard)
492489
}
493490
#endif
494491

495-
// If a reset of the I/O interface is required for any reason, do it now.
496-
// We must do this before acquiring lock.
497-
if (resetRequired) {
498-
NOTE_C_LOG_DEBUG("Resetting Notecard I/O Interface...");
499-
if (!NoteReset()) {
500-
_Free(json);
501-
_TransactionStop();
502-
const char *errStr = ERRSTR("failed to reset Notecard interface {io}", c_iobad);
503-
if (cmdFound) {
504-
NOTE_C_LOG_ERROR(errStr);
505-
return NULL;
506-
}
507-
return _errDoc(id, errStr);
508-
}
509-
}
510-
511-
// Take the lock on the Notecard. This is required to ensure that we don't
512-
// have multiple threads trying to access the Notecard at the same time.
513-
if (lockNotecard) {
514-
_LockNote();
515-
}
516-
517492
// Calculate the transaction timeout based on the parameters in the request.
518493
const uint32_t transactionTimeoutMs = _noteTransaction_calculateTimeoutMs(req, reqFound);
519494

@@ -547,6 +522,30 @@ J *_noteTransactionShouldLock(J *req, bool lockNotecard)
547522
}
548523
#endif // !NOTE_C_LOW_MEM
549524

525+
// Take the lock on the Notecard. This is required to ensure that we don't
526+
// have multiple threads trying to access the Notecard at the same time.
527+
if (lockNotecard) {
528+
_LockNote();
529+
}
530+
531+
// If a reset of the I/O interface is required for any reason, do it now.
532+
if (resetRequired) {
533+
NOTE_C_LOG_DEBUG("Resetting Notecard I/O Interface...");
534+
if ((resetRequired = !_Reset())) {
535+
if (lockNotecard) {
536+
_UnlockNote();
537+
}
538+
_Free(json);
539+
_TransactionStop();
540+
const char *errStr = ERRSTR("failed to reset Notecard interface {io}", c_iobad);
541+
if (cmdFound) {
542+
NOTE_C_LOG_ERROR(errStr);
543+
return NULL;
544+
}
545+
return _errDoc(id, errStr);
546+
}
547+
}
548+
550549
// If we're performing retries, this is where we come back to
551550
// after a failed transaction.
552551
const char *errStr = NULL;

src/note-c/note.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum {
4141

4242
#define NOTE_C_VERSION_MAJOR 2
4343
#define NOTE_C_VERSION_MINOR 5
44-
#define NOTE_C_VERSION_PATCH 2
44+
#define NOTE_C_VERSION_PATCH 3
4545

4646
#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)
4747

0 commit comments

Comments
 (0)