summaryrefslogtreecommitdiff
path: root/src/components/ble/MusicService.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2022-03-17 21:15:05 +0100
committerJF <JF002@users.noreply.github.com>2022-03-21 20:53:15 +0100
commit88197b66328ab8cbecc199c91d1ce1e1688ade83 (patch)
tree860f9225a4645544750ed7af58a97a38eb055e75 /src/components/ble/MusicService.cpp
parentf973f1c12c5f82ddacfdaca29fbe1043d94313ee (diff)
Music app : when title/track name are truncated, add an ellipsis at the end of the strings.
Diffstat (limited to 'src/components/ble/MusicService.cpp')
-rw-r--r--src/components/ble/MusicService.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp
index 0e53b9cb..c99aa1e3 100644
--- a/src/components/ble/MusicService.cpp
+++ b/src/components/ble/MusicService.cpp
@@ -17,6 +17,7 @@
*/
#include "components/ble/MusicService.h"
#include "systemtask/SystemTask.h"
+#include <cstring>
namespace {
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
@@ -127,14 +128,21 @@ void Pinetime::Controllers::MusicService::Init() {
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) {
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
-
+ size_t bufferSize = notifSize;
if (notifSize > MaxStringSize) {
- notifSize = MaxStringSize;
+ bufferSize = MaxStringSize;
+ }
+
+ char data[bufferSize + 1];
+ os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
+
+ if (notifSize > bufferSize) {
+ data[bufferSize-1] = '.';
+ data[bufferSize-2] = '.';
+ data[bufferSize-3] = '.';
}
+ data[bufferSize] = '\0';
- char data[notifSize + 1];
- data[notifSize] = '\0';
- os_mbuf_copydata(ctxt->om, 0, notifSize, data);
char* s = &data[0];
if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) {
artistName = s;