You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/11 23:50:33 UTC
[43/50] [abbrv] incubator-mynewt-core git commit: BLE Host - GAP
event callback updates.
BLE Host - GAP event callback updates.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/27445b80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/27445b80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/27445b80
Branch: refs/heads/ble_hs_api
Commit: 27445b801be5ed517b2577b7c4e335fdfb20b75b
Parents: 3bb2419
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Jul 7 13:44:46 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Jul 11 16:43:34 2016 -0700
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gap.h | 226 +++++++++++---
net/nimble/host/include/host/ble_hs.h | 6 +-
net/nimble/host/src/ble_gap.c | 362 ++++++++++++-----------
net/nimble/host/src/ble_gap_priv.h | 2 +-
net/nimble/host/src/ble_gattc.c | 2 +-
net/nimble/host/src/ble_hs.c | 11 +-
net/nimble/host/src/ble_sm.c | 8 +-
net/nimble/host/src/ble_sm_priv.h | 2 +-
net/nimble/host/src/ble_sm_sc.c | 8 +-
net/nimble/host/src/test/ble_att_svr_test.c | 17 +-
net/nimble/host/src/test/ble_gap_test.c | 98 +++---
net/nimble/host/src/test/ble_hs_test_util.c | 4 +-
net/nimble/host/src/test/ble_hs_test_util.h | 2 +-
net/nimble/host/src/test/ble_l2cap_test.c | 5 +-
net/nimble/host/src/test/ble_os_test.c | 56 ++--
net/nimble/host/src/test/ble_sm_test_util.c | 36 +--
net/nimble/host/src/test/ble_sm_test_util.h | 3 +-
17 files changed, 497 insertions(+), 351 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/include/host/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index f83b1de..7577d6d 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -105,7 +105,7 @@ struct hci_conn_update;
#define BLE_GAP_EVENT_CONN_UPDATE_REQ 4
#define BLE_GAP_EVENT_L2CAP_UPDATE_REQ 5
#define BLE_GAP_EVENT_TERM_FAILURE 6
-#define BLE_GAP_EVENT_DISC_SUCCESS 7
+#define BLE_GAP_EVENT_DISC 7
#define BLE_GAP_EVENT_DISC_COMPLETE 8
#define BLE_GAP_EVENT_ADV_COMPLETE 9
#define BLE_GAP_EVENT_ENC_CHANGE 10
@@ -194,89 +194,225 @@ struct ble_gap_upd_params {
uint16_t max_ce_len;
};
-struct ble_gap_notify_params {
- uint16_t attr_handle;
- void *attr_data;
- uint16_t attr_len;
-
- unsigned indication:1;
-};
-
-struct ble_gap_passkey_action {
+struct ble_gap_passkey_params {
uint8_t action;
uint32_t numcmp;
};
-struct ble_gap_event_ctxt {
- struct ble_gap_conn_desc *desc;
+struct ble_gap_disc_desc {
+ /*** Common fields. */
+ uint8_t event_type;
+ uint8_t addr_type;
+ uint8_t length_data;
+ int8_t rssi;
+ uint8_t addr[6];
+
+ /*** LE advertising report fields; both null if no data present. */
+ uint8_t *data;
+ struct ble_hs_adv_fields *fields;
+ /***
+ * LE direct advertising report fields; direct_addr_type is
+ * BLE_GAP_ADDR_TYPE_NONE if direct address fields are not present.
+ */
+ uint8_t direct_addr_type;
+ uint8_t direct_addr[6];
+};
+
+/**
+ * Represents a GAP-related event. When such an event occurs, the host
+ * notifies the application by passing an instance of this structure to an
+ * application-specified callback.
+ */
+struct ble_gap_event {
+ /**
+ * Indicates the type of GAP event that occurred. This is one of the
+ * BLE_GAP_EVENT codes.
+ */
+ uint8_t type;
+
+ /**
+ * A discriminated union containing additional details concerning the GAP
+ * event. The 'type' field indicates which member of the union is valid.
+ */
union {
+ /**
+ * Represents a connection attempt. Valid for the following event
+ * types:
+ * o BLE_GAP_EVENT_CONNECT
+ */
struct {
+ /**
+ * The status of the connection attempt;
+ * o 0: the connection was successfully established.
+ * o BLE host error code: the connection attempt failed for
+ * the specified reason.
+ */
int status;
+
+ /**
+ * Information about the established connection. Only valid on
+ * success.
+ */
+ struct ble_gap_conn_desc conn;
} connect;
+ /**
+ * Represents a terminated connection. Valid for the following event
+ * types:
+ * o BLE_GAP_EVENT_DISCONNECT
+ */
struct {
+ /**
+ * A BLE host return code indicating the reason for the
+ * disconnect.
+ */
int reason;
+
+ /** Information about the terminated connection. */
+ struct ble_gap_conn_desc conn;
} disconnect;
+ /**
+ * Represents an advertising report received during a discovery
+ * procedure. Valid for the following event types:
+ * o BLE_GAP_EVENT_DISC
+ */
+ struct ble_gap_disc_desc disc;
+
+ /**
+ * Represents an attempt to update a connection's parameters. Valid
+ * for the following event types:
+ * o BLE_GAP_EVENT_CONN_UPDATE
+ */
struct {
+ /**
+ * The result of the connection update attempt;
+ * o 0: the connection was successfully updated.
+ * o BLE host error code: the connection update attempt failed
+ * for the specified reason.
+ */
int status;
+
+ /**
+ * Information about the relevant connection. If the connection
+ * update attempt was successful, this descriptor contains the
+ * updated parameters.
+ */
+ struct ble_gap_conn_desc conn;
} conn_update;
+ /**
+ * Represents a peer's request to update the connection parameters.
+ * This event is generated when a peer performs any of the following
+ * procedures:
+ * o L2CAP Connection Parameter Update Procedure
+ * o Link-Layer Connection Parameters Request Procedure
+ *
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_L2CAP_UPDATE_REQ
+ * o BLE_GAP_EVENT_CONN_UPDATE_REQ
+ *
+ */
struct {
+ /**
+ * Indicates the connection parameters that the peer would like to
+ * use.
+ */
+ const struct ble_gap_upd_params *peer_params;
+
+ /**
+ * Indicates the connection parameters that the local device would
+ * like to use. The application callback should fill this in. By
+ * default, this struct contains the requested parameters (i.e.,
+ * it is a copy of 'peer_params').
+ */
struct ble_gap_upd_params *self_params;
- struct ble_gap_upd_params *peer_params;
+
+ /** Information about the relevant connection. */
+ struct ble_gap_conn_desc conn;
} conn_update_req;
+ /**
+ * Represents a failed attempt to terminate an established connection.
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_TERM_FAILURE
+ */
struct {
+ /**
+ * A BLE host return code indicating the reason for the failure.
+ */
int status;
+
+ /** Information about the relevant connection. */
+ struct ble_gap_conn_desc conn;
} term_failure;
+ /**
+ * Represents an attempt to change the encrypted state of a
+ * connection. Valid for the following event types:
+ * o BLE_GAP_EVENT_ENC_CHANGE
+ */
struct {
+ /**
+ * Indicates the result of the encryption state change attempt;
+ * o 0: the encrypted state was successfully updated;
+ * o BLE host error code: the encryption state change attempt
+ * failed for the specified reason.
+ */
int status;
- } enc_change;
- struct ble_gap_passkey_action passkey_action;
+ /**
+ * Information about the relevant connection. If the encryption
+ * state change attempt was successful, this descriptor reflects
+ * the updated state.
+ */
+ struct ble_gap_conn_desc conn;
+ } enc_change;
+ /**
+ * Represents a passkey query needed to complete a pairing procedure.
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_PASSKEY_ACTION
+ */
+ struct {
+ /** Contains details about the passkey query. */
+ struct ble_gap_passkey_params params;
+
+ /** Information about the relevant connection. */
+ struct ble_gap_conn_desc conn;
+ } passkey;
+
+ /**
+ * Represents a received ATT notification or indication.
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_NOTIFY
+ */
struct {
+ /** The handle of the relevant ATT attribute. */
uint16_t attr_handle;
+
+ /** The contents of the notification or indication. */
void *attr_data;
+
+ /** The number of data bytes contained in the message. */
uint16_t attr_len;
+ /** Information about the relevant connection. */
+ struct ble_gap_conn_desc conn;
+
+ /**
+ * Whether the received command is a notification or an
+ * indication;
+ * o 0: Notification;
+ * o 1: Indication.
+ */
unsigned indication:1;
} notify;
-
- struct ble_gap_ltk_params *ltk_params;
};
};
-typedef int ble_gap_event_fn(int event, struct ble_gap_event_ctxt *ctxt,
- void *arg);
-
-struct ble_gap_disc_desc {
- /*** Common fields. */
- uint8_t event_type;
- uint8_t addr_type;
- uint8_t length_data;
- int8_t rssi;
- uint8_t addr[6];
-
- /*** LE advertising report fields; both null if no data present. */
- uint8_t *data;
- struct ble_hs_adv_fields *fields;
-
- /***
- * LE direct advertising report fields; direct_addr_type is
- * BLE_GAP_ADDR_TYPE_NONE if direct address fields are not present.
- */
- uint8_t direct_addr_type;
- uint8_t direct_addr[6];
-};
-
-typedef void ble_gap_disc_fn(int event, int status,
- struct ble_gap_disc_desc *desc, void *arg);
-
-typedef void ble_gap_wl_fn(int status, void *arg);
+typedef int ble_gap_event_fn(struct ble_gap_event *ctxt, void *arg);
#define BLE_GAP_CONN_MODE_NON 0
#define BLE_GAP_CONN_MODE_DIR 1
@@ -303,7 +439,7 @@ int ble_gap_adv_set_fields(const struct ble_hs_adv_fields *adv_fields);
int ble_gap_adv_rsp_set_fields(const struct ble_hs_adv_fields *rsp_fields);
int ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
const struct ble_gap_disc_params *disc_params,
- ble_gap_disc_fn *cb, void *cb_arg);
+ ble_gap_event_fn *cb, void *cb_arg);
int ble_gap_disc_cancel(void);
int ble_gap_disc_active(void);
int ble_gap_connect(uint8_t own_addr_type,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index 3113b0d..61900b6 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -73,17 +73,13 @@ struct os_event;
#define BLE_HS_ERR_SM_PEER_BASE 0x500 /* 1280 */
#define BLE_HS_SM_PEER_ERR(x) ((x) ? BLE_HS_ERR_SM_PEER_BASE + (x) : 0)
-/* defines the input output (io) capabilities for the host device */
+/* Defines the IO capabilities for the local device. */
#define BLE_HS_IO_DISPLAY_ONLY 0x00
#define BLE_HS_IO_DISPLAY_YESNO 0x01
#define BLE_HS_IO_KEYBOARD_ONLY 0x02
#define BLE_HS_IO_NO_INPUT_OUTPUT 0x03
#define BLE_HS_IO_KEYBOARD_DISPLAY 0x04
-#define BLE_HS_PRIVACY_MODE_NONE 0
-#define BLE_HS_PRIVACY_MODE_RANDOM_STATIC 1
-#define BLE_HS_PRIVACY_MODE_RESOLV_RAND 2
-
struct ble_hs_cfg {
/*** HCI settings. */
/**
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 7254287..48285d6 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -94,19 +94,18 @@ static bssnz_t struct {
uint8_t exp_set:1;
os_time_t exp_os_ticks;
+ ble_gap_event_fn *cb;
+ void *cb_arg;
+
union {
- struct {
- ble_gap_event_fn *cb;
- void *cb_arg;
+ struct {
uint8_t using_wl:1;
uint8_t our_addr_type:2;
} conn;
struct {
uint8_t limited:1;
- ble_gap_disc_fn *cb;
- void *cb_arg;
} disc;
};
} ble_gap_master;
@@ -139,7 +138,7 @@ static int ble_gap_disc_tx_disable(void);
static int ble_gap_adv_disable_tx(void);
struct ble_gap_snapshot {
- struct ble_gap_conn_desc desc;
+ struct ble_gap_conn_desc *desc;
ble_gap_event_fn *cb;
void *cb_arg;
};
@@ -315,7 +314,7 @@ static void
ble_gap_conn_to_snapshot(struct ble_hs_conn *conn,
struct ble_gap_snapshot *snap)
{
- ble_gap_fill_conn_desc(conn, &snap->desc);
+ ble_gap_fill_conn_desc(conn, snap->desc);
snap->cb = conn->bhc_cb;
snap->cb_arg = conn->bhc_cb_arg;
}
@@ -380,7 +379,7 @@ ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc)
*****************************************************************************/
static int
-ble_gap_call_event_cb(int event, struct ble_gap_event_ctxt *ctxt,
+ble_gap_call_event_cb(struct ble_gap_event *event,
ble_gap_event_fn *cb, void *cb_arg)
{
int rc;
@@ -388,12 +387,12 @@ ble_gap_call_event_cb(int event, struct ble_gap_event_ctxt *ctxt,
BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task());
if (cb != NULL) {
- rc = cb(event, ctxt, cb_arg);
+ rc = cb(event, cb_arg);
} else {
- if (event == BLE_GAP_EVENT_CONN_UPDATE_REQ) {
+ if (event->type == BLE_GAP_EVENT_CONN_UPDATE_REQ) {
/* Just copy peer parameters back into the reply. */
- *ctxt->conn_update_req.self_params =
- *ctxt->conn_update_req.peer_params;
+ *event->conn_update_req.self_params =
+ *event->conn_update_req.peer_params;
}
rc = 0;
}
@@ -416,13 +415,17 @@ ble_gap_slave_reset_state(void)
}
static void
-ble_gap_master_extract_cb(ble_gap_event_fn **out_cb, void **out_cb_arg)
+ble_gap_master_extract_cb(ble_gap_event_fn **out_cb, void **out_cb_arg,
+ int reset_state)
{
ble_hs_lock();
- *out_cb = ble_gap_master.conn.cb;
- *out_cb_arg = ble_gap_master.conn.cb_arg;
- ble_gap_master_reset_state();
+ *out_cb = ble_gap_master.cb;
+ *out_cb_arg = ble_gap_master.cb_arg;
+
+ if (reset_state) {
+ ble_gap_master_reset_state();
+ }
ble_hs_unlock();
}
@@ -442,40 +445,34 @@ ble_gap_slave_extract_cb(ble_gap_event_fn **out_cb, void **out_cb_arg)
static void
ble_gap_adv_finished(void)
{
- struct ble_gap_event_ctxt ctxt;
- struct ble_gap_conn_desc desc;
+ struct ble_gap_event event;
ble_gap_event_fn *cb;
void *cb_arg;
ble_gap_slave_extract_cb(&cb, &cb_arg);
if (cb != NULL) {
- memset(&ctxt, 0, sizeof ctxt);
- desc.conn_handle = BLE_HS_CONN_HANDLE_NONE;
- ctxt.desc = &desc;
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_ADV_COMPLETE;
- cb(BLE_GAP_EVENT_ADV_COMPLETE, &ctxt, cb_arg);
+ cb(&event, cb_arg);
}
}
static int
ble_gap_master_connect_failure(int status)
{
- struct ble_gap_event_ctxt ctxt;
- struct ble_gap_conn_desc desc;
+ struct ble_gap_event event;
ble_gap_event_fn *cb;
void *cb_arg;
int rc;
- memset(&desc, 0, sizeof ctxt);
-
- ble_gap_master_extract_cb(&cb, &cb_arg);
+ ble_gap_master_extract_cb(&cb, &cb_arg, 1);
if (cb != NULL) {
- memset(&ctxt, 0, sizeof ctxt);
- desc.conn_handle = BLE_HS_CONN_HANDLE_NONE;
- ctxt.desc = &desc;
- ctxt.connect.status = status;
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_CONNECT;
+ event.connect.status = status;
- rc = cb(BLE_GAP_EVENT_CONNECT, &ctxt, cb_arg);
+ rc = cb(&event, cb_arg);
} else {
rc = 0;
}
@@ -486,20 +483,16 @@ ble_gap_master_connect_failure(int status)
static int
ble_gap_master_connect_cancel(void)
{
- struct ble_gap_event_ctxt ctxt;
- struct ble_gap_conn_desc desc;
+ struct ble_gap_event event;
ble_gap_event_fn *cb;
void *cb_arg;
int rc;
- memset(&desc, 0, sizeof ctxt);
- desc.conn_handle = BLE_HS_CONN_HANDLE_NONE;
-
- ble_gap_master_extract_cb(&cb, &cb_arg);
+ ble_gap_master_extract_cb(&cb, &cb_arg, 1);
if (cb != NULL) {
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &desc;
- rc = cb(BLE_GAP_EVENT_CONN_CANCEL, &ctxt, cb_arg);
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_CONN_CANCEL;
+ rc = cb(&event, cb_arg);
} else {
rc = 0;
}
@@ -508,46 +501,58 @@ ble_gap_master_connect_cancel(void)
}
static void
-ble_gap_call_master_disc_cb(int event, int status,
- struct ble_gap_disc_desc *desc,
- struct ble_hs_adv_fields *fields, int reset_state)
+ble_gap_disc_report(struct ble_gap_disc_desc *desc)
{
- ble_gap_disc_fn *cb;
+ struct ble_gap_event event;
+ ble_gap_event_fn *cb;
void *cb_arg;
- ble_hs_lock();
+ ble_gap_master_extract_cb(&cb, &cb_arg, 0);
- cb = ble_gap_master.disc.cb;
- cb_arg = ble_gap_master.disc.cb_arg;
+ if (cb != NULL) {
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_DISC;
+ event.disc = *desc;
- if (reset_state) {
- ble_gap_master_reset_state();
+ cb(&event, cb_arg);
}
+}
- ble_hs_unlock();
+static void
+ble_gap_disc_complete(void)
+{
+ struct ble_gap_event event;
+ ble_gap_event_fn *cb;
+ void *cb_arg;
+
+ ble_gap_master_extract_cb(&cb, &cb_arg, 1);
if (cb != NULL) {
- cb(event, status, desc, cb_arg);
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_DISC_COMPLETE;
+
+ ble_gap_call_event_cb(&event, cb, cb_arg);
}
}
static void
ble_gap_update_notify(uint16_t conn_handle, int status)
{
- struct ble_gap_event_ctxt ctxt;
struct ble_gap_snapshot snap;
+ struct ble_gap_event event;
int rc;
+ memset(&event, 0, sizeof event);
+
+ snap.desc = &event.conn_update.conn;
rc = ble_gap_find_snapshot(conn_handle, &snap);
if (rc != 0) {
return;
}
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.conn_update.status = status;
- ble_gap_call_event_cb(BLE_GAP_EVENT_CONN_UPDATE, &ctxt,
- snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_CONN_UPDATE;
+ event.conn_update.status = status;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
}
static uint32_t
@@ -624,25 +629,19 @@ ble_gap_slave_set_timer(uint32_t ticks_from_now)
/**
* Called when an error is encountered while the master-connection-fsm is
- * active. Resets the state machine, clears the HCI ack callback, and notifies
- * the host task that the next hci_batch item can be processed.
+ * active.
*/
static void
ble_gap_master_failed(int status)
{
switch (ble_gap_master.op) {
- case BLE_GAP_OP_M_DISC:
- STATS_INC(ble_gap_stats, discover_fail);
- ble_gap_call_master_disc_cb(BLE_GAP_EVENT_DISC_COMPLETE, status,
- NULL, NULL, 1);
- break;
-
case BLE_GAP_OP_M_CONN:
STATS_INC(ble_gap_stats, initiate_fail);
ble_gap_master_connect_failure(status);
break;
default:
+ BLE_HS_DBG_ASSERT(0);
break;
}
}
@@ -656,24 +655,33 @@ ble_gap_update_failed(uint16_t conn_handle, int status)
}
static void
-ble_gap_conn_broken(struct ble_gap_snapshot *snap, int reason)
+ble_gap_conn_broken(uint16_t conn_handle, int reason)
{
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_snapshot snap;
+ struct ble_gap_event event;
+ int rc;
+
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.disconnect.conn;
+
+ rc = ble_gap_find_snapshot(conn_handle, &snap);
+ if (rc != 0) {
+ /* No longer connected. */
+ return;
+ }
/* XXX: Consider removing the connection from the list and handing it to
* each of the "connection_broken" functions below.
*/
- ble_sm_connection_broken(snap->desc.conn_handle);
- ble_gattc_connection_broken(snap->desc.conn_handle);
+ ble_sm_connection_broken(conn_handle);
+ ble_gattc_connection_broken(conn_handle);
- ble_hs_atomic_conn_delete(snap->desc.conn_handle);
+ ble_hs_atomic_conn_delete(conn_handle);
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap->desc;
- ctxt.disconnect.reason = reason;
- ble_gap_call_event_cb(BLE_GAP_EVENT_DISCONNECT, &ctxt,
- snap->cb, snap->cb_arg);
+ event.type = BLE_GAP_EVENT_DISCONNECT;
+ event.disconnect.reason = reason;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
STATS_INC(ble_gap_stats, disconnect);
}
@@ -685,28 +693,28 @@ ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt)
return;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
int status;
int rc;
STATS_INC(ble_gap_stats, rx_disconnect);
- rc = ble_gap_find_snapshot(evt->connection_handle, &snap);
- if (rc != 0) {
- /* No longer connected. */
- return;
- }
-
if (evt->status == 0) {
status = BLE_HS_HCI_ERR(evt->reason);
- ble_gap_conn_broken(&snap, status);
+ ble_gap_conn_broken(evt->connection_handle, status);
} else {
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.term_failure.status = BLE_HS_HCI_ERR(evt->status);
- ble_gap_call_event_cb(BLE_GAP_EVENT_TERM_FAILURE, &ctxt,
- snap.cb, snap.cb_arg);
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.term_failure.conn;
+ rc = ble_gap_find_snapshot(evt->connection_handle, &snap);
+ if (rc != 0) {
+ /* No longer connected. */
+ return;
+ }
+
+ event.type = BLE_GAP_EVENT_TERM_FAILURE;
+ event.term_failure.status = BLE_HS_HCI_ERR(evt->status);
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
}
}
@@ -717,12 +725,15 @@ ble_gap_rx_update_complete(struct hci_le_conn_upd_complete *evt)
return;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
struct ble_hs_conn *conn;
STATS_INC(ble_gap_stats, rx_update_complete);
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.conn_update.conn;
+
ble_hs_lock();
conn = ble_hs_conn_find(evt->connection_handle);
@@ -741,11 +752,9 @@ ble_gap_rx_update_complete(struct hci_le_conn_upd_complete *evt)
ble_hs_unlock();
if (conn != NULL) {
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.conn_update.status = BLE_HS_HCI_ERR(evt->status);
- ble_gap_call_event_cb(BLE_GAP_EVENT_CONN_UPDATE, &ctxt,
- snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_CONN_UPDATE;
+ event.conn_update.status = BLE_HS_HCI_ERR(evt->status);
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
}
}
@@ -884,8 +893,8 @@ ble_gap_rx_adv_report(struct ble_gap_disc_desc *desc)
return;
}
- ble_gap_call_master_disc_cb(BLE_GAP_EVENT_DISC_SUCCESS, 0, desc,
- &fields, 0);
+ desc->fields = &fields;
+ ble_gap_disc_report(desc);
}
/**
@@ -898,24 +907,20 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
return BLE_HS_ENOTSUP;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
struct ble_hs_conn *conn;
int rc;
STATS_INC(ble_gap_stats, rx_conn_complete);
- /* Determine if this event refers to a completed connection or a connection
- * in progress.
- */
- rc = ble_gap_find_snapshot(evt->connection_handle, &snap);
-
/* Apply the event to the existing connection if it exists. */
- if (rc == 0) {
+ if (ble_hs_atomic_conn_flags(evt->connection_handle, NULL) == 0) {
/* XXX: Does this ever happen? */
if (evt->status != 0) {
- ble_gap_conn_broken(&snap, BLE_HS_HCI_ERR(evt->status));
+ ble_gap_conn_broken(evt->connection_handle,
+ BLE_HS_HCI_ERR(evt->status));
}
return 0;
}
@@ -982,10 +987,10 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
conn->bhc_supervision_timeout = evt->supervision_timeout;
conn->bhc_master_clock_accuracy = evt->master_clk_acc;
if (evt->role == BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER) {
+ conn->bhc_cb = ble_gap_master.cb;
+ conn->bhc_cb_arg = ble_gap_master.cb_arg;
conn->bhc_flags |= BLE_HS_CONN_F_MASTER;
- conn->bhc_cb = ble_gap_master.conn.cb;
conn->bhc_our_addr_type = ble_gap_master.conn.our_addr_type;
- conn->bhc_cb_arg = ble_gap_master.conn.cb_arg;
ble_gap_master_reset_state();
} else {
conn->bhc_cb = ble_gap_slave.cb;
@@ -999,15 +1004,16 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
ble_hs_lock();
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.connect.conn;
ble_gap_conn_to_snapshot(conn, &snap);
ble_hs_conn_insert(conn);
ble_hs_unlock();
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.connect.status = 0;
- ble_gap_call_event_cb(BLE_GAP_EVENT_CONNECT, &ctxt, snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_CONNECT;
+ event.connect.status = 0;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
return 0;
}
@@ -1016,20 +1022,21 @@ int
ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
struct ble_gap_upd_params *params)
{
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
int rc;
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.conn_update.conn;
rc = ble_gap_find_snapshot(conn_handle, &snap);
if (rc != 0) {
return rc;
}
if (snap.cb != NULL) {
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.conn_update_req.peer_params = params;
- rc = snap.cb(BLE_GAP_EVENT_L2CAP_UPDATE_REQ, &ctxt, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_L2CAP_UPDATE_REQ;
+ event.conn_update_req.peer_params = params;
+ rc = snap.cb(&event, snap.cb_arg);
} else {
rc = 0;
}
@@ -1052,6 +1059,10 @@ ble_gap_master_heartbeat(void)
/*** Timer expired; process event. */
switch (ble_gap_master.op) {
+ case BLE_GAP_OP_M_CONN:
+ ble_gap_master_failed(BLE_HS_ETIMEOUT);
+ break;
+
case BLE_GAP_OP_M_DISC:
/* When a discovery procedure times out, it is not a failure. */
rc = ble_gap_disc_tx_disable();
@@ -1060,18 +1071,14 @@ ble_gap_master_heartbeat(void)
return 100;
}
- ble_gap_call_master_disc_cb(BLE_GAP_EVENT_DISC_COMPLETE, rc,
- NULL, NULL, 1);
+ ble_gap_disc_complete();
break;
default:
- ble_gap_master_failed(BLE_HS_ETIMEOUT);
+ BLE_HS_DBG_ASSERT(0);
break;
}
- /* Clear the timer and cancel the current procedure. */
- ble_gap_master_reset_state();
-
return BLE_HS_FOREVER;
}
@@ -1606,15 +1613,15 @@ ble_gap_adv_validate(uint8_t own_addr_type, uint8_t peer_addr_type,
* o BLE_ADDR_TYPE_RANDOM
* o BLE_ADDR_TYPE_RPA_PUB_DEFAULT
* o BLE_ADDR_TYPE_RPA_RND_DEFAULT
- * @param peer_addr_type This parameter is ignored unless directed
- * advertising is being used. Address type of
- * the peer's identity address. Valid values
- * are:
+ * @param peer_addr_type Address type of the peer's identity address.
+ * Valid values are:
* o BLE_ADDR_TYPE_PUBLIC
* o BLE_ADDR_TYPE_RANDOM
- * @param peer_addr This parameter is ignored unless directed
- * advertising is being used. The peer's
- * six-byte identity address.
+ * This parameter is ignored unless directed
+ * advertising is being used.
+ * @param peer_addr The peer's six-byte identity address.
+ * This parameter is ignored unless directed
+ * advertising is being used.
* @param duration_ms The duration of the advertisement procedure.
* On expiration, the procedure ends and a
* BLE_GAP_EVENT_ADV_COMPLETE event is
@@ -1962,7 +1969,7 @@ ble_gap_disc_fill_dflts(struct ble_gap_disc_params *disc_params)
}
static int
-ble_gap_disc_validate(uint8_t own_addr_type,
+ble_gap_disc_validate(uint8_t own_addr_type,
const struct ble_gap_disc_params *disc_params)
{
if (disc_params == NULL) {
@@ -1981,17 +1988,17 @@ ble_gap_disc_validate(uint8_t own_addr_type,
}
/**
- * Performs the Limited or General Discovery Procedures (vol. 3, part C,
- * section 9.2.5 / 9.2.6).
+ * Performs the Limited or General Discovery Procedures.
*
- * @param own_addr_type This parameter is ignored unless active
- * scanning is being used. The type of address
- * the stack should use for itself when
- * sending scan requests. Valid values are:
+ * @param own_addr_type The type of address the stack should use for
+ * itself when sending scan requests. Valid
+ * values are:
* o BLE_ADDR_TYPE_PUBLIC
* o BLE_ADDR_TYPE_RANDOM
* o BLE_ADDR_TYPE_RPA_PUB_DEFAULT
* o BLE_ADDR_TYPE_RPA_RND_DEFAULT
+ * This parameter is ignored unless active
+ * scanning is being used.
* @param duration_ms The duration of the discovery procedure.
* On expiration, the procedure ends and a
* BLE_GAP_EVENT_DISC_COMPLETE event is
@@ -2011,7 +2018,7 @@ ble_gap_disc_validate(uint8_t own_addr_type,
int
ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
const struct ble_gap_disc_params *disc_params,
- ble_gap_disc_fn *cb, void *cb_arg)
+ ble_gap_event_fn *cb, void *cb_arg)
{
#if !NIMBLE_OPT(ROLE_OBSERVER)
return BLE_HS_ENOTSUP;
@@ -2057,8 +2064,8 @@ ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
}
ble_gap_master.disc.limited = params.limited;
- ble_gap_master.disc.cb = cb;
- ble_gap_master.disc.cb_arg = cb_arg;
+ ble_gap_master.cb = cb;
+ ble_gap_master.cb_arg = cb_arg;
BLE_HS_LOG(INFO, "GAP procedure initiated: discovery; ");
ble_gap_log_disc(own_addr_type, duration_ms, ¶ms);
@@ -2164,7 +2171,7 @@ ble_gap_conn_create_tx(uint8_t own_addr_type,
* o BLE_ADDR_TYPE_RANDOM
* o BLE_ADDR_TYPE_RPA_PUB_DEFAULT
* o BLE_ADDR_TYPE_RPA_RND_DEFAULT
- * @param peer_addr_type The peer's identity address type. One of:
+ * @param peer_addr_type The peer's address type. One of:
* o BLE_HCI_CONN_PEER_ADDR_PUBLIC
* o BLE_HCI_CONN_PEER_ADDR_RANDOM
* o BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT
@@ -2180,6 +2187,14 @@ ble_gap_conn_create_tx(uint8_t own_addr_type,
* @param conn_params Additional arguments specifying the particulars
* of the connect procedure. Specify null for
* default values.
+ * @param cb The callback to associate with this connect
+ * procedure. When the connect procedure
+ * completes, the result is reported through
+ * this callback. If the connect procedure
+ * succeeds, the connection inherits this
+ * callback as its event-reporting mechanism.
+ * @param cb_arg The optional argument to pass to the callback
+ * function.
*
* @return 0 on success; nonzero on failure.
*/
@@ -2234,8 +2249,8 @@ ble_gap_connect(uint8_t own_addr_type,
ble_gap_log_conn(own_addr_type, peer_addr_type, peer_addr, conn_params);
BLE_HS_LOG(INFO, "\n");
- ble_gap_master.conn.cb = cb;
- ble_gap_master.conn.cb_arg = cb_arg;
+ ble_gap_master.cb = cb;
+ ble_gap_master.cb_arg = cb_arg;
ble_gap_master.conn.using_wl = peer_addr_type == BLE_GAP_ADDR_TYPE_WL;
ble_gap_master.conn.our_addr_type = own_addr_type;
@@ -2428,13 +2443,15 @@ ble_gap_rx_param_req(struct hci_le_conn_param_req *evt)
struct ble_gap_upd_params peer_params;
struct ble_gap_upd_params self_params;
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
uint8_t reject_reason;
int rc;
reject_reason = 0; /* Silence warning. */
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.conn_update_req.conn;
rc = ble_gap_find_snapshot(evt->connection_handle, &snap);
if (rc != 0) {
/* We are not connected to the sender. */
@@ -2454,12 +2471,11 @@ ble_gap_rx_param_req(struct hci_le_conn_param_req *evt)
*/
self_params = peer_params;
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.conn_update_req.self_params = &self_params;
- ctxt.conn_update_req.peer_params = &peer_params;
- rc = ble_gap_call_event_cb(BLE_GAP_EVENT_CONN_UPDATE_REQ, &ctxt,
- snap.cb, snap.cb_arg);
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_CONN_UPDATE_REQ;
+ event.conn_update_req.self_params = &self_params;
+ event.conn_update_req.peer_params = &peer_params;
+ rc = ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
if (rc != 0) {
reject_reason = rc;
}
@@ -2693,16 +2709,19 @@ ble_gap_encryption_initiate(uint16_t conn_handle,
void
ble_gap_passkey_event(uint16_t conn_handle,
- struct ble_gap_passkey_action *passkey_action)
+ struct ble_gap_passkey_params *passkey_params)
{
#if !NIMBLE_OPT(SM)
return;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
struct ble_hs_conn *conn;
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.passkey.conn;
+
ble_hs_lock();
conn = ble_hs_conn_find(conn_handle);
@@ -2718,13 +2737,11 @@ ble_gap_passkey_event(uint16_t conn_handle,
}
BLE_HS_LOG(DEBUG, "send passkey action request %d\n",
- passkey_action->action);
+ passkey_params->action);
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.passkey_action = *passkey_action;
- ble_gap_call_event_cb(BLE_GAP_EVENT_PASSKEY_ACTION, &ctxt,
- snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_PASSKEY_ACTION;
+ event.passkey.params = *passkey_params;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
}
void
@@ -2734,24 +2751,24 @@ ble_gap_enc_event(uint16_t conn_handle, int status, int security_restored)
return;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
int rc;
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.enc_change.conn;
rc = ble_gap_find_snapshot(conn_handle, &snap);
if (rc != 0) {
/* No longer connected. */
return;
}
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.enc_change.status = status;
- ble_gap_call_event_cb(BLE_GAP_EVENT_ENC_CHANGE, &ctxt,
- snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_ENC_CHANGE;
+ event.enc_change.status = status;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
if (status == 0 && security_restored) {
- BLE_HS_DBG_ASSERT(snap.desc.sec_state.bonded);
+ BLE_HS_DBG_ASSERT(snap.desc->sec_state.bonded);
ble_gatts_bonding_restored(conn_handle);
}
}
@@ -2768,23 +2785,24 @@ ble_gap_notify_event(uint16_t conn_handle, uint16_t attr_handle,
return;
#endif
- struct ble_gap_event_ctxt ctxt;
+ struct ble_gap_event event;
struct ble_gap_snapshot snap;
int rc;
+ memset(&event, 0, sizeof event);
+ snap.desc = &event.notify.conn;
rc = ble_gap_find_snapshot(conn_handle, &snap);
if (rc != 0) {
/* No longer connected. */
return;
}
- memset(&ctxt, 0, sizeof ctxt);
- ctxt.desc = &snap.desc;
- ctxt.notify.attr_handle = attr_handle;
- ctxt.notify.attr_data = attr_data;
- ctxt.notify.attr_len = attr_len;
- ctxt.notify.indication = is_indication;
- ble_gap_call_event_cb(BLE_GAP_EVENT_NOTIFY, &ctxt, snap.cb, snap.cb_arg);
+ event.type = BLE_GAP_EVENT_NOTIFY;
+ event.notify.attr_handle = attr_handle;
+ event.notify.attr_data = attr_data;
+ event.notify.attr_len = attr_len;
+ event.notify.indication = is_indication;
+ ble_gap_call_event_cb(&event, snap.cb, snap.cb_arg);
}
/*****************************************************************************
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_gap_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_priv.h b/net/nimble/host/src/ble_gap_priv.h
index 43030fd..1cb48b5 100644
--- a/net/nimble/host/src/ble_gap_priv.h
+++ b/net/nimble/host/src/ble_gap_priv.h
@@ -81,7 +81,7 @@ int ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
void ble_gap_enc_event(uint16_t conn_handle, int status,
int security_restored);
void ble_gap_passkey_event(uint16_t conn_handle,
- struct ble_gap_passkey_action *passkey_action);
+ struct ble_gap_passkey_params *passkey_params);
void ble_gap_notify_event(uint16_t conn_handle, uint16_t attr_handle,
void *attr_data, uint16_t attr_len,
int is_indication);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index 04ff94f..825365b 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -3579,7 +3579,7 @@ ble_gattc_write_reliable_rx_exec(struct ble_gattc_proc *proc, int status)
}
/**
- * Initiates GATT procedure: Write Long Characteristic Values.
+ * Initiates GATT procedure: Reliable Writes.
*
* @param conn_handle The connection over which to execute the
* procedure.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index e3f4bcb..b9f55ae 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -286,12 +286,11 @@ ble_hs_event_enqueue(struct os_event *ev)
}
/**
- * Sends a sequence of HCI commands to the controller. This sequence of
- * commands is necessary for the host and controller to remain in sync. This
- * function must be called before any other host functionality is used, but it
- * must be called after both the host and controller are initialized.
- * Typically, the host-parent-task calls this function at the top of its task
- * routine.
+ * Synchronizes the host with the controller by sending a sequence of HCI
+ * commands. This function must be called before any other host functionality
+ * is used, but it must be called after both the host and controller are
+ * initialized. Typically, the host-parent-task calls this function at the top
+ * of its task routine.
*
* @return 0 on success; nonzero on error.
*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c
index 3f3def0..6f77db2 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -824,9 +824,9 @@ ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res)
}
if (res->app_status == 0 &&
- res->passkey_action.action != BLE_SM_IOACT_NONE) {
+ res->passkey_params.action != BLE_SM_IOACT_NONE) {
- ble_gap_passkey_event(conn_handle, &res->passkey_action);
+ ble_gap_passkey_event(conn_handle, &res->passkey_params);
}
/* Persist keys if bonding has successfully completed. */
@@ -1466,7 +1466,7 @@ ble_sm_pair_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
ioact = ble_sm_io_action(proc);
if (ble_sm_ioact_state(ioact) == proc->state) {
- res->passkey_action.action = ioact;
+ res->passkey_params.action = ioact;
}
}
@@ -1575,7 +1575,7 @@ ble_sm_pair_rsp_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
proc->state = ble_sm_state_after_pair(proc);
ioact = ble_sm_io_action(proc);
if (ble_sm_ioact_state(ioact) == proc->state) {
- res->passkey_action.action = ioact;
+ res->passkey_params.action = ioact;
}
if (ble_sm_proc_can_advance(proc)) {
res->execute = 1;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_sm_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_priv.h b/net/nimble/host/src/ble_sm_priv.h
index 95b312b..fbc7139 100644
--- a/net/nimble/host/src/ble_sm_priv.h
+++ b/net/nimble/host/src/ble_sm_priv.h
@@ -276,7 +276,7 @@ struct ble_sm_proc {
struct ble_sm_result {
int app_status;
uint8_t sm_err;
- struct ble_gap_passkey_action passkey_action;
+ struct ble_gap_passkey_params passkey_params;
void *state_arg;
unsigned execute:1;
unsigned enc_cb:1;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/ble_sm_sc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_sc.c b/net/nimble/host/src/ble_sm_sc.c
index d98c93b..bb92a19 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -280,7 +280,7 @@ ble_sm_sc_gen_numcmp(struct ble_sm_proc *proc, struct ble_sm_result *res)
pkb = ble_sm_sc_pub_key.u8;
}
res->app_status = ble_sm_alg_g2(pka, pkb, proc->randm, proc->rands,
- &res->passkey_action.numcmp);
+ &res->passkey_params.numcmp);
if (res->app_status != 0) {
res->sm_err = BLE_SM_ERR_UNSPECIFIED;
res->enc_cb = 1;
@@ -341,7 +341,7 @@ ble_sm_sc_random_exec(struct ble_sm_proc *proc, struct ble_sm_result *res)
if (ble_sm_ioact_state(ioact) == proc->state &&
!(proc->flags & BLE_SM_PROC_F_IO_INJECTED)) {
- res->passkey_action.action = ioact;
+ res->passkey_params.action = ioact;
BLE_HS_DBG_ASSERT(ioact == BLE_SM_IOACT_NUMCMP);
ble_sm_sc_gen_numcmp(proc, res);
}
@@ -423,7 +423,7 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
if (ble_sm_ioact_state(ioact) == proc->state &&
!(proc->flags & BLE_SM_PROC_F_IO_INJECTED)) {
- res->passkey_action.action = ioact;
+ res->passkey_params.action = ioact;
BLE_HS_DBG_ASSERT(ioact == BLE_SM_IOACT_NUMCMP);
ble_sm_sc_gen_numcmp(proc, res);
} else {
@@ -459,7 +459,7 @@ ble_sm_sc_public_key_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
ioact = ble_sm_sc_io_action(proc);
if (ble_sm_ioact_state(ioact) == BLE_SM_PROC_STATE_CONFIRM) {
- res->passkey_action.action = ioact;
+ res->passkey_params.action = ioact;
}
if (!(proc->flags & BLE_SM_PROC_F_INITIATOR)) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_svr_test.c b/net/nimble/host/src/test/ble_att_svr_test.c
index a8db378..bb9910a 100644
--- a/net/nimble/host/src/test/ble_att_svr_test.c
+++ b/net/nimble/host/src/test/ble_att_svr_test.c
@@ -42,18 +42,17 @@ static uint8_t ble_att_svr_test_attr_n[1024];
static int ble_att_svr_test_attr_n_len;
static int
-ble_att_svr_test_misc_gap_cb(int event,
- struct ble_gap_event_ctxt *ctxt, void *arg)
+ble_att_svr_test_misc_gap_cb(struct ble_gap_event *event, void *arg)
{
- switch (event) {
+ switch (event->type) {
case BLE_GAP_EVENT_NOTIFY:
- ble_att_svr_test_n_conn_handle = ctxt->desc->conn_handle;
- ble_att_svr_test_n_attr_handle = ctxt->notify.attr_handle;
- TEST_ASSERT_FATAL(ctxt->notify.attr_len <=
+ ble_att_svr_test_n_conn_handle = event->notify.conn.conn_handle;
+ ble_att_svr_test_n_attr_handle = event->notify.attr_handle;
+ TEST_ASSERT_FATAL(event->notify.attr_len <=
sizeof ble_att_svr_test_attr_n);
- ble_att_svr_test_attr_n_len = ctxt->notify.attr_len;
- memcpy(ble_att_svr_test_attr_n, ctxt->notify.attr_data,
- ctxt->notify.attr_len);
+ ble_att_svr_test_attr_n_len = event->notify.attr_len;
+ memcpy(ble_att_svr_test_attr_n, event->notify.attr_data,
+ event->notify.attr_len);
break;
default:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_gap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gap_test.c b/net/nimble/host/src/test/ble_gap_test.c
index 43a0269..51469a2 100644
--- a/net/nimble/host/src/test/ble_gap_test.c
+++ b/net/nimble/host/src/test/ble_gap_test.c
@@ -26,15 +26,14 @@
#include "host/ble_hs_test.h"
#include "ble_hs_test_util.h"
-static int ble_gap_test_conn_event;
+static int ble_gap_test_conn_event_type;
static int ble_gap_test_conn_status;
static struct ble_gap_conn_desc ble_gap_test_conn_desc;
static void *ble_gap_test_conn_arg;
static struct ble_gap_upd_params ble_gap_test_conn_peer_params;
static struct ble_gap_upd_params ble_gap_test_conn_self_params;
-static int ble_gap_test_disc_event;
-static int ble_gap_test_disc_status;
+static int ble_gap_test_disc_event_type;
static struct ble_gap_disc_desc ble_gap_test_disc_desc;
static void *ble_gap_test_disc_arg;
@@ -55,13 +54,12 @@ ble_gap_test_util_update_in_progress(uint16_t conn_handle)
static void
ble_gap_test_util_reset_cb_info(void)
{
- ble_gap_test_conn_event = -1;
+ ble_gap_test_conn_event_type = -1;
ble_gap_test_conn_status = -1;
memset(&ble_gap_test_conn_desc, 0xff, sizeof ble_gap_test_conn_desc);
ble_gap_test_conn_arg = (void *)-1;
- ble_gap_test_disc_event = -1;
- ble_gap_test_disc_status = -1;
+ ble_gap_test_disc_event_type = -1;
memset(&ble_gap_test_disc_desc, 0xff, sizeof ble_gap_test_disc_desc);
ble_gap_test_disc_arg = (void *)-1;
}
@@ -74,44 +72,46 @@ ble_gap_test_util_init(void)
ble_gap_test_util_reset_cb_info();
}
-static void
-ble_gap_test_util_disc_cb(int event, int status,
- struct ble_gap_disc_desc *desc, void *arg)
+static int
+ble_gap_test_util_disc_cb(struct ble_gap_event *event, void *arg)
{
- ble_gap_test_disc_event = event;
- ble_gap_test_disc_status = status;
- ble_gap_test_disc_desc = *desc;
+ ble_gap_test_disc_event_type = event->type;
+ ble_gap_test_disc_desc = event->disc;
ble_gap_test_disc_arg = arg;
+
+ return 0;
}
static int
-ble_gap_test_util_connect_cb(int event, struct ble_gap_event_ctxt *ctxt,
- void *arg)
+ble_gap_test_util_connect_cb(struct ble_gap_event *event, void *arg)
{
int *fail_reason;
- ble_gap_test_conn_event = event;
- ble_gap_test_conn_desc = *ctxt->desc;
+ ble_gap_test_conn_event_type = event->type;
ble_gap_test_conn_arg = arg;
- switch (event) {
+ switch (event->type) {
case BLE_GAP_EVENT_CONNECT:
- ble_gap_test_conn_status = ctxt->connect.status;
+ ble_gap_test_conn_status = event->connect.status;
+ ble_gap_test_conn_desc = event->connect.conn;
break;
case BLE_GAP_EVENT_DISCONNECT:
- ble_gap_test_conn_status = ctxt->disconnect.reason;
+ ble_gap_test_conn_status = event->disconnect.reason;
+ ble_gap_test_conn_desc = event->disconnect.conn;
break;
case BLE_GAP_EVENT_CONN_UPDATE:
- ble_gap_test_conn_status = ctxt->conn_update.status;
+ ble_gap_test_conn_status = event->conn_update.status;
+ ble_gap_test_conn_desc = event->conn_update.conn;
break;
case BLE_GAP_EVENT_CONN_CANCEL:
break;
case BLE_GAP_EVENT_TERM_FAILURE:
- ble_gap_test_conn_status = ctxt->term_failure.status;
+ ble_gap_test_conn_status = event->term_failure.status;
+ ble_gap_test_conn_desc = event->term_failure.conn;
break;
case BLE_GAP_EVENT_ADV_COMPLETE:
@@ -119,8 +119,9 @@ ble_gap_test_util_connect_cb(int event, struct ble_gap_event_ctxt *ctxt,
break;
case BLE_GAP_EVENT_CONN_UPDATE_REQ:
- ble_gap_test_conn_peer_params = *ctxt->conn_update_req.peer_params;
- *ctxt->conn_update_req.self_params = ble_gap_test_conn_self_params;
+ ble_gap_test_conn_peer_params = *event->conn_update_req.peer_params;
+ *event->conn_update_req.self_params = ble_gap_test_conn_self_params;
+ ble_gap_test_conn_desc = event->conn_update.conn;
fail_reason = arg;
if (fail_reason == NULL) {
@@ -532,7 +533,7 @@ ble_gap_test_util_disc(uint8_t own_addr_type,
TEST_ASSERT(ble_gap_master_in_progress());
ble_gap_rx_adv_report(desc);
} else {
- TEST_ASSERT(ble_gap_test_disc_status == -1);
+ TEST_ASSERT(ble_gap_test_disc_event_type == -1);
}
if (cmd_fail_idx > 0) {
@@ -632,8 +633,7 @@ TEST_CASE(ble_gap_test_case_disc_good)
ble_gap_test_util_disc(own_addr_type, &disc_params, &desc, -1, 0);
TEST_ASSERT(ble_gap_master_in_progress());
- TEST_ASSERT(ble_gap_test_disc_event == BLE_GAP_EVENT_DISC_SUCCESS);
- TEST_ASSERT(ble_gap_test_disc_status == 0);
+ TEST_ASSERT(ble_gap_test_disc_event_type == BLE_GAP_EVENT_DISC);
TEST_ASSERT(ble_gap_test_disc_desc.event_type ==
BLE_HCI_ADV_TYPE_ADV_IND);
TEST_ASSERT(ble_gap_test_disc_desc.addr_type ==
@@ -675,7 +675,7 @@ TEST_CASE(ble_gap_test_case_disc_ltd_mismatch)
TEST_ASSERT(ble_gap_master_in_progress());
/* Verify that the report was ignored because of a mismatched LTD flag. */
- TEST_ASSERT(ble_gap_test_disc_event == -1);
+ TEST_ASSERT(ble_gap_test_disc_event_type == -1);
/* Stop the scan and swap the flags. */
rc = ble_hs_test_util_disc_cancel(0);
@@ -691,7 +691,7 @@ TEST_CASE(ble_gap_test_case_disc_ltd_mismatch)
/* This time we should have reported the advertisement; general discovery
* hears everything.
*/
- TEST_ASSERT(ble_gap_test_disc_event == BLE_GAP_EVENT_DISC_SUCCESS);
+ TEST_ASSERT(ble_gap_test_disc_event_type == BLE_GAP_EVENT_DISC);
}
TEST_CASE(ble_gap_test_case_disc_hci_fail)
@@ -819,7 +819,7 @@ TEST_CASE(ble_gap_test_case_conn_dir_good)
TEST_ASSERT(!ble_gap_master_in_progress());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONNECT);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONNECT);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -924,7 +924,7 @@ TEST_CASE(ble_gap_test_case_conn_cancel_good)
ble_gap_test_util_conn_cancel(peer_addr, 0);
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_CANCEL);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_CANCEL);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == BLE_HS_CONN_HANDLE_NONE);
}
@@ -940,7 +940,7 @@ TEST_CASE(ble_gap_test_case_conn_cancel_ctlr_fail)
/* Make sure the host didn't invoke the application callback. The cancel
* failure was indicated via the return code from the gap call.
*/
- TEST_ASSERT(ble_gap_test_conn_event == -1);
+ TEST_ASSERT(ble_gap_test_conn_event_type == -1);
/* Allow connection complete to succeed. */
memset(&evt, 0, sizeof evt);
@@ -954,7 +954,7 @@ TEST_CASE(ble_gap_test_case_conn_cancel_ctlr_fail)
TEST_ASSERT(!ble_gap_master_in_progress());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONNECT);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONNECT);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
peer_addr, 6) == 0);
@@ -988,7 +988,7 @@ ble_gap_test_util_terminate(uint8_t *peer_addr, uint8_t hci_status)
/* Reset the callback event code; we don't care about the successful
* connection in this test.
*/
- ble_gap_test_conn_event = -1;
+ ble_gap_test_conn_event_type = -1;
/* Terminate the connection. */
rc = ble_hs_test_util_conn_terminate(2, hci_status);
@@ -1024,7 +1024,7 @@ TEST_CASE(ble_gap_test_case_conn_terminate_good)
ble_gap_test_util_terminate(peer_addr, 0);
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_DISCONNECT);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_DISCONNECT);
TEST_ASSERT(ble_gap_test_conn_status ==
BLE_HS_HCI_ERR(BLE_ERR_CONN_TERM_LOCAL));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
@@ -1064,7 +1064,7 @@ TEST_CASE(ble_gap_test_case_conn_terminate_ctlr_fail)
evt.reason = 0;
ble_gap_rx_disconn_complete(&evt);
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_TERM_FAILURE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_TERM_FAILURE);
TEST_ASSERT(ble_gap_test_conn_status ==
BLE_HS_HCI_ERR(BLE_ERR_UNSUPPORTED));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
@@ -1083,7 +1083,7 @@ TEST_CASE(ble_gap_test_case_conn_terminate_hci_fail)
ble_gap_test_util_terminate(peer_addr, BLE_ERR_REPEATED_ATTEMPTS);
- TEST_ASSERT(ble_gap_test_conn_event == -1);
+ TEST_ASSERT(ble_gap_test_conn_event_type == -1);
TEST_ASSERT(ble_hs_atomic_conn_flags(2, NULL) == 0);
TEST_ASSERT(!ble_gap_master_in_progress());
}
@@ -1456,7 +1456,7 @@ TEST_CASE(ble_gap_test_case_adv_good)
if (c != BLE_GAP_CONN_MODE_NON) {
TEST_ASSERT(!ble_gap_adv_active());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONNECT);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONNECT);
TEST_ASSERT(ble_gap_test_conn_status == 0);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
@@ -1479,7 +1479,7 @@ TEST_CASE(ble_gap_test_case_adv_ctlr_fail)
peer_addr, c, d, BLE_ERR_DIR_ADV_TMO, -1, 0);
TEST_ASSERT(!ble_gap_adv_active());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_ADV_COMPLETE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_ADV_COMPLETE);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle ==
BLE_HS_CONN_HANDLE_NONE);
TEST_ASSERT(ble_gap_test_conn_arg == NULL);
@@ -1509,7 +1509,7 @@ TEST_CASE(ble_gap_test_case_adv_hci_fail)
c, d, 0, fail_idx, BLE_ERR_UNSUPPORTED);
TEST_ASSERT(!ble_gap_adv_active());
- TEST_ASSERT(ble_gap_test_conn_event == -1);
+ TEST_ASSERT(ble_gap_test_conn_event_type == -1);
}
}
}
@@ -1565,7 +1565,7 @@ TEST_CASE(ble_gap_test_case_stop_adv_good)
ble_gap_test_util_stop_adv(BLE_ADDR_TYPE_PUBLIC, peer_addr, c, d,
-1, 0);
TEST_ASSERT(!ble_gap_adv_active());
- TEST_ASSERT(ble_gap_test_conn_event == -1);
+ TEST_ASSERT(ble_gap_test_conn_event_type == -1);
TEST_ASSERT(ble_gap_test_conn_status == -1);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == (uint16_t)-1);
TEST_ASSERT(ble_gap_test_conn_arg == (void *)-1);
@@ -1584,7 +1584,7 @@ TEST_CASE(ble_gap_test_case_stop_adv_hci_fail)
ble_gap_test_util_stop_adv(BLE_ADDR_TYPE_PUBLIC, peer_addr, c, d,
0, BLE_ERR_UNSUPPORTED);
TEST_ASSERT(ble_gap_adv_active());
- TEST_ASSERT(ble_gap_test_conn_event == -1);
+ TEST_ASSERT(ble_gap_test_conn_event_type == -1);
TEST_ASSERT(ble_gap_test_conn_status == -1);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == (uint16_t)-1);
TEST_ASSERT(ble_gap_test_conn_arg == (void *)-1);
@@ -1643,7 +1643,7 @@ ble_gap_test_util_update(struct ble_gap_upd_params *params,
TEST_ASSERT(!ble_gap_master_in_progress());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == 0);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1657,7 +1657,7 @@ ble_gap_test_util_update(struct ble_gap_upd_params *params,
return;
fail:
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == status);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1688,7 +1688,7 @@ ble_gap_test_util_update_peer(uint8_t status,
TEST_ASSERT(!ble_gap_master_in_progress());
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(status));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
@@ -1743,7 +1743,7 @@ ble_gap_test_util_update_req_pos(struct ble_gap_upd_params *peer_params,
TEST_ASSERT(!ble_gap_master_in_progress());
TEST_ASSERT(!ble_gap_test_util_update_in_progress(2));
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == 0);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1755,7 +1755,7 @@ ble_gap_test_util_update_req_pos(struct ble_gap_upd_params *peer_params,
return;
hci_fail:
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(hci_status));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1804,7 +1804,7 @@ ble_gap_test_util_update_req_neg(struct ble_gap_upd_params *peer_params,
return;
hci_fail:
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(hci_status));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1879,7 +1879,7 @@ ble_gap_test_util_update_req_concurrent(
TEST_ASSERT(!ble_gap_master_in_progress());
TEST_ASSERT(!ble_gap_test_util_update_in_progress(2));
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == 0);
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
@@ -1891,7 +1891,7 @@ ble_gap_test_util_update_req_concurrent(
return;
hci_fail:
- TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
+ TEST_ASSERT(ble_gap_test_conn_event_type == BLE_GAP_EVENT_CONN_UPDATE);
TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(fail_status));
TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c
index fe701d8..9723b90 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.c
+++ b/net/nimble/host/src/test/ble_hs_test_util.c
@@ -377,7 +377,7 @@ ble_hs_test_util_connect(uint8_t own_addr_type, uint8_t peer_addr_type,
ack_status);
rc = ble_gap_connect(own_addr_type, peer_addr_type, peer_addr,
- params, cb, cb_arg);
+ params, cb, cb_arg);
TEST_ASSERT(rc == BLE_HS_HCI_ERR(ack_status));
@@ -441,7 +441,7 @@ ble_hs_test_util_exp_hci_status(int cmd_idx, int fail_idx, uint8_t fail_status)
int
ble_hs_test_util_disc(uint8_t own_addr_type, int32_t duration_ms,
const struct ble_gap_disc_params *disc_params,
- ble_gap_disc_fn *cb, void *cb_arg, int fail_idx,
+ ble_gap_event_fn *cb, void *cb_arg, int fail_idx,
uint8_t fail_status)
{
int rc;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_hs_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.h b/net/nimble/host/src/test/ble_hs_test_util.h
index d54c8aa..8d2221a 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.h
+++ b/net/nimble/host/src/test/ble_hs_test_util.h
@@ -76,7 +76,7 @@ int ble_hs_test_util_exp_hci_status(int cmd_idx, int fail_idx,
uint8_t fail_status);
int ble_hs_test_util_disc(uint8_t own_addr_type, int32_t duration_ms,
const struct ble_gap_disc_params *disc_params,
- ble_gap_disc_fn *cb, void *cb_arg, int fail_idx,
+ ble_gap_event_fn *cb, void *cb_arg, int fail_idx,
uint8_t fail_status);
int ble_hs_test_util_disc_cancel(uint8_t ack_status);
int ble_hs_test_util_adv_set_fields(struct ble_hs_adv_fields *adv_fields,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_l2cap_test.c b/net/nimble/host/src/test/ble_l2cap_test.c
index 1e373f5..b651325 100644
--- a/net/nimble/host/src/test/ble_l2cap_test.c
+++ b/net/nimble/host/src/test/ble_l2cap_test.c
@@ -480,12 +480,11 @@ TEST_CASE(ble_l2cap_test_case_sig_unsol_rsp)
*****************************************************************************/
static int
-ble_l2cap_test_util_conn_cb(int event, struct ble_gap_event_ctxt *ctxt,
- void *arg)
+ble_l2cap_test_util_conn_cb(struct ble_gap_event *event, void *arg)
{
int *accept;
- switch (event) {
+ switch (event->type) {
case BLE_GAP_EVENT_L2CAP_UPDATE_REQ:
accept = arg;
return !*accept;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_os_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_os_test.c b/net/nimble/host/src/test/ble_os_test.c
index 7aae46e..4df85d9 100644
--- a/net/nimble/host/src/test/ble_os_test.c
+++ b/net/nimble/host/src/test/ble_os_test.c
@@ -43,7 +43,7 @@ static uint8_t ble_os_test_peer_addr[6] = { 1, 2, 3, 4, 5, 6 };
static void ble_os_test_app_task_handler(void *arg);
-static int ble_os_test_gap_event;
+static int ble_os_test_gap_event_type;
static void
ble_os_test_init_app_task(void)
@@ -91,20 +91,20 @@ ble_os_test_misc_conn_exists(uint16_t conn_handle)
}
static int
-ble_gap_direct_connect_test_connect_cb(int event,
- struct ble_gap_event_ctxt *ctxt,
- void *arg)
+ble_gap_direct_connect_test_connect_cb(struct ble_gap_event *event, void *arg)
{
int *cb_called;
cb_called = arg;
*cb_called = 1;
- TEST_ASSERT(event == BLE_GAP_EVENT_CONNECT);
- TEST_ASSERT(ctxt->connect.status == 0);
- TEST_ASSERT(ctxt->desc->conn_handle == 2);
- TEST_ASSERT(ctxt->desc->peer_id_addr_type == BLE_ADDR_TYPE_PUBLIC);
- TEST_ASSERT(memcmp(ctxt->desc->peer_id_addr, ble_os_test_peer_addr, 6) == 0);
+ TEST_ASSERT(event->type == BLE_GAP_EVENT_CONNECT);
+ TEST_ASSERT(event->connect.status == 0);
+ TEST_ASSERT(event->connect.conn.conn_handle == 2);
+ TEST_ASSERT(event->connect.conn.peer_id_addr_type ==
+ BLE_ADDR_TYPE_PUBLIC);
+ TEST_ASSERT(memcmp(event->connect.conn.peer_id_addr,
+ ble_os_test_peer_addr, 6) == 0);
return 0;
}
@@ -164,21 +164,21 @@ TEST_CASE(ble_gap_direct_connect_test_case)
os_start();
}
-static void
-ble_gap_gen_disc_test_connect_cb(int event, int status,
- struct ble_gap_disc_desc *desc, void *arg)
+static int
+ble_os_disc_test_cb(struct ble_gap_event *event, void *arg)
{
int *cb_called;
cb_called = arg;
*cb_called = 1;
- TEST_ASSERT(event == BLE_GAP_EVENT_DISC_COMPLETE);
- TEST_ASSERT(status == 0);
+ TEST_ASSERT(event->type == BLE_GAP_EVENT_DISC_COMPLETE);
+
+ return 0;
}
static void
-ble_gap_gen_disc_test_task_handler(void *arg)
+ble_os_disc_test_task_handler(void *arg)
{
struct ble_gap_disc_params disc_params;
int cb_called;
@@ -203,7 +203,7 @@ ble_gap_gen_disc_test_task_handler(void *arg)
/* Initiate the general discovery procedure with a 300 ms timeout. */
memset(&disc_params, 0, sizeof disc_params);
rc = ble_hs_test_util_disc(BLE_ADDR_TYPE_PUBLIC, 300, &disc_params,
- ble_gap_gen_disc_test_connect_cb,
+ ble_os_disc_test_cb,
&cb_called, 0, 0);
TEST_ASSERT(rc == 0);
TEST_ASSERT(!ble_os_test_misc_conn_exists(BLE_HS_CONN_HANDLE_NONE));
@@ -234,13 +234,13 @@ ble_gap_gen_disc_test_task_handler(void *arg)
tu_restart();
}
-TEST_CASE(ble_gap_gen_disc_test_case)
+TEST_CASE(ble_os_disc_test_case)
{
ble_os_test_misc_init();
os_task_init(&ble_os_test_task,
- "ble_gap_gen_disc_test_task",
- ble_gap_gen_disc_test_task_handler, NULL,
+ "ble_os_disc_test_task",
+ ble_os_disc_test_task_handler, NULL,
BLE_OS_TEST_TASK_PRIO, OS_WAIT_FOREVER, ble_os_test_stack,
OS_STACK_ALIGN(BLE_OS_TEST_STACK_SIZE));
@@ -248,15 +248,15 @@ TEST_CASE(ble_gap_gen_disc_test_case)
}
static int
-ble_gap_terminate_cb(int event, struct ble_gap_event_ctxt *ctxt, void *arg)
+ble_gap_terminate_cb(struct ble_gap_event *event, void *arg)
{
int *disconn_handle;
- ble_os_test_gap_event = event;
+ ble_os_test_gap_event_type = event->type;
- if (event == BLE_GAP_EVENT_DISCONNECT) {
+ if (event->type == BLE_GAP_EVENT_DISCONNECT) {
disconn_handle = arg;
- *disconn_handle = ctxt->desc->conn_handle;
+ *disconn_handle = event->disconnect.conn.conn_handle;
}
return 0;
@@ -291,8 +291,8 @@ ble_gap_terminate_test_task_handler(void *arg)
/* Create two direct connections. */
ble_hs_test_util_connect(BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_PUBLIC,
- addr1, NULL, ble_gap_terminate_cb,
- &disconn_handle, 0);
+ addr1, NULL, ble_gap_terminate_cb,
+ &disconn_handle, 0);
memset(&conn_evt, 0, sizeof conn_evt);
conn_evt.subevent_code = BLE_HCI_LE_SUBEV_CONN_COMPLETE;
conn_evt.status = BLE_ERR_SUCCESS;
@@ -322,7 +322,7 @@ ble_gap_terminate_test_task_handler(void *arg)
disconn_evt.status = 0;
disconn_evt.reason = BLE_ERR_REM_USER_CONN_TERM;
ble_hs_test_util_rx_disconn_complete_event(&disconn_evt);
- TEST_ASSERT(ble_os_test_gap_event == BLE_GAP_EVENT_DISCONNECT);
+ TEST_ASSERT(ble_os_test_gap_event_type == BLE_GAP_EVENT_DISCONNECT);
TEST_ASSERT(disconn_handle == 1);
TEST_ASSERT_FATAL(!ble_os_test_misc_conn_exists(1));
TEST_ASSERT_FATAL(ble_os_test_misc_conn_exists(2));
@@ -334,7 +334,7 @@ ble_gap_terminate_test_task_handler(void *arg)
disconn_evt.status = 0;
disconn_evt.reason = BLE_ERR_REM_USER_CONN_TERM;
ble_hs_test_util_rx_disconn_complete_event(&disconn_evt);
- TEST_ASSERT(ble_os_test_gap_event == BLE_GAP_EVENT_DISCONNECT);
+ TEST_ASSERT(ble_os_test_gap_event_type == BLE_GAP_EVENT_DISCONNECT);
TEST_ASSERT(disconn_handle == 2);
TEST_ASSERT_FATAL(!ble_os_test_misc_conn_exists(1));
TEST_ASSERT_FATAL(!ble_os_test_misc_conn_exists(2));
@@ -382,7 +382,7 @@ TEST_CASE(ble_gap_terminate_test_case)
TEST_SUITE(ble_os_test_suite)
{
- ble_gap_gen_disc_test_case();
+ ble_os_disc_test_case();
ble_gap_direct_connect_test_case();
ble_gap_terminate_test_case();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_sm_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_sm_test_util.c b/net/nimble/host/src/test/ble_sm_test_util.c
index 524e8f1..57080dd 100644
--- a/net/nimble/host/src/test/ble_sm_test_util.c
+++ b/net/nimble/host/src/test/ble_sm_test_util.c
@@ -30,7 +30,7 @@
#include "ble_hs_test_util.h"
#include "ble_sm_test_util.h"
-int ble_sm_test_gap_event;
+int ble_sm_test_gap_event_type;
int ble_sm_test_gap_status;
struct ble_gap_sec_state ble_sm_test_sec_state;
@@ -103,7 +103,7 @@ ble_sm_test_util_init(void)
ble_hs_cfg.store_write_cb = ble_sm_test_util_store_write;
ble_sm_test_store_obj_type = -1;
- ble_sm_test_gap_event = -1;
+ ble_sm_test_gap_event_type = -1;
ble_sm_test_gap_status = -1;
memset(&ble_sm_test_sec_state, 0xff, sizeof ble_sm_test_sec_state);
@@ -261,29 +261,29 @@ ble_sm_test_util_init_good(struct ble_sm_test_params *params,
}
}
-struct ble_gap_passkey_action ble_sm_test_ioact;
+struct ble_gap_passkey_params ble_sm_test_ioact;
int
-ble_sm_test_util_conn_cb(int event, struct ble_gap_event_ctxt *ctxt, void *arg)
+ble_sm_test_util_conn_cb(struct ble_gap_event *event, void *arg)
{
int rc;
- switch (event) {
+ switch (event->type) {
case BLE_GAP_EVENT_ENC_CHANGE:
- ble_sm_test_gap_status = ctxt->enc_change.status;
- ble_sm_test_sec_state = ctxt->desc->sec_state;
+ ble_sm_test_gap_status = event->enc_change.status;
+ ble_sm_test_sec_state = event->enc_change.conn.sec_state;
rc = 0;
break;
case BLE_GAP_EVENT_PASSKEY_ACTION:
- ble_sm_test_ioact = ctxt->passkey_action;
+ ble_sm_test_ioact = event->passkey.params;
break;
default:
return 0;
}
- ble_sm_test_gap_event = event;
+ ble_sm_test_gap_event_type = event->type;
return rc;
}
@@ -1260,7 +1260,7 @@ ble_sm_test_util_peer_bonding_good(int send_enc_req,
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated ==
@@ -1383,7 +1383,7 @@ ble_sm_test_util_us_bonding_good(int send_enc_req, uint8_t our_addr_type,
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated ==
@@ -1442,7 +1442,7 @@ ble_sm_test_util_peer_fail_inval(
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was not executed. */
- TEST_ASSERT(ble_sm_test_gap_event == -1);
+ TEST_ASSERT(ble_sm_test_gap_event_type == -1);
TEST_ASSERT(ble_sm_test_gap_status == -1);
/* Verify that connection has correct security state. */
@@ -1519,7 +1519,7 @@ ble_sm_test_util_peer_lgcy_fail_confirm(
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status ==
BLE_HS_SM_US_ERR(BLE_SM_ERR_CONFIRM_MISMATCH));
TEST_ASSERT(!ble_sm_test_sec_state.encrypted);
@@ -1779,7 +1779,7 @@ ble_sm_test_util_us_lgcy_good_once(struct ble_sm_test_params *params)
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated == params->authenticated);
@@ -1905,7 +1905,7 @@ ble_sm_test_util_peer_lgcy_good_once(struct ble_sm_test_params *params)
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated ==
@@ -2090,7 +2090,7 @@ ble_sm_test_util_us_sc_good_once(struct ble_sm_test_params *params)
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated ==
@@ -2278,7 +2278,7 @@ ble_sm_test_util_peer_sc_good_once(struct ble_sm_test_params *params)
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was executed. */
- TEST_ASSERT(ble_sm_test_gap_event == BLE_GAP_EVENT_ENC_CHANGE);
+ TEST_ASSERT(ble_sm_test_gap_event_type == BLE_GAP_EVENT_ENC_CHANGE);
TEST_ASSERT(ble_sm_test_gap_status == 0);
TEST_ASSERT(ble_sm_test_sec_state.encrypted);
TEST_ASSERT(ble_sm_test_sec_state.authenticated ==
@@ -2376,7 +2376,7 @@ ble_sm_test_util_us_fail_inval(struct ble_sm_test_params *params)
TEST_ASSERT(ble_sm_dbg_num_procs() == 0);
/* Verify that security callback was not executed. */
- TEST_ASSERT(ble_sm_test_gap_event == -1);
+ TEST_ASSERT(ble_sm_test_gap_event_type == -1);
TEST_ASSERT(ble_sm_test_gap_status == -1);
/* Verify that connection has correct security state. */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27445b80/net/nimble/host/src/test/ble_sm_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_sm_test_util.h b/net/nimble/host/src/test/ble_sm_test_util.h
index 099ed28..3323be6 100644
--- a/net/nimble/host/src/test/ble_sm_test_util.h
+++ b/net/nimble/host/src/test/ble_sm_test_util.h
@@ -78,8 +78,7 @@ extern union ble_store_key ble_sm_test_store_key;
extern union ble_store_value ble_sm_test_store_value;
void ble_sm_test_util_init(void);
-int ble_sm_test_util_conn_cb(int event, struct ble_gap_event_ctxt *ctxt,
- void *arg);
+int ble_sm_test_util_conn_cb(struct ble_gap_event *ctxt, void *arg);
void ble_sm_test_util_io_inject(struct ble_sm_test_passkey_info *passkey_info,
uint8_t cur_sm_state);
void ble_sm_test_util_io_inject_bad(uint16_t conn_handle,