Skip to content

Commit

Permalink
release: v1.3.1 (#39)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zfields authored Mar 5, 2021
1 parent 51a902b commit 922fbb2
Show file tree
Hide file tree
Showing 21 changed files with 2,880 additions and 2,542 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,18 @@ This library depends on the blues [note-c repo][note-c] and utilizes
git subtrees to include those files in the src/note-c folder. To
update this repo with the latest from note-c:

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

## Documentation

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

# Examples
## Examples

The [examples](examples/) directory contains examples for using this library
with:
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Blues Wireless Notecard
version=1.3.0
version=1.3.1
author=Blues Wireless
maintainer=Blues Wireless <[email protected]>
sentence=An easy to use Notecard Library for Arduino.
Expand Down
11 changes: 6 additions & 5 deletions src/Notecard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

#include "Notecard.h"

#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

TwoWire *Notecard::_i2cPort;
HardwareSerial *Notecard::_notecardSerial;
Expand Down Expand Up @@ -354,6 +354,7 @@ char Notecard::noteSerialReceive()
/**************************************************************************/
bool Notecard::noteI2CReset(uint16_t DevAddress)
{
(void)DevAddress;
#if WIRE_HAS_END
_i2cPort->end();
#endif
Expand Down Expand Up @@ -480,14 +481,14 @@ const char *Notecard::noteI2CReceive(uint16_t DevAddress, uint8_t* pBuffer, uint
if (goodbyte != Size) {
#if I2C_DATA_TRACE
NoteDebugf("%d != %d, received:\n", goodbyte, Size);
for (int i=0; i<Size; i++) {
for (size_t i=0; i<Size; i++) {
NoteDebugf("%c", _i2cPort.read());
}
NoteDebugf("\n");
#endif
errstr = ERRSTR("i2c: incorrect amount of data",i2cerr);
} else {
for (int i=0; i<Size; i++) {
for (size_t i=0; i<Size; i++) {
*pBuffer++ = _i2cPort->read();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Notecard.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#ifndef Notecard_h
#define Notecard_h

#include <cstddef>
#include <cstdint>
#include <stddef.h>
#include <stdint.h>
#ifndef MOCK
#include <Arduino.h>
#include <HardwareSerial.h>
Expand Down
8 changes: 4 additions & 4 deletions src/note-c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ For details on contributions we accept and the process for contributing, see our

For additional Notecard SDKs and Libraries, see:

* [note-arduino](note-arduino) for Arduino support
* [note-python](note-python) for Python
* [note-go](note-go) for Go
* [note-arduino][note-arduino] for Arduino support
* [note-python][note-python] for Python
* [note-go][note-go] for Go

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

Expand All @@ -45,4 +45,4 @@ Copyright (c) 2019 Blues Inc. Released under the MIT license. See
[note-arduino]: https://github.com/blues/note-arduino
[note-go]: https://github.com/blues/note-go
[note-python]: https://github.com/blues/note-python
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
92 changes: 45 additions & 47 deletions src/note-c/n_atof.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define NULL 0
#endif

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

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

decPt = -1;
for (mantSize = 0; ; mantSize += 1)
{
for (mantSize = 0; ; mantSize += 1) {
c = *p;
if (c < '0' || c > '9') {
if ((c != '.') || (decPt >= 0)) {
Expand All @@ -146,7 +145,7 @@ JAtoN(string, endPtr)
* If the mantissa has more than 18 digits, ignore the extras, since
* they can't affect the value anyway.
*/

pExp = p;
p -= mantSize;
if (decPt < 0) {
Expand All @@ -167,8 +166,7 @@ JAtoN(string, endPtr)
} else {
long frac1, frac2;
frac1 = 0L;
for ( ; mantSize > 9; mantSize -= 1)
{
for ( ; mantSize > 9; mantSize -= 1) {
c = *p;
p += 1;
if (c == '.') {
Expand All @@ -178,8 +176,7 @@ JAtoN(string, endPtr)
frac1 = 10*frac1 + (c - '0');
}
frac2 = 0L;
for (; mantSize > 0; mantSize -= 1)
{
for (; mantSize > 0; mantSize -= 1) {
c = *p;
p += 1;
if (c == '.') {
Expand Down Expand Up @@ -224,7 +221,7 @@ JAtoN(string, endPtr)
* many powers of 2 of 10. Then combine the exponent with the
* fraction.
*/

if (exp < 0) {
expSign = TRUE;
exp = -exp;
Expand All @@ -235,45 +232,46 @@ JAtoN(string, endPtr)
exp = MAX_EXPONENT;
}
dblExp = 1.0;
int d;
int d;
for (d = 0; exp != 0; exp >>= 1, d += 1) {
/* Table giving binary powers of 10. Entry */
/* is 10^2^i. Used to convert decimal */
/* exponents into floating-point numbers. */
JNUMBER p10 = 0.0;
switch (d) {
case 0:
p10 = 10.0;
break;
case 1:
p10 = 100.0;
break;
case 2:
p10 = 1.0e4;
break;
case 3:
p10 = 1.0e8;
break;
case 4:
p10 = 1.0e16;
break;
case 5:
p10 = 1.0e32;
break;
/* Table giving binary powers of 10. Entry */
/* is 10^2^i. Used to convert decimal */
/* exponents into floating-point numbers. */
JNUMBER p10 = 0.0;
switch (d) {
case 0:
p10 = 10.0;
break;
case 1:
p10 = 100.0;
break;
case 2:
p10 = 1.0e4;
break;
case 3:
p10 = 1.0e8;
break;
case 4:
p10 = 1.0e16;
break;
case 5:
p10 = 1.0e32;
break;
#ifndef NOTE_FLOAT
case 6:
p10 = 1.0e64;
break;
case 7:
p10 = 1.0e128;
break;
case 8:
p10 = 1.0e256;
break;
case 6:
p10 = 1.0e64;
break;
case 7:
p10 = 1.0e128;
break;
case 8:
p10 = 1.0e256;
break;
#endif
}
if (p10 == 0.0)
break;
}
if (p10 == 0.0) {
break;
}
if (exp & 01) {
dblExp *= p10;
}
Expand Down
59 changes: 27 additions & 32 deletions src/note-c/n_b64.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@
#include "n_lib.h"

/* aaaack but it's fast and const should make it shared text page. */
static const unsigned char pr2six[256] =
{
static const unsigned char pr2six[256] = {
/* ASCII table */
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
Expand Down Expand Up @@ -135,28 +134,28 @@ int JB64Decode(char *bufplain, const char *bufcoded)
bufin = (const unsigned char *) bufcoded;

while (nprbytes > 4) {
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
bufin += 4;
nprbytes -= 4;
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
bufin += 4;
nprbytes -= 4;
}

/* Note: (nprbytes == 1) would be an error, so just ingore that case */
if (nprbytes > 1) {
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
}
if (nprbytes > 2) {
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
}
if (nprbytes > 3) {
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
}

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

p = encoded;
for (i = 0; i < len - 2; i += 3) {
*p++ = basis_64[(string[i] >> 2) & 0x3F];
*p++ = basis_64[((string[i] & 0x3) << 4) |
((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2) |
((int) (string[i + 2] & 0xC0) >> 6)];
*p++ = basis_64[string[i + 2] & 0x3F];
*p++ = basis_64[(string[i] >> 2) & 0x3F];
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] & 0xC0) >> 6)];
*p++ = basis_64[string[i + 2] & 0x3F];
}
if (i < len) {
*p++ = basis_64[(string[i] >> 2) & 0x3F];
if (i == (len - 1)) {
*p++ = basis_64[((string[i] & 0x3) << 4)];
*p++ = basis_64[(string[i] >> 2) & 0x3F];
if (i == (len - 1)) {
*p++ = basis_64[((string[i] & 0x3) << 4)];
*p++ = '=';
} else {
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
}
*p++ = '=';
}
else {
*p++ = basis_64[((string[i] & 0x3) << 4) |
((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
}
*p++ = '=';
}

*p++ = '\0';
return p - encoded;
Expand Down
Loading

0 comments on commit 922fbb2

Please sign in to comment.