Ensure that on 2v26+ ble_advert removes the manufacturer=0x590 from setAdvertising to make space for extra advertising info

master
Gordon Williams 2025-05-20 10:26:31 +01:00
parent 1c1b77dfa1
commit 5ee4355bc3
2 changed files with 22 additions and 2 deletions

View File

@ -12,7 +12,17 @@ var advertise = function (options) {
}
return obj;
};
NRF.setAdvertising(clone(Bangle.bleAdvert), options);
if (process.env.VERSION >= "2.26") {
options = options || {};
if (!options.manufacturer)
options.manufacturer = false;
}
try {
NRF.setAdvertising(clone(Bangle.bleAdvert), options);
}
catch (e) {
console.log("ble_advert error", e);
}
};
var manyAdv = function (bleAdvert) {
return Array.isArray(bleAdvert) && typeof bleAdvert[0] === "object";

View File

@ -21,6 +21,12 @@ const advertise = (options: SetAdvertisingOptions) => {
}
return obj;
};
/* 2v26 added manufacturer=0x0590 by default, but if we're advertising
extra stuff we'll want to explicitly remove that so there's space */
if (process.env.VERSION >= "2.26") {
options = options||{};
if (!options.manufacturer) options.manufacturer=false;
}
// clone the object, to avoid firmware behaving like so:
// bleAdvert = [Uint8Array, { [0x180f]: ... }]
@ -35,7 +41,11 @@ const advertise = (options: SetAdvertisingOptions) => {
// taking effect for later calls.
//
// This also allows us to identify previous adverts correctly by id.
NRF.setAdvertising(clone((Bangle as BangleWithAdvert).bleAdvert), options);
try {
NRF.setAdvertising(clone((Bangle as BangleWithAdvert).bleAdvert), options);
} catch (e) {
console.log("ble_advert error", e);
}
};
const manyAdv = (bleAdvert: BleAdvert | BleAdvert[] | undefined): bleAdvert is BleAdvert[] => {