summaryrefslogtreecommitdiff
path: root/net/nimble/host/include/host
diff options
context:
space:
mode:
Diffstat (limited to 'net/nimble/host/include/host')
-rw-r--r--net/nimble/host/include/host/ble_att.h49
-rw-r--r--net/nimble/host/include/host/ble_gap.h448
-rw-r--r--net/nimble/host/include/host/ble_gatt.h428
-rw-r--r--net/nimble/host/include/host/ble_hs.h93
-rw-r--r--net/nimble/host/include/host/ble_hs_adv.h21
-rw-r--r--net/nimble/host/include/host/ble_hs_id.h30
-rw-r--r--net/nimble/host/include/host/ble_hs_log.h39
-rw-r--r--net/nimble/host/include/host/ble_hs_mbuf.h31
-rw-r--r--net/nimble/host/include/host/ble_hs_test.h11
-rw-r--r--net/nimble/host/include/host/ble_ibeacon.h25
-rw-r--r--net/nimble/host/include/host/ble_store.h72
-rw-r--r--net/nimble/host/include/host/ble_uuid.h4
-rw-r--r--net/nimble/host/include/host/host_hci.h133
13 files changed, 964 insertions, 420 deletions
diff --git a/net/nimble/host/include/host/ble_att.h b/net/nimble/host/include/host/ble_att.h
index 53b4e19f..24b44961 100644
--- a/net/nimble/host/include/host/ble_att.h
+++ b/net/nimble/host/include/host/ble_att.h
@@ -21,6 +21,7 @@
#define H_BLE_ATT_
#include "os/queue.h"
+struct os_mbuf;
#define BLE_ATT_UUID_PRIMARY_SERVICE 0x2800
#define BLE_ATT_UUID_SECONDARY_SERVICE 0x2801
@@ -31,14 +32,17 @@
#define BLE_ATT_ERR_READ_NOT_PERMITTED 0x02
#define BLE_ATT_ERR_WRITE_NOT_PERMITTED 0x03
#define BLE_ATT_ERR_INVALID_PDU 0x04
-#define BLE_ATT_ERR_INSUFFICIENT_AUTHENT 0x05
+#define BLE_ATT_ERR_INSUFFICIENT_AUTHEN 0x05
#define BLE_ATT_ERR_REQ_NOT_SUPPORTED 0x06
#define BLE_ATT_ERR_INVALID_OFFSET 0x07
+#define BLE_ATT_ERR_INSUFFICIENT_AUTHOR 0x08
#define BLE_ATT_ERR_PREPARE_QUEUE_FULL 0x09
#define BLE_ATT_ERR_ATTR_NOT_FOUND 0x0a
#define BLE_ATT_ERR_ATTR_NOT_LONG 0x0b
+#define BLE_ATT_ERR_INSUFFICIENT_KEY_SZ 0x0c
#define BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN 0x0d
#define BLE_ATT_ERR_UNLIKELY 0x0e
+#define BLE_ATT_ERR_INSUFFICIENT_ENC 0x0f
#define BLE_ATT_ERR_UNSUPPORTED_GROUP 0x10
#define BLE_ATT_ERR_INSUFFICIENT_RES 0x11
@@ -86,44 +90,15 @@
#define BLE_ATT_ACCESS_OP_READ 1
#define BLE_ATT_ACCESS_OP_WRITE 2
-struct ble_att_svr_access_ctxt {
- void *attr_data;
- uint16_t data_len;
- uint16_t offset; /* Only used for read-blob requests. */
-};
+#define BLE_ATT_MTU_DFLT 23 /* Also the minimum. */
+#define BLE_ATT_MTU_MAX 240
+#define BLE_ATT_MTU_PREFERRED_DFLT 240
-/**
- * Handles a host attribute request.
- *
- * @param entry The host attribute being requested.
- * @param op The operation being performed on the attribute.
- * @param arg The request data associated with that host
- * attribute.
- *
- * @return 0 on success;
- * One of the BLE_ATT_ERR_[...] codes on
- * failure.
- */
-typedef int ble_att_svr_access_fn(uint16_t conn_handle, uint16_t attr_handle,
- uint8_t *uuid128, uint8_t op,
- struct ble_att_svr_access_ctxt *ctxt,
- void *arg);
-
-int ble_att_svr_register(uint8_t *uuid, uint8_t flags, uint16_t *handle_id,
- ble_att_svr_access_fn *cb, void *cb_arg);
-int ble_att_svr_register_uuid16(uint16_t uuid16, uint8_t flags,
- uint16_t *handle_id, ble_att_svr_access_fn *cb,
- void *cb_arg);
-
-typedef int ble_att_svr_notify_fn(uint16_t conn_handle, uint16_t attr_handle,
- uint8_t *attr_val, uint16_t attr_len,
- void *arg);
-
-int ble_att_svr_read_local(uint16_t attr_handle, void **out_data,
- uint16_t *out_attr_len);
-int ble_att_svr_write_local(uint16_t attr_handle, void *data,
- uint16_t data_len);
+int ble_att_svr_read_local(uint16_t attr_handle, struct os_mbuf **out_om);
+int ble_att_svr_write_local(uint16_t attr_handle, struct os_mbuf *om);
+uint16_t ble_att_mtu(uint16_t conn_handle);
+uint16_t ble_att_preferred_mtu(void);
int ble_att_set_preferred_mtu(uint16_t mtu);
#endif
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index 23b8f462..960ad7b2 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -24,7 +24,6 @@
#include "host/ble_hs.h"
struct hci_le_conn_complete;
struct hci_conn_update;
-struct hci_adv_params;
/** 30 ms. */
#define BLE_GAP_ADV_FAST_INTERVAL1_MIN (30 * 1000 / BLE_HCI_ADV_ITVL)
@@ -44,6 +43,12 @@ struct hci_adv_params;
/** 60 ms; active scanning. */
#define BLE_GAP_SCAN_FAST_INTERVAL_MAX (60 * 1000 / BLE_HCI_ADV_ITVL)
+/** 11.25 ms; limited discovery interval. */
+#define BLE_GAP_LIM_DISC_SCAN_INT (11.25 * 1000 / BLE_HCI_SCAN_ITVL)
+
+/** 11.25 ms; limited discovery window (not from the spec). */
+#define BLE_GAP_LIM_DISC_SCAN_WINDOW (11.25 * 1000 / BLE_HCI_SCAN_ITVL)
+
/** 30 ms; active scanning. */
#define BLE_GAP_SCAN_FAST_WINDOW (30 * 1000 / BLE_HCI_SCAN_ITVL)
@@ -57,7 +62,10 @@ struct hci_adv_params;
#define BLE_GAP_SCAN_SLOW_WINDOW1 (11.25 * 1000 / BLE_HCI_SCAN_ITVL)
/** 10.24 seconds. */
-#define BLE_GAP_GEN_DISC_SCAN_MIN (10.24 * 1000)
+#define BLE_GAP_DISC_DUR_DFLT (10.24 * 1000)
+
+/** 30 seconds (not from the spec). */
+#define BLE_GAP_CONN_DUR_DFLT (30 * 1000)
/** 1 second. */
#define BLE_GAP_CONN_PAUSE_CENTRAL (1 * 1000)
@@ -71,21 +79,18 @@ struct hci_adv_params;
/* 50 ms. */
#define BLE_GAP_INITIAL_CONN_ITVL_MAX (50 * 1000 / BLE_HCI_CONN_ITVL)
+#define BLE_GAP_ADV_DFLT_CHANNEL_MAP 0x07 /* All three channels. */
+
#define BLE_GAP_INITIAL_CONN_LATENCY 0
#define BLE_GAP_INITIAL_SUPERVISION_TIMEOUT 0x0100
#define BLE_GAP_INITIAL_CONN_MIN_CE_LEN 0x0010
#define BLE_GAP_INITIAL_CONN_MAX_CE_LEN 0x0300
-#define BLE_GAP_SVC_UUID16 0x1800
-#define BLE_GAP_CHR_UUID16_DEVICE_NAME 0x2a00
-#define BLE_GAP_CHR_UUID16_APPEARANCE 0x2a01
-#define BLE_GAP_CHR_UUID16_PERIPH_PRIV_FLAG 0x2a02
-#define BLE_GAP_CHR_UUID16_RECONNECT_ADDR 0x2a03
-#define BLE_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS 0x2a04
-
-#define BLE_GAP_APPEARANCE_GEN_COMPUTER 128
-
#define BLE_GAP_ADDR_TYPE_WL 0xff
+#define BLE_GAP_ADDR_TYPE_NONE 0xfe
+
+#define BLE_GAP_ROLE_MASTER 0
+#define BLE_GAP_ROLE_SLAVE 1
#define BLE_GAP_EVENT_CONNECT 0
#define BLE_GAP_EVENT_DISCONNECT 1
@@ -94,12 +99,29 @@ struct hci_adv_params;
#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
#define BLE_GAP_EVENT_PASSKEY_ACTION 11
-#define BLE_GAP_EVENT_NOTIFY 12
+#define BLE_GAP_EVENT_NOTIFY_RX 12
+#define BLE_GAP_EVENT_NOTIFY_TX 13
+#define BLE_GAP_EVENT_SUBSCRIBE 14
+#define BLE_GAP_EVENT_MTU 15
+
+/*** Reason codes for the subscribe GAP event. */
+
+/** Peer's CCCD subscription state changed due to a descriptor write. */
+#define BLE_GAP_SUBSCRIBE_REASON_WRITE 1
+
+/** Peer's CCCD subscription state cleared due to connection termination. */
+#define BLE_GAP_SUBSCRIBE_REASON_TERM 2
+
+/**
+ * Peer's CCCD subscription state changed due to restore from persistence
+ * (bonding restored).
+ */
+#define BLE_GAP_SUBSCRIBE_REASON_RESTORE 3
struct ble_gap_sec_state {
unsigned encrypted:1;
@@ -107,13 +129,33 @@ struct ble_gap_sec_state {
unsigned bonded:1;
};
+/**
+ * @param discoverable_mode One of the following constants:
+ * o BLE_GAP_DISC_MODE_NON
+ * (non-discoverable; 3.C.9.2.2).
+ * o BLE_GAP_DISC_MODE_LTD
+ * (limited-discoverable; 3.C.9.2.3).
+ * o BLE_GAP_DISC_MODE_GEN
+ * (general-discoverable; 3.C.9.2.4).
+ * @param connectable_mode One of the following constants:
+ * o BLE_GAP_CONN_MODE_NON
+ * (non-connectable; 3.C.9.3.2).
+ * o BLE_GAP_CONN_MODE_DIR
+ * (directed-connectable; 3.C.9.3.3).
+ * o BLE_GAP_CONN_MODE_UND
+ * (undirected-connectable; 3.C.9.3.4).
+ */
struct ble_gap_adv_params {
- uint8_t adv_type;
- uint8_t adv_channel_map;
- uint8_t own_addr_type;
- uint8_t adv_filter_policy;
- uint16_t adv_itvl_min;
- uint16_t adv_itvl_max;
+ /*** Mandatory fields. */
+ uint8_t conn_mode;
+ uint8_t disc_mode;
+
+ /*** Optional fields; assign 0 to make the stack calculate them. */
+ uint16_t itvl_min;
+ uint16_t itvl_max;
+ uint8_t channel_map;
+ uint8_t filter_policy;
+ uint8_t high_duty_cycle:1;
};
struct ble_gap_conn_desc {
@@ -130,12 +172,13 @@ struct ble_gap_conn_desc {
uint8_t peer_id_addr_type;
uint8_t our_id_addr_type;
uint8_t our_ota_addr_type;
+ uint8_t role;
+ uint8_t master_clock_accuracy;
};
-struct ble_gap_crt_params {
- uint16_t scan_window;
+struct ble_gap_conn_params {
uint16_t scan_itvl;
- uint8_t our_addr_type;
+ uint16_t scan_window;
uint16_t itvl_min;
uint16_t itvl_max;
uint16_t latency;
@@ -144,6 +187,15 @@ struct ble_gap_crt_params {
uint16_t max_ce_len;
};
+struct ble_gap_disc_params {
+ uint16_t itvl;
+ uint16_t window;
+ uint8_t filter_policy;
+ uint8_t limited:1;
+ uint8_t passive:1;
+ uint8_t filter_duplicates:1;
+};
+
struct ble_gap_upd_params {
uint16_t itvl_min;
uint16_t itvl_max;
@@ -153,85 +205,315 @@ 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_enhanced_conn {
- uint8_t peer_rpa[6];
- uint8_t local_rpa[6];
-};
-
-struct ble_gap_passkey_action {
+struct ble_gap_passkey_params {
uint8_t action;
uint32_t numcmp;
};
-struct ble_gap_conn_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;
- struct ble_gap_enhanced_conn *enhanced_conn;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
} 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 connection prior to termination. */
+ 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. If the
+ * attempt was successful, the connection's descriptor reflects the
+ * updated 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;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
} 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
+ *
+ * To reject the request, return a non-zero HCI error code. The value
+ * returned is the reject reason given to the controller.
+ *
+ * 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;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
} 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;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
} term_failure;
+ /**
+ * Represents an attempt to change the encrypted state of a
+ * connection. If the attempt was successful, the connection
+ * descriptor reflects the updated encrypted state.
+ *
+ * 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;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
} enc_change;
- struct ble_gap_passkey_action passkey_action;
+ /**
+ * 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;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
+ } passkey;
+
+ /**
+ * Represents a received ATT notification or indication.
+ *
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_NOTIFY_RX
+ */
+ struct {
+ /**
+ * The contents of the notification or indication. If the
+ * application wishes to retain this mbuf for later use, it must
+ * set this pointer to NULL to prevent the stack from freeing it.
+ */
+ struct os_mbuf *om;
+
+ /** The handle of the relevant ATT attribute. */
+ uint16_t attr_handle;
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
+
+ /**
+ * Whether the received command is a notification or an
+ * indication;
+ * o 0: Notification;
+ * o 1: Indication.
+ */
+ uint8_t indication:1;
+ } notify_rx;
+
+ /**
+ * Represents a transmitted ATT notification or indication, or a
+ * completed indication transaction.
+ *
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_NOTIFY_TX
+ */
struct {
+ /**
+ * The status of the notification or indication transaction;
+ * o 0: Command successfully sent;
+ * o BLE_HS_EDONE: Confirmation (indication ack) received;
+ * o BLE_HS_ETIMEOUT: Confirmation (indication ack) never
+ * received;
+ * o Other return code: Error.
+ */
+ int status;
+
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
+
+ /** The handle of the relevant characterstic value. */
uint16_t attr_handle;
- void *attr_data;
- uint16_t attr_len;
- unsigned indication:1;
- } notify;
+ /**
+ * Whether the transmitted command is a notification or an
+ * indication;
+ * o 0: Notification;
+ * o 1: Indication.
+ */
+ uint8_t indication:1;
+ } notify_tx;
+
+ /**
+ * Represents a state change in a peer's subscription status. In this
+ * comment, the term "update" is used to refer to either a notification
+ * or an indication. This event is triggered by any of the following
+ * occurrences:
+ * o Peer enables or disables updates via a CCCD write.
+ * o Connection is about to be terminated and the peer is
+ * subscribed to updates.
+ * o Peer is now subscribed to updates after its state was restored
+ * from persistence. This happens when bonding is restored.
+ *
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_SUBSCRIBE
+ */
+ struct {
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
- struct ble_gap_ltk_params *ltk_params;
- };
-};
+ /** The value handle of the relevant characteristic. */
+ uint16_t attr_handle;
-typedef int ble_gap_event_fn(int event, struct ble_gap_conn_ctxt *ctxt,
- void *arg);
+ /** One of the BLE_GAP_SUBSCRIBE_REASON codes. */
+ uint8_t reason;
-struct ble_gap_disc_desc {
- uint8_t event_type;
- uint8_t addr_type;
- uint8_t length_data;
- int8_t rssi;
- uint8_t addr[6];
- uint8_t *data;
- struct ble_hs_adv_fields *fields;
-};
+ /** Whether the peer was previously subscribed to notifications. */
+ uint8_t prev_notify:1;
+
+ /** Whether the peer is currently subscribed to notifications. */
+ uint8_t cur_notify:1;
-typedef void ble_gap_disc_fn(int event, int status,
- struct ble_gap_disc_desc *desc, void *arg);
+ /** Whether the peer was previously subscribed to indications. */
+ uint8_t prev_indicate:1;
-typedef void ble_gap_wl_fn(int status, void *arg);
+ /** Whether the peer is currently subscribed to indications. */
+ uint8_t cur_indicate:1;
+ } subscribe;
+
+ /**
+ * Represents a change in an L2CAP channel's MTU.
+ *
+ * Valid for the following event types:
+ * o BLE_GAP_EVENT_MTU
+ */
+ struct {
+ /** The handle of the relevant connection. */
+ uint16_t conn_handle;
+
+ /**
+ * Indicates the channel whose MTU has been updated; either
+ * BLE_L2CAP_CID_ATT or the ID of a connection-oriented channel.
+ */
+ uint16_t channel_id;
+
+ /* The channel's new MTU. */
+ uint16_t value;
+ } mtu;
+ };
+};
+
+typedef int ble_gap_event_fn(struct ble_gap_event *event, void *arg);
#define BLE_GAP_CONN_MODE_NON 0
#define BLE_GAP_CONN_MODE_DIR 1
@@ -246,35 +528,37 @@ struct ble_gap_white_entry {
uint8_t addr[6];
};
-int ble_gap_find_conn(uint16_t handle, struct ble_gap_conn_desc *out_desc);
+int ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc);
-int ble_gap_adv_start(uint8_t discoverable_mode, uint8_t connectable_mode,
- uint8_t *peer_addr, uint8_t peer_addr_type,
+int ble_gap_adv_start(uint8_t own_addr_type, uint8_t peer_addr_type,
+ const uint8_t *peer_addr, int32_t duration_ms,
const struct ble_gap_adv_params *adv_params,
ble_gap_event_fn *cb, void *cb_arg);
-
int ble_gap_adv_stop(void);
-int ble_gap_adv_set_fields(struct ble_hs_adv_fields *adv_fields);
-int ble_gap_adv_rsp_set_fields(struct ble_hs_adv_fields *rsp_fields);
-int ble_gap_disc(uint32_t duration_ms, uint8_t discovery_mode,
- uint8_t scan_type, uint8_t filter_policy,
- uint8_t addr_mode,
- ble_gap_disc_fn *cb, void *cb_arg);
+int ble_gap_adv_active(void);
+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_event_fn *cb, void *cb_arg);
int ble_gap_disc_cancel(void);
-int ble_gap_conn_initiate(int addr_type, uint8_t *addr,
- struct ble_gap_crt_params *params,
- ble_gap_event_fn *cb, void *cb_arg);
-int ble_gap_terminate(uint16_t handle);
-int ble_gap_cancel(void);
-int ble_gap_wl_set(struct ble_gap_white_entry *white_list,
+int ble_gap_disc_active(void);
+int ble_gap_connect(uint8_t own_addr_type,
+ uint8_t peer_addr_type, const uint8_t *peer_addr,
+ int32_t duration_ms,
+ const struct ble_gap_conn_params *params,
+ ble_gap_event_fn *cb, void *cb_arg);
+int ble_gap_conn_cancel(void);
+int ble_gap_conn_active(void);
+int ble_gap_terminate(uint16_t conn_handle, uint8_t hci_reason);
+int ble_gap_wl_set(const struct ble_gap_white_entry *white_list,
uint8_t white_list_count);
int ble_gap_update_params(uint16_t conn_handle,
- struct ble_gap_upd_params *params);
+ const struct ble_gap_upd_params *params);
int ble_gap_security_initiate(uint16_t conn_handle);
int ble_gap_pair_initiate(uint16_t conn_handle);
-int ble_gap_encryption_initiate(uint16_t conn_handle, uint8_t *ltk,
+int ble_gap_encryption_initiate(uint16_t conn_handle, const uint8_t *ltk,
uint16_t ediv, uint64_t rand_val, int auth);
-int ble_gap_provide_ltk(uint16_t conn_handle, uint8_t *ltk);
-void ble_gap_init_identity_addr(uint8_t *addr);
+int ble_gap_conn_rssi(uint16_t conn_handle, int8_t *out_rssi);
#endif
diff --git a/net/nimble/host/include/host/ble_gatt.h b/net/nimble/host/include/host/ble_gatt.h
index 194ebf31..fbc32a2f 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -24,9 +24,48 @@
#include "host/ble_att.h"
struct ble_hs_conn;
struct ble_att_error_rsp;
+struct ble_hs_cfg;
+
+#define BLE_GATT_REGISTER_OP_SVC 1
+#define BLE_GATT_REGISTER_OP_CHR 2
+#define BLE_GATT_REGISTER_OP_DSC 3
#define BLE_GATT_SVC_UUID16 0x1801
-#define BLE_GATT_CHR_SERVICE_CHANGED_UUID16 0x2a05
+#define BLE_GATT_DSC_CLT_CFG_UUID16 0x2902
+
+#define BLE_GATT_CHR_PROP_BROADCAST 0x01
+#define BLE_GATT_CHR_PROP_READ 0x02
+#define BLE_GATT_CHR_PROP_WRITE_NO_RSP 0x04
+#define BLE_GATT_CHR_PROP_WRITE 0x08
+#define BLE_GATT_CHR_PROP_NOTIFY 0x10
+#define BLE_GATT_CHR_PROP_INDICATE 0x20
+#define BLE_GATT_CHR_PROP_AUTH_SIGN_WRITE 0x40
+#define BLE_GATT_CHR_PROP_EXTENDED 0x80
+
+#define BLE_GATT_ACCESS_OP_READ_CHR 0
+#define BLE_GATT_ACCESS_OP_WRITE_CHR 1
+#define BLE_GATT_ACCESS_OP_READ_DSC 2
+#define BLE_GATT_ACCESS_OP_WRITE_DSC 3
+
+#define BLE_GATT_CHR_F_BROADCAST 0x0001
+#define BLE_GATT_CHR_F_READ 0x0002
+#define BLE_GATT_CHR_F_WRITE_NO_RSP 0x0004
+#define BLE_GATT_CHR_F_WRITE 0x0008
+#define BLE_GATT_CHR_F_NOTIFY 0x0010
+#define BLE_GATT_CHR_F_INDICATE 0x0020
+#define BLE_GATT_CHR_F_AUTH_SIGN_WRITE 0x0040
+#define BLE_GATT_CHR_F_RELIABLE_WRITE 0x0080
+#define BLE_GATT_CHR_F_AUX_WRITE 0x0100
+#define BLE_GATT_CHR_F_READ_ENC 0x0200
+#define BLE_GATT_CHR_F_READ_AUTHEN 0x0400
+#define BLE_GATT_CHR_F_READ_AUTHOR 0x0800
+#define BLE_GATT_CHR_F_WRITE_ENC 0x1000
+#define BLE_GATT_CHR_F_WRITE_AUTHEN 0x2000
+#define BLE_GATT_CHR_F_WRITE_AUTHOR 0x4000
+
+#define BLE_GATT_SVC_TYPE_END 0
+#define BLE_GATT_SVC_TYPE_PRIMARY 1
+#define BLE_GATT_SVC_TYPE_SECONDARY 2
/*** @client. */
struct ble_gatt_error {
@@ -43,8 +82,7 @@ struct ble_gatt_svc {
struct ble_gatt_attr {
uint16_t handle;
uint16_t offset;
- uint16_t value_len;
- void *value;
+ struct os_mbuf *om;
};
struct ble_gatt_chr {
@@ -59,32 +97,49 @@ struct ble_gatt_dsc {
uint8_t uuid128[16];
};
-typedef int ble_gatt_mtu_fn(uint16_t conn_handle, struct ble_gatt_error *error,
+typedef int ble_gatt_mtu_fn(uint16_t conn_handle,
+ const struct ble_gatt_error *error,
uint16_t mtu, void *arg);
typedef int ble_gatt_disc_svc_fn(uint16_t conn_handle,
- struct ble_gatt_error *error,
- struct ble_gatt_svc *service,
+ const struct ble_gatt_error *error,
+ const struct ble_gatt_svc *service,
void *arg);
+
+/**
+ * The host will free the attribute mbuf automatically after the callback is
+ * executed. The application can take ownership of the mbuf and prevent it
+ * from being freed by assigning NULL to attr->om.
+ */
typedef int ble_gatt_attr_fn(uint16_t conn_handle,
- struct ble_gatt_error *error,
- struct ble_gatt_attr *attr, void *arg);
+ const struct ble_gatt_error *error,
+ struct ble_gatt_attr *attr,
+ void *arg);
+
+/**
+ * The host will free the attribute mbufs automatically after the callback is
+ * executed. The application can take ownership of the mbufs and prevent them
+ * from being freed by assigning NULL to each attribute's om field.
+ */
typedef int ble_gatt_reliable_attr_fn(uint16_t conn_handle,
- struct ble_gatt_error *error,
+ const struct ble_gatt_error *error,
struct ble_gatt_attr *attrs,
uint8_t num_attrs, void *arg);
-typedef int ble_gatt_chr_fn(uint16_t conn_handle, struct ble_gatt_error *error,
- struct ble_gatt_chr *chr, void *arg);
+typedef int ble_gatt_chr_fn(uint16_t conn_handle,
+ const struct ble_gatt_error *error,
+ const struct ble_gatt_chr *chr, void *arg);
-typedef int ble_gatt_dsc_fn(uint16_t conn_handle, struct ble_gatt_error *error,
- uint16_t chr_def_handle, struct ble_gatt_dsc *dsc,
+typedef int ble_gatt_dsc_fn(uint16_t conn_handle,
+ const struct ble_gatt_error *error,
+ uint16_t chr_def_handle,
+ const struct ble_gatt_dsc *dsc,
void *arg);
int ble_gattc_exchange_mtu(uint16_t conn_handle,
ble_gatt_mtu_fn *cb, void *cb_arg);
int ble_gattc_disc_all_svcs(uint16_t conn_handle,
ble_gatt_disc_svc_fn *cb, void *cb_arg);
-int ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, void *service_uuid128,
+int ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, const void *svc_uuid128,
ble_gatt_disc_svc_fn *cb, void *cb_arg);
int ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
uint16_t end_handle,
@@ -93,7 +148,7 @@ int ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
uint16_t end_handle, ble_gatt_chr_fn *cb,
void *cb_arg);
int ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
- uint16_t end_handle, void *uuid128,
+ uint16_t end_handle, const void *uuid128,
ble_gatt_chr_fn *cb, void *cb_arg);
int ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle,
uint16_t chr_end_handle,
@@ -101,150 +156,295 @@ int ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle,
int ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle,
ble_gatt_attr_fn *cb, void *cb_arg);
int ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
- uint16_t end_handle, void *uuid128,
+ uint16_t end_handle, const void *uuid128,
ble_gatt_attr_fn *cb, void *cb_arg);
int ble_gattc_read_long(uint16_t conn_handle, uint16_t handle,
ble_gatt_attr_fn *cb, void *cb_arg);
-int ble_gattc_read_mult(uint16_t conn_handle, uint16_t *handles,
+int ble_gattc_read_mult(uint16_t conn_handle, const uint16_t *handles,
uint8_t num_handles, ble_gatt_attr_fn *cb,
void *cb_arg);
int ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
- void *value, uint16_t value_len);
-int ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
- uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg);
+ struct os_mbuf *om);
+int ble_gattc_write_no_rsp_flat(uint16_t conn_handle, uint16_t attr_handle,
+ const void *data, uint16_t data_len);
+int ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle,
+ struct os_mbuf *om,
+ ble_gatt_attr_fn *cb, void *cb_arg);
+int ble_gattc_write_flat(uint16_t conn_handle, uint16_t attr_handle,
+ const void *data, uint16_t data_len,
+ ble_gatt_attr_fn *cb, void *cb_arg);
int ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle,
- void *value, uint16_t value_len, ble_gatt_attr_fn *cb,
- void *cb_arg);
-int ble_gattc_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
+ struct os_mbuf *om,
+ ble_gatt_attr_fn *cb, void *cb_arg);
+int ble_gattc_write_reliable(uint16_t conn_handle,
+ struct ble_gatt_attr *attrs,
int num_attrs, ble_gatt_reliable_attr_fn *cb,
void *cb_arg);
-int ble_gattc_read_dsc(uint16_t conn_handle, uint16_t attr_handle,
- ble_gatt_attr_fn *cb, void *cb_arg);
-int ble_gattc_read_long_dsc(uint16_t conn_handle, uint16_t attr_handle,
- ble_gatt_attr_fn *cb, void *cb_arg);
-int ble_gattc_write_dsc(uint16_t conn_handle, uint16_t attr_handle,
- void *value, uint16_t value_len,
- ble_gatt_attr_fn *cb, void *cb_arg);
-int ble_gattc_write_long_dsc(uint16_t conn_handle, uint16_t attr_handle,
- void *value, uint16_t value_len,
- ble_gatt_attr_fn *cb, void *cb_arg);
-int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
- void *attr_data, uint16_t attr_data_len);
+ struct os_mbuf *om);
+int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
+int ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle);
int ble_gattc_init(void);
/*** @server. */
-#define BLE_GATT_CHR_PROP_BROADCAST 0x01
-#define BLE_GATT_CHR_PROP_READ 0x02
-#define BLE_GATT_CHR_PROP_WRITE_NO_RSP 0x04
-#define BLE_GATT_CHR_PROP_WRITE 0x08
-#define BLE_GATT_CHR_PROP_NOTIFY 0x10
-#define BLE_GATT_CHR_PROP_INDICATE 0x20
-#define BLE_GATT_CHR_PROP_AUTH_SIGN_WRITE 0x40
-#define BLE_GATT_CHR_PROP_EXTENDED 0x80
-
-#define BLE_GATT_ACCESS_OP_READ_CHR 0
-#define BLE_GATT_ACCESS_OP_WRITE_CHR 1
-#define BLE_GATT_ACCESS_OP_READ_DSC 2
-#define BLE_GATT_ACCESS_OP_WRITE_DSC 3
-
-union ble_gatt_access_ctxt;
+struct ble_gatt_access_ctxt;
typedef int ble_gatt_access_fn(uint16_t conn_handle, uint16_t attr_handle,
- uint8_t op, union ble_gatt_access_ctxt *ctxt,
- void *arg);
+ struct ble_gatt_access_ctxt *ctxt, void *arg);
typedef uint16_t ble_gatt_chr_flags;
-#define BLE_GATT_CHR_F_BROADCAST 0x0001
-#define BLE_GATT_CHR_F_READ 0x0002
-#define BLE_GATT_CHR_F_WRITE_NO_RSP 0x0004
-#define BLE_GATT_CHR_F_WRITE 0x0008
-#define BLE_GATT_CHR_F_NOTIFY 0x0010
-#define BLE_GATT_CHR_F_INDICATE 0x0020
-#define BLE_GATT_CHR_F_AUTH_SIGN_WRITE 0x0040
-#define BLE_GATT_CHR_F_RELIABLE_WRITE 0x0080
-#define BLE_GATT_CHR_F_AUX_WRITE 0x0100
-#define BLE_GATT_CHR_F_READ_ENC 0x0200
-#define BLE_GATT_CHR_F_READ_AUTHEN 0x0400
-#define BLE_GATT_CHR_F_READ_AUTHOR 0x0800
-#define BLE_GATT_CHR_F_WRITE_ENC 0x1000
-#define BLE_GATT_CHR_F_WRITE_AUTHEN 0x2000
-#define BLE_GATT_CHR_F_WRITE_AUTHOR 0x4000
-
struct ble_gatt_chr_def {
- uint8_t *uuid128; /* NULL if no more characteristics. */
+ /**
+ * Pointer to first element in a uint8_t[16]; use the BLE_UUID16 macro for
+ * 16-bit UUIDs; NULL if there are no more characteristics in the service.
+ */
+ const uint8_t *uuid128;
+
+ /**
+ * Callback that gets executed when this characteristic is read or
+ * written.
+ */
ble_gatt_access_fn *access_cb;
+
+ /** Optional argument for callback. */
void *arg;
+
+ /**
+ * Array of this characteristic's descriptors. NULL if no descriptors.
+ * Do not include CCCD; it gets added automatically if this
+ * characteristic's notify or indicate flag is set.
+ */
struct ble_gatt_dsc_def *descriptors;
+
+ /** Specifies the set of permitted operations for this characteristic. */
ble_gatt_chr_flags flags;
-};
-#define BLE_GATT_SVC_TYPE_END 0
-#define BLE_GATT_SVC_TYPE_PRIMARY 1
-#define BLE_GATT_SVC_TYPE_SECONDARY 2
+ /**
+ * At registration time, this is filled in with the characteristic's value
+ * attribute handle.
+ */
+ uint16_t * const val_handle;
+};
struct ble_gatt_svc_def {
+ /**
+ * One of the following:
+ * o BLE_GATT_SVC_TYPE_PRIMARY - primary service
+ * o BLE_GATT_SVC_TYPE_SECONDARY - secondary service
+ * o 0 - No more services in this array.
+ */
uint8_t type;
- uint8_t *uuid128;
- const struct ble_gatt_svc_def **includes; /* Terminated with null. */
- struct ble_gatt_chr_def *characteristics;
-};
-
-union ble_gatt_access_ctxt {
- struct {
- const struct ble_gatt_chr_def *chr;
- void *data;
- int len;
- } chr_access;
- struct {
- const struct ble_gatt_dsc_def *dsc;
- void *data;
- int len;
- } dsc_access;
+ /**
+ * Pointer to first element in a uint8_t[16]; use the BLE_UUID16 macro for
+ * 16-bit UUIDs.
+ */
+ const uint8_t *uuid128;
+
+ /**
+ * Array of pointers to other service definitions. These services are
+ * reported as "included services" during service discovery. Terminate the
+ * array with NULL.
+ */
+ const struct ble_gatt_svc_def **includes;
+
+ /**
+ * Array of characteristic definitions corresponding to characteristics
+ * belonging to this service.
+ */
+ const struct ble_gatt_chr_def *characteristics;
};
struct ble_gatt_dsc_def {
+ /**
+ * The first element in a uint8_t[16]; use the BLE_UUID16 macro for 16-bit
+ * UUIDs; NULL if there are no more descriptors in the characteristic.
+ */
uint8_t *uuid128;
+
+ /** Specifies the set of permitted operations for this descriptor. */
uint8_t att_flags;
+
+ /** Callback that gets executed when the descriptor is read or written. */
ble_gatt_access_fn *access_cb;
+
+ /** Optional argument for callback. */
void *arg;
};
-#define BLE_GATT_REGISTER_OP_SVC 1
-#define BLE_GATT_REGISTER_OP_CHR 2
-#define BLE_GATT_REGISTER_OP_DSC 3
+/**
+ * Context for an access to a GATT characteristic or descriptor. When a client
+ * reads or writes a locally registered characteristic or descriptor, an
+ * instance of this struct gets passed to the application callback.
+ */
+struct ble_gatt_access_ctxt {
+ /**
+ * Indicates the gatt operation being performed. This is equal to one of
+ * the following values:
+ * o BLE_GATT_ACCESS_OP_READ_CHR
+ * o BLE_GATT_ACCESS_OP_WRITE_CHR
+ * o BLE_GATT_ACCESS_OP_READ_DSC
+ * o BLE_GATT_ACCESS_OP_WRITE_DSC
+ */
+ uint8_t op;
+
+ /**
+ * A container for the GATT access data.
+ * o For reads: The application populates this with the value of the
+ * characteristic or descriptor being read.
+ * o For writes: This is already populated with the value being written
+ * by the peer. If the application wishes to retain this mbuf for
+ * later use, the access callback must set this pointer to NULL to
+ * prevent the stack from freeing it.
+ */
+ struct os_mbuf *om;
+
+ /**
+ * The GATT operation being performed dictates which field in this union is
+ * valid. If a characteristic is being accessed, the chr field is valid.
+ * Otherwise a descriptor is being accessed, in which case the dsc field
+ * is valid.
+ */
+ union {
+ /**
+ * The characteristic definition corresponding to the characteristic
+ * being accessed. This is what the app registered at startup.
+ */
+ const struct ble_gatt_chr_def *chr;
+
+ /**
+ * The descriptor definition corresponding to the descriptor being
+ * accessed. This is what the app registered at startup.
+ */
+ const struct ble_gatt_dsc_def *dsc;
+ };
+};
+
+/**
+ * Context passed to the registration callback; represents the GATT service,
+ * characteristic, or descriptor being registered.
+ */
+struct ble_gatt_register_ctxt {
+ /**
+ * Indicates the gatt registration operation just performed. This is
+ * equal to one of the following values:
+ * o BLE_GATT_REGISTER_OP_SVC
+ * o BLE_GATT_REGISTER_OP_CHR
+ * o BLE_GATT_REGISTER_OP_DSC
+ */
+ uint8_t op;
+
+ /**
+ * The value of the op field determines which field in this union is valid.
+ */
+ union {
+ /** Service; valid if op == BLE_GATT_REGISTER_OP_SVC. */
+ struct {
+ /** The ATT handle of the service definition attribute. */
+ uint16_t handle;
+
+ /**
+ * The service definition representing the service being
+ * registered.
+ */
+ const struct ble_gatt_svc_def *svc_def;
+ } svc;
+
+ /** Characteristic; valid if op == BLE_GATT_REGISTER_OP_CHR. */
+ struct {
+ /** The ATT handle of the characteristic definition attribute. */
+ uint16_t def_handle;
+
+ /** The ATT handle of the characteristic value attribute. */
+ uint16_t val_handle;
+
+ /**
+ * The characteristic definition representing the characteristic
+ * being registered.
+ */
+ const struct ble_gatt_chr_def *chr_def;
+
+ /**
+ * The service definition corresponding to the characteristic's
+ * parent service.
+ */
+ const struct ble_gatt_svc_def *svc_def;
+ } chr;
+
+ /** Descriptor; valid if op == BLE_GATT_REGISTER_OP_DSC. */
+ struct {
+ /** The ATT handle of the descriptor definition attribute. */
+ uint16_t handle;
+
+ /**
+ * The descriptor definition corresponding to the descriptor being
+ * registered.
+ */
+ const struct ble_gatt_dsc_def *dsc_def;
+
+ /**
+ * The characteristic definition corresponding to the descriptor's
+ * parent characteristic.
+ */
+ const struct ble_gatt_chr_def *chr_def;
+
+ /**
+ * The service definition corresponding to the descriptor's
+ * grandparent service
+ */
+ const struct ble_gatt_svc_def *svc_def;
+ } dsc;
+ };
+};
+
+/**
+ * Contains counts of resources required by the GATT server. The contents of
+ * this struct are generally used to populate a configuration struct before
+ * the host is initialized.
+ */
+struct ble_gatt_resources {
+ /** Number of services. */
+ uint16_t svcs;
+
+ /** Number of included services. */
+ uint16_t incs;
-union ble_gatt_register_ctxt;
-typedef void ble_gatt_register_fn(uint8_t op,
- union ble_gatt_register_ctxt *ctxt,
+ /** Number of characteristics. */
+ uint16_t chrs;
+
+ /** Number of descriptors. */
+ uint16_t dscs;
+
+ /**
+ * Number of client characteristic configuration descriptors. Each of
+ * these also contributes to the total descriptor count.
+ */
+ uint16_t cccds;
+
+ /** Total number of ATT attributes. */
+ uint16_t attrs;
+};
+
+typedef void ble_gatt_register_fn(struct ble_gatt_register_ctxt *ctxt,
void *arg);
int ble_gatts_register_svcs(const struct ble_gatt_svc_def *svcs,
ble_gatt_register_fn *register_cb,
void *cb_arg);
-void ble_gatts_chr_updated(uint16_t chr_def_handle);
+int ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs);
+int ble_gatts_count_resources(const struct ble_gatt_svc_def *svcs,
+ struct ble_gatt_resources *res);
+int ble_gatts_count_cfg(const struct ble_gatt_svc_def *defs,
+ struct ble_hs_cfg *cfg);
-union ble_gatt_register_ctxt {
- struct {
- uint16_t handle;
- const struct ble_gatt_svc_def *svc;
- } svc_reg;
-
- struct {
- uint16_t def_handle;
- uint16_t val_handle;
- const struct ble_gatt_chr_def *chr;
- } chr_reg;
+void ble_gatts_chr_updated(uint16_t chr_def_handle);
- struct {
- uint16_t dsc_handle;
- const struct ble_gatt_dsc_def *dsc;
- uint16_t chr_def_handle;
- const struct ble_gatt_chr_def *chr;
- } dsc_reg;
-};
+int ble_gatts_find_svc(const void *uuid128, uint16_t *out_handle);
+int ble_gatts_find_chr(const void *svc_uuid128, const void *chr_uuid128,
+ uint16_t *out_def_handle, uint16_t *out_val_handle);
+int ble_gatts_find_dsc(const void *svc_uuid128, const void *chr_uuid128,
+ const void *dsc_uuid128, uint16_t *out_dsc_handle);
#endif
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index e493723f..8d850097 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -21,17 +21,24 @@
#define H_BLE_HS_
#include <inttypes.h>
+#include "nimble/hci_common.h"
#include "host/ble_att.h"
#include "host/ble_gap.h"
#include "host/ble_gatt.h"
#include "host/ble_hs.h"
+#include "host/ble_hs_adv.h"
+#include "host/ble_hs_id.h"
+#include "host/ble_hs_log.h"
#include "host/ble_hs_test.h"
-#include "host/ble_uuid.h"
+#include "host/ble_hs_mbuf.h"
+#include "host/ble_sm.h"
#include "host/ble_store.h"
-#include "host/host_hci.h"
+#include "host/ble_uuid.h"
struct os_eventq;
struct os_event;
+#define BLE_HS_FOREVER INT32_MAX
+
#define BLE_HS_CONN_HANDLE_NONE 0xffff
#define BLE_HS_EAGAIN 1
@@ -45,17 +52,17 @@ struct os_event;
#define BLE_HS_EAPP 9
#define BLE_HS_EBADDATA 10
#define BLE_HS_EOS 11
-#define BLE_HS_ECONGESTED 12
-#define BLE_HS_ECONTROLLER 13
-#define BLE_HS_ETIMEOUT 14
-#define BLE_HS_EDONE 15
-#define BLE_HS_EBUSY 16
-#define BLE_HS_EREJECT 17
-#define BLE_HS_EUNKNOWN 18
-#define BLE_HS_EROLE 19
-#define BLE_HS_ETIMEOUT_HCI 20
-#define BLE_HS_ENOMEM_HCI 21
-#define BLE_HS_ENOMEM_EVT 22
+#define BLE_HS_ECONTROLLER 12
+#define BLE_HS_ETIMEOUT 13
+#define BLE_HS_EDONE 14
+#define BLE_HS_EBUSY 15
+#define BLE_HS_EREJECT 16
+#define BLE_HS_EUNKNOWN 17
+#define BLE_HS_EROLE 18
+#define BLE_HS_ETIMEOUT_HCI 19
+#define BLE_HS_ENOMEM_EVT 20
+#define BLE_HS_ENOADDR 21
+#define BLE_HS_ENOTSYNCED 22
#define BLE_HS_ERR_ATT_BASE 0x100 /* 256 */
#define BLE_HS_ATT_ERR(x) ((x) ? BLE_HS_ERR_ATT_BASE + (x) : 0)
@@ -69,39 +76,31 @@ struct os_event;
#define BLE_HS_ERR_SM_US_BASE 0x400 /* 1024 */
#define BLE_HS_SM_US_ERR(x) ((x) ? BLE_HS_ERR_SM_US_BASE + (x) : 0)
-#define BLE_HS_ERR_SM_THEM_BASE 0x500 /* 1280 */
-#define BLE_HS_SM_THEM_ERR(x) ((x) ? BLE_HS_ERR_SM_THEM_BASE + (x) : 0)
+#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 */
+/* Note: A hardware error of 0 is not success. */
+#define BLE_HS_ERR_HW_BASE 0x600 /* 1536 */
+#define BLE_HS_HW_ERR(x) (BLE_HS_ERR_HW_BASE + (x))
+
+/* 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
+typedef void ble_hs_reset_fn(int reason);
+typedef void ble_hs_sync_fn(void);
struct ble_hs_cfg {
- /*** HCI settings. */
/**
- * An HCI buffer is a "flat" 260-byte buffer. HCI buffers are used by the
- * controller to send unsolicited events to the host.
- *
- * HCI buffers can get tied up when the controller sends lots of
- * asynchronous / unsolicited events (i.e., non-acks). When the controller
- * needs to send one of these events, it allocates an HCI buffer, fills it
- * with the event payload, and puts it on a host queue. If the controller
- * sends a quick burst of these events, the buffer pool may be exhausted,
- * preventing the host from sending an HCI command to the controller.
- *
* Every time the controller sends a non-ack HCI event to the host, it also
* allocates an OS event (it is unfortunate that these are both called
* "events"). The OS event is put on the host-parent-task's event queue;
* it is what wakes up the host-parent-task and indicates that an HCI event
- * needs to be processsed. The pool of OS events is allocated with the
- * same number of elements as the HCI buffer pool.
+ * needs to be processsed. This setting should be equal to the total
+ * number of HCI event buffers that the transport is configured to use.
*/
uint8_t max_hci_bufs;
@@ -132,6 +131,18 @@ struct ble_hs_cfg {
*/
uint16_t max_client_configs;
+ /**
+ * An optional callback that gets executed upon registration of each GATT
+ * resource (service, characteristic, or descriptor).
+ */
+ ble_gatt_register_fn *gatts_register_cb;
+
+ /**
+ * An optional argument that gets passed to the GATT registration
+ * callback.
+ */
+ void *gatts_register_arg;
+
/*** GATT client settings. */
/**
* The maximum number of concurrent GATT client procedures. When you
@@ -197,6 +208,19 @@ struct ble_hs_cfg {
uint8_t sm_our_key_dist;
uint8_t sm_their_key_dist;
+ /*** HCI settings */
+ /**
+ * This callback is executed when the host resets itself and the controller
+ * due to fatal error.
+ */
+ ble_hs_reset_fn *reset_cb;
+
+ /**
+ * This callback is executed when the host and controller become synced.
+ * This happens at startup and after a reset.
+ */
+ ble_hs_sync_fn *sync_cb;
+
/*** Store settings. */
/**
* These function callbacks handle persistence of sercurity material
@@ -206,7 +230,7 @@ struct ble_hs_cfg {
ble_store_write_fn *store_write_cb;
ble_store_delete_fn *store_delete_cb;
- /*** privacy settings */
+ /*** Privacy settings. */
/**
* The frequency at which new resovlable private addresses are generated.
* Units are seconds.
@@ -216,9 +240,8 @@ struct ble_hs_cfg {
extern const struct ble_hs_cfg ble_hs_cfg_dflt;
+int ble_hs_synced(void);
int ble_hs_start(void);
-void ble_hs_event_enqueue(struct os_event *ev);
-int ble_ibeacon_set_adv_data(void *uuid128, uint16_t major, uint16_t minor);
int ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg);
#endif
diff --git a/net/nimble/host/include/host/ble_hs_adv.h b/net/nimble/host/include/host/ble_hs_adv.h
index 0377d1d9..8ae2b00b 100644
--- a/net/nimble/host/include/host/ble_hs_adv.h
+++ b/net/nimble/host/include/host/ble_hs_adv.h
@@ -22,18 +22,21 @@
#include <inttypes.h>
+/** Max field payload size (account for 2-byte header). */
+#define BLE_HS_ADV_MAX_FIELD_SZ (BLE_HCI_MAX_ADV_DATA_LEN - 2)
+
struct ble_hs_adv_fields {
/*** 0x01 - Flags. */
uint8_t flags;
unsigned flags_is_present:1;
/*** 0x02,0x03 - 16-bit service class UUIDs. */
- void *uuids16;
+ uint16_t *uuids16;
uint8_t num_uuids16;
unsigned uuids16_is_complete:1;
/*** 0x04,0x05 - 32-bit service class UUIDs. */
- void *uuids32;
+ uint32_t *uuids32;
uint8_t num_uuids32;
unsigned uuids32_is_complete:1;
@@ -48,7 +51,7 @@ struct ble_hs_adv_fields {
unsigned name_is_complete:1;
/*** 0x0a - Tx power level. */
- uint8_t tx_pwr_lvl;
+ int8_t tx_pwr_lvl;
unsigned tx_pwr_lvl_is_present:1;
/*** 0x0d - Class of device. */
@@ -141,6 +144,12 @@ struct ble_hs_adv_fields {
#define BLE_HS_ADV_TX_PWR_LVL_LEN 1
+/**
+ * Set the tx_pwr_lvl field to this if you want the stack to fill in the tx
+ * power level field.
+ */
+#define BLE_HS_ADV_TX_PWR_LVL_AUTO (-128)
+
#define BLE_HS_ADV_DEVICE_CLASS_LEN 3
#define BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN 4
@@ -165,10 +174,4 @@ struct ble_hs_adv_fields {
#define BLE_HS_ADV_SVC_DATA_UUID128_MIN_LEN 16
-int ble_hs_adv_set_flat(uint8_t type, int data_len, void *data,
- uint8_t *dst, uint8_t *dst_len, uint8_t max_len);
-int ble_hs_adv_set_fields(struct ble_hs_adv_fields *adv_fields,
- uint8_t *dst, uint8_t *dst_len, uint8_t max_len);
-int ble_hs_adv_parse_fields(struct ble_hs_adv_fields *adv_fields, uint8_t *src,
- uint8_t src_len);
#endif
diff --git a/net/nimble/host/include/host/ble_hs_id.h b/net/nimble/host/include/host/ble_hs_id.h
new file mode 100644
index 00000000..749524b8
--- /dev/null
+++ b/net/nimble/host/include/host/ble_hs_id.h
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_HS_ID_
+#define H_BLE_HS_ID_
+
+#include <inttypes.h>
+
+int ble_hs_id_gen_rnd(int nrpa, uint8_t *out_addr);
+int ble_hs_id_set_rnd(const uint8_t *rnd_addr);
+int ble_hs_id_copy_addr(uint8_t id_addr_type, uint8_t *out_id_addr,
+ int *out_is_nrpa);
+
+#endif
diff --git a/net/nimble/host/include/host/ble_hs_log.h b/net/nimble/host/include/host/ble_hs_log.h
new file mode 100644
index 00000000..fd10ddba
--- /dev/null
+++ b/net/nimble/host/include/host/ble_hs_log.h
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_HS_LOG_
+#define H_BLE_HS_LOG_
+
+#include "log/log.h"
+struct os_mbuf;
+
+extern struct log ble_hs_log;
+
+#define BLE_HS_LOG(lvl, ...) \
+ LOG_ ## lvl(&ble_hs_log, LOG_MODULE_NIMBLE_HOST, __VA_ARGS__)
+
+#define BLE_HS_LOG_ADDR(lvl, addr) \
+ BLE_HS_LOG(lvl, "%02x:%02x:%02x:%02x:%02x:%02x", \
+ (addr)[5], (addr)[4], (addr)[3], \
+ (addr)[2], (addr)[1], (addr)[0])
+
+void ble_hs_log_mbuf(const struct os_mbuf *om);
+void ble_hs_log_flat_buf(const void *data, int len);
+
+#endif
diff --git a/net/nimble/host/include/host/ble_hs_mbuf.h b/net/nimble/host/include/host/ble_hs_mbuf.h
new file mode 100644
index 00000000..d3606f2e
--- /dev/null
+++ b/net/nimble/host/include/host/ble_hs_mbuf.h
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_HS_MBUF_
+#define H_BLE_HS_MBUF_
+
+#include <inttypes.h>
+struct os_mbuf;
+
+struct os_mbuf *ble_hs_mbuf_att_pkt(void);
+struct os_mbuf *ble_hs_mbuf_from_flat(const void *buf, uint16_t len);
+int ble_hs_mbuf_to_flat(const struct os_mbuf *om, void *flat, uint16_t max_len,
+ uint16_t *out_copy_len);
+
+#endif
diff --git a/net/nimble/host/include/host/ble_hs_test.h b/net/nimble/host/include/host/ble_hs_test.h
index 787ec41e..3247b59d 100644
--- a/net/nimble/host/include/host/ble_hs_test.h
+++ b/net/nimble/host/include/host/ble_hs_test.h
@@ -23,9 +23,6 @@
#include <inttypes.h>
struct os_mbuf;
-void ble_hs_test_pkt_txed(struct os_mbuf *om);
-void ble_hs_test_hci_txed(uint8_t *cmdbuf);
-
int ble_att_clt_test_all(void);
int ble_att_svr_test_all(void);
int ble_gap_test_all(void);
@@ -37,16 +34,16 @@ int ble_gatt_find_s_test_all(void);
int ble_gatt_read_test_all(void);
int ble_gatt_write_test_all(void);
int ble_gatts_notify_test_all(void);
+int ble_gatts_read_test_suite(void);
int ble_gatts_reg_test_all(void);
-int ble_host_hci_test_all(void);
+int ble_hs_hci_test_all(void);
int ble_hs_adv_test_all(void);
int ble_hs_conn_test_all(void);
int ble_l2cap_test_all(void);
int ble_os_test_all(void);
-int ble_sm_test_all(void);
-int ble_uuid_test_all(void);
-
int ble_sm_lgcy_test_suite(void);
int ble_sm_sc_test_suite(void);
+int ble_sm_test_all(void);
+int ble_uuid_test_all(void);
#endif
diff --git a/net/nimble/host/include/host/ble_ibeacon.h b/net/nimble/host/include/host/ble_ibeacon.h
new file mode 100644
index 00000000..112f52b3
--- /dev/null
+++ b/net/nimble/host/include/host/ble_ibeacon.h
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_IBEACON_
+#define H_BLE_IBEACON_
+
+int ble_ibeacon_set_adv_data(void *uuid128, uint16_t major, uint16_t minor);
+
+#endif
diff --git a/net/nimble/host/include/host/ble_store.h b/net/nimble/host/include/host/ble_store.h
index 9a7efab3..a5331594 100644
--- a/net/nimble/host/include/host/ble_store.h
+++ b/net/nimble/host/include/host/ble_store.h
@@ -28,6 +28,12 @@
#define BLE_STORE_ADDR_TYPE_NONE 0xff
+/**
+ * Used as a key for lookups of security material. This struct corresponds to
+ * the following store object types:
+ * o BLE_STORE_OBJ_TYPE_OUR_SEC
+ * o BLE_STORE_OBJ_TYPE_PEER_SEC
+ */
struct ble_store_key_sec {
/**
* Key by peer identity address;
@@ -52,6 +58,12 @@ struct ble_store_key_sec {
uint8_t idx;
};
+/**
+ * Represents stored security material. This struct corresponds to the
+ * following store object types:
+ * o BLE_STORE_OBJ_TYPE_OUR_SEC
+ * o BLE_STORE_OBJ_TYPE_PEER_SEC
+ */
struct ble_store_value_sec {
uint8_t peer_addr[6];
uint8_t peer_addr_type;
@@ -71,6 +83,11 @@ struct ble_store_value_sec {
unsigned sc:1;
};
+/**
+ * Used as a key for lookups of stored client characteristic configuration
+ * descriptors (CCCDs). This struct corresponds to the BLE_STORE_OBJ_TYPE_CCCD
+ * store object type.
+ */
struct ble_store_key_cccd {
/**
* Key by peer identity address;
@@ -89,6 +106,10 @@ struct ble_store_key_cccd {
uint8_t idx;
};
+/**
+ * Represents a stored client characteristic configuration descriptor (CCCD).
+ * This struct corresponds to the BLE_STORE_OBJ_TYPE_CCCD store object type.
+ */
struct ble_store_value_cccd {
uint8_t peer_addr[6];
uint8_t peer_addr_type;
@@ -97,21 +118,72 @@ struct ble_store_value_cccd {
unsigned value_changed:1;
};
+/**
+ * Used as a key for store lookups. This union must be accompanied by an
+ * object type code to indicate which field is valid.
+ */
union ble_store_key {
struct ble_store_key_sec sec;
struct ble_store_key_cccd cccd;
};
+/**
+ * Represents stored data. This union must be accompanied by an object type
+ * code to indicate which field is valid.
+ */
union ble_store_value {
struct ble_store_value_sec sec;
struct ble_store_value_cccd cccd;
};
+/**
+ * Searches the store for an object matching the specified criteria. If a
+ * match is found, it is read from the store and the dst parameter is populated
+ * with the retrieved object.
+ *
+ * @param obj_type The type of object to search for; one of the
+ * BLE_STORE_OBJ_TYPE_[...] codes.
+ * @param key Specifies properties of the object to search
+ * for. An object is retrieved if it matches
+ * these criteria.
+ * @param dst On success, this is populated with the
+ * retrieved object.
+ *
+ * @return 0 if an object was successfully retreived;
+ * BLE_HS_ENOENT if no matching object was found;
+ * Other nonzero on error.
+ */
typedef int ble_store_read_fn(int obj_type, union ble_store_key *key,
union ble_store_value *dst);
+/**
+ * Writes the specified object to the store. If an object with the same
+ * identity is already in the store, it is replaced. If the store lacks
+ * sufficient capacity to write the object, this function may remove previously
+ * stored values to make room.
+ *
+ * @param obj_type The type of object being written; one of the
+ * BLE_STORE_OBJ_TYPE_[...] codes.
+ * @param val The object to persist.
+ *
+ * @return 0 if the object was successfully written;
+ * Other nonzero on error.
+ */
typedef int ble_store_write_fn(int obj_type, union ble_store_value *val);
+/**
+ * Searches the store for the first object matching the specified criteria. If
+ * a match is found, it is deleted from the store.
+ *
+ * @param obj_type The type of object to delete; one of the
+ * BLE_STORE_OBJ_TYPE_[...] codes.
+ * @param key Specifies properties of the object to search
+ * for. An object is deleted if it matches
+ * these criteria.
+ * @return 0 if an object was successfully retreived;
+ * BLE_HS_ENOENT if no matching object was found;
+ * Other nonzero on error.
+ */
typedef int ble_store_delete_fn(int obj_type, union ble_store_key *key);
int ble_store_read(int obj_type, union ble_store_key *key,
diff --git a/net/nimble/host/include/host/ble_uuid.h b/net/nimble/host/include/host/ble_uuid.h
index a092dd66..89d9df07 100644
--- a/net/nimble/host/include/host/ble_uuid.h
+++ b/net/nimble/host/include/host/ble_uuid.h
@@ -23,10 +23,8 @@
#include <inttypes.h>
struct os_mbuf;
-uint16_t ble_uuid_128_to_16(void *uuid128);
+uint16_t ble_uuid_128_to_16(const void *uuid128);
int ble_uuid_16_to_128(uint16_t uuid16, void *dst);
-int ble_uuid_append(struct os_mbuf *om, void *uuid128);
-int ble_uuid_extract(struct os_mbuf *om, int off, void *uuid128);
#define BLE_UUID16_ARR(uuid16) { \
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, \
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
deleted file mode 100644
index c33cb390..00000000
--- a/net/nimble/host/include/host/host_hci.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_HOST_HCI_
-#define H_HOST_HCI_
-
-#include "nimble/hci_common.h"
-struct ble_hs_conn;
-struct os_mbuf;
-
-#define HCI_CMD_BUF_SIZE 260
-
-extern uint8_t host_hci_cmd_buf[HCI_CMD_BUF_SIZE];
-
-int host_hci_os_event_proc(struct os_event *ev);
-int host_hci_event_rx(uint8_t *data);
-uint16_t host_hci_opcode_join(uint8_t ogf, uint16_t ocf);
-void host_hci_write_hdr(uint8_t ogf, uint8_t ocf, uint8_t len, void *buf);
-int host_hci_cmd_send(uint8_t ogf, uint8_t ocf, uint8_t len, void *cmddata);
-int host_hci_cmd_send_buf(void *cmddata);
-void host_hci_cmd_build_set_event_mask(uint64_t event_mask,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_set_event_mask2(uint64_t event_mask, uint8_t *dst,
- int dst_len);
-void host_hci_cmd_build_disconnect(uint16_t handle, uint8_t reason,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_disconnect(uint16_t handle, uint8_t reason);
-void host_hci_cmd_build_read_rssi(uint16_t handle, uint8_t *dst, int dst_len);
-int host_hci_cmd_read_rssi(uint16_t handle);
-int host_hci_cmd_build_le_set_scan_rsp_data(uint8_t *data, uint8_t len,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_set_adv_data(uint8_t *data, uint8_t len,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_set_adv_params(struct hci_adv_params *adv,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_set_event_mask(uint64_t event_mask,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_read_buffer_size(uint8_t *dst, int dst_len);
-int host_hci_cmd_le_read_buffer_size(void);
-void host_hci_cmd_build_le_read_loc_supp_feat(uint8_t *dst, uint8_t dst_len);
-void host_hci_cmd_build_le_set_adv_enable(uint8_t enable, uint8_t *dst,
- int dst_len);
-int host_hci_cmd_le_set_adv_enable(uint8_t enable);
-int host_hci_cmd_build_le_set_scan_params(uint8_t scan_type,
- uint16_t scan_itvl,
- uint16_t scan_window,
- uint8_t own_addr_type,
- uint8_t filter_policy,
- uint8_t *cmd, int cmd_len);
-void host_hci_cmd_build_le_set_scan_enable(uint8_t enable,
- uint8_t filter_dups,
- uint8_t *dst, uint8_t dst_len);
-int host_hci_cmd_le_set_scan_enable(uint8_t enable, uint8_t filter_dups);
-int host_hci_cmd_build_le_create_connection(struct hci_create_conn *hcc,
- uint8_t *cmd, int cmd_len);
-int host_hci_cmd_le_create_connection(struct hci_create_conn *hcc);
-void host_hci_cmd_build_le_clear_whitelist(uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_add_to_whitelist(uint8_t *addr, uint8_t addr_type,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_reset(uint8_t *dst, int dst_len);
-int host_hci_cmd_reset(void);
-void host_hci_cmd_build_read_adv_pwr(uint8_t *dst, int dst_len);
-int host_hci_cmd_read_adv_pwr(void);
-void host_hci_cmd_build_le_create_conn_cancel(uint8_t *dst, int dst_len);
-int host_hci_cmd_le_create_conn_cancel(void);
-int host_hci_cmd_build_le_conn_update(struct hci_conn_update *hcu,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_update(struct hci_conn_update *hcu);
-void host_hci_cmd_build_le_lt_key_req_reply(struct hci_lt_key_req_reply *hkr,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_lt_key_req_neg_reply(uint16_t conn_handle,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_conn_param_reply(struct hci_conn_param_reply *hcr,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_param_reply(struct hci_conn_param_reply *hcr);
-void host_hci_cmd_build_le_conn_param_neg_reply(
- struct hci_conn_param_neg_reply *hcn, uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_param_neg_reply(struct hci_conn_param_neg_reply *hcn);
-void host_hci_cmd_build_le_rand(uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_start_encrypt(struct hci_start_encrypt *cmd,
- uint8_t *dst, int dst_len);
-int host_hci_set_buf_size(uint16_t pktlen, uint8_t max_pkts);
-
-uint16_t host_hci_handle_pb_bc_join(uint16_t handle, uint8_t pb, uint8_t bc);
-
-int host_hci_data_rx(struct os_mbuf *om);
-int host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf *om);
-
-int host_hci_cmd_build_set_data_len(uint16_t connection_handle,
- uint16_t tx_octets, uint16_t tx_time,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_add_to_resolv_list(
- struct hci_add_dev_to_resolving_list *padd,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_remove_from_resolv_list(uint8_t addr_type,
- uint8_t *addr, uint8_t *dst,
- int dst_len);
-int host_hci_cmd_build_read_resolv_list_size(uint8_t *dst, int dst_len);
-int
-host_hci_cmd_build_clear_resolv_list(uint8_t *dst, int dst_len);
-int host_hci_cmd_build_read_peer_resolv_addr(uint8_t peer_identity_addr_type,
- uint8_t *peer_identity_addr,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_read_lcl_resolv_addr(uint8_t local_identity_addr_type,
- uint8_t *local_identity_addr,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_set_addr_res_en(uint8_t enable,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_set_resolv_priv_addr_timeout(uint16_t timeout,
- uint8_t *dst,
- int dst_len);
-
-void host_hci_timer_set(void);
-
-int host_hci_cmd_build_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len);
-
-#endif /* H_HOST_HCI_ */