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/28 23:18:51 UTC
[1/3] incubator-mynewt-larva git commit: Use GATT-specific callbacks
for GATT access.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 41fbd980a -> 14b5ded6d
Use GATT-specific callbacks for GATT access.
Instead of using the ATT-server callbacks. Also, call a registration callback
whenever a service, characteristic, or descriptor is successfully registered.
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/f0aa64b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f0aa64b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f0aa64b5
Branch: refs/heads/master
Commit: f0aa64b5005f5c163c858d6eb4b0485e55a163ab
Parents: 41fbd98
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 28 14:02:28 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 28 14:02:28 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_att.h | 6 +-
net/nimble/host/include/host/ble_gatt.h | 68 +++++++--
net/nimble/host/include/host/ble_hs_uuid.h | 10 ++
net/nimble/host/src/ble_gatt.c | 5 +-
net/nimble/host/src/ble_gatt_priv.h | 3 +-
net/nimble/host/src/ble_gattc.c | 2 +-
net/nimble/host/src/ble_gatts.c | 180 +++++++++++++++++++-----
7 files changed, 227 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/include/host/ble_att.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_att.h b/net/nimble/host/include/host/ble_att.h
index 7705f39..8a0cc17 100644
--- a/net/nimble/host/include/host/ble_att.h
+++ b/net/nimble/host/include/host/ble_att.h
@@ -93,9 +93,9 @@ union ble_att_svr_access_ctxt {
* failure.
*/
typedef int ble_att_svr_access_fn(uint16_t handle_id, uint8_t *uuid128,
- uint8_t op,
- union ble_att_svr_access_ctxt *ctxt,
- void *arg);
+ uint8_t op,
+ union 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);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/include/host/ble_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gatt.h b/net/nimble/host/include/host/ble_gatt.h
index 6706613..cc54db6 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -72,16 +72,18 @@ int ble_gatt_exchange_mtu(uint16_t conn_handle);
int ble_gatt_init(void);
/*** @server. */
-struct ble_gatt_dsc_def {
- uint8_t *uuid128;
- uint8_t att_flags;
- ble_att_svr_access_fn *access_cb;
- void *arg;
-};
+
+#define BLE_GATT_ACCESS_OP_READ_CHR 0
+#define BLE_GATT_ACCESS_OP_WRITE_CHR 1
+/* XXX: Notify, listen. */
+
+union ble_gatt_access_ctxt;
+typedef int ble_gatt_access_fn(uint16_t handle_id, uint8_t op,
+ union ble_gatt_access_ctxt *ctxt, void *arg);
struct ble_gatt_chr_def {
uint8_t *uuid128; /* NULL if no more characteristics. */
- ble_att_svr_access_fn *access_cb;
+ ble_gatt_access_fn *access_cb;
void *arg;
struct ble_gatt_dsc_def *descriptors;
uint8_t properties;
@@ -98,6 +100,56 @@ struct ble_gatt_svc_def {
struct ble_gatt_chr_def *characteristics;
};
-int ble_gatt_register_services(const struct ble_gatt_svc_def *svcs);
+union ble_gatt_access_ctxt {
+ struct {
+ const struct ble_gatt_chr_def *chr;
+ void *chr_data;
+ int chr_len;
+ } bgc_read;
+
+ struct {
+ const struct ble_gatt_chr_def *chr;
+ void *chr_data;
+ int chr_len;
+ } bgc_write;
+};
+
+struct ble_gatt_dsc_def {
+ uint8_t *uuid128;
+ uint8_t att_flags;
+ ble_att_svr_access_fn *access_cb;
+ void *arg;
+};
+
+#define BLE_GATT_REGISTER_OP_SVC 0
+#define BLE_GATT_REGISTER_OP_CHR 1
+#define BLE_GATT_REGISTER_OP_DSC 2
+
+union ble_gatt_register_ctxt;
+typedef void ble_gatt_register_fn(uint8_t op,
+ union ble_gatt_register_ctxt *ctxt);
+
+int ble_gatt_register_services(const struct ble_gatt_svc_def *svcs,
+ ble_gatt_register_fn *register_cb);
+
+union ble_gatt_register_ctxt {
+ struct {
+ uint16_t handle;
+ const struct ble_gatt_svc_def *svc;
+ } bgr_svc;
+
+ struct {
+ uint16_t def_handle;
+ uint16_t val_handle;
+ const struct ble_gatt_chr_def *chr;
+ } bgr_chr;
+
+ struct {
+ uint16_t dsc_handle;
+ const struct ble_gatt_dsc_def *dsc;
+ uint16_t chr_def_handle;
+ const struct ble_gatt_chr_def *chr;
+ } bgr_dsc;
+};
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/include/host/ble_hs_uuid.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_uuid.h b/net/nimble/host/include/host/ble_hs_uuid.h
index 1515a60..c38f1a8 100644
--- a/net/nimble/host/include/host/ble_hs_uuid.h
+++ b/net/nimble/host/include/host/ble_hs_uuid.h
@@ -24,4 +24,14 @@ int ble_hs_uuid_from_16bit(uint16_t uuid16, void *dst);
int ble_hs_uuid_append(struct os_mbuf *om, void *uuid128);
int ble_hs_uuid_extract(struct os_mbuf *om, int off, void *uuid128);
+/**
+ * Expands to a designated initializer byte array containing the 128-bit
+ * representation of the specified 16-bit UUID.
+ */
+#define BLE_UUID16(uuid16) ((uint8_t[16]) { \
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, \
+ 0x00, 0x10, 0x00, 0x00, (uuid16) & 0xff, (((uuid16) & 0xff00) >> 8), \
+ 0x00, 0x00 \
+})
+
#endif /* _BLE_HOST_UUID_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/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 920e4e2..5af7e17 100644
--- a/net/nimble/host/src/ble_gatt.c
+++ b/net/nimble/host/src/ble_gatt.c
@@ -62,9 +62,10 @@ ble_gatt_connection_broken(uint16_t conn_handle)
}
int
-ble_gatt_register_services(const struct ble_gatt_svc_def *svcs)
+ble_gatt_register_services(const struct ble_gatt_svc_def *svcs,
+ ble_gatt_register_fn *register_cb)
{
- return ble_gatts_register_services(svcs);
+ return ble_gatts_register_services(svcs, register_cb);
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/src/ble_gatt_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatt_priv.h b/net/nimble/host/src/ble_gatt_priv.h
index 51dfc27..5271617 100644
--- a/net/nimble/host/src/ble_gatt_priv.h
+++ b/net/nimble/host/src/ble_gatt_priv.h
@@ -65,6 +65,7 @@ void ble_gattc_connection_broken(uint16_t conn_handle);
int ble_gattc_init(void);
/*** @server. */
-int ble_gatts_register_services(const struct ble_gatt_svc_def *svcs);
+int ble_gatts_register_services(const struct ble_gatt_svc_def *svcs,
+ ble_gatt_register_fn *register_cb);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index bd48e41..e3d9cbb 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -153,7 +153,7 @@ static const struct ble_gattc_dispatch_entry
#define BLE_GATT_ENTRY_F_CONGESTED 0x04
#define BLE_GATT_ENTRY_F_NO_MEM 0x08
-#define BLE_GATT_NUM_ENTRIES 4
+#define BLE_GATT_NUM_ENTRIES 16
static void *ble_gattc_entry_mem;
static struct os_mempool ble_gattc_entry_pool;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f0aa64b5/net/nimble/host/src/ble_gatts.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatts.c b/net/nimble/host/src/ble_gatts.c
index d5010c8..83d54e8 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -82,8 +82,8 @@ ble_gatts_inc_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
}
static int
-ble_gatts_chr_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
- union ble_att_svr_access_ctxt *ctxt, void *arg)
+ble_gatts_chr_def_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
+ union ble_att_svr_access_ctxt *ctxt, void *arg)
{
static uint8_t buf[BLE_GATTS_CHR_MAX_SZ];
const struct ble_gatt_chr_def *chr;
@@ -111,6 +111,81 @@ ble_gatts_chr_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
return 0;
}
+static void
+ble_gatts_ctxt_from_att_ctxt(uint8_t att_op,
+ union ble_att_svr_access_ctxt *att_ctxt,
+ uint8_t *out_gatt_op,
+ union ble_gatt_access_ctxt *out_gatt_ctxt,
+ void *att_arg)
+{
+ switch (att_op) {
+ case BLE_ATT_ACCESS_OP_READ:
+ *out_gatt_op = BLE_GATT_ACCESS_OP_READ_CHR;
+ out_gatt_ctxt->bgc_read.chr = att_arg;
+ out_gatt_ctxt->bgc_read.chr_data = att_ctxt->ahc_read.attr_data;
+ out_gatt_ctxt->bgc_read.chr_len = att_ctxt->ahc_read.attr_len;
+ break;
+
+ case BLE_ATT_ACCESS_OP_WRITE:
+ *out_gatt_op = BLE_GATT_ACCESS_OP_WRITE_CHR;
+ out_gatt_ctxt->bgc_write.chr = att_arg;
+ out_gatt_ctxt->bgc_write.chr_data = att_ctxt->ahc_write.attr_data;
+ out_gatt_ctxt->bgc_write.chr_len = att_ctxt->ahc_write.attr_len;
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+static void
+ble_gatts_ctxt_to_att_ctxt(uint8_t gatt_op,
+ union ble_gatt_access_ctxt *gatt_ctxt,
+ union ble_att_svr_access_ctxt *out_att_ctxt)
+{
+ switch (gatt_op) {
+ case BLE_GATT_ACCESS_OP_READ_CHR:
+ out_att_ctxt->ahc_read.attr_data = gatt_ctxt->bgc_read.chr_data;
+ out_att_ctxt->ahc_read.attr_len = gatt_ctxt->bgc_read.chr_len;
+ break;
+
+ case BLE_GATT_ACCESS_OP_WRITE_CHR:
+ out_att_ctxt->ahc_write.attr_data = gatt_ctxt->bgc_write.chr_data;
+ out_att_ctxt->ahc_write.attr_len = gatt_ctxt->bgc_write.chr_len;
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+static int
+ble_gatts_chr_val_access(uint16_t handle_id, uint8_t *uuid128, uint8_t att_op,
+ union ble_att_svr_access_ctxt *att_ctxt, void *arg)
+{
+ const struct ble_gatt_chr_def *chr;
+ union ble_gatt_access_ctxt gatt_ctxt;
+ uint8_t gatt_op;
+ int rc;
+
+ ble_gatts_ctxt_from_att_ctxt(att_op, att_ctxt, &gatt_op, &gatt_ctxt, arg);
+
+ chr = arg;
+ assert(chr != NULL && chr->access_cb != NULL);
+
+ rc = chr->access_cb(handle_id, gatt_op, &gatt_ctxt, chr->arg);
+ if (rc != 0) {
+ return rc;
+ }
+
+ ble_gatts_ctxt_to_att_ctxt(gatt_op, &gatt_ctxt, att_ctxt);
+
+ return 0;
+}
+
+
static int
ble_gatts_find_svc(const struct ble_gatt_svc_def *svc)
{
@@ -165,34 +240,49 @@ ble_gatts_register_inc(struct ble_gatts_svc_entry *entry)
}
static int
-ble_gatts_register_dsc(const struct ble_gatt_dsc_def *dsc)
+ble_gatts_register_dsc(const struct ble_gatt_dsc_def *dsc,
+ const struct ble_gatt_chr_def *chr,
+ uint16_t chr_def_handle,
+ ble_gatt_register_fn *register_cb)
{
- uint16_t handle;
+ union ble_gatt_register_ctxt register_ctxt;
+ uint16_t dsc_handle;
int rc;
- rc = ble_att_svr_register(dsc->uuid128, dsc->att_flags, &handle,
+ rc = ble_att_svr_register(dsc->uuid128, dsc->att_flags, &dsc_handle,
dsc->access_cb, (void *)dsc->arg);
if (rc != 0) {
return rc;
}
+ if (register_cb != NULL) {
+ register_ctxt.bgr_dsc.dsc_handle = dsc_handle;
+ register_ctxt.bgr_dsc.dsc = dsc;
+ register_ctxt.bgr_dsc.chr_def_handle = chr_def_handle;
+ register_ctxt.bgr_dsc.chr = chr;
+ register_cb(BLE_GATT_REGISTER_OP_DSC, ®ister_ctxt);
+ }
+
return 0;
}
static int
-ble_gatts_register_chr(const struct ble_gatt_chr_def *chr)
+ble_gatts_register_chr(const struct ble_gatt_chr_def *chr,
+ ble_gatt_register_fn *register_cb)
{
+ union ble_gatt_register_ctxt register_ctxt;
struct ble_gatt_dsc_def *dsc;
- uint16_t handle;
+ uint16_t def_handle;
+ uint16_t val_handle;
int rc;
/* Register characteristic declaration attribute (cast away const on
* callback arg).
*/
rc = ble_att_svr_register_uuid16(BLE_ATT_UUID_CHARACTERISTIC,
- HA_FLAG_PERM_READ, &handle,
- ble_gatts_chr_access, (void *)chr);
+ HA_FLAG_PERM_READ, &def_handle,
+ ble_gatts_chr_def_access, (void *)chr);
if (rc != 0) {
return rc;
}
@@ -200,16 +290,25 @@ ble_gatts_register_chr(const struct ble_gatt_chr_def *chr)
/* Register characteristic value attribute (cast away const on callback
* arg).
*/
- rc = ble_att_svr_register(chr->uuid128, HA_FLAG_PERM_READ /*XXX*/, &handle,
- chr->access_cb, (void *)chr->arg);
+ rc = ble_att_svr_register(chr->uuid128, HA_FLAG_PERM_READ /*XXX*/,
+ &val_handle,
+ ble_gatts_chr_val_access, (void *)chr);
if (rc != 0) {
return rc;
}
+ assert(val_handle == def_handle + 1);
+
+ if (register_cb != NULL) {
+ register_ctxt.bgr_chr.def_handle = def_handle;
+ register_ctxt.bgr_chr.val_handle = val_handle;
+ register_ctxt.bgr_chr.chr = chr;
+ register_cb(BLE_GATT_REGISTER_OP_CHR, ®ister_ctxt);
+ }
/* Register each descriptor. */
if (chr->descriptors != NULL) {
for (dsc = chr->descriptors; dsc->uuid128 != NULL; dsc++) {
- rc = ble_gatts_register_dsc(dsc);
+ rc = ble_gatts_register_dsc(dsc, chr, def_handle, register_cb);
if (rc != 0) {
return rc;
}
@@ -220,11 +319,30 @@ ble_gatts_register_chr(const struct ble_gatt_chr_def *chr)
}
static int
+ble_gatts_svc_type_to_uuid(uint8_t svc_type, uint16_t *out_uuid16)
+{
+ switch (svc_type) {
+ case BLE_GATT_SVC_TYPE_PRIMARY:
+ *out_uuid16 = BLE_ATT_UUID_PRIMARY_SERVICE;
+ return 0;
+
+ case BLE_GATT_SVC_TYPE_SECONDARY:
+ *out_uuid16 = BLE_ATT_UUID_SECONDARY_SERVICE;
+ return 0;
+
+ default:
+ return BLE_HS_EINVAL;
+ }
+}
+
+static int
ble_gatts_register_svc(const struct ble_gatt_svc_def *svc,
- uint16_t *out_handle)
+ uint16_t *out_handle,
+ ble_gatt_register_fn *register_cb)
{
const struct ble_gatt_svc_def *incl;
const struct ble_gatt_chr_def *chr;
+ union ble_gatt_register_ctxt register_ctxt;
uint16_t uuid16;
int idx;
int rc;
@@ -233,28 +351,26 @@ ble_gatts_register_svc(const struct ble_gatt_svc_def *svc,
return BLE_HS_EAGAIN;
}
+ rc = ble_gatts_svc_type_to_uuid(svc->type, &uuid16);
+ if (rc != 0) {
+ return rc;
+ }
+
/* Register service definition attribute (cast away const on callback
* arg).
*/
- switch (svc->type) {
- case BLE_GATT_SVC_TYPE_PRIMARY:
- uuid16 = BLE_ATT_UUID_PRIMARY_SERVICE;
- break;
-
- case BLE_GATT_SVC_TYPE_SECONDARY:
- uuid16 = BLE_ATT_UUID_SECONDARY_SERVICE;
- break;
-
- default:
- return BLE_HS_EINVAL;
- }
-
rc = ble_att_svr_register_uuid16(uuid16, HA_FLAG_PERM_READ, out_handle,
ble_gatts_svc_access, (void *)svc);
if (rc != 0) {
return rc;
}
+ if (register_cb != NULL) {
+ register_ctxt.bgr_svc.handle = *out_handle;
+ register_ctxt.bgr_svc.svc = svc;
+ register_cb(BLE_GATT_REGISTER_OP_SVC, ®ister_ctxt);
+ }
+
/* Register each include. */
if (svc->includes != NULL) {
for (incl = *svc->includes; incl != NULL; incl++) {
@@ -271,7 +387,7 @@ ble_gatts_register_svc(const struct ble_gatt_svc_def *svc,
/* Register each characteristic. */
if (svc->characteristics != NULL) {
for (chr = svc->characteristics; chr->uuid128 != NULL; chr++) {
- rc = ble_gatts_register_chr(chr);
+ rc = ble_gatts_register_chr(chr, register_cb);
if (rc != 0) {
return rc;
}
@@ -283,7 +399,7 @@ ble_gatts_register_svc(const struct ble_gatt_svc_def *svc,
}
static int
-ble_gatts_register_round(int *out_num_registered)
+ble_gatts_register_round(int *out_num_registered, ble_gatt_register_fn *cb)
{
struct ble_gatts_svc_entry *entry;
uint16_t handle;
@@ -295,13 +411,12 @@ ble_gatts_register_round(int *out_num_registered)
entry = ble_gatts_svc_entries + i;
if (entry->handle == 0) {
- rc = ble_gatts_register_svc(entry->svc, &handle);
+ rc = ble_gatts_register_svc(entry->svc, &handle, cb);
switch (rc) {
case 0:
/* Service successfully registered. */
entry->handle = handle;
(*out_num_registered)++;
- /* XXX: Call callback. */
break;
case BLE_HS_EAGAIN:
@@ -324,7 +439,8 @@ ble_gatts_register_round(int *out_num_registered)
}
int
-ble_gatts_register_services(const struct ble_gatt_svc_def *svcs)
+ble_gatts_register_services(const struct ble_gatt_svc_def *svcs,
+ ble_gatt_register_fn *cb)
{
int total_registered;
int cur_registered;
@@ -339,7 +455,7 @@ ble_gatts_register_services(const struct ble_gatt_svc_def *svcs)
total_registered = 0;
while (total_registered < ble_gatts_num_svc_entries) {
- rc = ble_gatts_register_round(&cur_registered);
+ rc = ble_gatts_register_round(&cur_registered, cb);
if (rc != 0) {
return rc;
}
[2/3] incubator-mynewt-larva git commit: Update test projects with
latest GATT changes.
Posted by cc...@apache.org.
Update test projects with latest GATT changes.
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/f23c5ab5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f23c5ab5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f23c5ab5
Branch: refs/heads/master
Commit: f23c5ab50dea99f1acef1bccca3fcdbf46eafd83
Parents: f0aa64b
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 28 14:07:20 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 28 14:07:20 2015 -0800
----------------------------------------------------------------------
project/centtest/src/main.c | 6 ++-
project/prphtest/src/main.c | 102 ++++++++++++++++++++++++++++++++++-----
2 files changed, 93 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f23c5ab5/project/centtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/centtest/src/main.c b/project/centtest/src/main.c
index 1fb76f3..fdc3c56 100755
--- a/project/centtest/src/main.c
+++ b/project/centtest/src/main.c
@@ -107,6 +107,7 @@ static int
centtest_on_disc_c(uint16_t conn_handle, int status,
struct ble_gatt_chr *chr, void *arg)
{
+ int rc;
int i;
if (status != 0) {
@@ -131,7 +132,8 @@ centtest_on_disc_c(uint16_t conn_handle, int status,
}
console_printf("\n");
- ble_gatt_read(conn_handle, chr->value_handle, centtest_on_read, NULL);
+ rc = ble_gatt_read(conn_handle, chr->value_handle, centtest_on_read, NULL);
+ assert(rc == 0);
return 0;
}
@@ -148,7 +150,7 @@ centtest_on_disc_s(uint16_t conn_handle, int status,
}
if (service == NULL) {
- console_printf("service discovery complete.");
+ console_printf("service discovery complete.\n");
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f23c5ab5/project/prphtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/prphtest/src/main.c b/project/prphtest/src/main.c
index 8d74552..7fcdc9e 100755
--- a/project/prphtest/src/main.c
+++ b/project/prphtest/src/main.c
@@ -77,15 +77,40 @@ void
bletest_inc_adv_pkt_num(void) { }
static int
-prphtest_attr_cb(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
- union ble_att_svr_access_ctxt *ctxt, void *arg);
+prphtest_gatt_cb(uint16_t handle_id, uint8_t op,
+ union ble_gatt_access_ctxt *ctxt, void *arg);
+
+#define PRPHTEST_SVC1_UUID 0x1234
+#define PRPHTEST_SVC2_UUID 0x5678
+#define PRPHTEST_CHR1_UUID 0x1111
+#define PRPHTEST_CHR2_UUID 0x1112
+#define PRPHTEST_CHR3_UUID 0x5555
static const struct ble_gatt_svc_def prphtest_svcs[] = { {
+ /*** Service 0x1234. */
+ .type = BLE_GATT_SVC_TYPE_PRIMARY,
+ .uuid128 = BLE_UUID16(PRPHTEST_SVC1_UUID),
+ .characteristics = (struct ble_gatt_chr_def[]) { {
+ /*** Characteristic 0x1111. */
+ .uuid128 = BLE_UUID16(PRPHTEST_CHR1_UUID),
+ .access_cb = prphtest_gatt_cb,
+ .properties = 0,
+ }, {
+ /*** Characteristic 0x1112. */
+ .uuid128 = BLE_UUID16(PRPHTEST_CHR2_UUID),
+ .access_cb = prphtest_gatt_cb,
+ .properties = 0,
+ }, {
+ .uuid128 = NULL, /* No more characteristics in this service. */
+ } },
+}, {
+ /*** Service 0x5678. */
.type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid128 = (uint8_t[]){ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 },
+ .uuid128 = BLE_UUID16(PRPHTEST_SVC2_UUID),
.characteristics = (struct ble_gatt_chr_def[]) { {
- .uuid128 = (uint8_t[]){ 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 },
- .access_cb = prphtest_attr_cb,
+ /*** Characteristic 0x5555. */
+ .uuid128 = BLE_UUID16(PRPHTEST_CHR3_UUID),
+ .access_cb = prphtest_gatt_cb,
.properties = 0,
}, {
.uuid128 = NULL, /* No more characteristics in this service. */
@@ -95,27 +120,78 @@ static const struct ble_gatt_svc_def prphtest_svcs[] = { {
}, };
static int
-prphtest_attr_cb(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
- union ble_att_svr_access_ctxt *ctxt, void *arg)
+prphtest_gatt_cb(uint16_t handle_id, uint8_t op,
+ union ble_gatt_access_ctxt *ctxt, void *arg)
{
static uint8_t buf[128];
+ uint16_t uuid16;
+
+ assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
+
+ uuid16 = ble_hs_uuid_16bit(ctxt->bgc_read.chr->uuid128);
+ switch (uuid16) {
+ case PRPHTEST_CHR1_UUID:
+ console_printf("reading characteristic1 value");
+ memcpy(buf, "char1", 5);
+ ctxt->bgc_read.chr_len = 5;
+ break;
- assert(op == BLE_ATT_ACCESS_OP_READ);
+ case PRPHTEST_CHR2_UUID:
+ console_printf("reading characteristic2 value");
+ memcpy(buf, "char2", 5);
+ ctxt->bgc_read.chr_len = 5;
+ break;
- console_printf("reading characteristic1 value");
- memcpy(buf, "char1", 5);
- ctxt->ahc_read.attr_data = buf;
- ctxt->ahc_read.attr_len = 5;
+ case PRPHTEST_CHR3_UUID:
+ console_printf("reading characteristic3 value");
+ memcpy(buf, "char3", 5);
+ ctxt->bgc_read.chr_len = 5;
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
+ ctxt->bgc_read.chr_data = buf;
return 0;
}
static void
+prphtest_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt)
+{
+ uint16_t uuid16;
+
+ switch (op) {
+ case BLE_GATT_REGISTER_OP_SVC:
+ uuid16 = ble_hs_uuid_16bit(ctxt->bgr_svc.svc->uuid128);
+ assert(uuid16 != 0);
+ console_printf("registered service 0x%04x with handle=%d\n",
+ uuid16, ctxt->bgr_svc.handle);
+ break;
+
+ case BLE_GATT_REGISTER_OP_CHR:
+ uuid16 = ble_hs_uuid_16bit(ctxt->bgr_chr.chr->uuid128);
+ assert(uuid16 != 0);
+ console_printf("registering characteristic 0x%04x with def_handle=%d "
+ "val_handle=%d\n",
+ uuid16, ctxt->bgr_chr.def_handle,
+ ctxt->bgr_chr.val_handle);
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+static void
prphtest_register_attrs(void)
{
int rc;
- rc = ble_gatt_register_services(prphtest_svcs);
+ rc = ble_gatt_register_services(prphtest_svcs, prphtest_register_cb);
assert(rc == 0);
}
[3/3] incubator-mynewt-larva git commit: Rename UUID identifiers.
Posted by cc...@apache.org.
Rename UUID identifiers.
ble_hs_uuid.* --> ble_uuid.*
ble_uuid_16bit --> ble_uuid_128_to_16
ble_uuid_from_16bit --> ble_uuid_16_to_128
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/14b5ded6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/14b5ded6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/14b5ded6
Branch: refs/heads/master
Commit: 14b5ded6d248376d117f7131310c77f05c9d5e7b
Parents: f23c5ab
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Dec 28 14:16:57 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Dec 28 14:18:23 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_hs_test.h | 2 +-
net/nimble/host/include/host/ble_hs_uuid.h | 37 -----
net/nimble/host/include/host/ble_uuid.h | 37 +++++
net/nimble/host/src/ble_att_clt.c | 8 +-
net/nimble/host/src/ble_att_cmd.c | 2 +-
net/nimble/host/src/ble_att_svr.c | 16 +--
net/nimble/host/src/ble_gattc.c | 10 +-
net/nimble/host/src/ble_gatts.c | 6 +-
net/nimble/host/src/ble_hs_uuid.c | 139 -------------------
net/nimble/host/src/ble_uuid.c | 139 +++++++++++++++++++
net/nimble/host/src/test/ble_att_svr_test.c | 4 +-
net/nimble/host/src/test/ble_gatt_disc_c_test.c | 4 +-
net/nimble/host/src/test/ble_gatt_disc_s_test.c | 6 +-
net/nimble/host/src/test/ble_gatt_read_test.c | 2 +-
net/nimble/host/src/test/ble_gatt_write_test.c | 2 +-
net/nimble/host/src/test/ble_hs_test.c | 2 +-
net/nimble/host/src/test/ble_hs_uuid_test.c | 87 ------------
net/nimble/host/src/test/ble_uuid_test.c | 87 ++++++++++++
project/centtest/src/main.c | 2 +-
project/prphtest/src/main.c | 8 +-
20 files changed, 300 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/include/host/ble_hs_test.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_test.h b/net/nimble/host/include/host/ble_hs_test.h
index bf145f3..4e69726 100644
--- a/net/nimble/host/include/host/ble_hs_test.h
+++ b/net/nimble/host/include/host/ble_hs_test.h
@@ -29,7 +29,7 @@ int ble_att_clt_test_all(void);
int ble_host_hci_test_all(void);
int ble_hs_conn_test_all(void);
int ble_os_test_all(void);
-int ble_hs_uuid_test_all(void);
+int ble_uuid_test_all(void);
int ble_gatt_disc_s_test_all(void);
int ble_gatt_disc_c_test_all(void);
int ble_gatt_read_test_all(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/include/host/ble_hs_uuid.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_uuid.h b/net/nimble/host/include/host/ble_hs_uuid.h
deleted file mode 100644
index c38f1a8..0000000
--- a/net/nimble/host/include/host/ble_hs_uuid.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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_UUID_
-#define H_BLE_HS_UUID_
-
-struct os_mbuf;
-
-uint16_t ble_hs_uuid_16bit(void *uuid128);
-int ble_hs_uuid_from_16bit(uint16_t uuid16, void *dst);
-int ble_hs_uuid_append(struct os_mbuf *om, void *uuid128);
-int ble_hs_uuid_extract(struct os_mbuf *om, int off, void *uuid128);
-
-/**
- * Expands to a designated initializer byte array containing the 128-bit
- * representation of the specified 16-bit UUID.
- */
-#define BLE_UUID16(uuid16) ((uint8_t[16]) { \
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, \
- 0x00, 0x10, 0x00, 0x00, (uuid16) & 0xff, (((uuid16) & 0xff00) >> 8), \
- 0x00, 0x00 \
-})
-
-#endif /* _BLE_HOST_UUID_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/include/host/ble_uuid.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_uuid.h b/net/nimble/host/include/host/ble_uuid.h
new file mode 100644
index 0000000..6b5ba04
--- /dev/null
+++ b/net/nimble/host/include/host/ble_uuid.h
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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_UUID_
+#define H_BLE_UUID_
+
+struct os_mbuf;
+
+uint16_t ble_uuid_128_to_16(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);
+
+/**
+ * Expands to a designated initializer byte array containing the 128-bit
+ * representation of the specified 16-bit UUID.
+ */
+#define BLE_UUID16(uuid16) ((uint8_t[16]) { \
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, \
+ 0x00, 0x10, 0x00, 0x00, (uuid16) & 0xff, (((uuid16) & 0xff00) >> 8), \
+ 0x00, 0x00 \
+})
+
+#endif /* _BLE_HOST_UUID_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/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 5bf9ddf..41fabc5 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include "os/os_mempool.h"
#include "nimble/ble.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_gatt_priv.h"
#include "ble_hs_priv.h"
#include "ble_hs_conn.h"
@@ -226,7 +226,7 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
off += 2;
uuid16 = le16toh(&uuid16);
- rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
+ rc = ble_uuid_16_to_128(uuid16, uuid128);
if (rc != 0) {
return BLE_HS_EINVAL;
}
@@ -277,7 +277,7 @@ ble_att_clt_tx_read_type(struct ble_hs_conn *conn,
rc = ble_att_read_type_req_write(txom->om_data, txom->om_len, req);
assert(rc == 0);
- rc = ble_hs_uuid_append(txom, uuid128);
+ rc = ble_uuid_append(txom, uuid128);
if (rc != 0) {
goto err;
}
@@ -451,7 +451,7 @@ ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
rc = ble_att_read_group_type_req_write(txom->om_data, txom->om_len, req);
assert(rc == 0);
- rc = ble_hs_uuid_append(txom, uuid128);
+ rc = ble_uuid_append(txom, uuid128);
if (rc != 0) {
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/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 ab51538..2a244d6 100644
--- a/net/nimble/host/src/ble_att_cmd.c
+++ b/net/nimble/host/src/ble_att_cmd.c
@@ -20,7 +20,7 @@
#include "nimble/ble.h"
#include "ble_hs_priv.h"
#include "host/ble_att.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_l2cap.h"
#include "ble_att_cmd.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/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 40f99dd..f36b8d8 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -19,7 +19,7 @@
#include <assert.h>
#include "os/os.h"
#include "nimble/ble.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_priv.h"
#include "ble_hs_priv.h"
#include "ble_l2cap.h"
@@ -165,7 +165,7 @@ ble_att_svr_register_uuid16(uint16_t uuid16, uint8_t flags,
uint8_t uuid128[16];
int rc;
- rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
+ rc = ble_uuid_16_to_128(uuid16, uuid128);
if (rc != 0) {
return rc;
}
@@ -463,7 +463,7 @@ ble_att_svr_fill_info(struct ble_att_find_info_req *req, struct os_mbuf *om,
goto done;
}
if (ha->ha_handle_id >= req->bafq_start_handle) {
- uuid16 = ble_hs_uuid_16bit(ha->ha_uuid);
+ uuid16 = ble_uuid_128_to_16(ha->ha_uuid);
if (*format == 0) {
if (uuid16 != 0) {
@@ -803,7 +803,7 @@ ble_att_svr_fill_type_value(struct ble_att_find_type_value_req *req,
/* Compare the attribute type and value to the request fields to
* determine if this attribute matches.
*/
- uuid16 = ble_hs_uuid_16bit(ha->ha_uuid);
+ uuid16 = ble_uuid_128_to_16(ha->ha_uuid);
if (uuid16 == req->bavq_attr_type) {
rc = ha->ha_cb(ha->ha_handle_id, ha->ha_uuid,
BLE_ATT_ACCESS_OP_READ, &arg, ha->ha_cb_arg);
@@ -1132,7 +1132,7 @@ ble_att_svr_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
switch ((*rxom)->om_len) {
case BLE_ATT_READ_TYPE_REQ_SZ_16:
uuid16 = le16toh((*rxom)->om_data + 5);
- rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
+ rc = ble_uuid_16_to_128(uuid16, uuid128);
if (rc != 0) {
att_err = BLE_ATT_ERR_ATTR_NOT_FOUND;
err_handle = 0;
@@ -1292,7 +1292,7 @@ ble_att_svr_is_valid_group_type(uint8_t *uuid128)
{
uint16_t uuid16;
- uuid16 = ble_hs_uuid_16bit(uuid128);
+ uuid16 = ble_uuid_128_to_16(uuid128);
return uuid16 == BLE_ATT_UUID_PRIMARY_SERVICE ||
uuid16 == BLE_ATT_UUID_SECONDARY_SERVICE;
@@ -1570,8 +1570,8 @@ ble_att_svr_rx_read_group_type(struct ble_hs_conn *conn,
goto err;
}
- rc = ble_hs_uuid_extract(*rxom, BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ,
- uuid128);
+ rc = ble_uuid_extract(*rxom, BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ,
+ uuid128);
if (rc != 0) {
att_err = BLE_ATT_ERR_INVALID_PDU;
err_handle = req.bagq_start_handle;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index e3d9cbb..896f754 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -23,7 +23,7 @@
#include "nimble/ble.h"
#include "ble_gatt_priv.h"
#include "ble_hs_priv.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_conn.h"
#include "ble_att_cmd.h"
#include "ble_att_priv.h"
@@ -485,7 +485,7 @@ ble_gattc_kick_disc_all_services(struct ble_gattc_entry *entry)
goto err;
}
- rc = ble_hs_uuid_from_16bit(BLE_ATT_UUID_PRIMARY_SERVICE, uuid128);
+ rc = ble_uuid_16_to_128(BLE_ATT_UUID_PRIMARY_SERVICE, uuid128);
assert(rc == 0);
req.bagq_start_handle = entry->disc_all_services.prev_handle + 1;
@@ -538,7 +538,7 @@ ble_gattc_rx_read_group_type_adata(struct ble_hs_conn *conn,
switch (adata->value_len) {
case 2:
uuid16 = le16toh(adata->value);
- rc = ble_hs_uuid_from_16bit(uuid16, service.uuid128);
+ rc = ble_uuid_16_to_128(uuid16, service.uuid128);
if (rc != 0) {
goto done;
}
@@ -780,7 +780,7 @@ ble_gattc_kick_disc_all_chars(struct ble_gattc_entry *entry)
goto err;
}
- rc = ble_hs_uuid_from_16bit(BLE_ATT_UUID_CHARACTERISTIC, uuid128);
+ rc = ble_uuid_16_to_128(BLE_ATT_UUID_CHARACTERISTIC, uuid128);
assert(rc == 0);
req.batq_start_handle = entry->disc_all_chars.prev_handle + 1;
@@ -837,7 +837,7 @@ ble_gattc_rx_read_type_adata(struct ble_hs_conn *conn,
switch (adata->value_len) {
case BLE_GATT_CHR_DECL_SZ_16:
uuid16 = le16toh(adata->value + 3);
- rc = ble_hs_uuid_from_16bit(uuid16, chr.uuid128);
+ rc = ble_uuid_16_to_128(uuid16, chr.uuid128);
if (rc != 0) {
rc = BLE_HS_EBADDATA;
goto done;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/ble_gatts.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatts.c b/net/nimble/host/src/ble_gatts.c
index 83d54e8..dd27b4e 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -18,7 +18,7 @@
#include <assert.h>
#include <string.h>
#include "nimble/ble.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_priv.h"
#include "ble_gatt_priv.h"
@@ -69,7 +69,7 @@ ble_gatts_inc_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
htole16(buf + 2, entry->end_group_handle);
/* Only include the service UUID if it has a 16-bit representation. */
- uuid16 = ble_hs_uuid_16bit(entry->svc->uuid128);
+ uuid16 = ble_uuid_128_to_16(entry->svc->uuid128);
if (uuid16 != 0) {
htole16(buf + 4, uuid16);
ctxt->ahc_read.attr_len = 6;
@@ -98,7 +98,7 @@ ble_gatts_chr_def_access(uint16_t handle_id, uint8_t *uuid128, uint8_t op,
/* The value attribute is always immediately after the declaration. */
htole16(buf + 1, handle_id + 1);
- uuid16 = ble_hs_uuid_16bit(chr->uuid128);
+ uuid16 = ble_uuid_128_to_16(chr->uuid128);
if (uuid16 != 0) {
htole16(buf + 3, uuid16);
ctxt->ahc_read.attr_len = 5;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/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
deleted file mode 100644
index 2dd5d83..0000000
--- a/net/nimble/host/src/ble_hs_uuid.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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.
- */
-
-#include <assert.h>
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include "os/os_mbuf.h"
-#include "nimble/ble.h"
-#include "ble_hs_priv.h"
-#include "host/ble_hs_uuid.h"
-
-static uint8_t ble_hs_uuid_base[16] = {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-/**
- * Attempts to convert the supplied 128-bit UUID into its shortened 16-bit
- * form.
- *
- * @return Positive 16-bit unsigned integer on
- * success;
- * 0 if the UUID could not be converted.
- */
-uint16_t
-ble_hs_uuid_16bit(void *uuid128)
-{
- uint16_t uuid16;
- uint8_t *u8ptr;
- int rc;
-
- u8ptr = uuid128;
-
- /* The UUID can only be converted if the final 96 bits of its big endian
- * representation are equal to the base UUID.
- */
- rc = memcmp(u8ptr, ble_hs_uuid_base, sizeof ble_hs_uuid_base - 4);
- if (rc != 0) {
- return 0;
- }
-
- if (u8ptr[14] != 0 || u8ptr[15] != 0) {
- /* This UUID has a 32-bit form, but not a 16-bit form. */
- return 0;
- }
-
- uuid16 = le16toh(u8ptr + 12);
- if (uuid16 == 0) {
- return 0;
- }
-
- return uuid16;
-}
-
-int
-ble_hs_uuid_from_16bit(uint16_t uuid16, void *uuid128)
-{
- uint8_t *u8ptr;
-
- if (uuid16 == 0) {
- return BLE_HS_EINVAL;
- }
-
- u8ptr = uuid128;
-
- memcpy(u8ptr, ble_hs_uuid_base, 16);
- htole16(u8ptr + 12, uuid16);
-
- return 0;
-}
-
-int
-ble_hs_uuid_append(struct os_mbuf *om, void *uuid128)
-{
- uint16_t uuid16;
- void *buf;
- int rc;
-
- uuid16 = ble_hs_uuid_16bit(uuid128);
- if (uuid16 != 0) {
- buf = os_mbuf_extend(om, 2);
- if (buf == NULL) {
- return BLE_HS_ENOMEM;
- }
-
- htole16(buf, uuid16);
- } else {
- rc = os_mbuf_append(om, uuid128, 16);
- if (rc != 0) {
- return BLE_HS_ENOMEM;
- }
- }
-
- return 0;
-}
-
-int
-ble_hs_uuid_extract(struct os_mbuf *om, int off, void *uuid128)
-{
- uint16_t uuid16;
- int remlen;
- int rc;
-
- remlen = OS_MBUF_PKTHDR(om)->omp_len - off;
- switch (remlen) {
- case 2:
- rc = os_mbuf_copydata(om, off, 2, &uuid16);
- assert(rc == 0);
-
- uuid16 = le16toh(&uuid16);
- rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
- if (rc != 0) {
- return rc;
- }
- return 0;
-
- case 16:
- rc = os_mbuf_copydata(om, off, 16, uuid128);
- assert(rc == 0);
- return 0;
-
- default:
- return BLE_HS_EMSGSIZE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/ble_uuid.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_uuid.c b/net/nimble/host/src/ble_uuid.c
new file mode 100644
index 0000000..7340df6
--- /dev/null
+++ b/net/nimble/host/src/ble_uuid.c
@@ -0,0 +1,139 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <string.h>
+#include <errno.h>
+#include "os/os_mbuf.h"
+#include "nimble/ble.h"
+#include "ble_hs_priv.h"
+#include "host/ble_uuid.h"
+
+static uint8_t ble_uuid_base[16] = {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/**
+ * Attempts to convert the supplied 128-bit UUID into its shortened 16-bit
+ * form.
+ *
+ * @return Positive 16-bit unsigned integer on
+ * success;
+ * 0 if the UUID could not be converted.
+ */
+uint16_t
+ble_uuid_128_to_16(void *uuid128)
+{
+ uint16_t uuid16;
+ uint8_t *u8ptr;
+ int rc;
+
+ u8ptr = uuid128;
+
+ /* The UUID can only be converted if the final 96 bits of its big endian
+ * representation are equal to the base UUID.
+ */
+ rc = memcmp(u8ptr, ble_uuid_base, sizeof ble_uuid_base - 4);
+ if (rc != 0) {
+ return 0;
+ }
+
+ if (u8ptr[14] != 0 || u8ptr[15] != 0) {
+ /* This UUID has a 32-bit form, but not a 16-bit form. */
+ return 0;
+ }
+
+ uuid16 = le16toh(u8ptr + 12);
+ if (uuid16 == 0) {
+ return 0;
+ }
+
+ return uuid16;
+}
+
+int
+ble_uuid_16_to_128(uint16_t uuid16, void *uuid128)
+{
+ uint8_t *u8ptr;
+
+ if (uuid16 == 0) {
+ return BLE_HS_EINVAL;
+ }
+
+ u8ptr = uuid128;
+
+ memcpy(u8ptr, ble_uuid_base, 16);
+ htole16(u8ptr + 12, uuid16);
+
+ return 0;
+}
+
+int
+ble_uuid_append(struct os_mbuf *om, void *uuid128)
+{
+ uint16_t uuid16;
+ void *buf;
+ int rc;
+
+ uuid16 = ble_uuid_128_to_16(uuid128);
+ if (uuid16 != 0) {
+ buf = os_mbuf_extend(om, 2);
+ if (buf == NULL) {
+ return BLE_HS_ENOMEM;
+ }
+
+ htole16(buf, uuid16);
+ } else {
+ rc = os_mbuf_append(om, uuid128, 16);
+ if (rc != 0) {
+ return BLE_HS_ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+int
+ble_uuid_extract(struct os_mbuf *om, int off, void *uuid128)
+{
+ uint16_t uuid16;
+ int remlen;
+ int rc;
+
+ remlen = OS_MBUF_PKTHDR(om)->omp_len - off;
+ switch (remlen) {
+ case 2:
+ rc = os_mbuf_copydata(om, off, 2, &uuid16);
+ assert(rc == 0);
+
+ uuid16 = le16toh(&uuid16);
+ rc = ble_uuid_16_to_128(uuid16, uuid128);
+ if (rc != 0) {
+ return rc;
+ }
+ return 0;
+
+ case 16:
+ rc = os_mbuf_copydata(om, off, 16, uuid128);
+ assert(rc == 0);
+ return 0;
+
+ default:
+ return BLE_HS_EMSGSIZE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_svr_test.c b/net/nimble/host/src/test/ble_att_svr_test.c
index 4b7372f..1492349 100644
--- a/net/nimble/host/src/test/ble_att_svr_test.c
+++ b/net/nimble/host/src/test/ble_att_svr_test.c
@@ -20,7 +20,7 @@
#include "nimble/hci_common.h"
#include "ble_hs_priv.h"
#include "host/ble_hs_test.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "testutil/testutil.h"
#include "ble_l2cap.h"
#include "ble_hs_test_util.h"
@@ -161,7 +161,7 @@ ble_att_svr_test_misc_register_uuid16(uint16_t uuid16, uint8_t flags,
uint8_t uuid128[16];
int rc;
- rc = ble_hs_uuid_from_16bit(uuid16, uuid128);
+ rc = ble_uuid_16_to_128(uuid16, uuid128);
TEST_ASSERT_FATAL(rc == 0);
ble_att_svr_test_misc_register_uuid128(uuid128, flags, expected_handle,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_gatt_disc_c_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_disc_c_test.c b/net/nimble/host/src/test/ble_gatt_disc_c_test.c
index 5a62704..00b96cf 100644
--- a/net/nimble/host/src/test/ble_gatt_disc_c_test.c
+++ b/net/nimble/host/src/test/ble_gatt_disc_c_test.c
@@ -20,7 +20,7 @@
#include "nimble/ble.h"
#include "host/ble_hs_test.h"
#include "host/ble_gatt.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_priv.h"
#include "ble_att_cmd.h"
#include "ble_gatt_priv.h"
@@ -153,7 +153,7 @@ ble_gatt_disc_c_test_misc_verify_chars(struct ble_gatt_disc_c_test_char *chars)
TEST_ASSERT(chars[i].value_handle ==
ble_gatt_disc_c_test_chars[i].value_handle);
if (chars[i].uuid16 != 0) {
- uuid16 = ble_hs_uuid_16bit(ble_gatt_disc_c_test_chars[i].uuid128);
+ uuid16 = ble_uuid_128_to_16(ble_gatt_disc_c_test_chars[i].uuid128);
TEST_ASSERT(chars[i].uuid16 == uuid16);
} else {
TEST_ASSERT(memcmp(chars[i].uuid128,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_gatt_disc_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_disc_s_test.c b/net/nimble/host/src/test/ble_gatt_disc_s_test.c
index 640e29d..a36238d 100644
--- a/net/nimble/host/src/test/ble_gatt_disc_s_test.c
+++ b/net/nimble/host/src/test/ble_gatt_disc_s_test.c
@@ -19,7 +19,7 @@
#include "testutil/testutil.h"
#include "nimble/ble.h"
#include "host/ble_hs_test.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_gatt_priv.h"
#include "ble_att_cmd.h"
#include "ble_hs_conn.h"
@@ -210,7 +210,7 @@ ble_gatt_disc_s_test_misc_verify_services(
ble_gatt_disc_s_test_svcs[i].end_handle);
uuid128 = ble_gatt_disc_s_test_svcs[i].uuid128;
- uuid16 = ble_hs_uuid_16bit(uuid128);
+ uuid16 = ble_uuid_128_to_16(uuid128);
if (uuid16 != 0) {
TEST_ASSERT(services[i].uuid16 == uuid16);
} else {
@@ -270,7 +270,7 @@ ble_gatt_disc_s_test_misc_good_uuid(
conn = ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}));
if (services[0].uuid16 != 0) {
- rc = ble_hs_uuid_from_16bit(services[0].uuid16, services[0].uuid128);
+ rc = ble_uuid_16_to_128(services[0].uuid16, services[0].uuid128);
TEST_ASSERT_FATAL(rc == 0);
}
rc = ble_gatt_disc_service_by_uuid(2, services[0].uuid128,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_gatt_read_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_read_test.c b/net/nimble/host/src/test/ble_gatt_read_test.c
index f6c6e52..9fd2505 100644
--- a/net/nimble/host/src/test/ble_gatt_read_test.c
+++ b/net/nimble/host/src/test/ble_gatt_read_test.c
@@ -19,7 +19,7 @@
#include "testutil/testutil.h"
#include "nimble/ble.h"
#include "host/ble_hs_test.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_priv.h"
#include "ble_gatt_priv.h"
#include "ble_att_cmd.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_gatt_write_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_write_test.c b/net/nimble/host/src/test/ble_gatt_write_test.c
index ce52b2e..b99c9b2 100644
--- a/net/nimble/host/src/test/ble_gatt_write_test.c
+++ b/net/nimble/host/src/test/ble_gatt_write_test.c
@@ -20,7 +20,7 @@
#include "nimble/ble.h"
#include "host/ble_hs_test.h"
#include "host/ble_gatt.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "ble_hs_priv.h"
#include "ble_att_cmd.h"
#include "ble_gatt_priv.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_hs_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test.c b/net/nimble/host/src/test/ble_hs_test.c
index b407e05..100594b 100644
--- a/net/nimble/host/src/test/ble_hs_test.c
+++ b/net/nimble/host/src/test/ble_hs_test.c
@@ -55,7 +55,7 @@ main(void)
ble_host_hci_test_all();
ble_hs_conn_test_all();
ble_os_test_all();
- ble_hs_uuid_test_all();
+ ble_uuid_test_all();
ble_gatt_disc_s_test_all();
ble_gatt_disc_c_test_all();
ble_gatt_read_test_all();
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_hs_uuid_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_uuid_test.c b/net/nimble/host/src/test/ble_hs_uuid_test.c
deleted file mode 100644
index 0503db2..0000000
--- a/net/nimble/host/src/test/ble_hs_uuid_test.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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.
- */
-
-#include <stddef.h>
-#include <string.h>
-#include "host/ble_hs_test.h"
-#include "testutil/testutil.h"
-#include "host/ble_hs_uuid.h"
-
-TEST_CASE(ble_hs_uuid_test_128_to_16)
-{
- uint16_t uuid16;
-
- /*** RFCOMM */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00
- }));
- TEST_ASSERT(uuid16 == 0x0003);
-
- /*** BNEP */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00
- }));
- TEST_ASSERT(uuid16 == 0x000f);
-
- /*** L2CAP */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00
- }));
- TEST_ASSERT(uuid16 == 0x0100);
-
- /*** ObEXObjectPush */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00
- }));
- TEST_ASSERT(uuid16 == 0x1105);
-
- /*** Invalid base. */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9c, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00
- }));
- TEST_ASSERT(uuid16 == 0);
-
- /*** Invalid prefix. */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01
- }));
- TEST_ASSERT(uuid16 == 0);
-
- /*** 16-bit UUID of 0. */
- uuid16 = ble_hs_uuid_16bit(((uint8_t[]) {
- 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- }));
-}
-
-TEST_SUITE(ble_hs_uuid_test_suite)
-{
- ble_hs_uuid_test_128_to_16();
-}
-
-int
-ble_hs_uuid_test_all(void)
-{
- ble_hs_uuid_test_suite();
-
- return tu_any_failed;
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/net/nimble/host/src/test/ble_uuid_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_uuid_test.c b/net/nimble/host/src/test/ble_uuid_test.c
new file mode 100644
index 0000000..20fd615
--- /dev/null
+++ b/net/nimble/host/src/test/ble_uuid_test.c
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+
+#include <stddef.h>
+#include <string.h>
+#include "host/ble_hs_test.h"
+#include "testutil/testutil.h"
+#include "host/ble_uuid.h"
+
+TEST_CASE(ble_uuid_test_128_to_16)
+{
+ uint16_t uuid16;
+
+ /*** RFCOMM */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00
+ }));
+ TEST_ASSERT(uuid16 == 0x0003);
+
+ /*** BNEP */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00
+ }));
+ TEST_ASSERT(uuid16 == 0x000f);
+
+ /*** L2CAP */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00
+ }));
+ TEST_ASSERT(uuid16 == 0x0100);
+
+ /*** ObEXObjectPush */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00
+ }));
+ TEST_ASSERT(uuid16 == 0x1105);
+
+ /*** Invalid base. */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9c, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00
+ }));
+ TEST_ASSERT(uuid16 == 0);
+
+ /*** Invalid prefix. */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01
+ }));
+ TEST_ASSERT(uuid16 == 0);
+
+ /*** 16-bit UUID of 0. */
+ uuid16 = ble_uuid_128_to_16(((uint8_t[]) {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ }));
+}
+
+TEST_SUITE(ble_uuid_test_suite)
+{
+ ble_uuid_test_128_to_16();
+}
+
+int
+ble_uuid_test_all(void)
+{
+ ble_uuid_test_suite();
+
+ return tu_any_failed;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/project/centtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/centtest/src/main.c b/project/centtest/src/main.c
index fdc3c56..3020ddb 100755
--- a/project/centtest/src/main.c
+++ b/project/centtest/src/main.c
@@ -26,7 +26,7 @@
#include "nimble/ble.h"
#include "host/host_hci.h"
#include "host/ble_hs.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "host/ble_att.h"
#include "host/ble_gap.h"
#include "host/ble_gatt.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14b5ded6/project/prphtest/src/main.c
----------------------------------------------------------------------
diff --git a/project/prphtest/src/main.c b/project/prphtest/src/main.c
index 7fcdc9e..3646305 100755
--- a/project/prphtest/src/main.c
+++ b/project/prphtest/src/main.c
@@ -26,7 +26,7 @@
#include "nimble/ble.h"
#include "host/host_hci.h"
#include "host/ble_hs.h"
-#include "host/ble_hs_uuid.h"
+#include "host/ble_uuid.h"
#include "host/ble_att.h"
#include "host/ble_gap.h"
#include "host/ble_gatt.h"
@@ -128,7 +128,7 @@ prphtest_gatt_cb(uint16_t handle_id, uint8_t op,
assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
- uuid16 = ble_hs_uuid_16bit(ctxt->bgc_read.chr->uuid128);
+ uuid16 = ble_uuid_128_to_16(ctxt->bgc_read.chr->uuid128);
switch (uuid16) {
case PRPHTEST_CHR1_UUID:
console_printf("reading characteristic1 value");
@@ -165,14 +165,14 @@ prphtest_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt)
switch (op) {
case BLE_GATT_REGISTER_OP_SVC:
- uuid16 = ble_hs_uuid_16bit(ctxt->bgr_svc.svc->uuid128);
+ uuid16 = ble_uuid_128_to_16(ctxt->bgr_svc.svc->uuid128);
assert(uuid16 != 0);
console_printf("registered service 0x%04x with handle=%d\n",
uuid16, ctxt->bgr_svc.handle);
break;
case BLE_GATT_REGISTER_OP_CHR:
- uuid16 = ble_hs_uuid_16bit(ctxt->bgr_chr.chr->uuid128);
+ uuid16 = ble_uuid_128_to_16(ctxt->bgr_chr.chr->uuid128);
assert(uuid16 != 0);
console_printf("registering characteristic 0x%04x with def_handle=%d "
"val_handle=%d\n",