|
17 | 17 | */ |
18 | 18 | #include "components/ble/MusicService.h" |
19 | 19 | #include "systemtask/SystemTask.h" |
| 20 | +#include <cstring> |
20 | 21 |
|
21 | 22 | namespace { |
22 | 23 | // 0000yyxx-78fc-48fe-8e23-433b3a1942d0 |
@@ -127,14 +128,21 @@ void Pinetime::Controllers::MusicService::Init() { |
127 | 128 | int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { |
128 | 129 | if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { |
129 | 130 | size_t notifSize = OS_MBUF_PKTLEN(ctxt->om); |
130 | | - |
| 131 | + size_t bufferSize = notifSize; |
131 | 132 | if (notifSize > MaxStringSize) { |
132 | | - notifSize = MaxStringSize; |
| 133 | + bufferSize = MaxStringSize; |
| 134 | + } |
| 135 | + |
| 136 | + char data[bufferSize + 1]; |
| 137 | + os_mbuf_copydata(ctxt->om, 0, bufferSize, data); |
| 138 | + |
| 139 | + if (notifSize > bufferSize) { |
| 140 | + data[bufferSize-1] = '.'; |
| 141 | + data[bufferSize-2] = '.'; |
| 142 | + data[bufferSize-3] = '.'; |
133 | 143 | } |
| 144 | + data[bufferSize] = '\0'; |
134 | 145 |
|
135 | | - char data[notifSize + 1]; |
136 | | - data[notifSize] = '\0'; |
137 | | - os_mbuf_copydata(ctxt->om, 0, notifSize, data); |
138 | 146 | char* s = &data[0]; |
139 | 147 | if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) { |
140 | 148 | artistName = s; |
|
0 commit comments