Skip to content

Commit

Permalink
Advertise HR service
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9064 authored and JF002 committed Aug 18, 2024
1 parent 83922fb commit 4fddf93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/ble/DfuService.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ namespace Pinetime {
uint16_t ComputeCrc(uint8_t const* p_data, uint32_t size, uint16_t const* p_crc);
};

static constexpr ble_uuid128_t serviceUuid {
.u {.type = BLE_UUID_TYPE_128},
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};

private:
Pinetime::System::SystemTask& systemTask;
Pinetime::Controllers::Ble& bleController;
Expand All @@ -90,10 +94,6 @@ namespace Pinetime {

uint16_t revision {0x0008};

static constexpr ble_uuid128_t serviceUuid {
.u {.type = BLE_UUID_TYPE_128},
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};

static constexpr ble_uuid128_t packetCharacteristicUuid {
.u {.type = BLE_UUID_TYPE_128},
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x32, 0x15, 0x00, 0x00}};
Expand Down
6 changes: 3 additions & 3 deletions src/components/ble/HeartRateService.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ namespace Pinetime {
void SubscribeNotification(uint16_t attributeHandle);
void UnsubscribeNotification(uint16_t attributeHandle);

static constexpr uint16_t heartRateServiceId {0x180D};
static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};

private:
NimbleController& nimble;
Controllers::HeartRateController& heartRateController;
static constexpr uint16_t heartRateServiceId {0x180D};
static constexpr uint16_t heartRateMeasurementId {0x2A37};

static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};

static constexpr ble_uuid16_t heartRateMeasurementUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateMeasurementId};

struct ble_gatt_chr_def characteristicDefinition[2];
Expand Down
5 changes: 4 additions & 1 deletion src/components/ble/NimbleController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ void NimbleController::StartAdvertising() {
}

fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
fields.uuids128 = &dfuServiceUuid;
fields.uuids16 = &HeartRateService::heartRateServiceUuid;
fields.num_uuids16 = 1;
fields.uuids16_is_complete = 1;
fields.uuids128 = &DfuService::serviceUuid;
fields.num_uuids128 = 1;
fields.uuids128_is_complete = 1;
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
Expand Down
4 changes: 0 additions & 4 deletions src/components/ble/NimbleController.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ namespace Pinetime {
uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE;
uint8_t fastAdvCount = 0;
uint8_t bondId[16] = {0};

ble_uuid128_t dfuServiceUuid {
.u {.type = BLE_UUID_TYPE_128},
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
};

static NimbleController* nptr;
Expand Down

0 comments on commit 4fddf93

Please sign in to comment.