Skip to content

Commit f7276d2

Browse files
committed
Make more ImmediateAlertClient private.
1 parent cb72ab9 commit f7276d2

2 files changed

Lines changed: 28 additions & 20 deletions

File tree

src/components/ble/ImmediateAlertClient.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@ using namespace Pinetime::Controllers;
88
constexpr ble_uuid16_t ImmediateAlertClient::immediateAlertClientUuid;
99
constexpr ble_uuid16_t ImmediateAlertClient::alertLevelCharacteristicUuid;
1010

11-
namespace {
12-
int OnDiscoveryEventCallback(uint16_t conn_handle, const struct ble_gatt_error* error, const struct ble_gatt_svc* service, void* arg) {
13-
auto client = static_cast<ImmediateAlertClient*>(arg);
14-
return client->OnDiscoveryEvent(conn_handle, error, service);
15-
}
16-
17-
int OnImmediateAlertCharacteristicDiscoveredCallback(uint16_t conn_handle,
18-
const struct ble_gatt_error* error,
19-
const struct ble_gatt_chr* chr,
20-
void* arg) {
21-
auto client = static_cast<ImmediateAlertClient*>(arg);
22-
return client->OnCharacteristicDiscoveryEvent(conn_handle, error, chr);
23-
}
24-
}
25-
2611
ImmediateAlertClient::ImmediateAlertClient(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
2712
}
2813

@@ -104,3 +89,19 @@ bool ImmediateAlertClient::SendImmediateAlert(ImmediateAlertClient::Levels level
10489
ble_gattc_write_no_rsp(connectionHandle, *alertLevelHandle, om);
10590
return true;
10691
}
92+
93+
int ImmediateAlertClient::OnDiscoveryEventCallback(uint16_t conn_handle,
94+
const struct ble_gatt_error* error,
95+
const struct ble_gatt_svc* service,
96+
void* arg) {
97+
auto client = static_cast<ImmediateAlertClient*>(arg);
98+
return client->OnDiscoveryEvent(conn_handle, error, service);
99+
}
100+
101+
int ImmediateAlertClient::OnImmediateAlertCharacteristicDiscoveredCallback(uint16_t conn_handle,
102+
const struct ble_gatt_error* error,
103+
const struct ble_gatt_chr* chr,
104+
void* arg) {
105+
auto client = static_cast<ImmediateAlertClient*>(arg);
106+
return client->OnCharacteristicDiscoveryEvent(conn_handle, error, chr);
107+
}

src/components/ble/ImmediateAlertClient.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ namespace Pinetime {
1919
public:
2020
enum class Levels : uint8_t { NoAlert = 0, MildAlert = 1, HighAlert = 2 };
2121

22-
ImmediateAlertClient(Pinetime::System::SystemTask& systemTask);
22+
explicit ImmediateAlertClient(Pinetime::System::SystemTask& systemTask);
2323
void Init();
2424

25+
bool SendImmediateAlert(Levels level);
26+
27+
void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override;
28+
29+
private:
2530
bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error* error, const ble_gatt_svc* service);
2631
int OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error* error, const ble_gatt_chr* characteristic);
2732

28-
bool SendImmediateAlert(Levels level);
29-
3033
static constexpr const ble_uuid16_t* Uuid() {
3134
return &ImmediateAlertClient::immediateAlertClientUuid;
3235
}
@@ -35,9 +38,13 @@ namespace Pinetime {
3538
return &ImmediateAlertClient::alertLevelCharacteristicUuid;
3639
}
3740

38-
void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override;
41+
static int
42+
OnDiscoveryEventCallback(uint16_t conn_handle, const struct ble_gatt_error* error, const struct ble_gatt_svc* service, void* arg);
43+
static int OnImmediateAlertCharacteristicDiscoveredCallback(uint16_t conn_handle,
44+
const struct ble_gatt_error* error,
45+
const struct ble_gatt_chr* chr,
46+
void* arg);
3947

40-
private:
4148
Pinetime::System::SystemTask& systemTask;
4249

4350
static constexpr uint16_t immediateAlertClientId {0x1802};

0 commit comments

Comments
 (0)