From 4e49fa5cc5794fe1eb7e39287c9af16fa7d1a78a Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Thu, 7 Mar 2019 16:23:13 +0100 Subject: [PATCH] examples/nimble_gatt: drop build-in init calls --- examples/nimble_gatt/main.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/examples/nimble_gatt/main.c b/examples/nimble_gatt/main.c index 9ac41b8bee..e7f0371d28 100644 --- a/examples/nimble_gatt/main.c +++ b/examples/nimble_gatt/main.c @@ -35,6 +35,7 @@ #include #include +#include "nimble_riot.h" #include "net/bluetil/ad.h" #include "host/ble_hs.h" @@ -65,7 +66,6 @@ static const ble_uuid128_t gatt_svr_chr_rw_demo_readonly_uuid 0x4d, 0xd5, 0x40, 0x3f, 0x11, 0xdd, 0xcc); static const char *device_name = "NimBLE on RIOT"; -static uint8_t own_addr_type; static char rm_demo_write_data[64] = "This characteristic is read- and writeable!"; @@ -159,7 +159,7 @@ static void start_advertise(void) memset(&advp, 0, sizeof advp); advp.conn_mode = BLE_GAP_CONN_MODE_UND; advp.disc_mode = BLE_GAP_DISC_MODE_GEN; - rc = ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER, + rc = ble_gap_adv_start(nimble_riot_own_addr_type, NULL, BLE_HS_FOREVER, &advp, gap_event_cb, NULL); assert(rc == 0); (void)rc; @@ -311,32 +311,17 @@ int main(void) int rc = 0; + /* verify and add our custom services */ rc = ble_gatts_count_cfg(gatt_svr_svcs); assert(rc == 0); - rc = ble_gatts_add_svcs(gatt_svr_svcs); assert(rc == 0); /* set the device name */ ble_svc_gap_device_name_set(device_name); - - /* initialize the GAP and GATT services */ - ble_svc_gap_init(); - ble_svc_gatt_init(); - /* XXX: seems to be needed to apply the added services */ + /* reload the GATT server to link our added services */ ble_gatts_start(); - /* make sure synchronization of host and controller is done, this should - * always be the case */ - while (!ble_hs_synced()) {} - - /* configure device address */ - rc = ble_hs_util_ensure_addr(0); - assert(rc == 0); - rc = ble_hs_id_infer_auto(0, &own_addr_type); - assert(rc == 0); - (void)rc; - /* configure and set the advertising data */ uint8_t buf[BLE_HS_ADV_MAX_SZ]; bluetil_ad_t ad;