diff options
author | Christopher Collins <ccollins@apache.org> | 2016-05-18 10:11:41 -0700 |
---|---|---|
committer | Christopher Collins <ccollins@apache.org> | 2016-05-18 10:11:41 -0700 |
commit | b54399551a9fd33a4eb54cefe467b63198d2d09f (patch) | |
tree | f6f98f793aca8b71746a53d2e4bcd9f4b1d8c756 | |
parent | 05401e1ebad4bbcf3b0bb9a5575ce5a15d8f567d (diff) |
bleprph - export GATT server data from header.
-rw-r--r-- | apps/bleprph/src/bleprph.h | 26 | ||||
-rw-r--r-- | apps/bleprph/src/gatt_svr.c | 13 | ||||
-rwxr-xr-x | apps/bleprph/src/main.c | 18 |
3 files changed, 38 insertions, 19 deletions
diff --git a/apps/bleprph/src/bleprph.h b/apps/bleprph/src/bleprph.h index 94024d7c..1a9b1502 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 diff --git a/apps/bleprph/src/gatt_svr.c b/apps/bleprph/src/gatt_svr.c index aacc650c..fe2a9ed3 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 }; diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c index 8731c063..5037bc8d 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); |