diff options
| author | JF <jf@codingfield.com> | 2020-03-25 20:23:40 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-03-25 20:23:40 (GMT) |
| commit | 68240704c7a60534342cfc0157564f11cf82d9d8 (patch) | |
| tree | 8472af61a5fa8a99ce5549f2de73b47f73cf41b6 /src/Components/Ble/BleController.cpp | |
| parent | 7e9a7e4d5fa0f55b43180600d499f1d0ce6aded1 (diff) | |
Add support for BLE notification (ANS client).
Work In Progress!!!
Diffstat (limited to 'src/Components/Ble/BleController.cpp')
| -rw-r--r-- | src/Components/Ble/BleController.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Components/Ble/BleController.cpp b/src/Components/Ble/BleController.cpp index c245808..fd40589 100644 --- a/src/Components/Ble/BleController.cpp +++ b/src/Components/Ble/BleController.cpp @@ -1,7 +1,13 @@ +#include <cstring> +#include <cstdlib> #include "BleController.h" using namespace Pinetime::Controllers; +Ble::Ble() { + notificationQueue = xQueueCreate(10, sizeof(NotificationMessage)); +} + void Ble::Connect() { isConnected = true; } @@ -9,3 +15,25 @@ void Ble::Connect() { void Ble::Disconnect() { isConnected = false; } + +void Ble::PushNotification(const char *message, uint8_t size) { + char* messageCopy = static_cast<char *>(malloc(sizeof(char) * size)); + std::memcpy(messageCopy, message, size); + NotificationMessage msg; + msg.size = size; + msg.message = messageCopy; + + BaseType_t xHigherPriorityTaskWoken; + xHigherPriorityTaskWoken = pdFALSE; + xQueueSendFromISR(notificationQueue, &msg, &xHigherPriorityTaskWoken); + if (xHigherPriorityTaskWoken) { + /* Actual macro used here is port specific. */ + // TODO : should I do something here? + } +} + +bool Ble::PopNotification(Ble::NotificationMessage& msg) { + return xQueueReceive(notificationQueue, &msg, 0) != 0; +} + + |
