1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

examples/nimble_gatt: unroll update_ad()

This static function was a leftover from very early stages of this
example and at the current state there is not sense in keeping it.
Having these few lines directly where the advertising is triggered
makes the code more clean and readible.
This commit is contained in:
Hauke Petersen 2019-03-07 16:22:56 +01:00
parent 8a849be118
commit 0cca1769cc

View File

@ -132,15 +132,6 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
},
};
static void update_ad(void)
{
uint8_t buf[BLE_HS_ADV_MAX_SZ];
bluetil_ad_t ad;
bluetil_ad_init_with_flags(&ad, buf, sizeof(buf), BLUETIL_AD_FLAGS_DEFAULT);
bluetil_ad_add_name(&ad, device_name);
ble_gap_adv_set_data(ad.buf, ad.pos);
}
static int gap_event_cb(struct ble_gap_event *event, void *arg)
{
(void)arg;
@ -346,8 +337,12 @@ int main(void)
assert(rc == 0);
(void)rc;
/* generate the advertising data */
update_ad();
/* configure and set the advertising data */
uint8_t buf[BLE_HS_ADV_MAX_SZ];
bluetil_ad_t ad;
bluetil_ad_init_with_flags(&ad, buf, sizeof(buf), BLUETIL_AD_FLAGS_DEFAULT);
bluetil_ad_add_name(&ad, device_name);
ble_gap_adv_set_data(ad.buf, ad.pos);
/* start to advertise this node */
start_advertise();