incyclist-devices 2.1.15 → 2.1.18
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/LICENSE +0 -0
- package/README.MD +238 -238
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +14 -0
- package/lib/antv2/adapter-factory.js +65 -0
- package/lib/antv2/adapter.d.ts +54 -0
- package/lib/antv2/adapter.js +291 -0
- package/lib/antv2/ant-interface.d.ts +35 -0
- package/lib/antv2/ant-interface.js +285 -0
- package/lib/antv2/base/adapter.d.ts +0 -0
- package/lib/antv2/base/adapter.js +0 -0
- package/lib/antv2/base/ant-interface.d.ts +35 -0
- package/lib/antv2/base/ant-interface.js +285 -0
- package/lib/antv2/base/binding.d.ts +0 -0
- package/lib/antv2/base/binding.js +0 -0
- package/lib/antv2/base/interface.d.ts +0 -0
- package/lib/antv2/base/interface.js +0 -0
- package/lib/antv2/binding.d.ts +13 -0
- package/lib/antv2/binding.js +27 -0
- package/lib/antv2/cad/adapter.d.ts +0 -0
- package/lib/antv2/cad/adapter.js +0 -0
- package/lib/antv2/cad/index.d.ts +0 -0
- package/lib/antv2/cad/index.js +0 -0
- package/lib/antv2/consts.d.ts +0 -0
- package/lib/antv2/consts.js +0 -0
- package/lib/antv2/factories/adapter-factory.d.ts +0 -0
- package/lib/antv2/factories/adapter-factory.js +0 -0
- package/lib/antv2/factories/sensor-factory.d.ts +0 -0
- package/lib/antv2/factories/sensor-factory.js +0 -0
- package/lib/antv2/fe/adapter.d.ts +0 -0
- package/lib/antv2/fe/adapter.js +0 -0
- package/lib/antv2/fe/index.d.ts +0 -0
- package/lib/antv2/fe/index.js +0 -0
- package/lib/antv2/hr/adapter.d.ts +0 -0
- package/lib/antv2/hr/adapter.js +0 -0
- package/lib/antv2/hr/index.d.ts +0 -0
- package/lib/antv2/hr/index.js +0 -0
- package/lib/antv2/hr copy/adapter.d.ts +11 -0
- package/lib/antv2/hr copy/adapter.js +30 -0
- package/lib/antv2/hr copy/index.d.ts +2 -0
- package/lib/antv2/hr copy/index.js +7 -0
- package/lib/antv2/index.d.ts +0 -0
- package/lib/antv2/index.js +0 -0
- package/lib/antv2/pwr/adapter.d.ts +0 -0
- package/lib/antv2/pwr/adapter.js +0 -0
- package/lib/antv2/pwr/index.d.ts +0 -0
- package/lib/antv2/pwr/index.js +0 -0
- package/lib/antv2/sensor-factory.d.ts +5 -0
- package/lib/antv2/sensor-factory.js +20 -0
- package/lib/antv2/types.d.ts +0 -0
- package/lib/antv2/types.js +0 -0
- package/lib/antv2/utils.d.ts +0 -0
- package/lib/antv2/utils.js +0 -0
- package/lib/base/adpater.d.ts +0 -0
- package/lib/base/adpater.js +0 -0
- package/lib/base/consts.d.ts +0 -0
- package/lib/base/consts.js +0 -0
- package/lib/ble/adapter-factory.d.ts +0 -0
- package/lib/ble/adapter-factory.js +0 -0
- package/lib/ble/base/adapter.d.ts +1 -0
- package/lib/ble/base/adapter.js +20 -13
- package/lib/ble/base/comms-utils.d.ts +0 -0
- package/lib/ble/base/comms-utils.js +0 -0
- package/lib/ble/base/comms.d.ts +0 -0
- package/lib/ble/base/comms.js +0 -0
- package/lib/ble/base/types.d.ts +0 -0
- package/lib/ble/base/types.js +0 -0
- package/lib/ble/bindings/index.d.ts +0 -0
- package/lib/ble/bindings/index.js +0 -0
- package/lib/ble/bindings/linux.d.ts +0 -0
- package/lib/ble/bindings/linux.js +0 -0
- package/lib/ble/bindings/mock.d.ts +0 -0
- package/lib/ble/bindings/mock.js +0 -0
- package/lib/ble/bindings/types.d.ts +0 -0
- package/lib/ble/bindings/types.js +0 -0
- package/lib/ble/ble-interface.d.ts +0 -0
- package/lib/ble/ble-interface.js +0 -0
- package/lib/ble/ble-peripheral.d.ts +0 -0
- package/lib/ble/ble-peripheral.js +0 -0
- package/lib/ble/consts.d.ts +0 -0
- package/lib/ble/consts.js +0 -0
- package/lib/ble/cp/adapter.d.ts +1 -0
- package/lib/ble/cp/adapter.js +8 -0
- package/lib/ble/cp/comm.d.ts +0 -0
- package/lib/ble/cp/comm.js +0 -0
- package/lib/ble/cp/index.d.ts +0 -0
- package/lib/ble/cp/index.js +0 -0
- package/lib/ble/cp/types.d.ts +0 -0
- package/lib/ble/cp/types.js +0 -0
- package/lib/ble/elite/adapter.d.ts +0 -0
- package/lib/ble/elite/adapter.js +0 -0
- package/lib/ble/elite/comms.d.ts +0 -0
- package/lib/ble/elite/comms.js +0 -0
- package/lib/ble/elite/index.d.ts +0 -0
- package/lib/ble/elite/index.js +0 -0
- package/lib/ble/fm/adapter.d.ts +0 -0
- package/lib/ble/fm/adapter.js +0 -0
- package/lib/ble/fm/comms.d.ts +0 -0
- package/lib/ble/fm/comms.js +0 -0
- package/lib/ble/fm/consts.d.ts +0 -0
- package/lib/ble/fm/consts.js +0 -0
- package/lib/ble/fm/index.d.ts +0 -0
- package/lib/ble/fm/index.js +0 -0
- package/lib/ble/fm/types.d.ts +0 -0
- package/lib/ble/fm/types.js +0 -0
- package/lib/ble/hr/adapter.d.ts +0 -0
- package/lib/ble/hr/adapter.js +0 -0
- package/lib/ble/hr/comm.d.ts +0 -0
- package/lib/ble/hr/comm.js +0 -0
- package/lib/ble/hr/index.d.ts +0 -0
- package/lib/ble/hr/index.js +0 -0
- package/lib/ble/hr/mock.d.ts +0 -0
- package/lib/ble/hr/mock.js +0 -0
- package/lib/ble/hr/types.d.ts +0 -0
- package/lib/ble/hr/types.js +0 -0
- package/lib/ble/index.d.ts +0 -0
- package/lib/ble/index.js +0 -0
- package/lib/ble/peripheral-cache.d.ts +0 -0
- package/lib/ble/peripheral-cache.js +0 -0
- package/lib/ble/tacx/adapter.d.ts +0 -0
- package/lib/ble/tacx/adapter.js +0 -0
- package/lib/ble/tacx/comms.d.ts +0 -0
- package/lib/ble/tacx/comms.js +0 -0
- package/lib/ble/tacx/index.d.ts +0 -0
- package/lib/ble/tacx/index.js +0 -0
- package/lib/ble/tacx/types.d.ts +0 -0
- package/lib/ble/tacx/types.js +0 -0
- package/lib/ble/types.d.ts +0 -0
- package/lib/ble/types.js +0 -0
- package/lib/ble/utils.d.ts +0 -0
- package/lib/ble/utils.js +0 -0
- package/lib/ble/wahoo/adapter.d.ts +0 -0
- package/lib/ble/wahoo/adapter.js +0 -0
- package/lib/ble/wahoo/comms.d.ts +0 -0
- package/lib/ble/wahoo/comms.js +0 -0
- package/lib/ble/wahoo/index.d.ts +0 -0
- package/lib/ble/wahoo/index.js +0 -0
- package/lib/ble/wahoo/types.d.ts +0 -0
- package/lib/ble/wahoo/types.js +0 -0
- package/lib/factories/adapters.d.ts +0 -0
- package/lib/factories/adapters.js +0 -0
- package/lib/factories/index.d.ts +0 -0
- package/lib/factories/index.js +0 -0
- package/lib/factories/interfaces.d.ts +0 -0
- package/lib/factories/interfaces.js +0 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -0
- package/lib/modes/ant-fe-adv-st-mode.d.ts +0 -0
- package/lib/modes/ant-fe-adv-st-mode.js +0 -0
- package/lib/modes/antble-erg.d.ts +0 -0
- package/lib/modes/antble-erg.js +0 -0
- package/lib/modes/antble-smarttrainer.d.ts +0 -0
- package/lib/modes/antble-smarttrainer.js +0 -0
- package/lib/modes/base.d.ts +0 -0
- package/lib/modes/base.js +0 -0
- package/lib/modes/daum-classic-standard.d.ts +0 -0
- package/lib/modes/daum-classic-standard.js +0 -0
- package/lib/modes/daum-erg.d.ts +0 -0
- package/lib/modes/daum-erg.js +0 -0
- package/lib/modes/daum-power.d.ts +0 -0
- package/lib/modes/daum-power.js +0 -0
- package/lib/modes/daum-premium-standard.d.ts +0 -0
- package/lib/modes/daum-premium-standard.js +0 -0
- package/lib/modes/daum-smarttrainer.d.ts +0 -0
- package/lib/modes/daum-smarttrainer.js +0 -0
- package/lib/modes/kettler-erg.d.ts +0 -0
- package/lib/modes/kettler-erg.js +0 -0
- package/lib/modes/power-base.d.ts +0 -0
- package/lib/modes/power-base.js +0 -0
- package/lib/modes/power-meter.d.ts +0 -0
- package/lib/modes/power-meter.js +0 -0
- package/lib/modes/simulator.d.ts +0 -0
- package/lib/modes/simulator.js +0 -0
- package/lib/modes/types.d.ts +0 -0
- package/lib/modes/types.js +0 -0
- package/lib/serial/SinglePathScanner.d.ts +17 -0
- package/lib/serial/SinglePathScanner.js +87 -0
- package/lib/serial/adapter-factory.d.ts +14 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +17 -0
- package/lib/serial/adapter.js +67 -0
- package/lib/serial/base/adapter.d.ts +0 -0
- package/lib/serial/base/adapter.js +0 -0
- package/lib/serial/base/comms.d.ts +0 -0
- package/lib/serial/base/comms.js +0 -0
- package/lib/serial/base/serial-interface.d.ts +0 -0
- package/lib/serial/base/serial-interface.js +1 -2
- package/lib/serial/base/serial-scanner.d.ts +0 -0
- package/lib/serial/base/serial-scanner.js +0 -0
- package/lib/serial/base/serialport.d.ts +0 -0
- package/lib/serial/base/serialport.js +0 -0
- package/lib/serial/bindings/tcp.d.ts +0 -0
- package/lib/serial/bindings/tcp.js +0 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/serial/comms.d.ts +62 -0
- package/lib/serial/comms.js +280 -0
- package/lib/serial/daum/DaumAdapter.d.ts +0 -0
- package/lib/serial/daum/DaumAdapter.js +0 -0
- package/lib/serial/daum/classic/PROTOCOL_NAME.d.ts +2 -0
- package/lib/serial/daum/classic/PROTOCOL_NAME.js +5 -0
- package/lib/serial/daum/classic/adapter.d.ts +0 -0
- package/lib/serial/daum/classic/adapter.js +3 -1
- package/lib/serial/daum/classic/comms.d.ts +0 -0
- package/lib/serial/daum/classic/comms.js +1 -1
- package/lib/serial/daum/classic/consts.d.ts +0 -0
- package/lib/serial/daum/classic/consts.js +0 -0
- package/lib/serial/daum/classic/mock.d.ts +0 -0
- package/lib/serial/daum/classic/mock.js +0 -0
- package/lib/serial/daum/classic/types.d.ts +0 -0
- package/lib/serial/daum/classic/types.js +0 -0
- package/lib/serial/daum/classic/utils.d.ts +0 -0
- package/lib/serial/daum/classic/utils.js +0 -0
- package/lib/serial/daum/consts.d.ts +0 -0
- package/lib/serial/daum/consts.js +0 -0
- package/lib/serial/daum/premium/adapter.d.ts +0 -0
- package/lib/serial/daum/premium/adapter.js +0 -0
- package/lib/serial/daum/premium/comms.d.ts +0 -0
- package/lib/serial/daum/premium/comms.js +0 -0
- package/lib/serial/daum/premium/consts.d.ts +0 -0
- package/lib/serial/daum/premium/consts.js +0 -0
- package/lib/serial/daum/premium/mock.d.ts +0 -0
- package/lib/serial/daum/premium/mock.js +0 -0
- package/lib/serial/daum/premium/types.d.ts +0 -0
- package/lib/serial/daum/premium/types.js +0 -0
- package/lib/serial/daum/premium/utils.d.ts +0 -0
- package/lib/serial/daum/premium/utils.js +0 -0
- package/lib/serial/daum/types.d.ts +0 -0
- package/lib/serial/daum/types.js +0 -0
- package/lib/serial/factories/adapter-factory.d.ts +0 -0
- package/lib/serial/factories/adapter-factory.js +0 -0
- package/lib/serial/index.d.ts +0 -0
- package/lib/serial/index.js +0 -0
- package/lib/serial/kettler/comms.d.ts +0 -0
- package/lib/serial/kettler/comms.js +0 -0
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +0 -0
- package/lib/serial/kettler/ergo-racer/adapter.js +0 -0
- package/lib/serial/kettler/ergo-racer/mock.d.ts +0 -0
- package/lib/serial/kettler/ergo-racer/mock.js +0 -0
- package/lib/serial/kettler/types.d.ts +0 -0
- package/lib/serial/kettler/types.js +0 -0
- package/lib/serial/serial-interface.d.ts +36 -0
- package/lib/serial/serial-interface.js +288 -0
- package/lib/serial/serial-scanner.d.ts +16 -0
- package/lib/serial/serial-scanner.js +87 -0
- package/lib/serial/serialport.d.ts +17 -0
- package/lib/serial/serialport.js +87 -0
- package/lib/serial/types.d.ts +0 -0
- package/lib/serial/types.js +0 -0
- package/lib/simulator/Simulator.d.ts +0 -0
- package/lib/simulator/Simulator.js +0 -0
- package/lib/types/Command.d.ts +8 -0
- package/lib/types/Command.js +2 -0
- package/lib/types/adapter.d.ts +0 -0
- package/lib/types/adapter.js +0 -0
- package/lib/types/capabilities.d.ts +0 -0
- package/lib/types/capabilities.js +0 -0
- package/lib/types/command.d.ts +0 -0
- package/lib/types/command.js +0 -0
- package/lib/types/data.d.ts +0 -0
- package/lib/types/data.js +0 -0
- package/lib/types/device.d.ts +0 -0
- package/lib/types/device.js +0 -0
- package/lib/types/index.d.ts +0 -0
- package/lib/types/index.js +0 -0
- package/lib/types/interface.d.ts +0 -0
- package/lib/types/interface.js +0 -0
- package/lib/types/route.d.ts +0 -0
- package/lib/types/route.js +0 -0
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.js +2 -0
- package/lib/types/user.d.ts +0 -0
- package/lib/types/user.js +0 -0
- package/lib/utils/calculations.d.ts +0 -0
- package/lib/utils/calculations.js +0 -0
- package/lib/utils/utils.d.ts +0 -0
- package/lib/utils/utils.js +0 -0
- package/package.json +51 -51
package/lib/ble/cp/types.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/ble/elite/adapter.js
CHANGED
|
File without changes
|
package/lib/ble/elite/comms.d.ts
CHANGED
|
File without changes
|
package/lib/ble/elite/comms.js
CHANGED
|
File without changes
|
package/lib/ble/elite/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/elite/index.js
CHANGED
|
File without changes
|
package/lib/ble/fm/adapter.d.ts
CHANGED
|
File without changes
|
package/lib/ble/fm/adapter.js
CHANGED
|
File without changes
|
package/lib/ble/fm/comms.d.ts
CHANGED
|
File without changes
|
package/lib/ble/fm/comms.js
CHANGED
|
File without changes
|
package/lib/ble/fm/consts.d.ts
CHANGED
|
File without changes
|
package/lib/ble/fm/consts.js
CHANGED
|
File without changes
|
package/lib/ble/fm/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/fm/index.js
CHANGED
|
File without changes
|
package/lib/ble/fm/types.d.ts
CHANGED
|
File without changes
|
package/lib/ble/fm/types.js
CHANGED
|
File without changes
|
package/lib/ble/hr/adapter.d.ts
CHANGED
|
File without changes
|
package/lib/ble/hr/adapter.js
CHANGED
|
File without changes
|
package/lib/ble/hr/comm.d.ts
CHANGED
|
File without changes
|
package/lib/ble/hr/comm.js
CHANGED
|
File without changes
|
package/lib/ble/hr/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/hr/index.js
CHANGED
|
File without changes
|
package/lib/ble/hr/mock.d.ts
CHANGED
|
File without changes
|
package/lib/ble/hr/mock.js
CHANGED
|
File without changes
|
package/lib/ble/hr/types.d.ts
CHANGED
|
File without changes
|
package/lib/ble/hr/types.js
CHANGED
|
File without changes
|
package/lib/ble/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/ble/tacx/adapter.js
CHANGED
|
File without changes
|
package/lib/ble/tacx/comms.d.ts
CHANGED
|
File without changes
|
package/lib/ble/tacx/comms.js
CHANGED
|
File without changes
|
package/lib/ble/tacx/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/tacx/index.js
CHANGED
|
File without changes
|
package/lib/ble/tacx/types.d.ts
CHANGED
|
File without changes
|
package/lib/ble/tacx/types.js
CHANGED
|
File without changes
|
package/lib/ble/types.d.ts
CHANGED
|
File without changes
|
package/lib/ble/types.js
CHANGED
|
File without changes
|
package/lib/ble/utils.d.ts
CHANGED
|
File without changes
|
package/lib/ble/utils.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/ble/wahoo/adapter.js
CHANGED
|
File without changes
|
package/lib/ble/wahoo/comms.d.ts
CHANGED
|
File without changes
|
package/lib/ble/wahoo/comms.js
CHANGED
|
File without changes
|
package/lib/ble/wahoo/index.d.ts
CHANGED
|
File without changes
|
package/lib/ble/wahoo/index.js
CHANGED
|
File without changes
|
package/lib/ble/wahoo/types.d.ts
CHANGED
|
File without changes
|
package/lib/ble/wahoo/types.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/factories/index.d.ts
CHANGED
|
File without changes
|
package/lib/factories/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/index.d.ts
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InterfaceProps } from "./types/interface";
|
|
2
|
+
import { SerialInterface } from "./serial";
|
|
3
|
+
import AntInterface from "./antv2/ant-interface";
|
|
4
|
+
import { BleInterface } from "./ble";
|
|
5
|
+
export default class InterfaceFactory {
|
|
6
|
+
static create(ifaceName: string, props?: InterfaceProps): AntInterface | BleInterface | SerialInterface;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 serial_1 = require("./serial");
|
|
7
|
+
const ant_interface_1 = __importDefault(require("./antv2/ant-interface"));
|
|
8
|
+
const device_1 = require("./types/device");
|
|
9
|
+
const ble_1 = require("./ble");
|
|
10
|
+
class InterfaceFactory {
|
|
11
|
+
static create(ifaceName, props) {
|
|
12
|
+
switch (ifaceName) {
|
|
13
|
+
case device_1.INTERFACE.SERIAL:
|
|
14
|
+
case device_1.INTERFACE.TCPIP:
|
|
15
|
+
const serialProps = props;
|
|
16
|
+
serialProps.ifaceName = ifaceName;
|
|
17
|
+
return serial_1.SerialInterface.getInstance(serialProps);
|
|
18
|
+
case device_1.INTERFACE.ANT:
|
|
19
|
+
const antProps = props;
|
|
20
|
+
return ant_interface_1.default.getInstance(antProps);
|
|
21
|
+
case device_1.INTERFACE.BLE:
|
|
22
|
+
const bleProps = props;
|
|
23
|
+
return ble_1.BleInterface.getInstance(bleProps);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = InterfaceFactory;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/modes/antble-erg.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/modes/base.d.ts
CHANGED
|
File without changes
|
package/lib/modes/base.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/modes/daum-erg.d.ts
CHANGED
|
File without changes
|
package/lib/modes/daum-erg.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/modes/daum-power.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/modes/kettler-erg.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/modes/power-base.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/modes/power-meter.js
CHANGED
|
File without changes
|
package/lib/modes/simulator.d.ts
CHANGED
|
File without changes
|
package/lib/modes/simulator.js
CHANGED
|
File without changes
|
package/lib/modes/types.d.ts
CHANGED
|
File without changes
|
package/lib/modes/types.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SerialDeviceSettings } from './adapter';
|
|
2
|
+
import { EventLogger } from "gd-eventlog";
|
|
3
|
+
import { SerialScannerProps } from "./types";
|
|
4
|
+
import SerialInterface from "./serial-interface";
|
|
5
|
+
export declare class SinglePathScanner {
|
|
6
|
+
path: string;
|
|
7
|
+
serial: SerialInterface;
|
|
8
|
+
result: SerialDeviceSettings;
|
|
9
|
+
isScanning: boolean;
|
|
10
|
+
props: SerialScannerProps;
|
|
11
|
+
logger: EventLogger;
|
|
12
|
+
isFound: boolean;
|
|
13
|
+
constructor(path: string, serial: SerialInterface, props: SerialScannerProps);
|
|
14
|
+
logEvent(event: any): void;
|
|
15
|
+
onStopRequest(resolve: any): Promise<void>;
|
|
16
|
+
scan(): Promise<SerialDeviceSettings | undefined>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SinglePathScanner = void 0;
|
|
16
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
|
+
const utils_1 = require("../utils/utils");
|
|
18
|
+
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
19
|
+
const types_1 = require("./types");
|
|
20
|
+
class SinglePathScanner {
|
|
21
|
+
constructor(path, serial, props) {
|
|
22
|
+
this.path = path;
|
|
23
|
+
this.serial = serial;
|
|
24
|
+
this.result = undefined;
|
|
25
|
+
this.isScanning = false;
|
|
26
|
+
this.isFound = false;
|
|
27
|
+
this.props = props;
|
|
28
|
+
this.logger = props.logger || new gd_eventlog_1.EventLogger('SerialScanner');
|
|
29
|
+
}
|
|
30
|
+
logEvent(event) {
|
|
31
|
+
if (this.logger) {
|
|
32
|
+
this.logger.logEvent(event);
|
|
33
|
+
}
|
|
34
|
+
const w = global.window;
|
|
35
|
+
if ((w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) || process.env.BLE_DEBUG) {
|
|
36
|
+
console.log('~~~ SerialScanner', event);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
onStopRequest(resolve) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
this.logEvent({ message: 'stopping scan', path: this.path });
|
|
42
|
+
if (!this.isFound)
|
|
43
|
+
yield this.serial.closePort(this.path);
|
|
44
|
+
this.isScanning = false;
|
|
45
|
+
resolve(this.result);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
scan() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (this.isScanning)
|
|
51
|
+
return;
|
|
52
|
+
this.isScanning = true;
|
|
53
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
this.logEvent({ message: 'starting scan', path: this.path, interface: this.serial.getName() });
|
|
55
|
+
this.serial.scanEvents.on('timeout', () => this.onStopRequest(resolve));
|
|
56
|
+
this.serial.scanEvents.on('stop', () => this.onStopRequest(resolve));
|
|
57
|
+
let found = false;
|
|
58
|
+
while (!found && this.isScanning) {
|
|
59
|
+
try {
|
|
60
|
+
const { protocol } = this.props;
|
|
61
|
+
let host, port;
|
|
62
|
+
if (this.serial.getName() === types_1.SerialInterfaceType.TCPIP) {
|
|
63
|
+
[host, port] = this.path.split(':');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
port = this.path;
|
|
67
|
+
}
|
|
68
|
+
const adapterSettings = { interface: this.serial.getName(), host, port, protocol };
|
|
69
|
+
const adapter = adapter_factory_1.default.getInstance().createInstance(adapterSettings);
|
|
70
|
+
found = yield adapter.check();
|
|
71
|
+
if (found) {
|
|
72
|
+
this.isFound = true;
|
|
73
|
+
const name = adapter.getName();
|
|
74
|
+
resolve(Object.assign(Object.assign({}, adapterSettings), { name }));
|
|
75
|
+
}
|
|
76
|
+
yield (0, utils_1.sleep)(100);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.logEvent({ message: 'error', fn: 'scan()', error: err.message || err, stack: err.stack });
|
|
80
|
+
yield (0, utils_1.sleep)(100);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.SinglePathScanner = SinglePathScanner;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeviceProperties } from '../types';
|
|
2
|
+
import { SerialIncyclistDevice } from './adapter';
|
|
3
|
+
import { SerialDeviceSettings } from "./types";
|
|
4
|
+
export default class SerialAdapterFactory {
|
|
5
|
+
static _instance: SerialAdapterFactory;
|
|
6
|
+
adapters: Array<{
|
|
7
|
+
protocol: string;
|
|
8
|
+
AdapterClass: typeof SerialIncyclistDevice<DeviceProperties>;
|
|
9
|
+
}>;
|
|
10
|
+
static getInstance(): SerialAdapterFactory;
|
|
11
|
+
constructor();
|
|
12
|
+
registerAdapter(protocol: string, AdapterClass: typeof SerialIncyclistDevice<DeviceProperties>): void;
|
|
13
|
+
createInstance(props: SerialDeviceSettings, settings?: any): SerialIncyclistDevice<DeviceProperties>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class SerialAdapterFactory {
|
|
4
|
+
static getInstance() {
|
|
5
|
+
if (!SerialAdapterFactory._instance)
|
|
6
|
+
SerialAdapterFactory._instance = new SerialAdapterFactory();
|
|
7
|
+
return SerialAdapterFactory._instance;
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
this.adapters = [];
|
|
11
|
+
}
|
|
12
|
+
registerAdapter(protocol, AdapterClass) {
|
|
13
|
+
const existing = this.adapters.findIndex(a => a.protocol === protocol);
|
|
14
|
+
if (existing !== -1)
|
|
15
|
+
this.adapters[existing].AdapterClass = AdapterClass;
|
|
16
|
+
else
|
|
17
|
+
this.adapters.push({ protocol, AdapterClass });
|
|
18
|
+
}
|
|
19
|
+
createInstance(props, settings) {
|
|
20
|
+
const { protocol } = props;
|
|
21
|
+
if (!protocol)
|
|
22
|
+
return null;
|
|
23
|
+
const adapter = this.adapters.find(a => a.protocol === protocol);
|
|
24
|
+
if (!adapter)
|
|
25
|
+
return null;
|
|
26
|
+
const { AdapterClass } = adapter;
|
|
27
|
+
return new AdapterClass(props, settings);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = SerialAdapterFactory;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import IncyclistDevice from "../base/adpater";
|
|
2
|
+
import { DeviceProperties } from "../types";
|
|
3
|
+
import SerialInterface from "./base/serial-interface";
|
|
4
|
+
import { SerialDeviceSettings } from "./types";
|
|
5
|
+
export declare class SerialIncyclistDevice<P extends DeviceProperties> extends IncyclistDevice<P> {
|
|
6
|
+
pullFrequency: number;
|
|
7
|
+
check(): Promise<boolean>;
|
|
8
|
+
constructor(settings: SerialDeviceSettings, props?: P);
|
|
9
|
+
isEqual(settings: SerialDeviceSettings): boolean;
|
|
10
|
+
getPort(): string;
|
|
11
|
+
getUniqueName(): string;
|
|
12
|
+
getSerialInterface(): SerialInterface;
|
|
13
|
+
getInterface(): string;
|
|
14
|
+
setMaxUpdateFrequency(ms: number): void;
|
|
15
|
+
setPullFrequency(ms: number): void;
|
|
16
|
+
getPullFrequency(): number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SerialIncyclistDevice = void 0;
|
|
16
|
+
const adpater_1 = __importDefault(require("../base/adpater"));
|
|
17
|
+
const DEFAULT_PULL_FREQUENCY = 1000;
|
|
18
|
+
class SerialIncyclistDevice extends adpater_1.default {
|
|
19
|
+
check() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () { throw new Error('not implemnted'); });
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
constructor(settings, props) {
|
|
24
|
+
super(settings, props);
|
|
25
|
+
this.pullFrequency = DEFAULT_PULL_FREQUENCY;
|
|
26
|
+
}
|
|
27
|
+
isEqual(settings) {
|
|
28
|
+
if (settings.interface !== this.getInterface())
|
|
29
|
+
return false;
|
|
30
|
+
const s = this.settings;
|
|
31
|
+
if (settings.protocol !== s.protocol)
|
|
32
|
+
return false;
|
|
33
|
+
if (settings.port !== s.port)
|
|
34
|
+
return false;
|
|
35
|
+
if (settings.host && (!s.host || s.host !== settings.host))
|
|
36
|
+
return false;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
getPort() {
|
|
40
|
+
const settings = this.settings;
|
|
41
|
+
return settings.port;
|
|
42
|
+
}
|
|
43
|
+
getUniqueName() {
|
|
44
|
+
return `${this.getName()} (${this.getPort()})`;
|
|
45
|
+
}
|
|
46
|
+
getSerialInterface() {
|
|
47
|
+
throw new Error('not implemented');
|
|
48
|
+
}
|
|
49
|
+
getInterface() {
|
|
50
|
+
return 'serial';
|
|
51
|
+
}
|
|
52
|
+
setMaxUpdateFrequency(ms) {
|
|
53
|
+
if (ms <= this.pullFrequency)
|
|
54
|
+
this.updateFrequency = -1;
|
|
55
|
+
else
|
|
56
|
+
this.updateFrequency = ms;
|
|
57
|
+
}
|
|
58
|
+
setPullFrequency(ms) {
|
|
59
|
+
this.pullFrequency = ms;
|
|
60
|
+
if (this.updateFrequency <= this.pullFrequency)
|
|
61
|
+
this.updateFrequency = -1;
|
|
62
|
+
}
|
|
63
|
+
getPullFrequency() {
|
|
64
|
+
return this.pullFrequency;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.SerialIncyclistDevice = SerialIncyclistDevice;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/serial/base/comms.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -207,8 +207,7 @@ class SerialInterface extends events_1.default {
|
|
|
207
207
|
do {
|
|
208
208
|
if (attemptNo === 0)
|
|
209
209
|
this.logEvent({ message: 'checking for ports', interface: this.ifaceName, port, excludes: this.inUse });
|
|
210
|
-
|
|
211
|
-
attemptNo++;
|
|
210
|
+
attemptNo++;
|
|
212
211
|
try {
|
|
213
212
|
if (isTcpip) {
|
|
214
213
|
const _binding = binding;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventLogger } from "gd-eventlog";
|
|
3
|
+
import SerialInterface from "./base/serial-interface";
|
|
4
|
+
import { SerialCommProps } from "./types";
|
|
5
|
+
import { SerialPortStream } from "@serialport/stream";
|
|
6
|
+
import { Queue } from "../utils/utils";
|
|
7
|
+
export type ConnectionState = 'Connecting' | 'Connected' | 'Disconnected' | 'Disconnecting';
|
|
8
|
+
export type Request = {
|
|
9
|
+
logString?: string;
|
|
10
|
+
isBinary?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type Response = {};
|
|
13
|
+
export interface CommsState {
|
|
14
|
+
data?: Queue<Response>;
|
|
15
|
+
}
|
|
16
|
+
export default class SerialPortComms<T extends CommsState, C extends Request, R extends Response> {
|
|
17
|
+
logger: EventLogger;
|
|
18
|
+
serial: SerialInterface;
|
|
19
|
+
protected path: string;
|
|
20
|
+
protected props: SerialCommProps;
|
|
21
|
+
protected sp: SerialPortStream;
|
|
22
|
+
protected connectState: ConnectionState;
|
|
23
|
+
protected connectPromise: Promise<SerialPortStream>;
|
|
24
|
+
protected disconnectPromise: Promise<boolean>;
|
|
25
|
+
protected writePromise: Promise<void>;
|
|
26
|
+
protected sendCmdPromise: Promise<R>;
|
|
27
|
+
protected actualBikeType?: string;
|
|
28
|
+
protected recvState: T;
|
|
29
|
+
protected isLoggingPaused: boolean;
|
|
30
|
+
constructor(props: SerialCommProps);
|
|
31
|
+
getBusyTimeout(): number;
|
|
32
|
+
getDefaultLoggerName(): string;
|
|
33
|
+
getInitialCommsState(): T;
|
|
34
|
+
validatePath(path: string): string;
|
|
35
|
+
getInterface(): string;
|
|
36
|
+
getPort(): string;
|
|
37
|
+
isConnected(): boolean;
|
|
38
|
+
pauseLogging(): void;
|
|
39
|
+
resumeLogging(): void;
|
|
40
|
+
logEvent(e: any): void;
|
|
41
|
+
connect(): Promise<boolean>;
|
|
42
|
+
onConnected(): void;
|
|
43
|
+
portFlush(): void;
|
|
44
|
+
portPipe(destination: any, options?: any): any;
|
|
45
|
+
portUnpipe(destination?: any): void;
|
|
46
|
+
closePort(): Promise<boolean>;
|
|
47
|
+
resetState(isDisconnected?: boolean): void;
|
|
48
|
+
cleanupPort(isDisconnected?: boolean): void;
|
|
49
|
+
close(): Promise<boolean>;
|
|
50
|
+
flush(): Promise<void>;
|
|
51
|
+
onPortClose(): Promise<void>;
|
|
52
|
+
onPortError(error: Error): Promise<void>;
|
|
53
|
+
isSending(): boolean;
|
|
54
|
+
rejectCurrent(error: Error): void;
|
|
55
|
+
getTimeoutValue(): number;
|
|
56
|
+
onData(data: any, depth?: number): Promise<void>;
|
|
57
|
+
send(command: C): Promise<R>;
|
|
58
|
+
portWrite(buffer: Buffer): Promise<void>;
|
|
59
|
+
write(buffer: Buffer): Promise<void>;
|
|
60
|
+
ensurePrevCmdFinish(logPayload: any): Promise<void>;
|
|
61
|
+
ensureConnection(): Promise<void>;
|
|
62
|
+
}
|