drivers/nble: Use flags for state tracking
Using atomic flags instead of bool allows adding new states easily without aditional memory footprint. Change-Id: I0289a49af8353dc832a33e16ebdd6651c3913fe3 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
47d104530c
commit
d2fa54d4a6
|
@ -419,7 +419,7 @@ static void notify_disconnected(struct bt_conn *conn)
|
|||
* FIXME: When disconnected NBLE stops advertising, this should
|
||||
* be fixed in the NBLE firmware, use this hack for now
|
||||
*/
|
||||
if (nble.keep_adv) {
|
||||
if (atomic_test_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING)) {
|
||||
BT_WARN("Re-enable advertising on disconnect");
|
||||
nble_gap_start_adv_req();
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ void on_nble_gap_start_adv_rsp(const struct nble_common_rsp *rsp)
|
|||
return;
|
||||
}
|
||||
|
||||
nble.keep_adv = true;
|
||||
atomic_set_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING);
|
||||
|
||||
BT_DBG("status %u", rsp->status);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void on_nble_gap_stop_advertise_rsp(const struct nble_common_rsp *rsp)
|
|||
return;
|
||||
}
|
||||
|
||||
nble.keep_adv = false;
|
||||
atomic_clear_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING);
|
||||
|
||||
BT_DBG("status %d", rsp->status);
|
||||
}
|
||||
|
|
|
@ -583,11 +583,15 @@ void ble_gap_set_rssi_report(struct ble_rssi_report_params *par,
|
|||
struct bt_conn *conn,
|
||||
rssi_report_resp_t resp_cb, rssi_report_t evt_cb);
|
||||
|
||||
enum {
|
||||
NBLE_FLAG_KEEP_ADVERTISING,
|
||||
};
|
||||
|
||||
struct nble {
|
||||
/* Local Bluetooth LE Device Address */
|
||||
bt_addr_le_t addr;
|
||||
const struct bt_conn_auth_cb *auth;
|
||||
bool keep_adv;
|
||||
atomic_t flags;
|
||||
};
|
||||
|
||||
extern struct nble nble;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
/* for bt_security_t */
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
#include <bluetooth/conn.h>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include <bluetooth/log.h>
|
||||
|
|
Loading…
Reference in a new issue