@openfitnessprotocol/ofp 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/noble.d.ts +2 -2
- package/adapters/noble.js +13 -4
- package/adapters/react-native-ble-manager.js +3 -1
- package/core/ofp_core.asm.js +7603 -7603
- package/core/ofp_core.wasm +0 -0
- package/index.js +5 -2
- package/package.json +1 -1
- package/registry.bundle.json +1 -1
- package/registry.js +1 -1
package/adapters/noble.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { OfpAdvertisement } from '../index'
|
|
2
2
|
|
|
3
|
-
/** A noble peripheral (from the 'discover' event) as an OFP advertisement, or null when it carries no data. */
|
|
3
|
+
/** A noble peripheral (from the 'discover' event) as an OFP advertisement, or null when it carries no manufacturer data, name or services. */
|
|
4
4
|
export function advertisementFrom(peripheral: {
|
|
5
5
|
id: string
|
|
6
6
|
rssi?: number
|
|
7
|
-
advertisement?: { localName?: string; manufacturerData?: Uint8Array | null }
|
|
7
|
+
advertisement?: { localName?: string; manufacturerData?: Uint8Array | null; serviceUuids?: string[]; overflowServiceUuids?: string[] }
|
|
8
8
|
}): OfpAdvertisement | null
|
|
9
9
|
/** Arguments for `noble.startScanning`: no service filter, with repeats. */
|
|
10
10
|
export const SCAN_ARGS: [string[], boolean]
|
package/adapters/noble.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
// OFP ↔ noble (@stoprocent/noble, @abandonware/noble): Node and Electron.
|
|
2
2
|
// noble hands over the manufacturer data raw, company id first: exactly what OFP wants.
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A noble peripheral (from the 'discover' event) as an OFP advertisement, or null when it carries nothing
|
|
6
|
+
* OFP could match: no manufacturer data, no name and no services. The services are how a device that is
|
|
7
|
+
* connected to (a `notify` table) is recognised; noble lists them without dashes.
|
|
8
|
+
*/
|
|
5
9
|
export function advertisementFrom(peripheral) {
|
|
6
10
|
const adv = peripheral && peripheral.advertisement;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
if (!adv) return null;
|
|
12
|
+
const data = adv.manufacturerData && adv.manufacturerData.length >= 2 ? adv.manufacturerData : null;
|
|
13
|
+
const services = [...(adv.serviceUuids || []), ...(adv.overflowServiceUuids || [])];
|
|
14
|
+
const name = adv.localName || null;
|
|
15
|
+
if (!data && !name && !services.length) return null;
|
|
16
|
+
const a = { deviceId: peripheral.id, name, rssi: peripheral.rssi, manufacturerData: data };
|
|
17
|
+
if (services.length) a.services = services;
|
|
18
|
+
return a;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
/** noble must scan with repeats, or it reports each device once: `noble.startScanning([], true)`. */
|
|
@@ -36,7 +36,9 @@ export function advertisementsFrom(peripheral, companyIds) {
|
|
|
36
36
|
* well enough. Spread them AFTER the app's own options: on iOS they replace two of them.
|
|
37
37
|
*
|
|
38
38
|
* Android: its filters are alternatives (a device passes if it matches any), and the library takes one
|
|
39
|
-
* company id, so that id is added beside the app's services
|
|
39
|
+
* company id, so that id is added beside the app's services: the first of `companyIds` (the lowest, today the
|
|
40
|
+
* Keiser M3i's). A broadcast device with another company id (a CORE as a beacon) is not let through on
|
|
41
|
+
* Android by this filter.
|
|
40
42
|
*
|
|
41
43
|
* iOS (`platform` 'ios'): there is no company-id filter, so the scan is opened to every device (an empty
|
|
42
44
|
* service list) and repeats are asked for (without them iOS reports a device once, and for a broadcast-only
|