diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h index 4b7e14d89..7f8a8e7e8 100644 --- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h @@ -33,12 +33,13 @@ struct ble_hs_cfg; #define BLE_SVC_GAP_CHR_UUID16_RECONNECT_ADDR 0x2a03 #define BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS 0x2a04 -#define BLE_SVC_GAP_APPEARANCE_GEN_COMPUTER 128 +#define BLE_SVC_GAP_APPEARANCE_GEN_UNKNOWN 0 +#define BLE_SVC_GAP_APPEARANCE_GEN_COMPUTER 128 +#define BLE_SVC_GAP_APPEARANCE_CYC_SPEED_AND_CADENCE_SENSOR 1157 const char *ble_svc_gap_device_name(void); int ble_svc_gap_device_name_set(const char *name); -int ble_svc_gap_device_appearance(void); -int ble_svc_gap_device_appearance_set(const uint16_t appearance); +uint16_t ble_svc_gap_device_appearance(void); void ble_svc_gap_init(void); diff --git a/nimble/host/services/gap/src/ble_svc_gap.c b/nimble/host/services/gap/src/ble_svc_gap.c index 2398c13c7..0ca195e83 100644 --- a/nimble/host/services/gap/src/ble_svc_gap.c +++ b/nimble/host/services/gap/src/ble_svc_gap.c @@ -23,12 +23,16 @@ #include "sysinit/sysinit.h" #include "host/ble_hs.h" #include "services/gap/ble_svc_gap.h" +#include "os/endian.h" /* XXX: This should be configurable. */ #define BLE_SVC_GAP_NAME_MAX_LEN 31 static char ble_svc_gap_name[BLE_SVC_GAP_NAME_MAX_LEN + 1] = "nimble"; -static uint16_t ble_svc_gap_appearance; +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 uint8_t ble_svc_gap_privacy_flag; static uint8_t ble_svc_gap_reconnect_addr[6]; static uint8_t ble_svc_gap_pref_conn_params[8]; @@ -150,18 +154,10 @@ ble_svc_gap_device_name_set(const char *name) return 0; } -int +uint16_t ble_svc_gap_device_appearance(void) { - return ble_svc_gap_appearance; -} - -int -ble_svc_gap_device_appearance_set(const uint16_t appearance) -{ - ble_svc_gap_appearance = appearance; - - return 0; + return get_le16(ble_svc_gap_appearance); } void diff --git a/nimble/host/services/gap/syscfg.yml b/nimble/host/services/gap/syscfg.yml new file mode 100644 index 000000000..f686e6762 --- /dev/null +++ b/nimble/host/services/gap/syscfg.yml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + +# Package: net/nimble/host/services/gap + +syscfg.defs: + BLE_SVC_GAP_APPEARANCE: + description: 'Device appearance' + value: 0