btadv: advertise on a cycle for long UUIDs

pull/2912/head
Rob Pilling 2023-07-31 21:29:45 +01:00
parent 1dc9870c07
commit 1f94a8f26e
1 changed files with 24 additions and 5 deletions

View File

@ -763,16 +763,35 @@ enableSensors();
// must have fixed services from the start: // must have fixed services from the start:
const ad = getBleAdvert(serv => serviceToAdvert(serv, true), /*all*/true); const ad = getBleAdvert(serv => serviceToAdvert(serv, true), /*all*/true);
const adServices = Object
.keys(ad)
.map((k: string) => k.replace("0x", ""));
NRF.setServices( NRF.setServices(
ad, ad,
{ {
advertise: adServices,
uart: false, 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,
}
);
} }
} }