You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/05/19 06:33:14 UTC

[03/12] incubator-mynewt-core git commit: bleprph - export GATT server data from header.

bleprph - export GATT server data from header.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b5439955
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b5439955
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b5439955

Branch: refs/heads/develop
Commit: b54399551a9fd33a4eb54cefe467b63198d2d09f
Parents: 05401e1
Author: Christopher Collins <cc...@apache.org>
Authored: Wed May 18 10:11:41 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed May 18 10:11:41 2016 -0700

----------------------------------------------------------------------
 apps/bleprph/src/bleprph.h  | 26 +++++++++++++++++++-------
 apps/bleprph/src/gatt_svr.c | 13 +++----------
 apps/bleprph/src/main.c     | 18 ++++++++++++++++--
 3 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b5439955/apps/bleprph/src/bleprph.h
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/bleprph.h b/apps/bleprph/src/bleprph.h
index 94024d7..1a9b150 100644
--- a/apps/bleprph/src/bleprph.h
+++ b/apps/bleprph/src/bleprph.h
@@ -22,13 +22,6 @@
 
 #include "log/log.h"
 
-void gatt_svr_init(void);
-
-int keystore_lookup(uint16_t ediv, uint64_t rand_num,
-                    void *out_ltk, int *out_authenticated);
-int keystore_add(uint16_t ediv, uint64_t rand_num, uint8_t *key,
-                 int authenticated);
-
 extern struct log bleprph_log;
 
 extern const char *bleprph_device_name;
@@ -45,4 +38,23 @@ extern uint8_t bleprph_gatt_service_changed[4];
 #define BLEPRPH_LOG(lvl, ...) \
     LOG_ ## lvl(&bleprph_log, BLEPRPH_LOG_MODULE, __VA_ARGS__)
 
+/** GATT server. */
+#define GATT_SVR_SVC_ALERT_UUID               0x1811
+#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
+#define GATT_SVR_CHR_NEW_ALERT                0x2A46
+#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
+#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID      0x2A45
+#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT        0x2A44
+extern const uint8_t gatt_svr_svc_bleprph[16];
+extern const uint8_t gatt_svr_chr_bleprph_read[16];
+extern const uint8_t gatt_svr_chr_bleprph_write[16];
+
+void gatt_svr_init(void);
+
+/** Keystore. */
+int keystore_lookup(uint16_t ediv, uint64_t rand_num,
+                    void *out_ltk, int *out_authenticated);
+int keystore_add(uint16_t ediv, uint64_t rand_num, uint8_t *key,
+                 int authenticated);
+
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b5439955/apps/bleprph/src/gatt_svr.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/gatt_svr.c b/apps/bleprph/src/gatt_svr.c
index aacc650..fe2a9ed 100644
--- a/apps/bleprph/src/gatt_svr.c
+++ b/apps/bleprph/src/gatt_svr.c
@@ -25,13 +25,6 @@
 #include "host/ble_hs.h"
 #include "bleprph.h"
 
-#define GATT_SVR_SVC_ALERT_UUID               0x1811
-#define GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID   0x2A47
-#define GATT_SVR_CHR_NEW_ALERT                0x2A46
-#define GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID   0x2A48
-#define GATT_SVR_CHR_UNR_ALERT_STAT_UUID      0x2A45
-#define GATT_SVR_CHR_ALERT_NOT_CTRL_PT        0x2A44
-
 /**
  * The vendor specific "bleprph" service consists of two characteristics:
  *     o "read": a single-byte characteristic that can only be read of an
@@ -41,19 +34,19 @@
  */
 
 /* 59462f12-9543-9999-12c8-58b459a2712d */
-static const uint8_t gatt_svr_svc_bleprph[16] = {
+const uint8_t gatt_svr_svc_bleprph[16] = {
     0x2d, 0x71, 0xa2, 0x59, 0xb4, 0x58, 0xc8, 0x12,
     0x99, 0x99, 0x43, 0x95, 0x12, 0x2f, 0x46, 0x59
 };
 
 /* 5c3a659e-897e-45e1-b016-007107c96df6 */
-static const uint8_t gatt_svr_chr_bleprph_read[16] = {
+const uint8_t gatt_svr_chr_bleprph_read[16] = {
     0xf6, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0,
     0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c
 };
 
 /* 5c3a659e-897e-45e1-b016-007107c96df7 */
-static const uint8_t gatt_svr_chr_bleprph_write[16] = {
+const uint8_t gatt_svr_chr_bleprph_write[16] = {
     0xf7, 0x6d, 0xc9, 0x07, 0x71, 0x00, 0x16, 0xb0,
     0xe1, 0x45, 0x7e, 0x89, 0x9e, 0x65, 0x3a, 0x5c
 };

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b5439955/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 8731c06..5037bc8 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -85,7 +85,7 @@ uint8_t bleprph_pref_conn_params[8];
 uint8_t bleprph_gatt_service_changed[4];
 
 static int bleprph_gap_event(int event, int status,
-                              struct ble_gap_conn_ctxt *ctxt, void *arg);
+                             struct ble_gap_conn_ctxt *ctxt, void *arg);
 
 /**
  * Utility function to log an array of bytes.
@@ -130,11 +130,25 @@ bleprph_advertise(void)
     struct ble_hs_adv_fields fields;
     int rc;
 
-    /* Set the advertisement data included in our advertisements. */
+    /**
+     *  Set the advertisement data included in our advertisements:
+     *     o Advertising tx power.
+     *     o Device name.
+     *     o 16-bit service UUIDs (alert notifications).
+     */
+
     memset(&fields, 0, sizeof fields);
+
+    fields.tx_pwr_lvl_is_present = 1;
+
     fields.name = (uint8_t *)bleprph_device_name;
     fields.name_len = strlen(bleprph_device_name);
     fields.name_is_complete = 1;
+
+    fields.uuids16 = (uint16_t[]){ GATT_SVR_SVC_ALERT_UUID };
+    fields.num_uuids16 = 1;
+    fields.uuids16_is_complete = 1;
+
     rc = ble_gap_adv_set_fields(&fields);
     if (rc != 0) {
         BLEPRPH_LOG(ERROR, "error setting advertisement data; rc=%d\n", rc);