Bluetooth: Allow to call enable function only once
Currently enable procedure can be called only once regardles if it failed or succeeded. Change-Id: I3869e97442720860baba7bb1b7610738ca95561a Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
d2fa54d4a6
commit
d1d0ee7b2d
|
@ -101,6 +101,10 @@ int bt_enable(bt_ready_cb_t cb)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_test_and_set_bit(&nble.flags, NBLE_FLAG_ENABLE)) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
ret = nble_open();
|
||||
if (ret) {
|
||||
return ret;
|
||||
|
|
|
@ -584,6 +584,7 @@ void ble_gap_set_rssi_report(struct ble_rssi_report_params *par,
|
|||
rssi_report_resp_t resp_cb, rssi_report_t evt_cb);
|
||||
|
||||
enum {
|
||||
NBLE_FLAG_ENABLE,
|
||||
NBLE_FLAG_KEEP_ADVERTISING,
|
||||
};
|
||||
|
||||
|
|
|
@ -3220,6 +3220,10 @@ int bt_enable(bt_ready_cb_t cb)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (atomic_test_and_set_bit(bt_dev.flags, BT_DEV_ENABLE)) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
/* Initialize the buffer pools */
|
||||
net_buf_pool_init(hci_cmd_pool);
|
||||
#if defined(CONFIG_BLUETOOTH_HOST_BUFFERS)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
/* bt_dev flags: the flags defined here represent BT controller state */
|
||||
enum {
|
||||
BT_DEV_ENABLE,
|
||||
BT_DEV_READY,
|
||||
BT_DEV_ID_STATIC_RANDOM,
|
||||
|
||||
|
|
Loading…
Reference in a new issue