Skip to content

Commit 1fb9ca8

Browse files
committed
More Bluetooth sleep tweaks for #2635
1 parent 9651f06 commit 1fb9ca8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

targets/nrf5x/bluetooth.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ uint16_t nuxTxBufLength = 0;
232232
#define DEFAULT_PERIPH_MAX_CONN_INTERVAL BLE_DYNAMIC_INTERVAL_HIGH_RATE // highest possible on connect
233233
#define BLE_DYNAMIC_INTERVAL_IDLE_TIME 30000 // time in milliseconds at which we enter idle
234234
#define BLE_DYNAMIC_INTERVAL_HIGH_TIME 500 // time in milliseconds since last activity at which we go back to high rate
235+
#define BLE_DYNAMIC_INTERVAL_COUNTDOWN 10000 // when we have activity, we subtract this from bleIdleCounter
235236
/// How long has BLE been idle for in msec? Use for dynamic interval adjustment
236237
uint16_t bleIdleCounter = 0;
237238
/// Are we using a high speed or low speed interval at the moment?
@@ -755,7 +756,11 @@ void jsble_peripheral_activity() {
755756
jsble_set_periph_connection_interval(BLE_DYNAMIC_INTERVAL_HIGH_RATE, BLE_DYNAMIC_INTERVAL_HIGH_RATE);
756757
}
757758
}
758-
bleIdleCounter = 0;
759+
// decrement our idle counter - don't zero it immediately so *some* activity can happen and we don't go back to high rate immediately
760+
if (bleIdleCounter > BLE_DYNAMIC_INTERVAL_COUNTDOWN)
761+
bleIdleCounter -= BLE_DYNAMIC_INTERVAL_COUNTDOWN;
762+
else
763+
bleIdleCounter = 0;
759764
#endif
760765
}
761766

0 commit comments

Comments
 (0)