summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authormabuch <marcel.buechler@gmail.com>2022-04-18 14:35:31 +0200
committermabuch <marcel.buechler@gmail.com>2022-04-18 14:35:31 +0200
commit82a4f9aa68c3f8d5f3cfa6de87de078fe680d944 (patch)
treecc83c0af796a029f9464003cda043f373b716749 /src/components
parentea14c580ca6296cb93facf526d65a2db0e3ff1b0 (diff)
parent2607c3d79947e900ce4c5ded296f649677511a34 (diff)
resolved merge conflict after renaming PineTimeStyle to WatchFacePineTimeStyle
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ble/MusicService.cpp21
-rw-r--r--src/components/ble/NimbleController.cpp1
-rw-r--r--src/components/datetime/DateTimeController.cpp4
-rw-r--r--src/components/datetime/DateTimeController.h4
-rw-r--r--src/components/settings/Settings.h2
5 files changed, 24 insertions, 8 deletions
diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp
index 3457ce4c..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
@@ -47,6 +48,8 @@ namespace {
constexpr ble_uuid128_t msRepeatCharUuid {CharUuid(0x0b, 0x00)};
constexpr ble_uuid128_t msShuffleCharUuid {CharUuid(0x0c, 0x00)};
+ constexpr uint8_t MaxStringSize {40};
+
int MusicCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
return static_cast<Pinetime::Controllers::MusicService*>(arg)->OnCommand(conn_handle, attr_handle, ctxt);
}
@@ -125,9 +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);
- char data[notifSize + 1];
- data[notifSize] = '\0';
- os_mbuf_copydata(ctxt->om, 0, notifSize, data);
+ size_t bufferSize = notifSize;
+ if (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* s = &data[0];
if (ble_uuid_cmp(ctxt->chr->uuid, &msArtistCharUuid.u) == 0) {
artistName = s;
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 0be7c0f7..10eb429a 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -77,6 +77,7 @@ int GAPEventCallback(struct ble_gap_event* event, void* arg) {
void NimbleController::Init() {
while (!ble_hs_synced()) {
+ vTaskDelay(10);
}
nptr = this;
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index e0d12431..3bfbdc7e 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -108,11 +108,11 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
}
}
-const char* DateTime::MonthShortToString() {
+const char* DateTime::MonthShortToString() const {
return MonthsString[static_cast<uint8_t>(month)];
}
-const char* DateTime::DayOfWeekShortToString() {
+const char* DateTime::DayOfWeekShortToString() const {
return DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
}
diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h
index 6e5ee3ca..00bbc2ee 100644
--- a/src/components/datetime/DateTimeController.h
+++ b/src/components/datetime/DateTimeController.h
@@ -61,8 +61,8 @@ namespace Pinetime {
return second;
}
- const char* MonthShortToString();
- const char* DayOfWeekShortToString();
+ const char* MonthShortToString() const;
+ const char* DayOfWeekShortToString() const;
static const char* MonthShortToStringLow(Months month);
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const {
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 24a82607..44a1a85c 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -237,7 +237,7 @@ namespace Pinetime {
uint8_t appMenu = 0;
uint8_t settingsMenu = 0;
- /* airplaneMode is intentionally not saved with the other watch settings and initialized
+ /* ble state is intentionally not saved with the other watch settings and initialized
* to off (false) on every boot because we always want ble to be enabled on startup
*/
bool bleRadioEnabled = true;