From 5ee4355bc36fefd20134fed365811d40b0f2cb68 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 20 May 2025 10:26:31 +0100 Subject: [PATCH] Ensure that on 2v26+ ble_advert removes the manufacturer=0x590 from setAdvertising to make space for extra advertising info --- modules/ble_advert.js | 12 +++++++++++- modules/ble_advert.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/ble_advert.js b/modules/ble_advert.js index 0a037cfd8..6ab47871c 100644 --- a/modules/ble_advert.js +++ b/modules/ble_advert.js @@ -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"; diff --git a/modules/ble_advert.ts b/modules/ble_advert.ts index c0b852f1d..9f0ac0765 100644 --- a/modules/ble_advert.ts +++ b/modules/ble_advert.ts @@ -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[] => {