diff --git a/firmware/app/src/peripheral_gatt_write.c b/firmware/app/src/peripheral_gatt_write.c index 94b25e0..cf69e13 100644 --- a/firmware/app/src/peripheral_gatt_write.c +++ b/firmware/app/src/peripheral_gatt_write.c @@ -46,15 +46,15 @@ static struct bt_conn_auth_cb auth_callbacks = { #endif /* CONFIG_BT_SMP */ static struct bt_gatt_cb gatt_callbacks = { - .att_mtu_updated = mtu_updated -}; + .att_mtu_updated = mtu_updated}; uint32_t peripheral_gatt_write(uint32_t count) { int err; err = bt_enable(NULL); - if (err) { + if (err) + { printk("Bluetooth init failed (err %d)\n", err); return 0U; } @@ -68,7 +68,8 @@ uint32_t peripheral_gatt_write(uint32_t count) #endif /* CONFIG_BT_SMP */ err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_1, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd)); - if (err) { + if (err) + { printk("Advertising failed to start (err %d)\n", err); return 0U; } @@ -78,10 +79,12 @@ uint32_t peripheral_gatt_write(uint32_t count) conn_connected = NULL; last_write_rate = 0U; - while (true) { + while (true) + { struct bt_conn *conn = NULL; - if (conn_connected) { + if (conn_connected) + { /* Get a connection reference to ensure that a * reference is maintained in case disconnected * callback is called while we perform GATT Write @@ -90,19 +93,24 @@ uint32_t peripheral_gatt_write(uint32_t count) conn = bt_conn_ref(conn_connected); } - if (conn) { + if (conn) + { write_cmd(conn); bt_conn_unref(conn); - if (count) { + if (count) + { count--; - if (!count) { + if (!count) + { break; } } k_yield(); - } else { + } + else + { k_sleep(K_SECONDS(1)); } }