Skip to content

Commit

Permalink
chore: more documentation clarificiation
Browse files Browse the repository at this point in the history
  • Loading branch information
zfields committed Sep 7, 2023
1 parent ebdd8a8 commit 36d5b16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions n_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ const char * NoteBinaryReceive(uint8_t * buffer, uint32_t bufLen,
@param unencodedData A buffer with data to encode in place
@param unencodedLen The length of the data in the buffer
@param bufLen The total length of the buffer
@param decodedOffset The offset where the data buffer should be appended
@param bufLen The total length of the buffer (see notes)
@param notecardOffset The offset where the data buffer should be appended
to the decoded binary data already residing on the
Notecard. This does not provide random access, but
rather ensures alignment across sequential writes.
Expand All @@ -466,13 +466,13 @@ const char * NoteBinaryReceive(uint8_t * buffer, uint32_t bufLen,
@note Buffers are encoded in place, the buffer _MUST_ be larger than the data
to be encoded. The original contents of the buffer will be modified.
@note You may use (`NoteBinaryMaxEncodedLength()` + 1) to calculate the
@note Use (`NoteBinaryMaxEncodedLength()` + sizeof(char)) to calculate the
required size for the buffer pointed to by the `unencodedData`
parameter.
parameter, which accommodates the encoded data and newline terminator.
*/
/**************************************************************************/
const char * NoteBinaryTransmit(uint8_t *unencodedData, uint32_t unencodedLen,
uint32_t bufLen, uint32_t decodedOffset)
uint32_t bufLen, uint32_t notecardOffset)
{
// Validate parameter(s)
if (!unencodedData) {
Expand Down Expand Up @@ -514,13 +514,13 @@ const char * NoteBinaryTransmit(uint8_t *unencodedData, uint32_t unencodedLen,
// Validate the index provided by the caller, against the `length` value
// returned from the Notecard to ensure the caller and Notecard agree on
// how much data is residing on the Notecard.
if ((long)decodedOffset != len) {
if ((long)notecardOffset != len) {
NOTE_C_LOG_ERROR("notecard data length is misaligned with offset");
return ERRSTR("notecard data length is misaligned with offset", c_mem);
}

// When offset is zero, the entire buffer is available
const uint32_t remaining = (decodedOffset ? (max - len) : max);
const uint32_t remaining = (notecardOffset ? (max - len) : max);
if (unencodedLen > remaining) {
NOTE_C_LOG_ERROR("buffer size exceeds available memory");
return ERRSTR("buffer size exceeds available memory", c_mem);
Expand Down Expand Up @@ -558,8 +558,8 @@ const char * NoteBinaryTransmit(uint8_t *unencodedData, uint32_t unencodedLen,
J *req = NoteNewRequest("card.binary.put");
if (req) {
JAddIntToObject(req, "cobs", encLen);
if (decodedOffset) {
JAddIntToObject(req, "offset", decodedOffset);
if (notecardOffset) {
JAddIntToObject(req, "offset", notecardOffset);
}
JAddStringToObject(req, "status", hashString);

Expand Down
2 changes: 1 addition & 1 deletion note.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ uint32_t NoteBinaryMaxEncodedLength(uint32_t unencodedLength);
const char * NoteBinaryReceive(uint8_t *buffer, uint32_t bufLen,
uint32_t decodedOffset, uint32_t *decodedLen);
const char * NoteBinaryTransmit(uint8_t *unencodedData, uint32_t unencodedLen,
uint32_t bufLen, uint32_t decodedOffset);
uint32_t bufLen, uint32_t notecardOffset);
uint32_t NoteSetSTSecs(uint32_t secs);
bool NoteTimeValid(void);
bool NoteTimeValidST(void);
Expand Down

0 comments on commit 36d5b16

Please sign in to comment.