Skip to content

Commit d8ad112

Browse files
authored
chore: Update note-c (#104)
* chore: bump version * chore: Update CI - Lock CI container base image - Update Arduino CLI - Update actions/checkout * remove note-c before re-add * Squashed 'src/note-c/' content from commit 14953bf git-subtree-dir: src/note-c git-subtree-split: 14953bfe1c36187e88276d822cfd1d51701bd5c9
1 parent 2ecd8ac commit d8ad112

File tree

19 files changed

+633
-108
lines changed

19 files changed

+633
-108
lines changed

.github/actions/compile-examples/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
# docker run --entrypoint bash --interactive --rm --tty --volume "$(pwd)":/host-volume/ --workdir /host-volume/ arduino-cli
1010

1111
# Define global arguments
12-
ARG ARDUINO_CLI_VERSION=0.23.0
12+
ARG ARDUINO_CLI_VERSION=0.33.0
1313
ARG DEBIAN_FRONTEND="noninteractive"
1414
ARG UID=1000
1515
ARG USER="blues"
1616

1717
# POSIX compatible (Linux/Unix) base image
18-
FROM debian:stable-slim
18+
FROM debian:bullseye-slim
1919

2020
# Import global arguments
2121
ARG ARDUINO_CLI_VERSION

.github/actions/run-tests-in-container/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN ["ash", "-c", "\
1515
apk add --no-cache \
1616
g++ \
1717
gdb \
18+
gzip \
1819
valgrind \
1920
"]
2021

.github/workflows/note-arduino-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Checkout Code
1414
id: checkout
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1616
- name: Run Tests In Container
1717
id: containerized_tests
1818
uses: ./.github/actions/run-tests-in-container
@@ -52,7 +52,7 @@ jobs:
5252
steps:
5353
- name: Checkout Code
5454
id: checkout
55-
uses: actions/checkout@v2
55+
uses: actions/checkout@v3
5656
- name: Compile Examples
5757
id: compile_examples
5858
uses: ./.github/actions/compile-examples

.vscode/extensions.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// for the documentation about the extensions.json format
44
"recommendations": [],
55
"unwantedRecommendations": [
6-
"ms-vscode.cpptools-extension-pack"
6+
"ms-vscode.cmake-tools",
7+
"ms-vscode.cpptools-extension-pack",
8+
"ms-azuretools.vscode-docker"
79
]
810
}

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Blues Wireless Notecard
2-
version=1.4.2
2+
version=1.4.3
33
author=Blues Wireless
44
maintainer=Blues Wireless <[email protected]>
55
sentence=An easy to use Notecard Library for Arduino.

src/note-c/.github/actions/run_unit_tests/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ARG UID=1000
1212
ARG USER="blues"
1313

1414
# POSIX compatible (Linux/Unix) base image.
15-
FROM debian:stable-slim
15+
FROM --platform=linux/amd64 debian:stable-slim
1616

1717
# Import Global Argument(s)
1818
ARG DEBIAN_FRONTEND

src/note-c/.vscode/extensions.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"unwantedRecommendations": [
5+
"ms-vscode.cmake-tools",
6+
"ms-vscode.cpptools-extension-pack",
7+
"ms-azuretools.vscode-docker"
8+
]
9+
}

src/note-c/n_cjson.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ typedef struct {
8989
static error global_error = { NULL, 0 };
9090

9191
// Forwards
92-
void htoa16(uint16_t n, unsigned char *p);
9392
static J *JNew_Item(void);
9493

9594
N_CJSON_PUBLIC(const char *) JGetErrorPtr(void)
@@ -712,7 +711,7 @@ static Jbool parse_string(J * const item, parse_buffer * const input_buffer)
712711
}
713712

714713
/* Convert a 16-bit number to 4 hex digits, null-terminating it */
715-
void htoa16(uint16_t n, unsigned char *p)
714+
void n_htoa16(uint16_t n, unsigned char *p)
716715
{
717716
int i;
718717
for (i=0; i<4; i++) {
@@ -827,7 +826,7 @@ static Jbool print_string_ptr(const unsigned char * const input, printbuffer * c
827826
default:
828827
/* escape and print as unicode codepoint */
829828
*output_pointer++ = 'u';
830-
htoa16(*input_pointer, output_pointer);
829+
n_htoa16(*input_pointer, output_pointer);
831830
output_pointer += 4;
832831
break;
833832
}

src/note-c/n_hooks.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,15 @@ void NoteDelayMs(uint32_t ms)
469469
}
470470
}
471471

472-
#if NOTE_SHOW_MALLOC
472+
#if NOTE_SHOW_MALLOC || !defined(NOTE_LOWMEM)
473473
//**************************************************************************/
474474
/*!
475-
@brief If set for low-memory platforms, show a malloc call.
476-
@param len the number of bytes of memory allocated by the last call.
475+
@brief Convert number to a hex string
476+
@param the number
477+
@param the buffer to return it into
477478
*/
478479
/**************************************************************************/
479-
void htoa32(uint32_t n, char *p);
480-
void htoa32(uint32_t n, char *p)
480+
void n_htoa32(uint32_t n, char *p)
481481
{
482482
int i;
483483
for (i=0; i<8; i++) {
@@ -491,6 +491,15 @@ void htoa32(uint32_t n, char *p)
491491
}
492492
*p = '\0';
493493
}
494+
#endif
495+
496+
#if NOTE_SHOW_MALLOC
497+
//**************************************************************************/
498+
/*!
499+
@brief If set for low-memory platforms, show a malloc call.
500+
@param len the number of bytes of memory allocated by the last call.
501+
*/
502+
/**************************************************************************/
494503
void *malloc_show(size_t len)
495504
{
496505
char str[16];
@@ -501,7 +510,7 @@ void *malloc_show(size_t len)
501510
if (p == NULL) {
502511
hookDebugOutput("FAIL");
503512
} else {
504-
htoa32((uint32_t)p, str);
513+
n_htoa32((uint32_t)p, str);
505514
hookDebugOutput(str);
506515
}
507516
return p;
@@ -537,7 +546,7 @@ void NoteFree(void *p)
537546
if (hookFree != NULL) {
538547
#if NOTE_SHOW_MALLOC
539548
char str[16];
540-
htoa32((uint32_t)p, str);
549+
n_htoa32((uint32_t)p, str);
541550
hookDebugOutput("free");
542551
hookDebugOutput(str);
543552
#endif

src/note-c/n_i2c.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ const char *i2cNoteTransaction(char *json, char **jsonResponse)
110110
// Dynamically grow the buffer as we read. Note that we always put the +1 in the alloc
111111
// so we can be assured that it can be null-terminated, which must be the case because
112112
// our json parser requires a null-terminated string.
113-
int growlen = ALLOC_CHUNK;
114-
int jsonbufAllocLen = growlen;
113+
size_t growlen = ALLOC_CHUNK;
114+
size_t jsonbufAllocLen = growlen;
115115
uint8_t *jsonbuf = (uint8_t *) _Malloc(jsonbufAllocLen+1);
116116
if (jsonbuf == NULL) {
117117
#ifdef ERRDBG
@@ -124,7 +124,7 @@ const char *i2cNoteTransaction(char *json, char **jsonResponse)
124124
// Loop, building a reply buffer out of received chunks. We'll build the reply in the same
125125
// buffer we used to transmit, and will grow it as necessary.
126126
bool receivedNewline = false;
127-
int jsonbufLen = 0;
127+
size_t jsonbufLen = 0;
128128
uint16_t chunkLen = 0;
129129
uint32_t startMs = _GetMs();
130130
while (true) {

src/note-c/n_lib.h

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ bool NoteHardReset(void);
9797
const char *NoteJSONTransaction(char *json, char **jsonResponse);
9898
bool NoteIsDebugOutputActive(void);
9999

100+
// Utilities
101+
void n_htoa32(uint32_t n, char *p);
102+
void n_htoa16(uint16_t n, unsigned char *p);
103+
uint64_t n_atoh(char *p, int maxlen);
104+
100105
// Constants, a global optimization to save static string memory
101106
extern const char *c_null;
102107
#define c_null_len 4

src/note-c/n_md5.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "n_lib.h"
3030

3131
// Forwards
32-
void htoa8(unsigned char n, unsigned char *p);
32+
void n_htoa8(unsigned char n, unsigned char *p);
3333
static void putu32 (unsigned long data, unsigned char *addr);
3434
static unsigned long getu32 (const unsigned char *addr);
3535

@@ -54,7 +54,7 @@ static void putu32 (unsigned long data, unsigned char *addr)
5454
}
5555

5656
/* Convert an 8-bit number to 2 hex digits, null-terminating it */
57-
void htoa8(unsigned char n, unsigned char *p)
57+
void n_htoa8(unsigned char n, unsigned char *p)
5858
{
5959
unsigned char nibble = (n >> 4) & 0xf;
6060
if (nibble >= 10) {
@@ -304,7 +304,7 @@ void NoteMD5HashString(unsigned char *data, unsigned long len, char *strbuf, uns
304304
NoteMD5Hash(data, len, hash);
305305
char hashstr[NOTE_MD5_HASH_SIZE*3] = {0};
306306
for (int i=0; i<NOTE_MD5_HASH_SIZE; i++) {
307-
htoa8(hash[i], (unsigned char *)&hashstr[i*2]);
307+
n_htoa8(hash[i], (unsigned char *)&hashstr[i*2]);
308308
}
309309
hashstr[NOTE_MD5_HASH_SIZE*2+1] = 0;
310310
strlcpy(strbuf, hashstr, buflen);
@@ -315,7 +315,7 @@ void NoteMD5HashToString(unsigned char *hash, char *strbuf, unsigned long buflen
315315
{
316316
char hashstr[NOTE_MD5_HASH_SIZE*3] = {0};
317317
for (int i=0; i<NOTE_MD5_HASH_SIZE; i++) {
318-
htoa8(hash[i], (unsigned char *)&hashstr[i*2]);
318+
n_htoa8(hash[i], (unsigned char *)&hashstr[i*2]);
319319
}
320320
strlcpy(strbuf, hashstr, buflen);
321321
}

0 commit comments

Comments
 (0)