aboutsummaryrefslogtreecommitdiffstats
path: root/src/Components
diff options
context:
space:
mode:
Diffstat (limited to 'src/Components')
-rw-r--r--src/Components/Ble/AlertNotificationClient.cpp4
-rw-r--r--src/Components/Ble/AlertNotificationClient.h1
-rw-r--r--src/Components/Ble/CurrentTimeClient.cpp4
-rw-r--r--src/Components/Ble/CurrentTimeClient.h1
-rw-r--r--src/Components/Ble/NimbleController.cpp10
-rw-r--r--src/Components/Ble/NimbleController.h2
6 files changed, 9 insertions, 13 deletions
diff --git a/src/Components/Ble/AlertNotificationClient.cpp b/src/Components/Ble/AlertNotificationClient.cpp
index 6e096353..bf4d851c 100644
--- a/src/Components/Ble/AlertNotificationClient.cpp
+++ b/src/Components/Ble/AlertNotificationClient.cpp
@@ -42,10 +42,6 @@ bool AlertNotificationClient::OnDiscoveryEvent(uint16_t connectionHandle, const
return false;
}
-void AlertNotificationClient::Init() {
-
-}
-
int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
const ble_gatt_chr *characteristic) {
if(error->status != 0 && error->status != BLE_HS_EDONE) {
diff --git a/src/Components/Ble/AlertNotificationClient.h b/src/Components/Ble/AlertNotificationClient.h
index 7a085b7e..ca4f4e94 100644
--- a/src/Components/Ble/AlertNotificationClient.h
+++ b/src/Components/Ble/AlertNotificationClient.h
@@ -16,7 +16,6 @@ namespace Pinetime {
public:
explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask,
Pinetime::Controllers::NotificationManager &notificationManager);
- void Init();
bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service);
int OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
diff --git a/src/Components/Ble/CurrentTimeClient.cpp b/src/Components/Ble/CurrentTimeClient.cpp
index fdebc084..caec39d1 100644
--- a/src/Components/Ble/CurrentTimeClient.cpp
+++ b/src/Components/Ble/CurrentTimeClient.cpp
@@ -10,10 +10,6 @@ CurrentTimeClient::CurrentTimeClient(DateTime& dateTimeController) : dateTimeCon
}
-void CurrentTimeClient::Init() {
-
-}
-
bool CurrentTimeClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service) {
if(service == nullptr && error->status == BLE_HS_EDONE) {
NRF_LOG_INFO("CTS Discovery complete");
diff --git a/src/Components/Ble/CurrentTimeClient.h b/src/Components/Ble/CurrentTimeClient.h
index 2278ef15..76caff9f 100644
--- a/src/Components/Ble/CurrentTimeClient.h
+++ b/src/Components/Ble/CurrentTimeClient.h
@@ -10,7 +10,6 @@ namespace Pinetime {
class CurrentTimeClient {
public:
explicit CurrentTimeClient(DateTime& dateTimeController);
- void Init();
bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service);
int OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error *error,
const ble_gatt_chr *characteristic);
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp
index ccb1e6ad..f3d271ec 100644
--- a/src/Components/Ble/NimbleController.cpp
+++ b/src/Components/Ble/NimbleController.cpp
@@ -73,7 +73,6 @@ void NimbleController::Init() {
ble_svc_gatt_init();
deviceInformationService.Init();
-// currentTimeClient.Init();
dfuService.Init();
int res;
res = ble_hs_util_ensure_addr(0);
@@ -156,8 +155,9 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
bleController.Disconnect();
} else {
bleController.Connect();
+ systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected);
connectionHandle = event->connect.conn_handle;
-// ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this);
+ // Service discovery is deffered via systemtask
}
}
break;
@@ -166,6 +166,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
NRF_LOG_INFO("disconnect; reason=%d ", event->disconnect.reason);
/* Connection terminated; resume advertising. */
+ connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
StartAdvertising();
break;
@@ -248,7 +249,6 @@ int NimbleController::OnDiscoveryEvent(uint16_t i, const ble_gatt_error *error,
ble_gattc_disc_all_chrs(connectionHandle, alertNotificationClient.StartHandle(), alertNotificationClient.EndHandle(),
AlertNotificationCharacteristicDiscoveredCallback, this);
}
- return 0;
}
alertNotificationClient.OnDiscoveryEvent(i, error, service);
@@ -295,6 +295,10 @@ int NimbleController::OnANSDescriptorDiscoveryEventCallback(uint16_t connectionH
return alertNotificationClient.OnDescriptorDiscoveryEventCallback(connectionHandle, error, characteristicValueHandle, descriptor);
}
+void NimbleController::StartDiscovery() {
+ ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this);
+}
+
diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h
index 25f583f2..945d3329 100644
--- a/src/Components/Ble/NimbleController.h
+++ b/src/Components/Ble/NimbleController.h
@@ -26,6 +26,8 @@ namespace Pinetime {
int OnCurrentTimeReadResult(uint16_t connectionHandle, const ble_gatt_error *error, ble_gatt_attr *attribute);
int OnANSDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
uint16_t characteristicValueHandle, const ble_gatt_dsc *descriptor);
+
+ void StartDiscovery();
private:
static constexpr char* deviceName = "Pinetime-JF";
Pinetime::System::SystemTask& systemTask;