-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ImmediateAlertClient to support FindMyPhone functionality.
Signed-off-by: Vyacheslav Chigrin <[email protected]>
- Loading branch information
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "components/ble/ImmediateAlertClient.h" | ||
#include <cstring> | ||
#include <nrf_log.h> | ||
#include "systemtask/SystemTask.h" | ||
|
||
using namespace Pinetime::Controllers; | ||
|
||
constexpr ble_uuid16_t ImmediateAlertClient::immediateAlertClientUuid; | ||
constexpr ble_uuid16_t ImmediateAlertClient::alertLevelCharacteristicUuid; | ||
|
||
ImmediateAlertClient::ImmediateAlertClient(Pinetime::System::SystemTask& systemTask) | ||
: systemTask {systemTask} { | ||
} | ||
|
||
void ImmediateAlertClient::Init() { | ||
} | ||
|
||
void ImmediateAlertClient::Discover(uint16_t connectionHandle, std::function<void(uint16_t)> onServiceDiscovered) { | ||
NRF_LOG_INFO("[IAS] Starting discovery"); | ||
this->onServiceDiscovered = onServiceDiscovered; | ||
// ble_gattc_disc_svc_by_uuid(connectionHandle, &immediateAlertClientUuid.u, OnDiscoveryEventCallback, this); | ||
} | ||
|
||
bool ImmediateAlertClient::SendImmediateAlert(ImmediateAlertClient::Levels level) { | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
#define min // workaround: nimble's min/max macros conflict with libstdc++ | ||
#define max | ||
#include <host/ble_gap.h> | ||
#undef max | ||
#undef min | ||
#include <cstdint> | ||
#include "components/ble/BleClient.h" | ||
|
||
namespace Pinetime { | ||
namespace System { | ||
class SystemTask; | ||
} | ||
|
||
namespace Controllers { | ||
class NotificationManager; | ||
|
||
class ImmediateAlertClient : public BleClient { | ||
public: | ||
enum class Levels : uint8_t { NoAlert = 0, MildAlert = 1, HighAlert = 2 }; | ||
enum class State { | ||
NoConnection, | ||
NoIAS, | ||
Connected, | ||
}; | ||
|
||
ImmediateAlertClient(Pinetime::System::SystemTask& systemTask); | ||
void Init(); | ||
|
||
bool SendImmediateAlert(Levels level); | ||
|
||
State GetState() const { | ||
return State::NoConnection; | ||
} | ||
|
||
void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) override; | ||
|
||
private: | ||
Pinetime::System::SystemTask& systemTask; | ||
|
||
static constexpr uint16_t immediateAlertClientId {0x1802}; | ||
static constexpr uint16_t alertLevelId {0x2A06}; | ||
|
||
static constexpr ble_uuid16_t immediateAlertClientUuid {.u {.type = BLE_UUID_TYPE_16}, .value = immediateAlertClientId}; | ||
static constexpr ble_uuid16_t alertLevelCharacteristicUuid {.u {.type = BLE_UUID_TYPE_16}, .value = alertLevelId}; | ||
|
||
std::function<void(uint16_t)> onServiceDiscovered; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters