summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/ble/NimbleController.cpp13
-rw-r--r--src/components/ble/NimbleController.h5
-rw-r--r--src/systemtask/SystemTask.cpp3
3 files changed, 20 insertions, 1 deletions
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 8e0fe756..226f6694 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -122,6 +122,15 @@ void NimbleController::StartAdvertising() {
adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
+ /* fast advertise for 30 sec */
+ if (fastAdvCount < 15) {
+ adv_params.itvl_min = 32;
+ adv_params.itvl_max = 47;
+ fastAdvCount++;
+ } else {
+ adv_params.itvl_min = 1636;
+ adv_params.itvl_max = 1651;
+ }
fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
fields.uuids128 = &dfuServiceUuid;
@@ -139,7 +148,7 @@ void NimbleController::StartAdvertising() {
rc = ble_gap_adv_rsp_set_fields(&rsp_fields);
ASSERT(rc == 0);
- rc = ble_gap_adv_start(addrType, NULL, 5000, &adv_params, GAPEventCallback, this);
+ rc = ble_gap_adv_start(addrType, NULL, 2000, &adv_params, GAPEventCallback, this);
ASSERT(rc == 0);
}
@@ -163,6 +172,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
+ fastAdvCount = 0;
StartAdvertising();
} else {
connectionHandle = event->connect.conn_handle;
@@ -181,6 +191,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
+ fastAdvCount = 0;
StartAdvertising();
break;
diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h
index 078d6158..473bb1af 100644
--- a/src/components/ble/NimbleController.h
+++ b/src/components/ble/NimbleController.h
@@ -72,6 +72,10 @@ namespace Pinetime {
uint16_t connHandle();
void NotifyBatteryLevel(uint8_t level);
+ void RestartFastAdv() {
+ fastAdvCount = 0;
+ }
+
private:
static constexpr const char* deviceName = "InfiniTime";
Pinetime::System::SystemTask& systemTask;
@@ -94,6 +98,7 @@ namespace Pinetime {
uint8_t addrType; // 1 = Random, 0 = PUBLIC
uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE;
+ uint8_t fastAdvCount = 0;
ble_uuid128_t dfuServiceUuid {
.u {.type = BLE_UUID_TYPE_128},
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 2dff9254..41f346ae 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -233,6 +233,9 @@ void SystemTask::Work() {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
+ if (!bleController.IsConnected())
+ nimbleController.RestartFastAdv();
+
isSleeping = false;
isWakingUp = false;
isDimmed = false;