This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-documentation.git
The following commit(s) were added to refs/heads/master by this push:
new 2b5a015 Fixed BLE Peripheral Project - Characteristic Access
2b5a015 is described below
commit 2b5a01588ec7b87a343e58cc281f9a1c297d0cad
Author: Krzysztof Kopyściński
AuthorDate: Wed Mar 18 13:21:13 2020 +0100
Fixed BLE Peripheral Project - Characteristic Access
- Tutorial accomodated to changes from commit 8fe77a4
- Functions updated to current version of mynewt-nimble/apps/bleprph
- Edited table contents to fit rest of changes
- Tutorial text changes commenting new syntax
- Tutorial text deletions commenting removed/swapped code snippets
- bleprph is part of nimble, not core
---
.../ble/bleprph/bleprph-sections/bleprph-app.rst | 2 +-
.../bleprph-sections/bleprph-chr-access.rst| 248 +
docs/tutorials/ble/bleprph/bleprph.rst | 2 +-
3 files changed, 106 insertions(+), 146 deletions(-)
diff --git a/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-app.rst
b/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-app.rst
index 9ded59d..4bd8498 100644
--- a/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-app.rst
+++ b/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-app.rst
@@ -34,7 +34,7 @@ Peripheral
$ newt target set myperiph bsp=@apache-mynewt-core/hw/bsp/nrf52dk
Target targets/myperiph successfully set target.bsp to
@apache-mynewt-core/hw/bsp/nrf52dk
$ newt target set myperiph app=@apache-mynewt-core/apps/bleprph
-Target targets/myperiph successfully set target.app to
@apache-mynewt-core/apps/bleprph
+Target targets/myperiph successfully set target.app to
@apache-mynewt-nimble/apps/bleprph
$ newt target set myperiph build_profile=optimized
Target targets/myperiph successfully set target.build_profile to optimized
$ newt build myperiph
diff --git a/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-chr-access.rst
b/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-chr-access.rst
index 0e34078..b2beacf 100644
--- a/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-chr-access.rst
+++ b/docs/tutorials/ble/bleprph/bleprph-sections/bleprph-chr-access.rst
@@ -23,19 +23,20 @@ few characteristics in this service.
static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
{
-/*** Service: GAP. */
+/*** Service: Security test. */
.type = BLE_GATT_SVC_TYPE_PRIMARY,
-.uuid128= BLE_UUID16(BLE_GAP_SVC_UUID16),
+.uuid = _svr_svc_sec_test_uuid.u,
.characteristics= (struct ble_gatt_chr_def[]) { {
-/*** Characteristic: Device Name. */
-.uuid128=
BLE_UUID16(BLE_GAP_CHR_UUID16_DEVICE_NAME),
-.access_cb = gatt_svr_chr_access_gap,
-.flags = BLE_GATT_CHR_F_READ,
+/*** Characteristic: Random number generator. */
+.uuid = _svr_chr_sec_test_rand_uuid.u,
+.access_cb = gatt_svr_chr_access_sec_test,
+.flags = BLE_GATT_CHR_F_READ |
BLE_GATT_CHR_F_READ_ENC,
}, {
-/*** Characteristic: Appearance. */
-.uuid128=
BLE_UUID16(BLE_GAP_CHR_UUID16_APPEARANCE),
-.access_cb = gatt_svr_chr_access_gap,
-.flags = BLE_GATT_CHR_F_READ,
+/*** Characteristic: Static value. */
+.uuid = gatt_svr_chr_sec_test_static_uuid.u,
+.access_cb = gatt_svr_chr_access_sec_test,
+.flags = BLE_GATT_CHR_F_READ |
+ BLE_GATT_CHR_F_WRITE |
BLE_GATT_CHR_F_WRITE_ENC,
}, {
// [...]
@@ -48,55 +49,55 @@ characteristics use:
.. code:: c
static int
-gatt_svr_chr_access_gap(uint16_t conn_handle, uint16_t attr_handle,
uint8_t op,
-union ble_gatt_access_ctxt *ctxt, void *arg)
+gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
+ struct ble_gatt_access_ctxt *ctxt,
+ void *arg)
{
-uint16_t uuid16;
-
-uuid16 = ble_uuid_128_to_16(ctxt->chr_access.chr->uuid128);
-assert(uuid16 != 0);
-
-switch (uuid16) {
-case BLE_GAP_CHR_UUID16_DEVICE_NAME:
-assert(op == BLE_GATT_ACCESS_OP_READ_CHR);
-ctxt->chr_access.data = (void *)bleprph_device_name;
-ctxt->chr_access.len = strlen(bleprph_device_name);
-break;
-
-case BLE_GAP_CHR_UUID16_APPEARANCE:
-assert(op ==