Skip to content

Commit 4fddf93

Browse files
mark9064JF002
authored andcommitted
Advertise HR service
1 parent 83922fb commit 4fddf93

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/components/ble/DfuService.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ namespace Pinetime {
7777
uint16_t ComputeCrc(uint8_t const* p_data, uint32_t size, uint16_t const* p_crc);
7878
};
7979

80+
static constexpr ble_uuid128_t serviceUuid {
81+
.u {.type = BLE_UUID_TYPE_128},
82+
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
83+
8084
private:
8185
Pinetime::System::SystemTask& systemTask;
8286
Pinetime::Controllers::Ble& bleController;
@@ -90,10 +94,6 @@ namespace Pinetime {
9094

9195
uint16_t revision {0x0008};
9296

93-
static constexpr ble_uuid128_t serviceUuid {
94-
.u {.type = BLE_UUID_TYPE_128},
95-
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
96-
9797
static constexpr ble_uuid128_t packetCharacteristicUuid {
9898
.u {.type = BLE_UUID_TYPE_128},
9999
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x32, 0x15, 0x00, 0x00}};

src/components/ble/HeartRateService.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ namespace Pinetime {
2121
void SubscribeNotification(uint16_t attributeHandle);
2222
void UnsubscribeNotification(uint16_t attributeHandle);
2323

24+
static constexpr uint16_t heartRateServiceId {0x180D};
25+
static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};
26+
2427
private:
2528
NimbleController& nimble;
2629
Controllers::HeartRateController& heartRateController;
27-
static constexpr uint16_t heartRateServiceId {0x180D};
2830
static constexpr uint16_t heartRateMeasurementId {0x2A37};
2931

30-
static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};
31-
3232
static constexpr ble_uuid16_t heartRateMeasurementUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateMeasurementId};
3333

3434
struct ble_gatt_chr_def characteristicDefinition[2];

src/components/ble/NimbleController.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ void NimbleController::StartAdvertising() {
158158
}
159159

160160
fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
161-
fields.uuids128 = &dfuServiceUuid;
161+
fields.uuids16 = &HeartRateService::heartRateServiceUuid;
162+
fields.num_uuids16 = 1;
163+
fields.uuids16_is_complete = 1;
164+
fields.uuids128 = &DfuService::serviceUuid;
162165
fields.num_uuids128 = 1;
163166
fields.uuids128_is_complete = 1;
164167
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;

src/components/ble/NimbleController.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ namespace Pinetime {
112112
uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE;
113113
uint8_t fastAdvCount = 0;
114114
uint8_t bondId[16] = {0};
115-
116-
ble_uuid128_t dfuServiceUuid {
117-
.u {.type = BLE_UUID_TYPE_128},
118-
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
119115
};
120116

121117
static NimbleController* nptr;

0 commit comments

Comments
 (0)