diff options
Diffstat (limited to 'src/components/ble')
| -rw-r--r-- | src/components/ble/AlertNotificationClient.cpp | 7 | ||||
| -rw-r--r-- | src/components/ble/BatteryInformationService.h | 1 | ||||
| -rw-r--r-- | src/components/ble/CurrentTimeClient.cpp | 19 | ||||
| -rw-r--r-- | src/components/ble/CurrentTimeService.cpp | 19 | ||||
| -rw-r--r-- | src/components/ble/DfuService.cpp | 20 | ||||
| -rw-r--r-- | src/components/ble/FSService.cpp | 12 | ||||
| -rw-r--r-- | src/components/ble/HeartRateService.cpp | 7 | ||||
| -rw-r--r-- | src/components/ble/MotionService.cpp | 32 | ||||
| -rw-r--r-- | src/components/ble/MusicService.cpp | 28 | ||||
| -rw-r--r-- | src/components/ble/MusicService.h | 1 | ||||
| -rw-r--r-- | src/components/ble/NavigationService.cpp | 26 | ||||
| -rw-r--r-- | src/components/ble/NimbleController.cpp | 2 | ||||
| -rw-r--r-- | src/components/ble/weather/WeatherService.h | 3 |
13 files changed, 111 insertions, 66 deletions
diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp index 335845e..095fdef 100644 --- a/src/components/ble/AlertNotificationClient.cpp +++ b/src/components/ble/AlertNotificationClient.cpp @@ -26,8 +26,11 @@ namespace { return client->OnCharacteristicsDiscoveryEvent(conn_handle, error, chr); } - int OnAlertNotificationDescriptorDiscoveryEventCallback( - uint16_t conn_handle, const struct ble_gatt_error* error, uint16_t chr_val_handle, const struct ble_gatt_dsc* dsc, void* arg) { + int OnAlertNotificationDescriptorDiscoveryEventCallback(uint16_t conn_handle, + const struct ble_gatt_error* error, + uint16_t chr_val_handle, + const struct ble_gatt_dsc* dsc, + void* arg) { auto client = static_cast<AlertNotificationClient*>(arg); return client->OnDescriptorDiscoveryEventCallback(conn_handle, error, chr_val_handle, dsc); } diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h index 1303fd6..c6fc52e 100644 --- a/src/components/ble/BatteryInformationService.h +++ b/src/components/ble/BatteryInformationService.h @@ -18,6 +18,7 @@ namespace Pinetime { int OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context); void NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level); + private: Controllers::Battery& batteryController; static constexpr uint16_t batteryInformationServiceId {0x180F}; diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp index dd8171b..53e98cb 100644 --- a/src/components/ble/CurrentTimeClient.cpp +++ b/src/components/ble/CurrentTimeClient.cpp @@ -85,10 +85,21 @@ int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_g // TODO check that attribute->handle equals the handle discovered in OnCharacteristicDiscoveryEvent CtsData result; os_mbuf_copydata(attribute->om, 0, sizeof(CtsData), &result); - NRF_LOG_INFO( - "Received data: %d-%d-%d %d:%d:%d", result.year, result.month, result.dayofmonth, result.hour, result.minute, result.second); - dateTimeController.SetTime( - result.year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", + result.year, + result.month, + result.dayofmonth, + result.hour, + result.minute, + result.second); + dateTimeController.SetTime(result.year, + result.month, + result.dayofmonth, + 0, + result.hour, + result.minute, + result.second, + nrf_rtc_counter_get(portNRF_RTC_REG)); } else { NRF_LOG_INFO("Error retrieving current time: %d", error->status); } diff --git a/src/components/ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp index e509aea..8430d1b 100644 --- a/src/components/ble/CurrentTimeService.cpp +++ b/src/components/ble/CurrentTimeService.cpp @@ -29,11 +29,22 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl CtsData result; os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result); - NRF_LOG_INFO( - "Received data: %d-%d-%d %d:%d:%d", result.year, result.month, result.dayofmonth, result.hour, result.minute, result.second); + NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", + result.year, + result.month, + result.dayofmonth, + result.hour, + result.minute, + result.second); - m_dateTimeController.SetTime( - result.year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + m_dateTimeController.SetTime(result.year, + result.month, + result.dayofmonth, + 0, + result.hour, + result.minute, + result.second, + nrf_rtc_counter_get(portNRF_RTC_REG)); } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) { CtsData currentDateTime; diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp index cf99f01..1f06b69 100644 --- a/src/components/ble/DfuService.cpp +++ b/src/components/ble/DfuService.cpp @@ -119,8 +119,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) { bootloaderSize = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24); applicationSize = om->om_data[8] + (om->om_data[9] << 8) + (om->om_data[10] << 16) + (om->om_data[11] << 24); bleController.FirmwareUpdateTotalBytes(applicationSize); - NRF_LOG_INFO( - "[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize); + NRF_LOG_INFO("[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", + softdeviceSize, + bootloaderSize, + applicationSize); // wait until SystemTask has finished waking up all devices while (systemTask.IsSleeping()) { @@ -165,10 +167,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) { if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) { uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification), - (uint8_t)(bytesReceived & 0x000000FFu), - (uint8_t)(bytesReceived >> 8u), - (uint8_t)(bytesReceived >> 16u), - (uint8_t)(bytesReceived >> 24u)}; + static_cast<uint8_t>(bytesReceived & 0x000000FFu), + static_cast<uint8_t>(bytesReceived >> 8u), + static_cast<uint8_t>(bytesReceived >> 16u), + static_cast<uint8_t>(bytesReceived >> 24u)}; NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived); notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5); } @@ -244,7 +246,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { NRF_LOG_INFO("[DFU] -> Receive firmware image requested, but we are not in Start Init"); return 0; } - // TODO the chunk size is dependant of the implementation of the host application... + // TODO the chunk size is dependent of the implementation of the host application... dfuImage.Init(20, applicationSize, expectedCrc); NRF_LOG_INFO("[DFU] -> Starting receive firmware"); state = States::Data; @@ -423,9 +425,9 @@ uint16_t DfuService::DfuImage::ComputeCrc(uint8_t const* p_data, uint32_t size, uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc; for (uint32_t i = 0; i < size; i++) { - crc = (uint8_t)(crc >> 8) | (crc << 8); + crc = static_cast<uint8_t>(crc >> 8) | (crc << 8); crc ^= p_data[i]; - crc ^= (uint8_t)(crc & 0xFF) >> 4; + crc ^= static_cast<uint8_t>(crc & 0xFF) >> 4; crc ^= (crc << 8) << 4; crc ^= ((crc & 0xFF) << 4) << 1; } diff --git a/src/components/ble/FSService.cpp b/src/components/ble/FSService.cpp index 8dc9ed6..fda6b39 100644 --- a/src/components/ble/FSService.cpp +++ b/src/components/ble/FSService.cpp @@ -81,7 +81,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { return -1; } memcpy(filepath, header->pathstr, plen); - filepath[plen] = 0; // Copy and null teminate string + filepath[plen] = 0; // Copy and null terminate string ReadResponse resp; os_mbuf* om; resp.command = commands::READ_DATA; @@ -148,7 +148,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { return -1; // TODO make this actually return a BLE notif } memcpy(filepath, header->pathstr, plen); - filepath[plen] = 0; // Copy and null teminate string + filepath[plen] = 0; // Copy and null terminate string fileSize = header->totalSize; WriteResponse resp; resp.command = commands::WRITE_PACING; @@ -193,7 +193,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { uint16_t plen = header->pathlen; char path[plen + 1] = {0}; memcpy(path, header->pathstr, plen); - path[plen] = 0; // Copy and null teminate string + path[plen] = 0; // Copy and null terminate string DelResponse resp {}; resp.command = commands::DELETE_STATUS; int res = fs.FileDelete(path); @@ -208,7 +208,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { uint16_t plen = header->pathlen; char path[plen + 1] = {0}; memcpy(path, header->pathstr, plen); - path[plen] = 0; // Copy and null teminate string + path[plen] = 0; // Copy and null terminate string MKDirResponse resp {}; resp.command = commands::MKDIR_STATUS; resp.modification_time = 0; @@ -223,7 +223,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { ListDirHeader* header = (ListDirHeader*) om->om_data; uint16_t plen = header->pathlen; char path[plen + 1] = {0}; - path[plen] = 0; // Copy and null teminate string + path[plen] = 0; // Copy and null terminate string memcpy(path, header->pathstr, plen); ListDirResponse resp {}; @@ -290,7 +290,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) { header->pathstr[plen] = 0; char path[header->NewPathLength + 1] = {0}; memcpy(path, &header->pathstr[plen + 1], header->NewPathLength); - path[header->NewPathLength] = 0; // Copy and null teminate string + path[header->NewPathLength] = 0; // Copy and null terminate string MoveResponse resp {}; resp.command = commands::MOVE_STATUS; int8_t res = (int8_t) fs.Rename(header->pathstr, path); diff --git a/src/components/ble/HeartRateService.cpp b/src/components/ble/HeartRateService.cpp index 4824a6b..d49a02c 100644 --- a/src/components/ble/HeartRateService.cpp +++ b/src/components/ble/HeartRateService.cpp @@ -57,7 +57,8 @@ int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t a } void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) { - if(!heartRateMeasurementNotificationEnable) return; + if (!heartRateMeasurementNotificationEnable) + return; uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value auto* om = ble_hs_mbuf_from_flat(buffer, 2); @@ -72,11 +73,11 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) { } void HeartRateService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { - if(attributeHandle == heartRateMeasurementHandle) + if (attributeHandle == heartRateMeasurementHandle) heartRateMeasurementNotificationEnable = true; } void HeartRateService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { - if(attributeHandle == heartRateMeasurementHandle) + if (attributeHandle == heartRateMeasurementHandle) heartRateMeasurementNotificationEnable = false; }
\ No newline at end of file diff --git a/src/components/ble/MotionService.cpp b/src/components/ble/MotionService.cpp index 87923c2..121ad3b 100644 --- a/src/components/ble/MotionService.cpp +++ b/src/components/ble/MotionService.cpp @@ -8,10 +8,8 @@ using namespace Pinetime::Controllers; namespace { // 0003yyxx-78fc-48fe-8e23-433b3a1942d0 constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) { - return ble_uuid128_t{ - .u = {.type = BLE_UUID_TYPE_128}, - .value = { 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x03, 0x00 } - }; + return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128}, + .value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x03, 0x00}}; } // 00030000-78fc-48fe-8e23-433b3a1942d0 @@ -45,11 +43,7 @@ MotionService::MotionService(Pinetime::System::SystemTask& system, Controllers:: .val_handle = &motionValuesHandle}, {0}}, serviceDefinition { - { - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = &motionServiceUuid.u, - .characteristics = characteristicDefinition - }, + {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &motionServiceUuid.u, .characteristics = characteristicDefinition}, {0}, } { // TODO refactor to prevent this loop dependency (service depends on controller and controller depends on service) @@ -72,8 +66,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr int res = os_mbuf_append(context->om, &buffer, 4); return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; - } else if(attributeHandle == motionValuesHandle) { - int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() }; + } else if (attributeHandle == motionValuesHandle) { + int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()}; int res = os_mbuf_append(context->om, buffer, 3 * sizeof(int16_t)); return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; @@ -82,7 +76,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr } void MotionService::OnNewStepCountValue(uint32_t stepCount) { - if(!stepCountNoficationEnabled) return; + if (!stepCountNoficationEnabled) + return; uint32_t buffer = stepCount; auto* om = ble_hs_mbuf_from_flat(&buffer, 4); @@ -96,9 +91,10 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) { ble_gattc_notify_custom(connectionHandle, stepCountHandle, om); } void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { - if(!motionValuesNoficationEnabled) return; + if (!motionValuesNoficationEnabled) + return; - int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() }; + int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()}; auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t)); uint16_t connectionHandle = system.nimble().connHandle(); @@ -111,15 +107,15 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { } void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { - if(attributeHandle == stepCountHandle) + if (attributeHandle == stepCountHandle) stepCountNoficationEnabled = true; - else if(attributeHandle == motionValuesHandle) + else if (attributeHandle == motionValuesHandle) motionValuesNoficationEnabled = true; } void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { - if(attributeHandle == stepCountHandle) + if (attributeHandle == stepCountHandle) stepCountNoficationEnabled = false; - else if(attributeHandle == motionValuesHandle) + else if (attributeHandle == motionValuesHandle) motionValuesNoficationEnabled = false; } diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp index c99aa1e..fc7cef0 100644 --- a/src/components/ble/MusicService.cpp +++ b/src/components/ble/MusicService.cpp @@ -22,10 +22,8 @@ namespace { // 0000yyxx-78fc-48fe-8e23-433b3a1942d0 constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) { - return ble_uuid128_t{ - .u = {.type = BLE_UUID_TYPE_128}, - .value = { 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x00, 0x00 } - }; + return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128}, + .value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x00, 0x00}}; } // 00000000-78fc-48fe-8e23-433b3a1942d0 @@ -111,8 +109,7 @@ Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask& .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; characteristicDefinition[13] = {0}; - serviceDefinition[0] = { - .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition}; + serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition}; serviceDefinition[1] = {0}; } @@ -137,9 +134,9 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_ os_mbuf_copydata(ctxt->om, 0, bufferSize, data); if (notifSize > bufferSize) { - data[bufferSize-1] = '.'; - data[bufferSize-2] = '.'; - data[bufferSize-3] = '.'; + data[bufferSize - 1] = '.'; + data[bufferSize - 2] = '.'; + data[bufferSize - 3] = '.'; } data[bufferSize] = '\0'; @@ -152,12 +149,21 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_ albumName = s; } else if (ble_uuid_cmp(ctxt->chr->uuid, &msStatusCharUuid.u) == 0) { playing = s[0]; + // These variables need to be updated, because the progress may not be updated immediately, + // leading to getProgress() returning an incorrect position. + if (playing) { + trackProgressUpdateTime = xTaskGetTickCount(); + } else { + trackProgress += + static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed()); + } } else if (ble_uuid_cmp(ctxt->chr->uuid, &msRepeatCharUuid.u) == 0) { repeat = s[0]; } else if (ble_uuid_cmp(ctxt->chr->uuid, &msShuffleCharUuid.u) == 0) { shuffle = s[0]; } else if (ble_uuid_cmp(ctxt->chr->uuid, &msPositionCharUuid.u) == 0) { trackProgress = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; + trackProgressUpdateTime = xTaskGetTickCount(); } else if (ble_uuid_cmp(ctxt->chr->uuid, &msTotalLengthCharUuid.u) == 0) { trackLength = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; } else if (ble_uuid_cmp(ctxt->chr->uuid, &msTrackNumberCharUuid.u) == 0) { @@ -192,6 +198,10 @@ float Pinetime::Controllers::MusicService::getPlaybackSpeed() const { } int Pinetime::Controllers::MusicService::getProgress() const { + if (isPlaying()) { + return trackProgress + + static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed()); + } return trackProgress; } diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h index 1ad9a42..047d0d2 100644 --- a/src/components/ble/MusicService.h +++ b/src/components/ble/MusicService.h @@ -81,6 +81,7 @@ namespace Pinetime { int trackLength {0}; int trackNumber {}; int tracksTotal {}; + TickType_t trackProgressUpdateTime {0}; float playbackSpeed {1.0f}; diff --git a/src/components/ble/NavigationService.cpp b/src/components/ble/NavigationService.cpp index 5418b9e..7614368 100644 --- a/src/components/ble/NavigationService.cpp +++ b/src/components/ble/NavigationService.cpp @@ -46,15 +46,23 @@ namespace { } // namespace Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) { - characteristicDefinition[0] = { - .uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; - - characteristicDefinition[1] = { - .uuid = &navNarrativeCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; - characteristicDefinition[2] = { - .uuid = &navManDistCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; - characteristicDefinition[3] = { - .uuid = &navProgressCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; + characteristicDefinition[0] = {.uuid = &navFlagCharUuid.u, + .access_cb = NAVCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; + + characteristicDefinition[1] = {.uuid = &navNarrativeCharUuid.u, + .access_cb = NAVCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; + characteristicDefinition[2] = {.uuid = &navManDistCharUuid.u, + .access_cb = NAVCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; + characteristicDefinition[3] = {.uuid = &navProgressCharUuid.u, + .access_cb = NAVCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}; characteristicDefinition[4] = {0}; diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index ce54bb7..b2cccf7 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -236,7 +236,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { currentTimeClient.Reset(); alertNotificationClient.Reset(); connectionHandle = BLE_HS_CONN_HANDLE_NONE; - if(bleController.IsConnected()) { + if (bleController.IsConnected()) { bleController.Disconnect(); fastAdvCount = 0; StartAdvertising(); diff --git a/src/components/ble/weather/WeatherService.h b/src/components/ble/weather/WeatherService.h index eca70cb..e37417d 100644 --- a/src/components/ble/weather/WeatherService.h +++ b/src/components/ble/weather/WeatherService.h @@ -127,7 +127,8 @@ namespace Pinetime { {.uuid = &weatherControlCharUuid.u, .access_cb = WeatherCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ}, {nullptr}}; const struct ble_gatt_svc_def serviceDefinition[2] = { - {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition}, {0}}; + {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition}, + {0}}; uint16_t eventHandle {}; |
