11#include < nrf_log.h>
22#include " FSService.h"
33#include " components/ble/BleController.h"
4+ #include " components/ble/NotificationManager.h"
5+ #include " components/settings/Settings.h"
46#include " systemtask/SystemTask.h"
57
68using namespace Pinetime ::Controllers;
@@ -14,9 +16,14 @@ int FSServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gat
1416 return fsService->OnFSServiceRequested (conn_handle, attr_handle, ctxt);
1517}
1618
17- FSService::FSService (Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::FS& fs)
19+ FSService::FSService (Pinetime::System::SystemTask& systemTask,
20+ Pinetime::Controllers::FS& fs,
21+ Pinetime::Controllers::Settings& settingsController,
22+ Pinetime::Controllers::NotificationManager& notificationManager)
1823 : systemTask {systemTask},
1924 fs {fs},
25+ settingsController {settingsController},
26+ notificationManager {notificationManager},
2027 characteristicDefinition {{.uuid = &fsVersionUuid.u ,
2128 .access_cb = FSServiceCallback,
2229 .arg = this ,
@@ -49,6 +56,18 @@ void FSService::Init() {
4956}
5057
5158int FSService::OnFSServiceRequested (uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) {
59+ #ifndef PINETIME_IS_RECOVERY
60+ if (settingsController.GetDfuAndFsMode () == Pinetime::Controllers::Settings::DfuAndFsMode::Disabled) {
61+ Pinetime::Controllers::NotificationManager::Notification notif;
62+ memcpy (notif.message .data (), denyAlert, denyAlertLength);
63+ notif.size = denyAlertLength;
64+ notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
65+ notificationManager.Push (std::move (notif));
66+ systemTask.PushMessage (Pinetime::System::Messages::OnNewNotification);
67+ return 0 ;
68+ }
69+ #endif
70+
5271 if (attributeHandle == versionCharacteristicHandle) {
5372 NRF_LOG_INFO (" FS_S : handle = %d" , versionCharacteristicHandle);
5473 int res = os_mbuf_append (context->om , &fsVersion, sizeof (fsVersion));
0 commit comments