diff options
Diffstat (limited to 'src/Components')
-rw-r--r-- | src/Components/Ble/BleController.h | 9 | ||||
-rw-r--r-- | src/Components/Ble/NimbleController.cpp | 7 | ||||
-rw-r--r-- | src/Components/Ble/NimbleController.h | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/Components/Ble/BleController.h b/src/Components/Ble/BleController.h index c47e65b6..3f52ea25 100644 --- a/src/Components/Ble/BleController.h +++ b/src/Components/Ble/BleController.h @@ -2,12 +2,15 @@ #include <FreeRTOS.h> #include <queue.h> +#include <array> namespace Pinetime { namespace Controllers { class Ble { public: + using BleAddress = std::array<uint8_t, 6>; enum class FirmwareUpdateStates {Idle, Running, Validated, Error}; + enum class AddressTypes { Public, Random }; Ble() = default; bool IsConnected() const {return isConnected;} @@ -24,12 +27,18 @@ namespace Pinetime { uint32_t FirmwareUpdateTotalBytes() const { return firmwareUpdateTotalBytes; } uint32_t FirmwareUpdateCurrentBytes() const { return firmwareUpdateCurrentBytes; } FirmwareUpdateStates State() const { return firmwareUpdateState; } + + void Address(BleAddress&& addr) { address = addr; } + const BleAddress& Address() const { return address; } + void AddressType(AddressTypes t) { addressType = t;} private: bool isConnected = false; bool isFirmwareUpdating = false; uint32_t firmwareUpdateTotalBytes = 0; uint32_t firmwareUpdateCurrentBytes = 0; FirmwareUpdateStates firmwareUpdateState = FirmwareUpdateStates::Idle; + BleAddress address; + AddressTypes addressType; }; } diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp index 4c8035b7..561dbce4 100644 --- a/src/Components/Ble/NimbleController.cpp +++ b/src/Components/Ble/NimbleController.cpp @@ -90,8 +90,13 @@ void NimbleController::Init() { res = ble_hs_id_infer_auto(0, &addrType); ASSERT(res == 0); res = ble_svc_gap_device_name_set(deviceName); - ASSERT(res == 0); + Pinetime::Controllers::Ble::BleAddress address; + res = ble_hs_id_copy_addr(addrType, address.data(), nullptr); + ASSERT(res == 0); + bleController.AddressType((addrType == 0) ? Ble::AddressTypes::Public : Ble::AddressTypes::Random); + bleController.Address(std::move(address)); + res = ble_gatts_start(); ASSERT(res == 0); } diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h index 7e680607..cf50d78d 100644 --- a/src/Components/Ble/NimbleController.h +++ b/src/Components/Ble/NimbleController.h @@ -50,7 +50,7 @@ namespace Pinetime { AlertNotificationClient alertNotificationClient; CurrentTimeService currentTimeService; - uint8_t addrType; + uint8_t addrType; // 1 = Random, 0 = PUBLIC uint16_t connectionHandle; ble_uuid128_t dfuServiceUuid { |