diff options
| author | Adam Pigg <adam@piggz.co.uk> | 2020-07-20 20:28:21 (GMT) |
|---|---|---|
| committer | Adam Pigg <adam@piggz.co.uk> | 2020-07-20 20:28:21 (GMT) |
| commit | 5713eac1045394928de19e76fd00a172f63bffa7 (patch) | |
| tree | a20e130e01147c4afc89981d7bcfa6773dc6445e /src/Components/Ble/MusicService.cpp | |
| parent | 686e826f4e656546523e989535c74f286a91855b (diff) | |
Fully implement music app and service
SystemTask can return a reference to the nimbleController
The nimbleController can return a reference to the musicService
The musicService get a connection handle from the nimbleController
The musicApp communicated directly with the musicService
Diffstat (limited to 'src/Components/Ble/MusicService.cpp')
| -rw-r--r-- | src/Components/Ble/MusicService.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Components/Ble/MusicService.cpp b/src/Components/Ble/MusicService.cpp index 080a814..5ec7669 100644 --- a/src/Components/Ble/MusicService.cpp +++ b/src/Components/Ble/MusicService.cpp @@ -1,3 +1,4 @@ +#include <SystemTask/SystemTask.h> #include "MusicService.h" int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { @@ -5,7 +6,7 @@ int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_acces return musicService->OnCommand(conn_handle, attr_handle, ctxt); } -Pinetime::Controllers::MusicService::MusicService() +Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system) { msUuid.value[11] = msId[0]; msUuid.value[12] = msId[1]; @@ -86,6 +87,8 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_ m_track = s; } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msAlbumCharUuid) == 0) { m_album = s; + } else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msStatusCharUuid) == 0) { + m_status = s[0]; } } return 0; @@ -106,18 +109,19 @@ std::string Pinetime::Controllers::MusicService::track() return m_track; } +unsigned char Pinetime::Controllers::MusicService::status() +{ + return m_status; +} + void Pinetime::Controllers::MusicService::event(char event) { - struct os_mbuf *om; + auto *om = ble_hs_mbuf_from_flat(&event, 1); int ret; - uint16_t connectionHandle = 0; - - om = ble_hs_mbuf_from_flat(&event, 1); - - ret = ble_gatts_find_svc((ble_uuid_t *) &msUuid, &connectionHandle); + uint16_t connectionHandle = m_system.nimble().connHandle(); - if (connectionHandle == 0) { + if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) { return; } |
