Skip to content

Commit 9a3a264

Browse files
authored
Update note-c and prepare for 1.6.4 (#136)
* Remove `note-c` before re-add * Squashed 'src/note-c/' content from commit 1503daa git-subtree-dir: src/note-c git-subtree-split: 1503daa65a201ae1aed3ae462a8a2ee5d6657d60 * Remove unneeded directories from `note-c` * chore: Update version information
1 parent 663921d commit 9a3a264

20 files changed

+940
-468
lines changed

README.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ with:
118118
- [Sensor tutorial](examples/Example6_SensorTutorial/Example6_SensorTutorial.ino)
119119
- [Power control](examples/Example7_PowerControl/Example7_PowerControl.ino)
120120

121-
Before running an example, you will need to set the Product Identifier, either in code or on your connected Notecard. Steps on how to do this can be found at [https://dev.blues.io/tools-and-sdks/samples/product-uid](https://dev.blues.io/tools-and-sdks/samples/product-uid).
121+
Before running an example, you will need to set the Product Identifier, either
122+
in code or on your connected Notecard. Steps on how to do this can be found at
123+
[https://dev.blues.io/tools-and-sdks/samples/product-uid](https://dev.blues.io/tools-and-sdks/samples/product-uid).
122124

123125

124126
## Contributing
@@ -256,6 +258,36 @@ in the `tests` array in the `main` function. The entry will occupy it's own line
256258
at the end of the array, and syntax should be as follows,
257259
`{test_name, "test_name"},`.
258260

261+
## Generating a Release
262+
263+
### Update Files
264+
265+
When generating a release of the `note-arduino` library, you will need to update
266+
the version in two places.
267+
268+
- `NoteDefines.h`
269+
270+
The `note-arduino` library provides preprocessor defines to allow for
271+
programmatic access to the version number. The following preprocessor
272+
defines should be updated with the version you wish to publish:
273+
274+
- `NOTE_ARDUINO_VERSION_MAJOR`
275+
- `NOTE_ARDUINO_VERSION_MINOR`
276+
- `NOTE_ARDUINO_VERSION_PATCH`
277+
278+
- `library.properties`
279+
280+
Update the `version` key to reflect the version you wish to publish. The
281+
version string should follow the form "\<major\>.\<minor\>.\<patch\>" (e.g.
282+
`1.6.4`). This value will be used by the Arduino Library Manager.
283+
284+
### GitHub Release
285+
286+
Publishing a release on GitHub will trigger the Arduino Library Manager. The
287+
Arduino Library Manager will then look to the `library.properties` file, and
288+
generate a release based on the `version` value it finds there. It should be
289+
noted, the version on GitHub is not evaluated by the Arduino Library Manager.
290+
259291
## More Information
260292

261293
For additional Notecard SDKs and Libraries, see:

library.properties

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

src/NoteDefines.h

+1-1
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 6
7-
#define NOTE_ARDUINO_VERSION_PATCH 3
7+
#define NOTE_ARDUINO_VERSION_PATCH 4
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/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ __pycache__/
88
*.code-workspace
99
*.orig
1010
settings.json
11+
12+
# Development Artifacts
13+
cppcheck_output.txt

src/note-c/CMakeLists.txt

+34-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.20)
2+
cmake_policy(SET CMP0095 NEW)
23

34
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
45
message(FATAL_ERROR "In-source builds are not allowed.
@@ -14,13 +15,14 @@ if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
1415
file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*")
1516
endif()
1617

17-
option(NOTE_C_BUILD_TESTS "Build tests." OFF)
18+
option(NOTE_C_BUILD_DOCS "Build docs." OFF)
19+
option(NOTE_C_BUILD_TESTS "Build tests." ON)
1820
option(NOTE_C_COVERAGE "Compile for test NOTE_C_COVERAGE reporting." OFF)
21+
option(NOTE_C_LOW_MEM "Build the library tailored for low memory usage." OFF)
1922
option(NOTE_C_MEM_CHECK "Run tests with Valgrind." OFF)
20-
option(NOTE_C_BUILD_DOCS "Build docs." OFF)
2123
option(NOTE_C_NO_LIBC "Build the library without linking against libc, generating errors for any undefined symbols." OFF)
22-
option(NOTE_C_LOW_MEM "Build the library tailored for low memory usage." OFF)
23-
option(NOTE_C_TEST_SINGLE_PRECISION "Use single precision for JSON floating point numbers." OFF)
24+
option(NOTE_C_SHOW_MALLOC "Build the library with flags required to log memory usage." OFF)
25+
option(NOTE_C_SINGLE_PRECISION "Use single precision for JSON floating point numbers." OFF)
2426

2527
set(NOTE_C_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2628
add_library(note_c SHARED)
@@ -52,11 +54,28 @@ target_compile_options(
5254
-Werror
5355
-Og
5456
-ggdb
57+
PUBLIC
58+
-m32
59+
-mfpmath=sse
60+
-msse2
5561
)
5662
target_include_directories(
5763
note_c
5864
PUBLIC ${NOTE_C_SRC_DIR}
5965
)
66+
target_link_directories(
67+
note_c
68+
PUBLIC
69+
/lib32
70+
/usr/lib32
71+
/usr/lib/gcc/x86_64-linux-gnu/12/32
72+
)
73+
target_link_options(
74+
note_c
75+
PUBLIC
76+
-m32
77+
-Wl,-melf_i386
78+
)
6079

6180
if(NOTE_C_LOW_MEM)
6281
target_compile_definitions(
@@ -85,11 +104,19 @@ if(NOTE_C_NO_LIBC)
85104
)
86105
endif()
87106

88-
if(NOTE_C_TEST_SINGLE_PRECISION)
107+
if(NOTE_C_SHOW_MALLOC)
108+
target_compile_definitions(
109+
note_c
110+
PUBLIC
111+
NOTE_C_SHOW_MALLOC
112+
)
113+
endif()
114+
115+
if(NOTE_C_SINGLE_PRECISION)
89116
target_compile_definitions(
90117
note_c
91118
PUBLIC
92-
NOTE_C_TEST_SINGLE_PRECISION
119+
NOTE_C_SINGLE_PRECISION
93120
)
94121
endif()
95122

src/note-c/CONTRIBUTING.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
We love pull requests from everyone. By participating in this project, you
44
agree to abide by the Blues Inc [code of conduct].
55

6-
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
7-
86
Here are some ways *you* can contribute:
97

108
* by using alpha, beta, and prerelease versions
@@ -33,6 +31,12 @@ clean up inconsistent whitespace )
3331

3432
[gist]: https://gist.github.com/
3533

34+
## Library Development
35+
36+
Review our [contribution guidelines](./CONTRIBUTING.md) and [developer
37+
documentation](./test/README.md) for setting up your environment and
38+
configuring your toolchain.
39+
3640
## Cleaning up issues
3741

3842
* Issues that have no response from the submitter will be closed after 30 days.
@@ -59,6 +63,7 @@ clean up inconsistent whitespace )
5963
https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
6064
[pr]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
6165

62-
Inspired by
66+
Inspired by:
6367
https://github.com/thoughtbot/factory_bot/blob/master/CONTRIBUTING.md
6468

69+
[code of conduct]: https://blues.github.io/opensource/code-of-conduct

src/note-c/Dockerfile

+12-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ARG USER
2121

2222
# Local Argument(s)
2323

24+
# Local Environment Variable(s)
25+
ENV LC_ALL="C.UTF-8"
26+
2427
# Create Non-Root User
2528
RUN ["dash", "-c", "\
2629
addgroup \
@@ -38,6 +41,11 @@ RUN ["dash", "-c", "\
3841
\"${USER}\" \
3942
"]
4043

44+
# Add 32-bit binaries to the index.
45+
RUN ["dash", "-c", "\
46+
dpkg --add-architecture i386 \
47+
"]
48+
4149
# Install whatever dependencies we can via apt-get.
4250
RUN ["dash", "-c", "\
4351
apt-get update --quiet \
@@ -46,14 +54,18 @@ RUN ["dash", "-c", "\
4654
ca-certificates \
4755
curl \
4856
g++ \
57+
g++-multilib \
4958
gcc \
59+
gcc-multilib \
5060
gdb \
5161
git \
5262
lcov \
63+
libc6-dbg:i386 \
5364
make \
5465
nano \
5566
python3-pip \
5667
python3-sphinx \
68+
cppcheck \
5769
valgrind \
5870
&& pip install --break-system-packages \
5971
breathe \
@@ -83,13 +95,3 @@ RUN ["dash", "-c", "\
8395
&& tar xf cmake-3.25.1-linux-x86_64.tar.gz --strip-components=1 -C /usr \
8496
&& rm cmake-3.25.1-linux-x86_64.tar.gz \
8597
"]
86-
87-
# Download and install Catch2 v3.2.1.
88-
RUN ["dash", "-c", "\
89-
curl -LO https://github.com/catchorg/Catch2/archive/refs/tags/v3.2.1.tar.gz \
90-
&& tar xf v3.2.1.tar.gz \
91-
&& cd Catch2-3.2.1 \
92-
&& cmake -DCATCH_INSTALL_DOCS=0 -B build/ \
93-
&& cmake --build build/ --target install \
94-
&& rm -rf Catch2-3.2.1 v3.2.1.tar.gz \
95-
"]

src/note-c/README.md

+111-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Coverage Status](https://coveralls.io/repos/github/blues/note-c/badge.svg?branch=master)](https://coveralls.io/github/blues/note-c?branch=master)
1+
[![Coverage Status][coverage badge]][coverage details]
22

33
# note-c
44

@@ -12,22 +12,116 @@ Notes to [Notehub.io][notehub].
1212
This library is used by the [note-arduino library][note-arduino], which includes
1313
it as a git subtree.
1414

15-
## Documentation
15+
## API Documentation
1616

17-
The documentation for this library can be found [here](https://blues.github.io/note-c/index.html).
17+
The API documentation for this library can be found [here][note-c API docs].
1818

19-
## CMake
19+
## Logging Control
2020

21-
The CMake build system is primarily here for testing note-c on a development
22-
machine. You can use it to generate a static or shared note-c library, but
23-
embedded users will typically just compile all the .c source files into their
24-
firmware image. For more on testing, see test/README.md.
21+
`note-c` provides a comprehensive and flexible logging functionality.
2522

26-
### Options
23+
To activate logging, you must provide a callback for logging via
24+
`hookDebugOutput()`. The callback takes the following form:
2725

28-
- BUILD_TESTS: Build the tests. See the tests directory. Default: ON.
29-
- BUILD_SHARED_LIBS: Build the note-c library as shared instead of static. This
30-
reduces the total size of the compiled tests. Default: ON.
26+
```c
27+
typedef size_t (*debugOutputFn) (const char *text);
28+
```
29+
30+
The callback is responsible for taking a character array (C-style string) and
31+
returning the number of bytes processed (written out) as confirmation. The
32+
exact implementation will be up to the user who provided the function pointer,
33+
but its presence will active logging in the library.
34+
35+
### Library Logging
36+
37+
#### Log Levels
38+
39+
`note-c` provides for four (4) levels of logging. Here they are listed from
40+
most severe to most verbose:
41+
42+
0. `NOTE_C_LOG_LEVEL_ERROR`
43+
1. `NOTE_C_LOG_LEVEL_WARN`
44+
2. `NOTE_C_LOG_LEVEL_INFO`
45+
3. `NOTE_C_LOG_LEVEL_DEBUG`
46+
47+
By default, `note-c` logs at `NOTE_C_LOG_LEVEL_INFO`.
48+
49+
#### Default Logging Behavior
50+
51+
To modify the default behavior, you may specify the desired log level at compile
52+
time, as follows:
53+
54+
```sh
55+
-DNOTE_C_LOG_LEVEL=0
56+
```
57+
58+
_**NOTE:** In the example above, you will notice we used zero (`0`), instead of
59+
`NOTE_C_LOG_LEVEL_ERROR`. This is because the warning constants are internal to
60+
the library, and not available in the context of the command line._
61+
62+
Here, we have decided to show only the most severe (i.e. `[ERROR]`) logs.
63+
Alternatively, you may set the level to any of the values listed above.
64+
65+
#### Dynamic Logging Behavior
66+
67+
In the previous section, we discussed setting the base (or default) logging
68+
behavior for the library. However, you may also set the log level dynamically,
69+
during runtime, by using the `NoteSetLogLevel()` API.
70+
71+
```c
72+
NoteSetLogLevel(NOTE_C_LOG_LEVEL_WARN);
73+
```
74+
75+
### Notecard Sync Logging (`[SYNC]`)
76+
77+
Tangential to the standard logging behavior, `note-c` also provides a helper
78+
function to invoke/extract synchronization logs from the Notecard.
79+
80+
- `NoteDebugSyncStatus()`
81+
82+
Instead of toggling features inside the library, this helper functions sends a
83+
request to the Notecard to inquire about its synchronization status and logs
84+
those details.
85+
86+
The function is designed to be called in a loop and throttled by a parameter.
87+
See [the documentation page][NoteDebugSyncStatus] for more information.
88+
89+
## Versioning
90+
91+
The `note-c` versioning scheme is a variant of [Semantic
92+
Versioning](https://semver.org/).
93+
94+
Below is a high-level overview of the major/minor/patch versions:
95+
96+
- Major Version: Signals incompatible API changes.
97+
- Minor Version: Signals added functionality in a backward compatible manner.
98+
- Patch Version: Signals backward compatible bug fixes.
99+
100+
Beyond the SemVer foundation, Blues has imposed additional requirements for a
101+
version to be considered valid:
102+
103+
- Major/minor/patch versions SHALL NOT be zero.
104+
- For anything other than major version, version numbers MUST NOT contain
105+
EITHER leading zeroes OR trailing zeroes (e.g. version `1.10.2` is invalid).
106+
107+
> Example version progression:
108+
>
109+
> `1.8.1`, `1.9.1`, `1.9.2`, `1.11.1`, `1.11.2`, `1.11.3`, `1.12.1`, `2.1.1`
110+
111+
These additional constraints have been observed to help disambiguate versions
112+
and reduce support burden.
113+
114+
### Version Artifacts
115+
116+
The version can be referenced/tested programmatically via the following
117+
preprocessor defined integers found in `note.h`:
118+
119+
- `NOTE_C_VERSION_MAJOR`
120+
- `NOTE_C_VERSION_MINOR`
121+
- `NOTE_C_VERSION_PATCH`
122+
123+
The version may also be logged via the preprocessor defined string literal,
124+
`NOTE_C_VERSION`.
31125
32126
## Contributing
33127
@@ -57,8 +151,12 @@ Copyright (c) 2019 Blues Inc. Released under the MIT license. See
57151
[LICENSE](LICENSE) for details.
58152
59153
[blues]: https://blues.com
154+
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
155+
[coverage badge]: https://coveralls.io/repos/github/blues/note-c/badge.svg?branch=master
156+
[coverage details]: https://coveralls.io/github/blues/note-c?branch=master
157+
[NoteDebugSyncStatus]: https://blues.github.io/note-c/api_reference.html#c.NoteDebugSyncStatus
60158
[notehub]: https://notehub.io
61159
[note-arduino]: https://github.com/blues/note-arduino
160+
[note-c API docs]: https://blues.github.io/note-c/index.html
62161
[note-go]: https://github.com/blues/note-go
63162
[note-python]: https://github.com/blues/note-python
64-
[code of conduct]: https://blues.github.io/opensource/code-of-conduct

src/note-c/n_atof.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ char **endPtr; /* If non-NULL, store terminating character's
256256
case 5:
257257
p10 = 1.0e32;
258258
break;
259-
#ifndef NOTE_C_LOW_MEM
259+
#ifndef NOTE_C_SINGLE_PRECISION
260260
case 6:
261261
p10 = 1.0e64;
262262
break;

0 commit comments

Comments
 (0)