From 1f94a8f26ead8692108730e7feda71cd12fbc5f6 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 31 Jul 2023 21:29:45 +0100 Subject: [PATCH] btadv: advertise on a cycle for long UUIDs --- apps/btadv/app.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/apps/btadv/app.ts b/apps/btadv/app.ts index c832eda62..8aeebd793 100644 --- a/apps/btadv/app.ts +++ b/apps/btadv/app.ts @@ -763,16 +763,35 @@ enableSensors(); // must have fixed services from the start: const ad = getBleAdvert(serv => serviceToAdvert(serv, true), /*all*/true); - const adServices = Object - .keys(ad) - .map((k: string) => k.replace("0x", "")); - NRF.setServices( ad, { - advertise: adServices, uart: false, }, ); + + if(!(Bangle as any).bleAdvert) + (Bangle as any).bleAdvert = {}; + + const cycle = []; + for(const id in ad){ + const serv = ad[id as BleServ]; + let value; + + // pick the first characteristic to advertise + for(const ch in serv){ + value = serv[ch as BleChar]!.value; + break; + } + + cycle.push({ [id]: value || [] }); + } + + NRF.setAdvertising( + cycle, + { + interval: 100, + } + ); } }