Skip to content

Commit 922fbb2

Browse files
authored
release: v1.3.1 (#39)
* fix: README typos * chore: ensure Uno compatibility * remove note-c before re-add * Squashed 'src/note-c/' content from commit ba6e761 git-subtree-dir: src/note-c git-subtree-split: ba6e761424fb7a159bb4867539d61c005142bca8 * release: v1.3.1 - Improve 16-bit microcontroller support
1 parent 51a902b commit 922fbb2

21 files changed

+2880
-2542
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,18 @@ This library depends on the blues [note-c repo][note-c] and utilizes
8989
git subtrees to include those files in the src/note-c folder. To
9090
update this repo with the latest from note-c:
9191

92-
```sh
92+
```none
9393
rm -rf src/note-c
94-
git commit -am 'remove note-c before readd'
94+
git commit -am 'remove note-c before re-add'
9595
git subtree add --prefix=src/note-c --squash https://github.com/blues/note-c.git master
9696
```
9797

9898
## Documentation
9999

100-
The documentation for this library can be found [here](https://blues.github.io/note-arduino/html/index.html).
100+
The documentation for this library can be found
101+
[here](https://dev.blues.io/tools-and-sdks/arduino-library/).
101102

102-
# Examples
103+
## Examples
103104

104105
The [examples](examples/) directory contains examples for using this library
105106
with:

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.3.0
2+
version=1.3.1
33
author=Blues Wireless
44
maintainer=Blues Wireless <[email protected]>
55
sentence=An easy to use Notecard Library for Arduino.

src/Notecard.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838

3939
#include "Notecard.h"
4040

41-
#include <cstdarg>
42-
#include <cstdio>
43-
#include <cstdlib>
41+
#include <stdarg.h>
42+
#include <stdio.h>
43+
#include <stdlib.h>
4444

4545
TwoWire *Notecard::_i2cPort;
4646
HardwareSerial *Notecard::_notecardSerial;
@@ -354,6 +354,7 @@ char Notecard::noteSerialReceive()
354354
/**************************************************************************/
355355
bool Notecard::noteI2CReset(uint16_t DevAddress)
356356
{
357+
(void)DevAddress;
357358
#if WIRE_HAS_END
358359
_i2cPort->end();
359360
#endif
@@ -480,14 +481,14 @@ const char *Notecard::noteI2CReceive(uint16_t DevAddress, uint8_t* pBuffer, uint
480481
if (goodbyte != Size) {
481482
#if I2C_DATA_TRACE
482483
NoteDebugf("%d != %d, received:\n", goodbyte, Size);
483-
for (int i=0; i<Size; i++) {
484+
for (size_t i=0; i<Size; i++) {
484485
NoteDebugf("%c", _i2cPort.read());
485486
}
486487
NoteDebugf("\n");
487488
#endif
488489
errstr = ERRSTR("i2c: incorrect amount of data",i2cerr);
489490
} else {
490-
for (int i=0; i<Size; i++) {
491+
for (size_t i=0; i<Size; i++) {
491492
*pBuffer++ = _i2cPort->read();
492493
}
493494
}

src/Notecard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#ifndef Notecard_h
2525
#define Notecard_h
2626

27-
#include <cstddef>
28-
#include <cstdint>
27+
#include <stddef.h>
28+
#include <stdint.h>
2929
#ifndef MOCK
3030
#include <Arduino.h>
3131
#include <HardwareSerial.h>

src/note-c/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ For details on contributions we accept and the process for contributing, see our
2525

2626
For additional Notecard SDKs and Libraries, see:
2727

28-
* [note-arduino](note-arduino) for Arduino support
29-
* [note-python](note-python) for Python
30-
* [note-go](note-go) for Go
28+
* [note-arduino][note-arduino] for Arduino support
29+
* [note-python][note-python] for Python
30+
* [note-go][note-go] for Go
3131

3232
## To learn more about Blues Wireless, the Notecard and Notehub, see:
3333

@@ -45,4 +45,4 @@ Copyright (c) 2019 Blues Inc. Released under the MIT license. See
4545
[note-arduino]: https://github.com/blues/note-arduino
4646
[note-go]: https://github.com/blues/note-go
4747
[note-python]: https://github.com/blues/note-python
48-
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
48+
[code of conduct]: https://blues.github.io/opensource/code-of-conduct

src/note-c/n_atof.c

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define NULL 0
4141
#endif
4242

43-
#define MAX_EXPONENT 511 /* Largest possible base 10 exponent. Any
43+
#define MAX_EXPONENT 511 /* Largest possible base 10 exponent. Any
4444
* exponent larger than this will already
4545
* produce underflow or overflow, so there's
4646
* no need to worry about additional digits.
@@ -69,7 +69,7 @@
6969

7070
JNUMBER
7171
JAtoN(string, endPtr)
72-
const char *string; /* A decimal ASCII floating-point number,
72+
const char *string; /* A decimal ASCII floating-point number,
7373
* optionally preceded by white space.
7474
* Must have form "-I.FE-X", where I is the
7575
* integer part of the mantissa, F is the
@@ -81,7 +81,7 @@ JAtoN(string, endPtr)
8181
* The "E" may actually be an "e". E and X
8282
* may both be omitted (but not just one).
8383
*/
84-
char **endPtr; /* If non-NULL, store terminating character's
84+
char **endPtr; /* If non-NULL, store terminating character's
8585
* address here. */
8686
{
8787
int sign, expSign = FALSE;
@@ -128,8 +128,7 @@ JAtoN(string, endPtr)
128128
*/
129129

130130
decPt = -1;
131-
for (mantSize = 0; ; mantSize += 1)
132-
{
131+
for (mantSize = 0; ; mantSize += 1) {
133132
c = *p;
134133
if (c < '0' || c > '9') {
135134
if ((c != '.') || (decPt >= 0)) {
@@ -146,7 +145,7 @@ JAtoN(string, endPtr)
146145
* If the mantissa has more than 18 digits, ignore the extras, since
147146
* they can't affect the value anyway.
148147
*/
149-
148+
150149
pExp = p;
151150
p -= mantSize;
152151
if (decPt < 0) {
@@ -167,8 +166,7 @@ JAtoN(string, endPtr)
167166
} else {
168167
long frac1, frac2;
169168
frac1 = 0L;
170-
for ( ; mantSize > 9; mantSize -= 1)
171-
{
169+
for ( ; mantSize > 9; mantSize -= 1) {
172170
c = *p;
173171
p += 1;
174172
if (c == '.') {
@@ -178,8 +176,7 @@ JAtoN(string, endPtr)
178176
frac1 = 10*frac1 + (c - '0');
179177
}
180178
frac2 = 0L;
181-
for (; mantSize > 0; mantSize -= 1)
182-
{
179+
for (; mantSize > 0; mantSize -= 1) {
183180
c = *p;
184181
p += 1;
185182
if (c == '.') {
@@ -224,7 +221,7 @@ JAtoN(string, endPtr)
224221
* many powers of 2 of 10. Then combine the exponent with the
225222
* fraction.
226223
*/
227-
224+
228225
if (exp < 0) {
229226
expSign = TRUE;
230227
exp = -exp;
@@ -235,45 +232,46 @@ JAtoN(string, endPtr)
235232
exp = MAX_EXPONENT;
236233
}
237234
dblExp = 1.0;
238-
int d;
235+
int d;
239236
for (d = 0; exp != 0; exp >>= 1, d += 1) {
240-
/* Table giving binary powers of 10. Entry */
241-
/* is 10^2^i. Used to convert decimal */
242-
/* exponents into floating-point numbers. */
243-
JNUMBER p10 = 0.0;
244-
switch (d) {
245-
case 0:
246-
p10 = 10.0;
247-
break;
248-
case 1:
249-
p10 = 100.0;
250-
break;
251-
case 2:
252-
p10 = 1.0e4;
253-
break;
254-
case 3:
255-
p10 = 1.0e8;
256-
break;
257-
case 4:
258-
p10 = 1.0e16;
259-
break;
260-
case 5:
261-
p10 = 1.0e32;
262-
break;
237+
/* Table giving binary powers of 10. Entry */
238+
/* is 10^2^i. Used to convert decimal */
239+
/* exponents into floating-point numbers. */
240+
JNUMBER p10 = 0.0;
241+
switch (d) {
242+
case 0:
243+
p10 = 10.0;
244+
break;
245+
case 1:
246+
p10 = 100.0;
247+
break;
248+
case 2:
249+
p10 = 1.0e4;
250+
break;
251+
case 3:
252+
p10 = 1.0e8;
253+
break;
254+
case 4:
255+
p10 = 1.0e16;
256+
break;
257+
case 5:
258+
p10 = 1.0e32;
259+
break;
263260
#ifndef NOTE_FLOAT
264-
case 6:
265-
p10 = 1.0e64;
266-
break;
267-
case 7:
268-
p10 = 1.0e128;
269-
break;
270-
case 8:
271-
p10 = 1.0e256;
272-
break;
261+
case 6:
262+
p10 = 1.0e64;
263+
break;
264+
case 7:
265+
p10 = 1.0e128;
266+
break;
267+
case 8:
268+
p10 = 1.0e256;
269+
break;
273270
#endif
274-
}
275-
if (p10 == 0.0)
276-
break;
271+
}
272+
if (p10 == 0.0) {
273+
break;
274+
}
277275
if (exp & 01) {
278276
dblExp *= p10;
279277
}

src/note-c/n_b64.c

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
#include "n_lib.h"
8484

8585
/* aaaack but it's fast and const should make it shared text page. */
86-
static const unsigned char pr2six[256] =
87-
{
86+
static const unsigned char pr2six[256] = {
8887
/* ASCII table */
8988
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
9089
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
@@ -135,28 +134,28 @@ int JB64Decode(char *bufplain, const char *bufcoded)
135134
bufin = (const unsigned char *) bufcoded;
136135

137136
while (nprbytes > 4) {
138-
*(bufout++) =
139-
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
140-
*(bufout++) =
141-
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
142-
*(bufout++) =
143-
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
144-
bufin += 4;
145-
nprbytes -= 4;
137+
*(bufout++) =
138+
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
139+
*(bufout++) =
140+
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
141+
*(bufout++) =
142+
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
143+
bufin += 4;
144+
nprbytes -= 4;
146145
}
147146

148147
/* Note: (nprbytes == 1) would be an error, so just ingore that case */
149148
if (nprbytes > 1) {
150-
*(bufout++) =
151-
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
149+
*(bufout++) =
150+
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
152151
}
153152
if (nprbytes > 2) {
154-
*(bufout++) =
155-
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
153+
*(bufout++) =
154+
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
156155
}
157156
if (nprbytes > 3) {
158-
*(bufout++) =
159-
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
157+
*(bufout++) =
158+
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
160159
}
161160

162161
*(bufout++) = '\0';
@@ -179,26 +178,22 @@ int JB64Encode(char *encoded, const char *string, int len)
179178

180179
p = encoded;
181180
for (i = 0; i < len - 2; i += 3) {
182-
*p++ = basis_64[(string[i] >> 2) & 0x3F];
183-
*p++ = basis_64[((string[i] & 0x3) << 4) |
184-
((int) (string[i + 1] & 0xF0) >> 4)];
185-
*p++ = basis_64[((string[i + 1] & 0xF) << 2) |
186-
((int) (string[i + 2] & 0xC0) >> 6)];
187-
*p++ = basis_64[string[i + 2] & 0x3F];
181+
*p++ = basis_64[(string[i] >> 2) & 0x3F];
182+
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
183+
*p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] & 0xC0) >> 6)];
184+
*p++ = basis_64[string[i + 2] & 0x3F];
188185
}
189186
if (i < len) {
190-
*p++ = basis_64[(string[i] >> 2) & 0x3F];
191-
if (i == (len - 1)) {
192-
*p++ = basis_64[((string[i] & 0x3) << 4)];
187+
*p++ = basis_64[(string[i] >> 2) & 0x3F];
188+
if (i == (len - 1)) {
189+
*p++ = basis_64[((string[i] & 0x3) << 4)];
190+
*p++ = '=';
191+
} else {
192+
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
193+
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
194+
}
193195
*p++ = '=';
194196
}
195-
else {
196-
*p++ = basis_64[((string[i] & 0x3) << 4) |
197-
((int) (string[i + 1] & 0xF0) >> 4)];
198-
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
199-
}
200-
*p++ = '=';
201-
}
202197

203198
*p++ = '\0';
204199
return p - encoded;

0 commit comments

Comments
 (0)