You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/03/12 13:37:41 UTC

[mynewt-nimble] 07/32: nimble/gap: Store appearance as simple uint16

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch new-master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 095bbc8f8889f73770a52115b9191e8e236456ca
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Feb 23 21:19:06 2018 +0100

    nimble/gap: Store appearance as simple uint16
    
    X-Original-Commit: a57cfcafecae8b880acb6a3214708f945d9e98b8
---
 nimble/host/services/gap/src/ble_svc_gap.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/nimble/host/services/gap/src/ble_svc_gap.c b/nimble/host/services/gap/src/ble_svc_gap.c
index f0dda62..3c9b53d 100644
--- a/nimble/host/services/gap/src/ble_svc_gap.c
+++ b/nimble/host/services/gap/src/ble_svc_gap.c
@@ -30,10 +30,8 @@
 
 static char ble_svc_gap_name[BLE_SVC_GAP_NAME_MAX_LEN + 1] =
         MYNEWT_VAL(BLE_SVC_GAP_DEVICE_NAME);
-static const uint8_t ble_svc_gap_appearance[2] = {
-     (MYNEWT_VAL(BLE_SVC_GAP_APPEARANCE)) & 0xFF,
-     ((MYNEWT_VAL(BLE_SVC_GAP_APPEARANCE)) >> 8) & 0xFF
-};
+static const uint16_t ble_svc_gap_appearance =
+        MYNEWT_VAL(BLE_SVC_GAP_APPEARANCE);
 static uint8_t ble_svc_gap_pref_conn_params[8];
 
 static int
@@ -83,6 +81,7 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
                    struct ble_gatt_access_ctxt *ctxt, void *arg)
 {
     uint16_t uuid16;
+    uint16_t appearance = htole16(ble_svc_gap_appearance);
 #if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
     uint8_t central_ar = MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION);
 #endif
@@ -100,8 +99,7 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
 
     case BLE_SVC_GAP_CHR_UUID16_APPEARANCE:
         assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
-        rc = os_mbuf_append(ctxt->om, &ble_svc_gap_appearance,
-                            sizeof ble_svc_gap_appearance);
+        rc = os_mbuf_append(ctxt->om, &appearance, sizeof(appearance));
         return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
 
     case BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
@@ -148,7 +146,7 @@ ble_svc_gap_device_name_set(const char *name)
 uint16_t
 ble_svc_gap_device_appearance(void)
 {
-  return get_le16(ble_svc_gap_appearance);
+  return ble_svc_gap_appearance;
 }
 
 void

-- 
To stop receiving notification emails like this one, please contact
andk@apache.org.