Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions omi/firmware/omi/omi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y

# Set preferred connection parameters
# 7.5ms
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=24
# 15ms
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=24
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
# 7.5ms
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=6
Comment on lines +210 to +212
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Reducing the connection interval to 7.5ms will significantly increase data throughput, but it will also substantially increase power consumption. Furthermore, requesting a fixed and very short connection interval might cause issues with some central devices (e.g., smartphones) that may not be able to sustain such a fast interval, potentially leading to connection instability. Consider using a slightly larger range for MIN and MAX intervals to give the central device more flexibility.

CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
# 15ms
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=12

CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
# 4 seconds
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
Expand Down
2 changes: 1 addition & 1 deletion omi/firmware/omi/src/lib/core/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void storage_write(void)
write_to_gatt(conn);

heartbeat_count = (heartbeat_count + 1) % (MAX_HEARTBEAT_FRAMES + 1);
k_msleep(100);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing k_msleep(100), this loop can become a busy-wait loop if the BLE transmit buffers fill up. When bt_gatt_notify() in write_to_gatt() returns an error indicating it cannot accept more data, this loop will spin very quickly, consuming significant CPU resources and power, even with k_yield(). This could negatively impact battery life.

A more power-efficient approach would be to use an event-driven mechanism. For instance, you could use bt_gatt_notify_cb() with a callback that signals a semaphore when the transmission is complete, allowing this thread to sleep until it's possible to send more data.

transport_started = 0;
if (remaining_length == 0) {
if (stop_started) {
Expand Down