autoformatting
This commit is contained in:
@ -46,15 +46,15 @@ static struct bt_conn_auth_cb auth_callbacks = {
|
|||||||
#endif /* CONFIG_BT_SMP */
|
#endif /* CONFIG_BT_SMP */
|
||||||
|
|
||||||
static struct bt_gatt_cb gatt_callbacks = {
|
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)
|
uint32_t peripheral_gatt_write(uint32_t count)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = bt_enable(NULL);
|
err = bt_enable(NULL);
|
||||||
if (err) {
|
if (err)
|
||||||
|
{
|
||||||
printk("Bluetooth init failed (err %d)\n", err);
|
printk("Bluetooth init failed (err %d)\n", err);
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,8 @@ uint32_t peripheral_gatt_write(uint32_t count)
|
|||||||
#endif /* CONFIG_BT_SMP */
|
#endif /* CONFIG_BT_SMP */
|
||||||
|
|
||||||
err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_1, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
|
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);
|
printk("Advertising failed to start (err %d)\n", err);
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
@ -78,10 +79,12 @@ uint32_t peripheral_gatt_write(uint32_t count)
|
|||||||
conn_connected = NULL;
|
conn_connected = NULL;
|
||||||
last_write_rate = 0U;
|
last_write_rate = 0U;
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
struct bt_conn *conn = NULL;
|
struct bt_conn *conn = NULL;
|
||||||
|
|
||||||
if (conn_connected) {
|
if (conn_connected)
|
||||||
|
{
|
||||||
/* Get a connection reference to ensure that a
|
/* Get a connection reference to ensure that a
|
||||||
* reference is maintained in case disconnected
|
* reference is maintained in case disconnected
|
||||||
* callback is called while we perform GATT Write
|
* 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);
|
conn = bt_conn_ref(conn_connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn) {
|
if (conn)
|
||||||
|
{
|
||||||
write_cmd(conn);
|
write_cmd(conn);
|
||||||
bt_conn_unref(conn);
|
bt_conn_unref(conn);
|
||||||
|
|
||||||
if (count) {
|
if (count)
|
||||||
|
{
|
||||||
count--;
|
count--;
|
||||||
if (!count) {
|
if (!count)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k_yield();
|
k_yield();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
k_sleep(K_SECONDS(1));
|
k_sleep(K_SECONDS(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user