Skip to content

Commit

Permalink
Samples: Bluetooth: Checking return value of functions
Browse files Browse the repository at this point in the history
Without this, an assert in gatt.c:5350 could happen.
It happened when the link got disconnected during
service discovery procedure.
  • Loading branch information
martintv committed Aug 8, 2024
1 parent 8a01cc3 commit ca4028d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions samples/bluetooth/central_uart/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,29 @@ static int uart_init(void)
static void discovery_complete(struct bt_gatt_dm *dm,
void *context)
{
int err;
struct bt_nus_client *nus = context;
LOG_INF("Service discovery completed");

bt_gatt_dm_data_print(dm);

bt_nus_handles_assign(dm, nus);
bt_nus_subscribe_receive(nus);
err = bt_nus_handles_assign(dm, nus);
if (err)

Check failure on line 299 in samples/bluetooth/central_uart/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

OPEN_BRACE

samples/bluetooth/central_uart/src/main.c:299 that open brace { should be on the previous line
{
bt_gatt_dm_data_release(dm);
LOG_INF("bt_nus_handles_assign failed with errorcode %i", err);
goto cleanup;
}

err = bt_nus_subscribe_receive(nus);
if (err)

Check failure on line 307 in samples/bluetooth/central_uart/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

OPEN_BRACE

samples/bluetooth/central_uart/src/main.c:307 that open brace { should be on the previous line
{
bt_gatt_dm_data_release(dm);
LOG_INF("bt_nus_subscribe_receive failed with errorcode %i", err);
goto cleanup;
}

cleanup:

Check warning on line 314 in samples/bluetooth/central_uart/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

INDENTED_LABEL

samples/bluetooth/central_uart/src/main.c:314 labels should not be indented
bt_gatt_dm_data_release(dm);
}

Expand Down

0 comments on commit ca4028d

Please sign in to comment.