Skip to content

Commit dbfa9e6

Browse files
committed
Merge branch 'main' of github.com:CivicTechTO/tRacket-sensor into 21-access-point-dropdown
2 parents 4694672 + 6319bfd commit dbfa9e6

File tree

10 files changed

+29
-78
lines changed

10 files changed

+29
-78
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
2525
- name: Create header files
2626
run: |
27-
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
2827
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
2928
3029
- name: Build PlatformIO Project (esp32-pcb)

.github/workflows/ota-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
OTA_KEY: ${{ secrets.OTA_SIGNING_KEY }}
3030
run: |
3131
echo "$OTA_KEY" > "${GITHUB_WORKSPACE}/priv_key.pem"
32-
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
3332
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
3433
3534
- name: Build signed firmware

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ The source code is released under the [GNU GPL v3 license](/noisemeter-device/LI
2929

3030
## Hardware Files
3131

32-
The [hardware](/hardware) folder contains design files and documentation for each iteration of the noisemeter hardware. The PCBs are designed using [KiCAD](https://www.kicad.org/).
32+
The [hardware](/hardware) folder contains design files and documentation for each iteration of the sensor hardware. The PCBs are designed using [KiCAD](https://www.kicad.org/).
3333

3434
The hardware design files are released under an [open hardware license](/hardware/pcb-rev2/LICENSE).
3535

3636
## For Developers
3737

38-
* Check out the [Issues page](https://github.com/CivicTechTO/proj-noisemeter-device/issues) to see current bugs and feature requests. Any contributions are welcome!
38+
* Check out the [Issues page](https://github.com/CivicTechTO/tRacket-sensor/issues) to see current bugs and feature requests. Any contributions are welcome!
3939
* Online documentation of the firmware [is available here](https://civictechto.github.io/tRacket-sensor/).
4040

noisemeter-device/BUILD.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,28 @@
77
python certs.py -s api.tracket.info > certs.h
88
```
99

10-
2. Copy `config.h.example` to `config.h`; if compiling with the Arduino IDE, edit the file to select your board type.
11-
12-
## Code compiling and upload
13-
14-
### PlatformIO
10+
## Code compilation and upload
1511

1612
1. [Install PlatformIO](https://platformio.org/install).
1713

1814
2. Run `pio run` to compile for the PCB. A breadboard target is available too: `pio run -e esp32-breadboard`.
1915

2016
3. Run `pio run -t upload` to upload to the device (this also compiles the code if there have been any changes).
2117

22-
### Arduino
23-
24-
1. Install the Arduino IDE and [follow these instructions](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html) to add support for ESP32 microcontrollers.
25-
26-
2. Under "Tools" > "Board: " > "ESP32 Arduino", select either "ESP32C3 Dev Module" for the PCB boards or "ESP32-WROOM-DA Module" for the ESP32 breadboard prototype.
27-
28-
3. Compile the sketch and upload it to the device.
29-
3018
## HMAC encryption key
3119

32-
Data stored on the device (e.g. WiFi credentials) are encrypted with an "eFuse" key. This key can only be written once, and is not be read or written after that.
33-
34-
Using PlatformIO:
20+
Data stored on the device (e.g. WiFi credentials) are encrypted with an "eFuse" key. This key can only be configured once, and cannot be read or written after that.
3521

3622
```bash
3723
dd if=/dev/urandom of=hmac_key bs=1 count=32
3824
pio pkg exec -- espefuse.py --port /dev/ttyACM0 burn_key BLOCK4 hmac_key HMAC_UP
25+
rm hmac_key
3926
```
4027

28+
This is done in the `bringup.sh` script that is used to program new sensors.
29+
30+
**Please generate a unique hmac_key for each device.**
31+
4132
## Enable secure download mode
4233

4334
Enabling secure download mode prevents users from using USB/serial download mode to dump memory contents (WiFi credentials and API token):
@@ -54,21 +45,20 @@ pio pkg exec -- esptool.py write_flash 0x10000 .pio/build/esp32-pcb/firmware.bin
5445

5546
## Signing OTA updates
5647

57-
A 4096-bit RSA key is used to sign OTA updates. Whoever controls the private OTA signing key can create a public key with this command and include its contents in `noisemeter_device/ota_update.cpp`:
48+
OTA updates must be signed for deployed tRacket sensors to accept them. The
49+
GitHub repo is configured to automatically sign firmware updates when releases
50+
are published.
5851

59-
```bash
60-
openssl rsa -in priv_key.pem -pubout > rsa_key.pub
61-
```
52+
Signing requires a 4096-bit RSA key. To sign an update (assuming you have the
53+
private key), run `pio run -t ota`.
6254

63-
They may also sign a firmware update with these commands (the signature is prepended to the firmware binary):
55+
The public key is to be stored in `noisemeter_device/ota_update.cpp`. To obtain
56+
the public key (assuming you have the private key), run:
6457

6558
```bash
66-
openssl dgst -sign priv_key.pem -keyform PEM -sha256 -out firmware.sign -binary .pio/build/esp32-pcb/firmware.bin
67-
cat firmware.sign .pio/build/esp32-pcb/firmware.bin > firmware_signed.bin
59+
openssl rsa -in priv_key.pem -pubout > rsa_key.pub
6860
```
6961

70-
`firmware_signed.bin` is then uploaded to the OTA server.
71-
7262
## Operation Overview:
7363

7464
* After initial programming or a factory reset, the device will enter Hotspot mode once it is powered on. This is indicated by a blinking LED.

noisemeter-device/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ RECURSIVE = YES
10031003
# Note that relative paths are relative to the directory from which doxygen is
10041004
# run.
10051005

1006-
EXCLUDE = doc certs.h secret.h config.h
1006+
EXCLUDE = doc certs.h secret.h
10071007

10081008
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
10091009
# directories that are symbolic links (a Unix file system feature) are excluded

noisemeter-device/board.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
///
44
/// Each supported board must have a defined section here to specify the
55
/// hardware pins and peripherals being used. Selecting a board for
6-
/// compilation is done either through PlatformIO or config.h.
6+
/// compilation is done through PlatformIO.
77
/* noisemeter-device - Firmware for CivicTechTO's Noisemeter Device
88
* Copyright (C) 2024 Clyne Sullivan, Nick Barnard
99
*
@@ -23,8 +23,6 @@
2323
#ifndef BOARD_H
2424
#define BOARD_H
2525

26-
#include "config.h"
27-
2826
#undef SERIAL
2927

3028
#if defined(BOARD_ESP32_PCB)
@@ -52,10 +50,8 @@
5250
/** Serial instance to use for logging output. */
5351
#define SERIAL USBSerial
5452

55-
#if defined(BUILD_PLATFORMIO)
5653
#include <HWCDC.h>
5754
extern HWCDC USBSerial;
58-
#endif
5955

6056
#elif defined(BOARD_ESP32_BREADBOARD)
6157

noisemeter-device/config.h.example

Lines changed: 0 additions & 37 deletions
This file was deleted.

noisemeter-device/noisemeter-device.ino

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@
3434
#include <list>
3535
#include <optional>
3636

37-
#if defined(BUILD_PLATFORMIO) && defined(BOARD_ESP32_PCB)
37+
#ifdef BOARD_ESP32_PCB
3838
HWCDC USBSerial;
3939
#endif
4040

41-
// Uncomment these to disable WiFi and/or data upload
42-
//#define UPLOAD_DISABLED
43-
4441
/** Maximum number of seconds to wait for successful WiFi connection. */
4542
constexpr auto WIFI_CONNECT_TIMEOUT_SEC = MIN_TO_SEC(2);
4643
/** Maximum number of seconds to try making new WiFi connection. */

noisemeter-device/storage.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17-
#include "config.h"
1817
#include "storage.h"
1918

2019
#include <Arduino.h>

platformio.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ build_unflags =
2525
-std=gnu++11
2626
build_flags =
2727
-std=gnu++17
28-
-DBUILD_PLATFORMIO
2928
-DNO_GLOBAL_EEPROM
3029
-DNOISEMETER_VERSION=\"0.2.3\"
3130
-Wall -Wextra
3231

32+
# Optional build flags:
33+
# Print credentials over serial (for debugging):
34+
# -DSTORAGE_SHOW_CREDENTIALS
35+
# Print verbose API logging over serial (for debugging):
36+
# -DAPI_VERBOSE
37+
# Disable WiFi and data upload:
38+
# -DUPLOAD_DISABLED
39+
3340
[env:esp32-pcb]
3441
board = esp32-c3-devkitm-1
3542
board_build.f_cpu = 80000000L
@@ -40,3 +47,4 @@ build_flags = ${env.build_flags} -DBOARD_ESP32_PCB
4047
[env:esp32-breadboard]
4148
board = upesy_wroom
4249
build_flags = ${env.build_flags} -DBOARD_ESP32_BREADBOARD
50+

0 commit comments

Comments
 (0)