Skip to content

Commit 0ca018b

Browse files
authored
Merge pull request #522 from jonvmey/fix-nav-uuid-docs
Fix Navigation Service UUID docs
2 parents f99f71c + 7cc73b7 commit 0ca018b

3 files changed

Lines changed: 26 additions & 46 deletions

File tree

doc/NavigationService.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ manDist (string) - Manouvre Distance, the distance to the upcoming change
99
progress (uint8) - Percent complete of total route, value 0-100
1010

1111
## Service
12-
The service UUID is c7e60001-78fc-48fe-8e23-433b3a1942d0
12+
The service UUID is 00010000-78fc-48fe-8e23-433b3a1942d0
1313

1414
## Characteristics
15-
## Flags (UUID c7e60002-78fc-48fe-8e23-433b3a1942d0)
15+
## Flags (UUID 00010001-78fc-48fe-8e23-433b3a1942d0)
1616
All included icons are from pure-maps, which provides the actual routing from the client. The icon names ultimately come from the mapbox project "direction-icons", See https://github.com/rinigus/pure-maps/tree/master/qml/icons/navigation See the end of this document for the full lsit of supported icon names.
1717

18-
## Narrative (UUID c7e60003-78fc-48fe-8e23-433b3a1942d0)
18+
## Narrative (UUID 00010002-78fc-48fe-8e23-433b3a1942d0)
1919
This is a client supplied string describing the upcoming instruction such as "At the roundabout take the first exit".
2020

21-
## Man Dist (UUID c7e60004-78fc-48fe-8e23-433b3a1942d0)
21+
## Man Dist (UUID 00010003-78fc-48fe-8e23-433b3a1942d0)
2222
This is a short string describing the distance to the upcoming instruction such as "50 m".
2323

24-
## Progress (UUID c7e60001=5-78fc-48fe-8e23-433b3a1942d0)
24+
## Progress (UUID 00010004-78fc-48fe-8e23-433b3a1942d0)
2525
The percent complete in a uint8. The watch displays this as an overall progress in a progress bar.
2626

2727
## Full icon list

src/components/ble/NavigationService.cpp

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,32 @@
2020

2121
#include "systemtask/SystemTask.h"
2222

23-
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
24-
auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
25-
return navService->OnCommand(conn_handle, attr_handle, ctxt);
26-
}
27-
28-
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
29-
navUuid.value[14] = navId[0];
30-
navUuid.value[15] = navId[1];
23+
namespace {
24+
// 0001yyxx-78fc-48fe-8e23-433b3a1942d0
25+
constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) {
26+
return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128},
27+
.value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x01, 0x00}};
28+
}
3129

32-
navFlagCharUuid.value[12] = navFlagCharId[0];
33-
navFlagCharUuid.value[13] = navFlagCharId[1];
34-
navFlagCharUuid.value[14] = navId[0];
35-
navFlagCharUuid.value[15] = navId[1];
30+
// 00010000-78fc-48fe-8e23-433b3a1942d0
31+
constexpr ble_uuid128_t BaseUuid() {
32+
return CharUuid(0x00, 0x00);
33+
}
3634

37-
navNarrativeCharUuid.value[12] = navNarrativeCharId[0];
38-
navNarrativeCharUuid.value[13] = navNarrativeCharId[1];
39-
navNarrativeCharUuid.value[14] = navId[0];
40-
navNarrativeCharUuid.value[15] = navId[1];
35+
constexpr ble_uuid128_t navUuid {BaseUuid()};
4136

42-
navManDistCharUuid.value[12] = navManDistCharId[0];
43-
navManDistCharUuid.value[13] = navManDistCharId[1];
44-
navManDistCharUuid.value[14] = navId[0];
45-
navManDistCharUuid.value[15] = navId[1];
37+
constexpr ble_uuid128_t navFlagCharUuid {CharUuid(0x01, 0x00)};
38+
constexpr ble_uuid128_t navNarrativeCharUuid {CharUuid(0x02, 0x00)};
39+
constexpr ble_uuid128_t navManDistCharUuid {CharUuid(0x03, 0x00)};
40+
constexpr ble_uuid128_t navProgressCharUuid {CharUuid(0x04, 0x00)};
4641

47-
navProgressCharUuid.value[12] = navProgressCharId[0];
48-
navProgressCharUuid.value[13] = navProgressCharId[1];
49-
navProgressCharUuid.value[14] = navId[0];
50-
navProgressCharUuid.value[15] = navId[1];
42+
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
43+
auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
44+
return navService->OnCommand(conn_handle, attr_handle, ctxt);
45+
}
46+
} // namespace
5147

48+
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
5249
characteristicDefinition[0] = {
5350
.uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
5451

src/components/ble/NavigationService.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
#undef max
2727
#undef min
2828

29-
// c7e60000-78fc-48fe-8e23-433b3a1942d0
30-
#define NAVIGATION_SERVICE_UUID_BASE \
31-
{ 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0x00, 0x00 }
32-
3329
namespace Pinetime {
3430
namespace System {
3531
class SystemTask;
@@ -53,19 +49,6 @@ namespace Pinetime {
5349
int getProgress();
5450

5551
private:
56-
static constexpr uint8_t navId[2] = {0x01, 0x00};
57-
static constexpr uint8_t navFlagCharId[2] = {0x01, 0x00};
58-
static constexpr uint8_t navNarrativeCharId[2] = {0x02, 0x00};
59-
static constexpr uint8_t navManDistCharId[2] = {0x03, 0x00};
60-
static constexpr uint8_t navProgressCharId[2] = {0x04, 0x00};
61-
62-
ble_uuid128_t navUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
63-
64-
ble_uuid128_t navFlagCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
65-
ble_uuid128_t navNarrativeCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
66-
ble_uuid128_t navManDistCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
67-
ble_uuid128_t navProgressCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
68-
6952
struct ble_gatt_chr_def characteristicDefinition[5];
7053
struct ble_gatt_svc_def serviceDefinition[2];
7154

0 commit comments

Comments
 (0)