Skip to content

Commit 68128e1

Browse files
authored
Introduce a track id, unique for all consuming systems. (#187 / #183)
* Add all bin file distribution * Create UUID as TrackId and pass on to consumers fixes #183 * Remove some BLE metadata
1 parent 498e470 commit 68128e1

18 files changed

+277
-55
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ jobs:
8282
run: |
8383
zip --junk-paths obs-${{ env.OBS_VERSION }}.zip \
8484
bin/.pio/build/esp32dev/firmware.bin
85+
cp /github/home/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin 0x01000.bin
86+
cp bin/.pio/build/esp32dev/partitions.bin 0x08000.bin
87+
cp /github/home/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x0e000.bin
88+
cp bin/.pio/build/esp32dev/firmware.bin 0x10000.bin
89+
zip --junk-paths obs-${{ env.OBS_VERSION }}-full-flash.zip \
90+
0x*.bin
8591
8692
- name: Analyze with SonarCloud
8793
env:
@@ -115,6 +121,14 @@ jobs:
115121
bin/.pio/build/esp32dev/firmware.bin
116122
if-no-files-found: error
117123

124+
- name: Upload Build Asset Full Flash
125+
uses: actions/upload-artifact@v2
126+
with:
127+
name: obs ${{ env.OBS_VERSION }} full flash
128+
path: |
129+
0x*.bin
130+
if-no-files-found: error
131+
118132
- name: Generate changelog
119133
id: changelog
120134
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
@@ -161,3 +175,15 @@ jobs:
161175
asset_path: ./obs-${{ env.OBS_VERSION }}.zip
162176
asset_name: obs-${{ env.OBS_VERSION }}.zip
163177
asset_content_type: application/zip
178+
179+
- name: Upload Release Asset Full Flash
180+
id: upload-release-asset-full-flash
181+
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
182+
uses: actions/upload-release-asset@v1
183+
env:
184+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185+
with:
186+
upload_url: ${{ steps.create_release.outputs.upload_url }}
187+
asset_path: ./obs-${{ env.OBS_VERSION }}-full-flash.zip
188+
asset_name: obs-${{ env.OBS_VERSION }}-full-flash.zip
189+
asset_content_type: application/zip

custom_config.ini.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,23 @@
1616
; === build_flags ===
1717
; build with development option
1818
; build_flags = -D DEVELOP
19+
20+
;;;; Loglevel for debugging ;;;;
21+
22+
; None
23+
;build_flags = -DCORE_DEBUG_LEVEL=0
24+
25+
; Error
26+
;build_flags = -DCORE_DEBUG_LEVEL=1
27+
28+
; Warn
29+
;build_flags = -DCORE_DEBUG_LEVEL=2
30+
31+
; Info
32+
;build_flags = -DCORE_DEBUG_LEVEL=3
33+
34+
; Debug
35+
;build_flags = -DCORE_DEBUG_LEVEL=4
36+
37+
; Verbose
38+
;build_flags = -DCORE_DEBUG_LEVEL=5

docs/software/firmware/bluetooth_services.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ The following events are defined:
9494
| Sensor Distance | `1FE7FAF9-CE63-4236-0004-000000000002` | `NOTIFY` | Gives sensor reading of the left and right sensor. |
9595
| Close Pass | `1FE7FAF9-CE63-4236-0004-000000000003` | `NOTIFY` | Notifies of button confirmed close pass events. |
9696
| Offset | `1FE7FAF9-CE63-4236-0004-000000000004` | `READ` | Configured handle bar offset values in cm. |
97+
| Track Id | `1FE7FAF9-CE63-4236-0004-000000000005` | `READ` | UUID as text to uniquely identify the current recorded track. |
9798

9899
This service uses binary format to transfer time counter as unit32 and unt16
99100
for distance in cm.
@@ -116,3 +117,7 @@ to match the event to the correct time and so location.
116117
is purely to ease the user configuration. The offset is not considered in any
117118
of the other reported values. The service uses 2 uint16 values to report the
118119
left and right offset in cm in that order.
120+
121+
*Tack Id* holds a UUID as String representation that can be used to uniquely
122+
identify the recorded track. If the value changes, a new track is recorded, and
123+
the millisecond counter on the OBS likely is restarted.

docs/software/firmware/csv_format.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ understand.
3838
| `DeviceId` | `affe` | internal Id of the OBS |
3939
| `PresetId` | `Wade` | Id to identify the selected preset. A owner might define multiple presets |
4040
| `BluetoothEnabled` | `1` | 1 if bluetooth is enabled, 0 otherwise
41+
| `TrackId` | `38605ba-76...` | A uuid that can be used to uniquely identify the track.
4142

4243
## CSV
4344

287 KB
Loading
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Initial ESP flashing
2+
3+
You can always use an IDE setup to flash the ESP but if you simply
4+
want to start using the OBS this way might be more straight forward.
5+
6+
As of today, this thing is foe Windows only.
7+
8+
Other than for the next updates that you can do over the air using
9+
the small release package, you need the "full flash" zip file, and
10+
the _Flash Download Tools_ from
11+
[ESPRESSIF](https://www.espressif.com/en/support/download/other-tools?keys=&field_type_tid%5B%5D=13)
12+
13+
## Preparation
14+
15+
Download the latest release archive from
16+
[OpenBikeSensorFirmware at GITHub](https://github.com/openbikesensor/OpenBikeSensorFirmware/releases).
17+
You need the larger ZIP file named `obs-v9.9.9999-full-flash.zip`.
18+
Extract the files in a temporary folder, they are named like
19+
0x??????.bin. The numbers are the base address where the data should
20+
be flashed. Don`t worry this will make sense in the next steps.
21+
22+
Please download _Flash Download Tools (ESP8266 & ESP32 & ESP32-S2)_ from
23+
[ESPRESSIF](https://www.espressif.com/en/support/download/other-tools?keys=&field_type_tid%5B%5D=13)
24+
and extract the tool also in a dedicated temporary folder. There
25+
will be no install step, the tool is started directly in the folder.
26+
27+
Remove USB devices from your computer, that you do not need right now.
28+
They can be confused during the selection of the right device to be
29+
flashed.
30+
31+
## Steps
32+
33+
Connect ESP via USB (checkme - driver needed?). Windows should
34+
confirm that a new device was detected.
35+
36+
Start `flash_download_tool_3.X.X.exe`, in the folder of the _Flash
37+
Download Tool_. Give it some time to start. It will open a console
38+
window 1st and eventually a simple UI.
39+
40+
Choose `Developer Mode` - `ESP32 DownloadTool` in the UI. The
41+
`Factory Mode` can be used if you need to flash a whole batch of
42+
ESPs. In that case you can also connect multiple ESPs at the same
43+
time.
44+
45+
Now we need to tell the tool what needs to be flashed. At the
46+
top of the dialog you now see several lines starting, with
47+
checkboxes, a textarea, 3 dots an `@` sign and one more
48+
text ara.
49+
50+
For each of the 4 files we need to flash, select the 3 dots which
51+
will bring up a file selector where you need to choose one of
52+
the 4 *.bin files. The order is not important, but you need to
53+
enter the _address_ of the file in the 2nd text field. The _address_
54+
is the same as the filename `0x10000` for example. The boxes get
55+
a green background confirming a positive sanity check of the flash
56+
tool.
57+
58+
Now select the checkboxes in front of the entries you just made.
59+
60+
All other values stay with the default:
61+
`SPI SPEED` : `40MHz`, `SPI MODE` : `DIO` (This one will change
62+
automatically in a moment), `FLASH SIZE` : `32Mbit` and finally
63+
`SpiAutoSet` : `selected`, `DoNotChgBin` : `not selected`.
64+
65+
On the button you see a drop-down box `COM:` here you have to
66+
select the correct com post for the flash process. If unsure
67+
leave the default and try a different value if the process
68+
fails. Make sure you have no other devices connected!
69+
70+
Press: "START".
71+
72+
You should see something like this now:
73+
![Flashing in progress](flashtool.png)
74+
75+
If all goes correct, you should see a progress bar with final
76+
success message. Unplug the USB cable. The ESP is then ready
77+
to be placed inside the OBS housing (if not done already).
78+
Thanks to OTA Update you should not need to update this way
79+
anymore.
80+
81+
If you get some _red_ error feedback, check that the USB
82+
connection is correct and that the right COM port was selected.
83+
If all fails, use the OBS Slack to get some help.
84+
Currently, there is not much troubleshooting info collected,
85+
but this will change.
86+
87+
88+
## Licenses
89+
90+
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/COPYRIGHT.html
91+
92+
TODO

src/OpenBikeSensorFirmware.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
the OpenBikeSensor sensor firmware. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
#include <utils/obsutils.h>
2122
#include "OpenBikeSensorFirmware.h"
2223

2324
#include "SPIFFS.h"
@@ -203,7 +204,7 @@ void setup() {
203204
displayTest->showTextOnGrid(2, 2, "SD... error",DEFAULT_FONT);
204205
if (config.simRaMode || digitalRead(PushButton_PIN) == HIGH) {
205206
break;
206-
}
207+
} // FIXME: Stop trying!!?
207208
}
208209
Serial.println("Card Mount Failed");
209210
//delay(100);
@@ -267,10 +268,12 @@ void setup() {
267268

268269
displayTest->showTextOnGrid(2, 3, "CSV file...",DEFAULT_FONT);
269270

271+
const String trackUniqueIdentifier = ObsUtils::createTrackUuid();
272+
270273
if (SD.begin()) {
271274
writer = new CSVFileWriter;
272275
writer->setFileName();
273-
writer->writeHeader();
276+
writer->writeHeader(trackUniqueIdentifier);
274277
displayTest->showTextOnGrid(2, 3, "CSV file... ok",DEFAULT_FONT);
275278
Serial.println("File initialised");
276279
} else {
@@ -307,7 +310,8 @@ void setup() {
307310
cfg.getProperty<String>(ObsConfig::PROPERTY_OBS_NAME),
308311
config.sensorOffsets[LEFT_SENSOR_ID],
309312
config.sensorOffsets[RIGHT_SENSOR_ID],
310-
batteryPercentage);
313+
batteryPercentage,
314+
trackUniqueIdentifier);
311315
bluetoothManager->activateBluetooth();
312316
} else {
313317
bluetoothManager = nullptr;

src/OpenBikeSensorFirmware.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <Adafruit_BMP280.h>
1919
#include <VL53L0X.h>
2020

21-
#ifdef BLUETOOTH_ACTIVATED
2221
#include "bluetooth/BluetoothManager.h"
23-
#endif
2422

2523
#endif

src/bluetooth/BluetoothManager.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
void BluetoothManager::init(
44
const String &obsName,
55
const uint16_t leftOffset, const uint16_t rightOffset,
6-
std::function<uint8_t()> batteryPercentage) {
6+
std::function<uint8_t()> batteryPercentage,
7+
const String &trackId) {
78

89
ESP_ERROR_CHECK_WITHOUT_ABORT(
910
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
@@ -17,7 +18,7 @@ void BluetoothManager::init(
1718
services.push_back(new DistanceService);
1819
services.push_back(new ConnectionService);
1920
services.push_back(new ClosePassService);
20-
services.push_back(new ObsService(leftOffset, rightOffset));
21+
services.push_back(new ObsService(leftOffset, rightOffset, trackId));
2122

2223
for (auto &service : services) {
2324
service->setup(pServer);
@@ -45,12 +46,6 @@ void BluetoothManager::disconnectDevice() const {
4546
}
4647

4748
void BluetoothManager::newSensorValues(const uint32_t millis, const uint16_t leftValues, const uint16_t rightValues) {
48-
// Discarding values if they are more recent than 50 ms
49-
if (millis - lastValueTimestamp < 50) {
50-
return;
51-
}
52-
lastValueTimestamp = millis;
53-
5449
for (auto &service : services) {
5550
service->newSensorValues(millis, leftValues, rightValues);
5651
}

src/bluetooth/BluetoothManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class BluetoothManager {
2323
*/
2424
void init(const String &obsName,
2525
uint16_t leftOffset, uint16_t rightOffset,
26-
std::function<uint8_t()> batteryPercentage);
26+
std::function<uint8_t()> batteryPercentage,
27+
const String &trackId);
2728

2829
/**
2930
* Starts advertising all services that internally implement shouldAdvertise()

0 commit comments

Comments
 (0)