diff options
author | JF <jf@codingfield.com> | 2020-04-27 20:13:27 +0200 |
---|---|---|
committer | JF <jf@codingfield.com> | 2020-04-27 20:13:27 +0200 |
commit | 746c164c593d2b9aa63a0f9a1c1ad032de9627a0 (patch) | |
tree | d7061f72ce0b348e1fe2f383765c751511e2ad30 /src/Components/Ble | |
parent | 557e8fa19fbc86e342b79df3f8dbf861d6129b43 (diff) |
BLE : Display the actual status of the connection on the screen.
Diffstat (limited to 'src/Components/Ble')
-rw-r--r-- | src/Components/Ble/NimbleController.cpp | 5 | ||||
-rw-r--r-- | src/Components/Ble/NimbleController.h | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp index 7894ff43..02f99180 100644 --- a/src/Components/Ble/NimbleController.cpp +++ b/src/Components/Ble/NimbleController.cpp @@ -22,9 +22,11 @@ using namespace Pinetime::Controllers; // Let's try to improve this code (and keep it working!) NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask, + Pinetime::Controllers::Ble& bleController, DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager) : systemTask{systemTask}, + bleController{bleController}, dateTimeController{dateTimeController}, notificationManager{notificationManager}, currentTimeClient{dateTimeController}, @@ -149,7 +151,9 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { if (event->connect.status != 0) { /* Connection failed; resume advertising. */ StartAdvertising(); + bleController.Disconnect(); } else { + bleController.Connect(); connectionHandle = event->connect.conn_handle; ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this); } @@ -160,6 +164,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { NRF_LOG_INFO("disconnect; reason=%d ", event->disconnect.reason); /* Connection terminated; resume advertising. */ + bleController.Disconnect(); StartAdvertising(); break; case BLE_GAP_EVENT_CONN_UPDATE: diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h index 7a7a94c9..99e0c811 100644 --- a/src/Components/Ble/NimbleController.h +++ b/src/Components/Ble/NimbleController.h @@ -12,7 +12,7 @@ namespace Pinetime { class NimbleController { public: - NimbleController(Pinetime::System::SystemTask& systemTask, DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager); + NimbleController(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController, DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager); void Init(); void StartAdvertising(); int OnGAPEvent(ble_gap_event *event); @@ -28,6 +28,7 @@ namespace Pinetime { private: static constexpr char* deviceName = "Pinetime-JF"; Pinetime::System::SystemTask& systemTask; + Pinetime::Controllers::Ble& bleController; DateTime& dateTimeController; Pinetime::Controllers::NotificationManager& notificationManager; |