incyclist-devices 2.3.9 → 2.3.11

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.
Files changed (46) hide show
  1. package/lib/ble/base/interface.d.ts +6 -3
  2. package/lib/ble/base/interface.js +83 -48
  3. package/lib/ble/fm/adapter.d.ts +2 -1
  4. package/lib/ble/fm/adapter.js +27 -9
  5. package/lib/ble/fm/sensor.js +9 -2
  6. package/lib/ble/wahoo/sensor.d.ts +1 -0
  7. package/lib/ble/wahoo/sensor.js +18 -0
  8. package/package.json +1 -1
  9. package/lib/ble/adapter-factory.d.ts +0 -34
  10. package/lib/ble/adapter-factory.js +0 -110
  11. package/lib/ble/base/comms-utils.d.ts +0 -7
  12. package/lib/ble/base/comms-utils.js +0 -90
  13. package/lib/ble/base/comms.d.ts +0 -75
  14. package/lib/ble/base/comms.js +0 -599
  15. package/lib/ble/ble-interface.d.ts +0 -84
  16. package/lib/ble/ble-interface.js +0 -622
  17. package/lib/ble/ble-peripheral.d.ts +0 -39
  18. package/lib/ble/ble-peripheral.js +0 -252
  19. package/lib/ble/cp/comm.d.ts +0 -30
  20. package/lib/ble/cp/comm.js +0 -126
  21. package/lib/ble/elite/adapter.d.ts +0 -21
  22. package/lib/ble/elite/adapter.js +0 -118
  23. package/lib/ble/elite/comms.d.ts +0 -31
  24. package/lib/ble/elite/comms.js +0 -127
  25. package/lib/ble/elite/index.d.ts +0 -3
  26. package/lib/ble/elite/index.js +0 -10
  27. package/lib/ble/fm/comms.d.ts +0 -49
  28. package/lib/ble/fm/comms.js +0 -506
  29. package/lib/ble/hr/comm.d.ts +0 -19
  30. package/lib/ble/hr/comm.js +0 -65
  31. package/lib/ble/peripheral-cache.d.ts +0 -45
  32. package/lib/ble/peripheral-cache.js +0 -109
  33. package/lib/ble/tacx/comms.d.ts +0 -59
  34. package/lib/ble/tacx/comms.js +0 -634
  35. package/lib/ble/wahoo/comms.d.ts +0 -64
  36. package/lib/ble/wahoo/comms.js +0 -399
  37. package/lib/direct-connect/base/comms.d.ts +0 -3
  38. package/lib/direct-connect/base/comms.js +0 -7
  39. package/lib/direct-connect/base/sensor.d.ts +0 -3
  40. package/lib/direct-connect/base/sensor.js +0 -7
  41. package/lib/direct-connect/utils.d.ts +0 -5
  42. package/lib/direct-connect/utils.js +0 -73
  43. package/lib/factories/index.d.ts +0 -3
  44. package/lib/factories/index.js +0 -10
  45. package/lib/utils/operation.d.ts +0 -17
  46. package/lib/utils/operation.js +0 -20
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ble_peripheral_1 = __importDefault(require("./ble-peripheral"));
7
- class BlePeripheralCache {
8
- constructor() {
9
- this.peripherals = [];
10
- }
11
- findAdapter(adapter) {
12
- return this.find(adapter.getSettings());
13
- }
14
- getConnector(peripheral) {
15
- if (!peripheral)
16
- return;
17
- const info = this.find({ address: peripheral.address });
18
- if (!info) {
19
- const item = this.add({ address: peripheral.address, ts: Date.now(), peripheral });
20
- return item.connector;
21
- }
22
- return info.connector;
23
- }
24
- getPeripheral(query) {
25
- const info = this.find(query);
26
- return info ? info.peripheral : undefined;
27
- }
28
- handleStopScan() {
29
- const ongoing = this.peripherals.filter(i => i.state && i.state.isLoading);
30
- if (ongoing)
31
- ongoing.forEach(i => { i.state.isInterrupted = true; });
32
- }
33
- find(query) {
34
- const { peripheral } = query;
35
- const { name, address, id } = peripheral ? peripheral : query;
36
- if (!name && !address && !id)
37
- throw new Error('illegal query, one of <id>,<name>,<address> needs to be provided');
38
- if (address)
39
- return this.peripherals.find(i => i.address === address);
40
- else if (name)
41
- return this.peripherals.find(i => i.name === name);
42
- else if (id)
43
- return this.peripherals.find(i => i.id === id);
44
- }
45
- filter(services) {
46
- if (services.length === 0) {
47
- return this.peripherals;
48
- }
49
- return this.peripherals.filter(i => {
50
- const announced = i.peripheral.services.map(s => s.uuid);
51
- const requested = services;
52
- return (announced.find(s => requested.includes(s)));
53
- });
54
- }
55
- _findIndex(query) {
56
- const { name, address, id } = query;
57
- if (!name && !address && !id)
58
- throw new Error('illegal query, one of <id>,<name>,<address> needs to be provided');
59
- if (address)
60
- return this.peripherals.findIndex(i => i.address === address);
61
- else if (name)
62
- return this.peripherals.findIndex(i => i.name === name);
63
- else if (id)
64
- return this.peripherals.findIndex(i => i.id === id);
65
- }
66
- add(item) {
67
- const { address, name, id } = item;
68
- const { ts, peripheral, state, characteristics } = item;
69
- const cachedItem = this.find({ address, name, id });
70
- if (cachedItem) {
71
- cachedItem.ts = ts;
72
- cachedItem.peripheral = peripheral;
73
- if (state)
74
- cachedItem.state = state;
75
- if (characteristics) {
76
- cachedItem.characteristics = characteristics;
77
- }
78
- if (!cachedItem.connector) {
79
- cachedItem.connector = item.connector || new ble_peripheral_1.default(cachedItem.peripheral);
80
- }
81
- return cachedItem;
82
- }
83
- else {
84
- const newItem = Object.assign({}, item);
85
- if (newItem.peripheral && !newItem.connector)
86
- newItem.connector = new ble_peripheral_1.default(item.peripheral);
87
- this.peripherals.push(newItem);
88
- return newItem;
89
- }
90
- }
91
- remove(query) {
92
- const item = query;
93
- const isCacheItem = item.peripheral !== undefined;
94
- let cachedItemIdx;
95
- if (isCacheItem) {
96
- const { address, name, id } = item;
97
- cachedItemIdx = this._findIndex({ address, name, id });
98
- }
99
- else {
100
- const peripheral = query;
101
- const { address } = peripheral;
102
- cachedItemIdx = this._findIndex({ address });
103
- }
104
- if (cachedItemIdx === -1)
105
- return;
106
- this.peripherals.splice(cachedItemIdx);
107
- }
108
- }
109
- exports.default = BlePeripheralCache;
@@ -1,59 +0,0 @@
1
- import { LegacyProfile } from "../../antv2/types";
2
- import { CrankData } from "../cp";
3
- import { IndoorBikeData } from "../fm";
4
- import BleFitnessMachineDevice from "../fm/comms";
5
- import { BleProtocol, IBlePeripheralConnector } from "../types";
6
- import { BleFeBikeData } from "./types";
7
- export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineDevice {
8
- static protocol: BleProtocol;
9
- static services: string[];
10
- static characteristics: string[];
11
- static PROFILE: string;
12
- static detectionPriority: number;
13
- prevCrankData: CrankData;
14
- currentCrankData: CrankData;
15
- timeOffset: number;
16
- tsPrevWrite: any;
17
- data: BleFeBikeData;
18
- hasFECData: boolean;
19
- messageCnt: number;
20
- tacxRx: string;
21
- tacxTx: string;
22
- constructor(props?: any);
23
- static isMatching(characteristics: string[]): boolean;
24
- setCharacteristicUUIDs(uuids: string[]): void;
25
- subscribeAll(conn?: IBlePeripheralConnector): Promise<void>;
26
- init(): Promise<boolean>;
27
- getProfile(): LegacyProfile;
28
- getProtocol(): BleProtocol;
29
- getServiceUUids(): string[];
30
- requestControl(): Promise<boolean>;
31
- parseCrankData(crankData: any): {
32
- rpm?: undefined;
33
- time?: undefined;
34
- } | {
35
- rpm: number;
36
- time: any;
37
- };
38
- parseCSC(_data: Buffer, logOnly?: boolean): IndoorBikeData;
39
- parsePower(_data: Buffer, logOnly?: boolean): IndoorBikeData;
40
- parseIndoorBikeData(_data: Buffer, logOnly?: boolean): IndoorBikeData;
41
- resetState(): void;
42
- parseFEState(capStateBF: number): void;
43
- parseGeneralFE(data: Buffer): BleFeBikeData;
44
- parseTrainerData(data: Buffer): BleFeBikeData;
45
- parseProductInformation(data: Buffer): BleFeBikeData;
46
- parseFECMessage(_data: Buffer): BleFeBikeData;
47
- onData(characteristic: string, data: Buffer): boolean;
48
- getChecksum(message: any[]): number;
49
- buildMessage(payload?: number[], msgID?: number): Buffer;
50
- sendMessage(message: Buffer): Promise<boolean>;
51
- sendUserConfiguration(userWeight: any, bikeWeight: any, wheelDiameter: any, gearRatio: any): Promise<boolean>;
52
- sendBasicResistance(resistance: any): Promise<boolean>;
53
- sendTargetPower(power: any): Promise<boolean>;
54
- sendWindResistance(windCoeff: any, windSpeed: any, draftFactor: any): Promise<boolean>;
55
- sendTrackResistance(slope: any, rrCoeff?: any): Promise<boolean>;
56
- setTargetPower(power: number): Promise<boolean>;
57
- setSlope(slope: any): Promise<boolean>;
58
- reset(): void;
59
- }