|
20 | 20 |
|
21 | 21 | #include "systemtask/SystemTask.h" |
22 | 22 |
|
| 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 | + } |
| 29 | + |
| 30 | + // 00010000-78fc-48fe-8e23-433b3a1942d0 |
| 31 | + constexpr ble_uuid128_t BaseUuid() { |
| 32 | + return CharUuid(0x00, 0x00); |
| 33 | + } |
| 34 | + |
| 35 | + constexpr ble_uuid128_t navUuid {BaseUuid()}; |
| 36 | + |
| 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)}; |
| 41 | +} // namespace |
| 42 | + |
23 | 43 | int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { |
24 | 44 | auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg); |
25 | 45 | return navService->OnCommand(conn_handle, attr_handle, ctxt); |
26 | 46 | } |
27 | 47 |
|
28 | 48 | Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) { |
29 | | - navFlagCharUuid.value[12] = navFlagCharId[0]; |
30 | | - navFlagCharUuid.value[13] = navFlagCharId[1]; |
31 | | - |
32 | | - navNarrativeCharUuid.value[12] = navNarrativeCharId[0]; |
33 | | - navNarrativeCharUuid.value[13] = navNarrativeCharId[1]; |
34 | | - |
35 | | - navManDistCharUuid.value[12] = navManDistCharId[0]; |
36 | | - navManDistCharUuid.value[13] = navManDistCharId[1]; |
37 | | - |
38 | | - navProgressCharUuid.value[12] = navProgressCharId[0]; |
39 | | - navProgressCharUuid.value[13] = navProgressCharId[1]; |
40 | | - |
41 | 49 | characteristicDefinition[0] = { |
42 | 50 | .uuid = (ble_uuid_t*) (&navFlagCharUuid), .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; |
43 | 51 |
|
|
0 commit comments