Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: bluetooth: Revert "encrypt throgputsample" #13040

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ Bluetooth samples

|no_changes_yet_note|

* :ref:`ble_throughput` sample:

* Enabled encryption in the sample.
The measured throughput is calculated over the encrypted data, which is how most of the Bluetooth products use this protocol.

Bluetooth mesh samples
----------------------

Expand Down
36 changes: 4 additions & 32 deletions samples/bluetooth/throughput/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
#define INTERVAL_MIN 0x6 /* 6 units, 7.5 ms, only used to setup connection */
#define INTERVAL_MAX 0x6 /* 6 units, 7.5 ms, only used to setup connection */
#define INTERVAL_MIN 0x140 /* 320 units, 400 ms */
#define INTERVAL_MAX 0x140 /* 320 units, 400 ms */

#define THROUGHPUT_CONFIG_TIMEOUT K_SECONDS(20)

Expand Down Expand Up @@ -205,34 +205,12 @@ static void connected(struct bt_conn *conn, uint8_t hci_err)
info.role == BT_CONN_ROLE_CENTRAL ? "central" : "peripheral");
printk("Conn. interval is %u units\n", info.le.interval);

if (info.role == BT_CONN_ROLE_PERIPHERAL) {
err = bt_conn_set_security(conn, BT_SECURITY_L2);
if (err) {
printk("Failed to set security: %d\n", err);
}
}
}

void security_changed(struct bt_conn *conn, bt_security_t level,
enum bt_security_err security_err)
{
printk("Security changed: level %i, err: %i\n", level, security_err);

if (security_err != 0) {
printk("Failed to encrypt link\n");
bt_conn_disconnect(conn, BT_HCI_ERR_PAIRING_NOT_SUPPORTED);
return;
}

struct bt_conn_info info = {0};
int err;

err = bt_conn_get_info(default_conn, &info);
if (info.role == BT_CONN_ROLE_CENTRAL) {
err = bt_gatt_dm_start(default_conn,
BT_UUID_THROUGHPUT,
&discovery_cb,
&throughput);

if (err) {
printk("Discover failed (err %d)\n", err);
}
Expand Down Expand Up @@ -319,11 +297,6 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
return;
}

err = bt_unpair(info.id, info.le.remote);
if (err) {
printk("Cannot unpair peer (err %d)", err);
}

/* Re-connect using same roles */
if (info.role == BT_CONN_ROLE_CENTRAL) {
scan_start();
Expand Down Expand Up @@ -654,8 +627,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
.le_param_req = le_param_req,
.le_param_updated = le_param_updated,
.le_phy_updated = le_phy_updated,
.le_data_len_updated = le_data_length_updated,
.security_changed = security_changed
.le_data_len_updated = le_data_length_updated
};

int main(void)
Expand Down
Loading