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 2015/12/09 23:08:30 UTC
[5/5] incubator-mynewt-larva git commit: Replace posix errno code
with ble_hs codes.
Replace posix errno code with ble_hs codes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/36b80fae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/36b80fae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/36b80fae
Branch: refs/heads/master
Commit: 36b80fae3089636478b28cc366763ab49fd36840
Parents: 6735a4a
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Dec 9 13:50:08 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Dec 9 14:07:34 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_hs.h | 11 +++-
net/nimble/host/include/host/host_hci.h | 3 +-
net/nimble/host/src/ble_att.c | 4 +-
net/nimble/host/src/ble_att_clt.c | 48 +++++++--------
net/nimble/host/src/ble_att_cmd.c | 67 +++++++++++----------
net/nimble/host/src/ble_att_svr.c | 73 +++++++++++++----------
net/nimble/host/src/ble_gap.c | 5 +-
net/nimble/host/src/ble_gap_conn.c | 13 ++--
net/nimble/host/src/ble_gatt.c | 34 ++++++-----
net/nimble/host/src/ble_hs.c | 18 +++---
net/nimble/host/src/ble_hs_conn.c | 4 +-
net/nimble/host/src/ble_hs_hci_batch.c | 4 +-
net/nimble/host/src/ble_hs_uuid.c | 9 +--
net/nimble/host/src/ble_l2cap.c | 12 ++--
net/nimble/host/src/host_hci.c | 26 ++++----
net/nimble/host/src/test/ble_att_clt_test.c | 5 +-
net/nimble/host/src/test/ble_host_hci_test.c | 10 ++--
net/nimble/host/src/test/ble_l2cap_test.c | 4 +-
project/hostctlrtest/src/main.c | 10 ++--
19 files changed, 195 insertions(+), 165 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/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 63411a0..45cc4dd 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -20,6 +20,16 @@
#include <inttypes.h>
struct os_mbuf;
+#define BLE_HS_EAGAIN 1
+#define BLE_HS_EALREADY 2
+#define BLE_HS_EINVAL 3
+#define BLE_HS_EMSGSIZE 4
+#define BLE_HS_ENOENT 5
+#define BLE_HS_ENOMEM 5
+#define BLE_HS_ENOTCONN 6
+#define BLE_HS_ENOTSUP 7
+#define BLE_HS_EATT 8
+
#define BLE_HOST_HCI_EVENT_CTLR_EVENT (OS_EVENT_T_PERUSER + 0)
#define BLE_HS_KICK_HCI_EVENT (OS_EVENT_T_PERUSER + 1)
#define BLE_HS_KICK_GATT_EVENT (OS_EVENT_T_PERUSER + 2)
@@ -30,7 +40,6 @@ extern struct os_mbuf_pool ble_hs_mbuf_pool;
extern struct os_eventq ble_hs_evq;
void ble_hs_process_tx_data_queue(void);
-void ble_hs_task_handler(void *arg);
int ble_hs_rx_data(struct os_mbuf *om);
int ble_hs_tx_data(struct os_mbuf *om);
void ble_hs_kick_hci(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/include/host/host_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
index f48dd76..a8e3d12 100644
--- a/net/nimble/host/include/host/host_hci.h
+++ b/net/nimble/host/include/host/host_hci.h
@@ -31,7 +31,8 @@ int host_hci_cmd_le_set_event_mask(uint64_t event_mask);
int host_hci_cmd_le_read_buffer_size(void);
int host_hci_cmd_le_set_adv_enable(uint8_t enable);
int host_hci_cmd_le_set_scan_params(uint8_t scan_type, uint16_t scan_itvl,
- uint16_t scan_window, uint8_t own_addr_type,
+ uint16_t scan_window,
+ uint8_t own_addr_type,
uint8_t filter_policy);
int host_hci_cmd_le_set_scan_enable(uint8_t enable, uint8_t filter_dups);
int host_hci_cmd_le_create_connection(struct hci_create_conn *hcc);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index 1398d39..9ce0fe0 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -80,12 +80,12 @@ ble_att_rx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
rc = os_mbuf_copydata(*om, 0, 1, &op);
if (rc != 0) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
entry = ble_att_rx_dispatch_entry_find(op);
if (entry == NULL) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
rc = entry->bde_fn(conn, chan, om);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index cceb653..cf10000 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -39,13 +39,13 @@ ble_att_clt_prep_req(struct ble_hs_conn *conn, struct ble_l2cap_chan **chan,
*txom = ble_att_get_pkthdr();
if (*txom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
buf = os_mbuf_extend(*txom, initial_sz);
if (buf == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
@@ -69,7 +69,7 @@ ble_att_clt_rx_error(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*om = os_mbuf_pullup(*om, BLE_ATT_ERROR_RSP_SZ);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_error_rsp_parse((*om)->om_data, (*om)->om_len, &rsp);
@@ -92,7 +92,7 @@ ble_att_clt_tx_mtu(struct ble_hs_conn *conn, struct ble_att_mtu_cmd *req)
txom = NULL;
if (req->bamc_mtu < BLE_ATT_MTU_DFLT) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -128,7 +128,7 @@ ble_att_clt_rx_mtu(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*om = os_mbuf_pullup(*om, BLE_ATT_MTU_CMD_SZ);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_mtu_cmd_parse((*om)->om_data, (*om)->om_len, &rsp);
@@ -156,7 +156,7 @@ ble_att_clt_tx_find_info(struct ble_hs_conn *conn,
if (req->bafq_start_handle == 0 ||
req->bafq_start_handle > req->bafq_end_handle) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -198,7 +198,7 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*om = os_mbuf_pullup(*om, BLE_ATT_FIND_INFO_RSP_BASE_SZ);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_find_info_rsp_parse((*om)->om_data, (*om)->om_len, &rsp);
@@ -212,7 +212,7 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
while (off < OS_MBUF_PKTHDR(rxom)->omp_len) {
rc = os_mbuf_copydata(rxom, off, 2, &handle_id);
if (rc != 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
off += 2;
handle_id = le16toh(&handle_id);
@@ -221,27 +221,27 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
case BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT:
rc = os_mbuf_copydata(rxom, off, 2, &uuid16);
if (rc != 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
off += 2;
uuid16 = le16toh(&uuid16);
rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
if (rc != 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
break;
case BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT:
rc = os_mbuf_copydata(rxom, off, 16, &uuid128);
if (rc != 0) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
}
off += 16;
break;
default:
- return EINVAL;
+ return BLE_HS_EINVAL;
}
}
@@ -262,7 +262,7 @@ ble_att_clt_tx_read_type(struct ble_hs_conn *conn,
if (req->batq_start_handle == 0 ||
req->batq_start_handle > req->batq_end_handle) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -301,7 +301,7 @@ ble_att_clt_parse_type_attribute_data(struct os_mbuf **om, int data_len,
{
*om = os_mbuf_pullup(*om, data_len);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
adata->att_handle = le16toh((*om)->om_data + 0);
@@ -322,7 +322,7 @@ ble_att_clt_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_TYPE_RSP_BASE_SZ);
if (*rxom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto done;
}
@@ -364,7 +364,7 @@ ble_att_clt_tx_read(struct ble_hs_conn *conn, struct ble_att_read_req *req)
txom = NULL;
if (req->barq_handle == 0) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -410,7 +410,7 @@ ble_att_clt_rx_read(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
/* Pass the Attribute Value field to the GATT. */
*rxom = os_mbuf_pullup(*rxom, OS_MBUF_PKTLEN(*rxom));
if (*rxom == NULL) {
- rc = EMSGSIZE;
+ rc = BLE_HS_EMSGSIZE;
goto done;
}
@@ -438,7 +438,7 @@ ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
if (req->bagq_start_handle == 0 ||
req->bagq_start_handle > req->bagq_end_handle) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -476,12 +476,12 @@ ble_att_clt_parse_group_attribute_data(struct os_mbuf **om, int data_len,
struct ble_att_clt_adata *adata)
{
if (data_len < BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ + 1) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
*om = os_mbuf_pullup(*om, data_len);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
adata->att_handle = le16toh((*om)->om_data + 0);
@@ -503,7 +503,7 @@ ble_att_clt_rx_read_group_type(struct ble_hs_conn *conn,
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
if (*rxom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto done;
}
@@ -549,7 +549,7 @@ ble_att_clt_tx_find_type_value(struct ble_hs_conn *conn,
if (req->bavq_start_handle == 0 ||
req->bavq_start_handle > req->bavq_end_handle) {
- rc = EINVAL;
+ rc = BLE_HS_EINVAL;
goto err;
}
@@ -566,7 +566,7 @@ ble_att_clt_tx_find_type_value(struct ble_hs_conn *conn,
rc = os_mbuf_append(txom, attribute_value, value_len);
if (rc != 0) {
- rc = EMSGSIZE;
+ rc = BLE_HS_EMSGSIZE;
goto err;
}
@@ -589,7 +589,7 @@ ble_att_clt_parse_handles_info(struct os_mbuf **om,
{
*om = os_mbuf_pullup(*om, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
adata->att_handle = le16toh((*om)->om_data + 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_att_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_cmd.c b/net/nimble/host/src/ble_att_cmd.c
index fd6052d..b3cf355 100644
--- a/net/nimble/host/src/ble_att_cmd.c
+++ b/net/nimble/host/src/ble_att_cmd.c
@@ -18,6 +18,7 @@
#include <string.h>
#include "os/os.h"
#include "nimble/ble.h"
+#include "host/ble_hs.h"
#include "host/ble_att.h"
#include "host/ble_hs_uuid.h"
#include "ble_l2cap.h"
@@ -29,13 +30,13 @@ ble_att_error_rsp_parse(void *payload, int len, struct ble_att_error_rsp *rsp)
uint8_t *u8ptr;
if (len < BLE_ATT_ERROR_RSP_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_ERROR_RSP) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
rsp->baep_req_op = u8ptr[1];
@@ -51,7 +52,7 @@ ble_att_error_rsp_write(void *payload, int len, struct ble_att_error_rsp *rsp)
uint8_t *u8ptr;
if (len < BLE_ATT_ERROR_RSP_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -70,7 +71,7 @@ ble_att_mtu_cmd_parse(void *payload, int len, struct ble_att_mtu_cmd *cmd)
uint8_t *u8ptr;
if (len < BLE_ATT_MTU_CMD_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -78,7 +79,7 @@ ble_att_mtu_cmd_parse(void *payload, int len, struct ble_att_mtu_cmd *cmd)
if (u8ptr[0] != BLE_ATT_OP_MTU_REQ &&
u8ptr[0] != BLE_ATT_OP_MTU_RSP) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
cmd->bamc_mtu = le16toh(u8ptr + 1);
@@ -93,7 +94,7 @@ ble_att_mtu_req_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_MTU_CMD_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -110,7 +111,7 @@ ble_att_mtu_rsp_write(void *payload, int len, struct ble_att_mtu_cmd *cmd)
uint8_t *u8ptr;
if (len < BLE_ATT_MTU_CMD_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -128,13 +129,13 @@ ble_att_find_info_req_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_INFO_REQ_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_FIND_INFO_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->bafq_start_handle = le16toh(u8ptr + 1);
@@ -150,7 +151,7 @@ ble_att_find_info_req_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_INFO_REQ_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -169,13 +170,13 @@ ble_att_find_info_rsp_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_INFO_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_FIND_INFO_RSP) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
rsp->bafp_format = u8ptr[1];
@@ -190,7 +191,7 @@ ble_att_find_info_rsp_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_INFO_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -208,13 +209,13 @@ ble_att_find_type_value_req_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_FIND_TYPE_VALUE_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->bavq_start_handle = le16toh(u8ptr + 1);
@@ -231,7 +232,7 @@ ble_att_find_type_value_req_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -251,13 +252,13 @@ ble_att_read_type_req_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_TYPE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_READ_TYPE_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->batq_start_handle = le16toh(u8ptr + 1);
@@ -273,7 +274,7 @@ ble_att_read_type_req_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_TYPE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -292,7 +293,7 @@ ble_att_read_type_rsp_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_TYPE_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -309,7 +310,7 @@ ble_att_read_type_rsp_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_TYPE_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -326,13 +327,13 @@ ble_att_read_req_parse(void *payload, int len, struct ble_att_read_req *req)
uint8_t *u8ptr;
if (len < BLE_ATT_READ_REQ_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_READ_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->barq_handle = le16toh(u8ptr + 1);
@@ -346,7 +347,7 @@ ble_att_read_req_write(void *payload, int len, struct ble_att_read_req *req)
uint8_t *u8ptr;
if (len < BLE_ATT_READ_REQ_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -364,13 +365,13 @@ ble_att_read_group_type_req_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_READ_GROUP_TYPE_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->bagq_start_handle = le16toh(u8ptr + 1);
@@ -386,7 +387,7 @@ ble_att_read_group_type_req_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -405,13 +406,13 @@ ble_att_read_group_type_rsp_parse(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_READ_GROUP_TYPE_RSP) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
rsp->bagp_length = u8ptr[1];
@@ -426,7 +427,7 @@ ble_att_read_group_type_rsp_write(void *payload, int len,
uint8_t *u8ptr;
if (len < BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
@@ -443,13 +444,13 @@ ble_att_write_req_parse(void *payload, int len, struct ble_att_write_req *req)
uint8_t *u8ptr;
if (len < BLE_ATT_WRITE_REQ_MIN_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
if (u8ptr[0] != BLE_ATT_OP_WRITE_REQ) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
req->bawq_handle = le16toh(u8ptr + 1);
@@ -463,7 +464,7 @@ ble_att_write_req_write(void *payload, int len, struct ble_att_write_req *req)
uint8_t *u8ptr;
if (len < BLE_ATT_WRITE_REQ_MIN_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
u8ptr = payload;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index de7f80a..c7d3abc 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -120,7 +120,7 @@ ble_att_svr_register(uint8_t *uuid, uint8_t flags, uint16_t *handle_id,
entry = ble_att_svr_entry_alloc();
if (entry == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
memcpy(&entry->ha_uuid, uuid, sizeof entry->ha_uuid);
@@ -207,7 +207,7 @@ ble_att_svr_match_handle(struct ble_att_svr_entry *ha, void *arg)
* @param ha_ptr A pointer to a pointer to put the matching host
* attr into.
*
- * @return 0 on success; ENOENT on not found.
+ * @return 0 on success; BLE_HS_ENOENT on not found.
*/
int
ble_att_svr_find_by_handle(uint16_t handle_id,
@@ -221,7 +221,7 @@ ble_att_svr_find_by_handle(uint16_t handle_id,
return 0;
} else {
/* Not found */
- return ENOENT;
+ return BLE_HS_ENOENT;
}
}
@@ -246,7 +246,7 @@ ble_att_svr_match_uuid(struct ble_att_svr_entry *ha, void *arg)
* @param ha_ptr A pointer to a pointer to put the matching host
* attr into.
*
- * @return 0 on success; ENOENT on not found.
+ * @return 0 on success; BLE_HS_ENOENT on not found.
*/
int
ble_att_svr_find_by_uuid(uint8_t *uuid,
@@ -260,7 +260,7 @@ ble_att_svr_find_by_uuid(uint8_t *uuid,
return 0;
} else {
/* No match */
- return ENOENT;
+ return BLE_HS_ENOENT;
}
}
@@ -359,7 +359,7 @@ ble_att_svr_rx_mtu(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*om = os_mbuf_pullup(*om, BLE_ATT_MTU_CMD_SZ);
if (*om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_mtu_cmd_parse((*om)->om_data, (*om)->om_len, &cmd);
@@ -488,7 +488,7 @@ done:
ble_att_svr_list_unlock();
if (rc == 0 && num_entries == 0) {
- return ENOENT;
+ return BLE_HS_ENOENT;
} else {
return rc;
}
@@ -508,7 +508,7 @@ ble_att_svr_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_MTU_CMD_SZ);
if (*rxom == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_find_info_req_parse((*rxom)->om_data, (*rxom)->om_len, &req);
@@ -586,8 +586,9 @@ err:
* @param mtu The ATT L2CAP channel MTU.
*
* @return 0 if the response should be sent;
- * EAGAIN if the entry was successfully processed
- * and subsequent entries can be inspected.
+ * BLE_HS_EAGAIN if the entry was successfully
+ * processed and subsequent entries can be
+ * inspected.
* Other nonzero on error.
*/
static int
@@ -600,7 +601,7 @@ ble_att_svr_fill_type_value_no_match(struct os_mbuf *om, uint16_t *first,
/* If there is no current group, then there is nothing to do. */
if (*first == 0) {
- return EAGAIN;
+ return BLE_HS_EAGAIN;
}
rsp_sz = OS_MBUF_PKTHDR(om)->omp_len + 4;
@@ -612,20 +613,20 @@ ble_att_svr_fill_type_value_no_match(struct os_mbuf *om, uint16_t *first,
htole16(&u16, u16);
rc = os_mbuf_append(om, &u16, 2);
if (rc != 0) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
u16 = *prev;
htole16(&u16, u16);
rc = os_mbuf_append(om, &u16, 2);
if (rc != 0) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
*first = 0;
*prev = 0;
- return EAGAIN;
+ return BLE_HS_EAGAIN;
}
/**
@@ -643,8 +644,9 @@ ble_att_svr_fill_type_value_no_match(struct os_mbuf *om, uint16_t *first,
* @param mtu The ATT L2CAP channel MTU.
*
* @return 0 if the response should be sent;
- * EAGAIN if the entry was successfully processed
- * and subsequent entries can be inspected.
+ * BLE_HS_EAGAIN if the entry was successfully
+ * processed and subsequent entries can be
+ * inspected.
* Other nonzero on error.
*/
static int
@@ -660,13 +662,13 @@ ble_att_svr_fill_type_value_match(struct os_mbuf *om, uint16_t *first,
if (*first == 0) {
*first = handle_id;
*prev = handle_id;
- return EAGAIN;
+ return BLE_HS_EAGAIN;
}
/* If this is the continuation of a group, keep searching. */
if (handle_id == *prev + 1) {
*prev = handle_id;
- return EAGAIN;
+ return BLE_HS_EAGAIN;
}
/* Otherwise, this handle is not a part of the previous group. Write the
@@ -756,7 +758,7 @@ ble_att_svr_fill_type_value(struct ble_att_find_type_value_req *req,
if (rc == 0) {
goto done;
}
- if (rc != EAGAIN) {
+ if (rc != BLE_HS_EAGAIN) {
rc = BLE_ATT_ERR_UNLIKELY;
goto done;
}
@@ -766,7 +768,7 @@ ble_att_svr_fill_type_value(struct ble_att_find_type_value_req *req,
* the end of the attribute list was reached.
*/
rc = ble_att_svr_fill_type_value_no_match(txom, &first, &prev, mtu);
- if (rc == EAGAIN) {
+ if (rc == BLE_HS_EAGAIN) {
rc = 0;
} else if (rc != 0) {
rc = BLE_ATT_ERR_UNLIKELY;
@@ -798,7 +800,7 @@ ble_att_svr_rx_find_type_value(struct ble_hs_conn *conn,
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_MTU_CMD_SZ);
if (*rxom == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_find_type_value_req_parse((*rxom)->om_data, (*rxom)->om_len,
@@ -888,7 +890,7 @@ ble_att_svr_tx_read_type_rsp(struct ble_hs_conn *conn,
entry = NULL;
while (1) {
rc = ble_att_svr_find_by_uuid(uuid128, &entry);
- if (rc == ENOENT) {
+ if (rc == BLE_HS_ENOENT) {
break;
} else if (rc != 0) {
rc = BLE_ATT_ERR_UNLIKELY;
@@ -975,7 +977,7 @@ ble_att_svr_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*rxom = os_mbuf_pullup(*rxom, OS_MBUF_PKTLEN(*rxom));
if (*rxom == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = ble_att_read_type_req_parse((*rxom)->om_data, (*rxom)->om_len, &req);
@@ -997,7 +999,7 @@ ble_att_svr_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
break;
default:
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
rc = ble_att_svr_tx_read_type_rsp(conn, chan, &req, uuid128);
@@ -1067,7 +1069,7 @@ ble_att_svr_rx_read(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*rxom = os_mbuf_pullup(*rxom, OS_MBUF_PKTLEN(*rxom));
if (*rxom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
@@ -1153,12 +1155,12 @@ ble_att_svr_service_uuid(struct ble_att_svr_entry *entry, uint16_t *uuid16,
case 2:
*uuid16 = le16toh(arg.aha_read.attr_data);
if (*uuid16 == 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
return 0;
default:
- return EINVAL;
+ return BLE_HS_EINVAL;
}
}
@@ -1178,12 +1180,12 @@ ble_att_svr_read_group_type_entry_write(struct os_mbuf *om, uint16_t mtu,
len = BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_128;
}
if (OS_MBUF_PKTLEN(om) + len > mtu) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
buf = os_mbuf_extend(om, len);
if (buf == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
htole16(buf + 0, start_group_handle);
@@ -1213,6 +1215,11 @@ ble_att_svr_tx_read_group_type(struct ble_hs_conn *conn,
void *rsp_buf;
int rc;
+ /* Silence warnings. */
+ rsp_buf = NULL;
+ service_uuid16 = 0;
+ end_group_handle = 0;
+
*err_handle = req->bagq_start_handle;
txom = ble_att_get_pkthdr();
@@ -1331,7 +1338,7 @@ done:
}
}
- if (rc == 0 || rc == EMSGSIZE) {
+ if (rc == 0 || rc == BLE_HS_EMSGSIZE) {
rc = ble_att_read_group_type_rsp_write(
rsp_buf, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ, &rsp);
assert(rc == 0);
@@ -1359,7 +1366,7 @@ ble_att_svr_rx_read_group_type(struct ble_hs_conn *conn,
*rxom = os_mbuf_pullup(*rxom, OS_MBUF_PKTLEN(*rxom));
if (*rxom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
@@ -1447,7 +1454,7 @@ ble_att_svr_rx_write(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_WRITE_REQ_MIN_SZ);
if (*rxom == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto send_err;
}
@@ -1507,7 +1514,7 @@ ble_att_svr_init(void)
OS_MEMPOOL_BYTES(BLE_ATT_SVR_NUM_ENTRIES,
sizeof (struct ble_att_svr_entry)));
if (ble_att_svr_entry_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/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 e970c61..56a77d4 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -17,6 +17,7 @@
#include <stddef.h>
#include <errno.h>
#include <string.h>
+#include "host/ble_hs.h"
#include "host/ble_gap.h"
#include "ble_hs_hci_batch.h"
#include "ble_gap_conn.h"
@@ -56,7 +57,7 @@ ble_gap_direct_connection_establishment(uint8_t addr_type, uint8_t *addr)
entry = ble_hs_hci_batch_entry_alloc();
if (entry == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
entry->bhb_type = BLE_HS_HCI_BATCH_TYPE_DIRECT_CONNECT;
@@ -89,7 +90,7 @@ ble_gap_directed_connectable(uint8_t addr_type, uint8_t *addr)
entry = ble_hs_hci_batch_entry_alloc();
if (entry == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
entry->bhb_type = BLE_HS_HCI_BATCH_TYPE_DIRECT_ADVERTISE;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_gap_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_conn.c b/net/nimble/host/src/ble_gap_conn.c
index 42fe3e4..9942734 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -18,6 +18,7 @@
#include <string.h>
#include <errno.h>
#include "os/os.h"
+#include "host/ble_hs.h"
#include "host/host_hci.h"
#include "ble_hs_ack.h"
#include "ble_hs_conn.h"
@@ -167,7 +168,7 @@ ble_gap_conn_direct_connect(int addr_type, uint8_t *addr)
/* Make sure no master connection attempt is already in progress. */
if (ble_gap_conn_master_in_progress()) {
- rc = EALREADY;
+ rc = BLE_HS_EALREADY;
goto err;
}
@@ -214,7 +215,7 @@ ble_gap_conn_direct_advertise(int addr_type, uint8_t *addr)
/* Make sure no slave connection attempt is already in progress. */
if (ble_gap_conn_slave_in_progress()) {
- rc = EALREADY;
+ rc = BLE_HS_EALREADY;
goto err;
}
@@ -264,7 +265,7 @@ ble_gap_conn_accept_new_conn(uint8_t *addr)
break;
}
- return ENOENT;
+ return BLE_HS_ENOENT;
}
/**
@@ -295,7 +296,7 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
/* This event refers to a new connection. */
rc = ble_gap_conn_accept_new_conn(evt->peer_addr);
if (rc != 0) {
- return ENOENT;
+ return BLE_HS_ENOENT;
}
if (evt->status != BLE_ERR_SUCCESS) {
@@ -309,7 +310,7 @@ ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
if (conn == NULL) {
/* XXX: Ensure this never happens. */
ble_gap_conn_notify_app(BLE_ERR_MEM_CAPACITY, NULL);
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
conn->bhc_handle = evt->connection_handle;
@@ -329,7 +330,7 @@ ble_gap_conn_rx_disconn_complete(struct hci_disconn_complete *evt)
conn = ble_hs_conn_find(evt->connection_handle);
if (conn == NULL) {
- return ENOENT;
+ return BLE_HS_ENOENT;
}
if (evt->status == 0) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_gatt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatt.c b/net/nimble/host/src/ble_gatt.c
index 6ce9636..2671ebc 100644
--- a/net/nimble/host/src/ble_gatt.c
+++ b/net/nimble/host/src/ble_gatt.c
@@ -270,12 +270,12 @@ ble_gatt_new_entry(uint16_t conn_handle, struct ble_gatt_entry **entry)
/* Ensure we have a connection with the specified handle. */
conn = ble_hs_conn_find(conn_handle);
if (conn == NULL) {
- return ENOTCONN;
+ return BLE_HS_ENOTCONN;
}
*entry = ble_gatt_entry_alloc();
if (*entry == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
memset(*entry, 0, sizeof **entry);
@@ -318,7 +318,7 @@ ble_gatt_kick_mtu(struct ble_gatt_entry *entry)
conn = ble_hs_conn_find(entry->conn_handle);
if (conn == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto err;
}
@@ -408,7 +408,7 @@ ble_gatt_kick_disc_all_services(struct ble_gatt_entry *entry)
conn = ble_hs_conn_find(entry->conn_handle);
if (conn == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto err;
}
@@ -433,7 +433,9 @@ static void
ble_gatt_err_disc_all_services(struct ble_gatt_entry *entry,
uint8_t ble_hs_status, uint8_t att_status)
{
- if (ble_hs_status == 255 && att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+ if (ble_hs_status == BLE_HS_EATT &&
+ att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+
/* Discovery is complete. */
ble_hs_status = 0;
att_status = 0;
@@ -474,7 +476,7 @@ ble_gatt_rx_read_group_type_adata(struct ble_hs_conn *conn,
break;
default:
- rc = EMSGSIZE;
+ rc = BLE_HS_EMSGSIZE;
goto done;
}
@@ -565,7 +567,7 @@ ble_gatt_kick_disc_service_uuid(struct ble_gatt_entry *entry)
conn = ble_hs_conn_find(entry->conn_handle);
if (conn == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto err;
}
@@ -591,7 +593,9 @@ static void
ble_gatt_err_disc_service_uuid(struct ble_gatt_entry *entry,
uint8_t ble_hs_status, uint8_t att_status)
{
- if (ble_hs_status == 255 && att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+ if (ble_hs_status == BLE_HS_EATT &&
+ att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+
/* Discovery is complete. */
ble_hs_status = 0;
att_status = 0;
@@ -700,7 +704,7 @@ ble_gatt_kick_disc_all_chars(struct ble_gatt_entry *entry)
conn = ble_hs_conn_find(entry->conn_handle);
if (conn == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto err;
}
@@ -726,7 +730,9 @@ static void
ble_gatt_err_disc_all_chars(struct ble_gatt_entry *entry,
uint8_t ble_hs_status, uint8_t att_status)
{
- if (ble_hs_status == 255 && att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+ if (ble_hs_status == BLE_HS_EATT &&
+ att_status == BLE_ATT_ERR_ATTR_NOT_FOUND) {
+
/* Discovery is complete. */
ble_hs_status = 0;
att_status = 0;
@@ -837,7 +843,7 @@ ble_gatt_kick_read(struct ble_gatt_entry *entry)
conn = ble_hs_conn_find(entry->conn_handle);
if (conn == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto err;
}
@@ -954,7 +960,7 @@ ble_gatt_rx_err(uint16_t conn_handle, struct ble_att_error_rsp *rsp)
}
dispatch = ble_gatt_dispatch_get(entry->op);
- dispatch->err_cb(entry, 255, rsp->baep_error_code);
+ dispatch->err_cb(entry, BLE_HS_EATT, rsp->baep_error_code);
ble_gatt_entry_remove_free(entry, prev);
}
@@ -973,7 +979,7 @@ ble_gatt_connection_broken(uint16_t conn_handle)
}
dispatch = ble_gatt_dispatch_get(entry->op);
- dispatch->err_cb(entry, 254, 0);
+ dispatch->err_cb(entry, BLE_HS_ENOTCONN, 0);
ble_gatt_entry_remove_free(entry, prev);
}
@@ -990,7 +996,7 @@ ble_gatt_init(void)
OS_MEMPOOL_BYTES(BLE_GATT_NUM_ENTRIES,
sizeof (struct ble_gatt_entry)));
if (ble_gatt_entry_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/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 b196f78..a5a4936 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -123,7 +123,7 @@ ble_hs_read_hci_buf_size(void)
entry = ble_hs_hci_batch_entry_alloc();
if (entry == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
entry->bhb_type = BLE_HS_HCI_BATCH_TYPE_READ_HCI_BUF_SIZE;
@@ -133,7 +133,7 @@ ble_hs_read_hci_buf_size(void)
return 0;
}
-void
+static void
ble_hs_task_handler(void *arg)
{
struct os_event *ev;
@@ -197,7 +197,7 @@ ble_hs_rx_data(struct os_mbuf *om)
pkt = os_memblock_get(&ble_hs_pkt_pool);
if (pkt == NULL) {
os_mbuf_free_chain(om);
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
pkt->bhp_om = om;
@@ -214,7 +214,7 @@ ble_hs_tx_data(struct os_mbuf *om)
pkt = os_memblock_get(&ble_hs_pkt_pool);
if (pkt == NULL) {
os_mbuf_free_chain(om);
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
pkt->bhp_om = om;
@@ -280,20 +280,20 @@ ble_hs_init(uint8_t prio)
ble_hs_mbuf_mem = malloc(BLE_HS_MBUF_MEMPOOL_SIZE);
if (ble_hs_mbuf_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
rc = os_mempool_init(&ble_hs_mbuf_mempool, BLE_HS_NUM_MBUFS,
BLE_HS_MBUF_MEMBLOCK_SIZE,
ble_hs_mbuf_mem, "ble_hs_mbuf_pool");
if (rc != 0) {
- rc = EINVAL; // XXX
+ rc = BLE_HS_EINVAL; // XXX
goto err;
}
rc = os_mbuf_pool_init(&ble_hs_mbuf_pool, &ble_hs_mbuf_mempool,
BLE_HS_MBUF_MEMBLOCK_SIZE, BLE_HS_NUM_MBUFS);
if (rc != 0) {
- rc = EINVAL; // XXX
+ rc = BLE_HS_EINVAL; // XXX
goto err;
}
@@ -301,14 +301,14 @@ ble_hs_init(uint8_t prio)
OS_MEMPOOL_BYTES(BLE_HS_PKT_MAX,
sizeof (struct ble_hs_pkt)));
if (ble_hs_pkt_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
rc = os_mempool_init(&ble_hs_pkt_pool, BLE_HS_PKT_MAX,
sizeof (struct ble_hs_pkt),
ble_hs_pkt_mem, "ble_hs_pkt_pool");
if (rc != 0) {
- rc = EINVAL; // XXX
+ rc = BLE_HS_EINVAL; // XXX
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index ffed3a4..b97718d 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -158,14 +158,14 @@ ble_hs_conn_init(void)
OS_MEMPOOL_BYTES(BLE_HS_CONN_MAX,
sizeof (struct ble_hs_conn)));
if (ble_hs_conn_elem_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
rc = os_mempool_init(&ble_hs_conn_pool, BLE_HS_CONN_MAX,
sizeof (struct ble_hs_conn),
ble_hs_conn_elem_mem, "ble_hs_conn_pool");
if (rc != 0) {
- rc = EINVAL; // XXX
+ rc = BLE_HS_EINVAL; // XXX
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_hs_hci_batch.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_batch.c b/net/nimble/host/src/ble_hs_hci_batch.c
index 09f0e7d..809203a 100644
--- a/net/nimble/host/src/ble_hs_hci_batch.c
+++ b/net/nimble/host/src/ble_hs_hci_batch.c
@@ -146,7 +146,7 @@ ble_hs_hci_batch_init(void)
OS_MEMPOOL_BYTES(BLE_HS_HCI_BATCH_NUM_ENTRIES,
sizeof (struct ble_hs_hci_batch_entry)));
if (ble_hs_hci_batch_entry_mem == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
rc = os_mempool_init(&ble_hs_hci_batch_entry_pool,
@@ -155,7 +155,7 @@ ble_hs_hci_batch_init(void)
ble_hs_hci_batch_entry_mem,
"ble_hs_hci_batch_entry_pool");
if (rc != 0) {
- return EINVAL; // XXX
+ return BLE_HS_EINVAL; // XXX
}
STAILQ_INIT(&ble_hs_hci_batch_queue);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_hs_uuid.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_uuid.c b/net/nimble/host/src/ble_hs_uuid.c
index eb3d943..06da0c8 100644
--- a/net/nimble/host/src/ble_hs_uuid.c
+++ b/net/nimble/host/src/ble_hs_uuid.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include "os/os_mbuf.h"
#include "nimble/ble.h"
+#include "host/ble_hs.h"
#include "host/ble_hs_uuid.h"
static uint8_t ble_hs_uuid_base[16] = {
@@ -71,7 +72,7 @@ ble_hs_uuid_from_16bit(uint16_t uuid16, void *uuid128)
uint8_t *u8ptr;
if (uuid16 == 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
u8ptr = uuid128;
@@ -93,14 +94,14 @@ ble_hs_uuid_append(struct os_mbuf *om, void *uuid128)
if (uuid16 != 0) {
buf = os_mbuf_extend(om, 2);
if (buf == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
htole16(buf, uuid16);
} else {
rc = os_mbuf_append(om, uuid128, 16);
if (rc != 0) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
}
@@ -133,6 +134,6 @@ ble_hs_uuid_extract(struct os_mbuf *om, int off, void *uuid128)
return 0;
default:
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index f75e91d..04ca0be 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -91,7 +91,7 @@ ble_l2cap_parse_hdr(struct os_mbuf *om, int off,
rc = os_mbuf_copydata(om, off, sizeof *l2cap_hdr, l2cap_hdr);
if (rc != 0) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
l2cap_hdr->blh_len = le16toh(&l2cap_hdr->blh_len);
@@ -159,12 +159,12 @@ ble_l2cap_rx(struct ble_hs_conn *conn,
os_mbuf_adj(om, BLE_L2CAP_HDR_SZ);
if (l2cap_hdr.blh_len != hci_hdr->hdh_len - BLE_L2CAP_HDR_SZ) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
chan = ble_hs_conn_chan_find(conn, l2cap_hdr.blh_cid);
if (chan == NULL) {
- return ENOENT;
+ return BLE_HS_ENOENT;
}
rc = ble_l2cap_rx_payload(conn, chan, om);
@@ -192,7 +192,7 @@ ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
om = ble_l2cap_prepend_hdr(om, chan->blc_cid);
if (om == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
@@ -227,7 +227,7 @@ ble_l2cap_init(void)
OS_MEMPOOL_BYTES(BLE_L2CAP_CHAN_MAX,
sizeof (struct ble_l2cap_chan)));
if (ble_l2cap_chan_mem == NULL) {
- rc = ENOMEM;
+ rc = BLE_HS_ENOMEM;
goto err;
}
@@ -235,7 +235,7 @@ ble_l2cap_init(void)
sizeof (struct ble_l2cap_chan),
ble_l2cap_chan_mem, "ble_l2cap_chan_pool");
if (rc != 0) {
- rc = EINVAL; // XXX
+ rc = BLE_HS_EINVAL; // XXX
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index 7ff42de..3a442d2 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -143,7 +143,7 @@ host_hci_rx_disconn_complete(uint8_t event_code, uint8_t *data, int len)
int rc;
if (len < BLE_HCI_EVENT_DISCONN_COMPLETE_LEN) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
evt.status = data[0];
@@ -168,7 +168,7 @@ host_hci_rx_cmd_complete(uint8_t event_code, uint8_t *data, int len)
if (len < BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN) {
/* XXX: Increment stat. */
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
num_pkts = data[2];
@@ -182,7 +182,7 @@ host_hci_rx_cmd_complete(uint8_t event_code, uint8_t *data, int len)
opcode != host_hci_outstanding_opcode) {
++g_host_hci_stats.bad_acks_rxd;
- return ENOENT;
+ return BLE_HS_ENOENT;
}
if (opcode == host_hci_outstanding_opcode) {
@@ -215,7 +215,7 @@ host_hci_rx_cmd_status(uint8_t event_code, uint8_t *data, int len)
if (len < BLE_HCI_EVENT_CMD_STATUS_LEN) {
/* XXX: Increment stat. */
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
status = data[2];
@@ -230,7 +230,7 @@ host_hci_rx_cmd_status(uint8_t event_code, uint8_t *data, int len)
opcode != host_hci_outstanding_opcode) {
++g_host_hci_stats.bad_acks_rxd;
- return ENOENT;
+ return BLE_HS_ENOENT;
}
if (opcode == host_hci_outstanding_opcode) {
@@ -258,7 +258,7 @@ host_hci_rx_le_meta(uint8_t event_code, uint8_t *data, int len)
if (len < BLE_HCI_EVENT_HDR_LEN + BLE_HCI_LE_MIN_LEN) {
/* XXX: Increment stat. */
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
subevent = data[2];
@@ -281,7 +281,7 @@ host_hci_rx_le_conn_complete(uint8_t subevent, uint8_t *data, int len)
int rc;
if (len < BLE_HCI_LE_CONN_COMPLETE_LEN) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
evt.subevent_code = data[0];
@@ -307,7 +307,7 @@ int
host_hci_set_buf_size(uint16_t pktlen, uint8_t max_pkts)
{
if (pktlen == 0 || max_pkts == 0) {
- return EINVAL;
+ return BLE_HS_EINVAL;
}
host_hci_buffer_sz = pktlen;
@@ -340,7 +340,7 @@ host_hci_event_rx(uint8_t *data)
entry = host_hci_dispatch_entry_find(event_code);
if (entry == NULL) {
++g_host_hci_stats.unknown_events_rxd;
- rc = ENOTSUP;
+ rc = BLE_HS_ENOTSUP;
} else {
rc = entry->hed_fn(event_code, data, event_len);
}
@@ -400,7 +400,7 @@ host_hci_data_hdr_strip(struct os_mbuf *om, struct hci_data_hdr *hdr)
rc = os_mbuf_copydata(om, 0, BLE_HCI_DATA_HDR_SZ, hdr);
if (rc != 0) {
- return EMSGSIZE;
+ return BLE_HS_EMSGSIZE;
}
/* Strip HCI ACL data header from the front of the packet. */
@@ -452,14 +452,14 @@ host_hci_data_rx(struct os_mbuf *om)
}
if (hci_hdr.hdh_len != OS_MBUF_PKTHDR(om)->omp_len) {
- rc = EMSGSIZE;
+ rc = BLE_HS_EMSGSIZE;
goto done;
}
handle = BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc);
connection = ble_hs_conn_find(handle);
if (connection == NULL) {
- rc = ENOTCONN;
+ rc = BLE_HS_ENOTCONN;
goto done;
}
@@ -519,7 +519,7 @@ host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf *om)
om = host_hci_data_hdr_prepend(om, connection->bhc_handle,
BLE_HCI_PB_FIRST_NON_FLUSH);
if (om == NULL) {
- return ENOMEM;
+ return BLE_HS_ENOMEM;
}
console_printf("host_hci_data_tx(): ");
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/test/ble_att_clt_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_clt_test.c b/net/nimble/host/src/test/ble_att_clt_test.c
index 83d3b49..7c00673 100644
--- a/net/nimble/host/src/test/ble_att_clt_test.c
+++ b/net/nimble/host/src/test/ble_att_clt_test.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include "testutil/testutil.h"
#include "nimble/ble.h"
+#include "host/ble_hs.h"
#include "host/ble_hs_test.h"
#include "ble_hs_conn.h"
#include "ble_att_priv.h"
@@ -54,13 +55,13 @@ TEST_CASE(ble_att_clt_test_tx_find_info)
req.bafq_start_handle = 0;
req.bafq_end_handle = 0xffff;
rc = ble_att_clt_tx_find_info(conn, &req);
- TEST_ASSERT(rc == EINVAL);
+ TEST_ASSERT(rc == BLE_HS_EINVAL);
/*** Error: start handle greater than end handle. */
req.bafq_start_handle = 500;
req.bafq_end_handle = 499;
rc = ble_att_clt_tx_find_info(conn, &req);
- TEST_ASSERT(rc == EINVAL);
+ TEST_ASSERT(rc == BLE_HS_EINVAL);
/*** Success; start and end handles equal. */
req.bafq_start_handle = 500;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/net/nimble/host/src/test/ble_host_hci_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_host_hci_test.c b/net/nimble/host/src/test/ble_host_hci_test.c
index 14f7c6f..062059e 100644
--- a/net/nimble/host/src/test/ble_host_hci_test.c
+++ b/net/nimble/host/src/test/ble_host_hci_test.c
@@ -37,7 +37,7 @@ TEST_CASE(ble_host_hci_test_event_bad)
buf[0] = 0xff;
buf[1] = 0;
rc = host_hci_event_rx(buf);
- TEST_ASSERT(rc == ENOTSUP);
+ TEST_ASSERT(rc == BLE_HS_ENOTSUP);
}
TEST_CASE(ble_host_hci_test_event_cmd_complete)
@@ -50,7 +50,7 @@ TEST_CASE(ble_host_hci_test_event_cmd_complete)
/*** Unsent OCF. */
ble_hs_test_util_build_cmd_complete(buf, sizeof buf, 1, 1, 12345);
rc = host_hci_event_rx(buf);
- TEST_ASSERT(rc == ENOENT);
+ TEST_ASSERT(rc == BLE_HS_ENOENT);
/*** No error on NOP. */
ble_hs_test_util_build_cmd_complete(buf, sizeof buf, 1, 1,
@@ -69,7 +69,7 @@ TEST_CASE(ble_host_hci_test_event_cmd_complete)
/*** Duplicate ack is error. */
rc = host_hci_event_rx(buf);
- TEST_ASSERT(rc == ENOENT);
+ TEST_ASSERT(rc == BLE_HS_ENOENT);
}
TEST_CASE(ble_host_hci_test_event_cmd_status)
@@ -82,7 +82,7 @@ TEST_CASE(ble_host_hci_test_event_cmd_status)
/*** Unsent OCF. */
ble_hs_test_util_build_cmd_status(buf, sizeof buf, 0, 1, 12345);
rc = host_hci_event_rx(buf);
- TEST_ASSERT(rc == ENOENT);
+ TEST_ASSERT(rc == BLE_HS_ENOENT);
/*** No error on NOP. */
ble_hs_test_util_build_cmd_complete(buf, sizeof buf, 0, 1,
@@ -101,7 +101,7 @@ TEST_CASE(ble_host_hci_test_event_cmd_status)
/*** Duplicate ack is error. */
rc = host_hci_event_rx(buf);
- TEST_ASSERT(rc == ENOENT);
+ TEST_ASSERT(rc == BLE_HS_ENOENT);
}
TEST_SUITE(ble_host_hci_suite)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/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 a1fe064..38bcd4d 100644
--- a/net/nimble/host/src/test/ble_l2cap_test.c
+++ b/net/nimble/host/src/test/ble_l2cap_test.c
@@ -52,7 +52,7 @@ TEST_CASE(l2cap_test_bad_header)
TEST_ASSERT_FATAL(om != NULL);
rc = ble_l2cap_rx(conn, &hci_hdr, om);
- TEST_ASSERT(rc == EMSGSIZE);
+ TEST_ASSERT(rc == BLE_HS_EMSGSIZE);
os_mbuf_free_chain(om);
@@ -67,7 +67,7 @@ TEST_CASE(l2cap_test_bad_header)
TEST_ASSERT_FATAL(om != NULL);
rc = ble_l2cap_rx(conn, &hci_hdr, om);
- TEST_ASSERT(rc == ENOENT);
+ TEST_ASSERT(rc == BLE_HS_ENOENT);
os_mbuf_free_chain(om);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/36b80fae/project/hostctlrtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/hostctlrtest/src/main.c b/project/hostctlrtest/src/main.c
index 71997c4..36eb18b 100755
--- a/project/hostctlrtest/src/main.c
+++ b/project/hostctlrtest/src/main.c
@@ -101,13 +101,15 @@ bletest_inc_adv_pkt_num(void) { }
#if HOSTCTLRTEST_CFG_ROLE == HOSTCTLRTEST_ROLE_ADVERTISER
static int
-hostctlrtest_on_disc(uint16_t conn_handle, int status,
- struct ble_gatt_service *service, void *arg)
+hostctlrtest_on_disc(uint16_t conn_handle, uint8_t ble_hs_status,
+ uint8_t att_status, struct ble_gatt_service *service,
+ void *arg)
{
int i;
- if (status != 0) {
- console_printf("service discovery failure: status=%d\n", status);
+ if (ble_hs_status != 0) {
+ console_printf("service discovery failure: ble_hs_status=%d "
+ "att_status=%d\n", ble_hs_status, att_status);
return 0;
}