Merge branch 'master' of github.com:churchs19/node-poweredup

This commit is contained in:
Nathan Kellenicki 2019-11-10 11:36:44 -08:00
commit dc360be318
12 changed files with 1408 additions and 1201 deletions

129
abandonware-noble.d.ts vendored Normal file
View File

@ -0,0 +1,129 @@
declare module "@abandonware/noble" {
// Type definitions for noble
// Project: https://github.com/sandeepmistry/noble
// Definitions by: Seon-Wook Park <https://github.com/swook>
// Shantanu Bhadoria <https://github.com/shantanubhadoria>
// Luke Libraro <https://github.com/lukel99>
// Dan Chao <https://github.com/bioball>
// Michal Lower <https://github.com/keton>
// Rob Moran <https://github.com/thegecko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import events = require("events");
export function startScanning(callback?: (error?: Error) => void): void;
export function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
export function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
export function stopScanning(callback?: () => void): void;
export function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
export function on(event: "scanStart", listener: () => void): events.EventEmitter;
export function on(event: "scanStop", listener: () => void): events.EventEmitter;
export function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
export function on(event: string, listener: Function): events.EventEmitter;
export function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter;
export function removeListener(event: "scanStart", listener: () => void): events.EventEmitter;
export function removeListener(event: "scanStop", listener: () => void): events.EventEmitter;
export function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter;
export function removeListener(event: string, listener: Function): events.EventEmitter;
export var state:string;
export class Peripheral extends events.EventEmitter {
id: string;
uuid: string;
address: string;
addressType: string;
connectable: boolean;
advertisement: Advertisement;
rssi: number;
services: Service[];
state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected';
connect(callback?: (error: string) => void): void;
disconnect(callback?: () => void): void;
updateRssi(callback?: (error: string, rssi: number) => void): void;
discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void;
discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
readHandle(handle: Buffer, callback: (error: string, data: Buffer) => void): void;
writeHandle(handle: Buffer, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void;
toString(): string;
on(event: "connect", listener: (error: string) => void): this;
on(event: "disconnect", listener: (error: string) => void): this;
on(event: "rssiUpdate", listener: (rssi: number) => void): this;
on(event: "servicesDiscover", listener: (services: Service[]) => void): this;
on(event: string, listener: Function): this;
}
export interface Advertisement {
localName: string;
serviceData: {
uuid: string,
data: Buffer
};
txPowerLevel: number;
manufacturerData: Buffer;
serviceUuids: string[];
}
export class Service extends events.EventEmitter {
uuid: string;
name: string;
type: string;
includedServiceUuids: string[];
characteristics: Characteristic[];
discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void;
discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void;
toString(): string;
on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this;
on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this;
on(event: string, listener: Function): this;
}
export class Characteristic extends events.EventEmitter {
uuid: string;
name: string;
type: string;
properties: string[];
descriptors: Descriptor[];
read(callback?: (error: string, data: Buffer) => void): void;
write(data: Buffer, notify: boolean, callback?: (error: string) => void): void;
broadcast(broadcast: boolean, callback?: (error: string) => void): void;
notify(notify: boolean, callback?: (error: string) => void): void;
discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void;
toString(): string;
subscribe(callback?: (error: string) => void): void;
unsubscribe(callback?: (error: string) => void): void;
on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this;
on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this;
on(event: "broadcast", listener: (state: string) => void): this;
on(event: "notify", listener: (state: string) => void): this;
on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this;
on(event: string, listener: Function): this;
on(event: string, option: boolean, listener: Function): this;
}
export class Descriptor extends events.EventEmitter {
uuid: string;
name: string;
type: string;
readValue(callback?: (error: string, data: Buffer) => void): void;
writeValue(data: Buffer, callback?: (error: string) => void): void;
toString(): string;
on(event: "valueRead", listener: (error: string, data: Buffer) => void): this;
on(event: "valueWrite", listener: (error: string) => void): this;
on(event: string, listener: Function): this;
}
}

2
noble-mac.d.ts vendored
View File

@ -1,3 +1,3 @@
declare module "noble-mac" { declare module "noble-mac" {
export * from "noble"; export * from "@abandonware/noble";
} }

2435
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,26 +16,26 @@
"author": "Nathan Kellenicki <nathan@kellenicki.com>", "author": "Nathan Kellenicki <nathan@kellenicki.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"compare-versions": "^3.5.0", "compare-versions": "^3.5.1",
"debug": "^4.1.1", "debug": "^4.1.1",
"noble": "1.9.1", "@abandonware/noble": "1.9.2-5",
"noble-mac": "git+https://github.com/Timeular/noble-mac.git#af4418e" "noble-mac": "Timeular/noble-mac#pull/38/head"
}, },
"devDependencies": { "devDependencies": {
"@types/debug": "4.1.4", "@types/debug": "4.1.5",
"@types/noble": "0.0.39", "@types/node": "^12.7.12",
"@types/node": "^11.13.7",
"@types/web-bluetooth": "0.0.4", "@types/web-bluetooth": "0.0.4",
"ink-docstrap": "^1.3.2", "ink-docstrap": "^1.3.2",
"jsdoc": "^3.6.3", "jsdoc": "^3.6.3",
"jsdoc-to-markdown": "^5.0.0", "jsdoc-to-markdown": "^5.0.2",
"ts-loader": "^5.4.3", "ts-loader": "^6.2.0",
"tslint": "^5.16.0", "tslint": "^5.20.0",
"typescript": "^3.4.5", "typescript": "^3.6.4",
"webpack": "^4.30.0", "webpack": "^4.41.1",
"webpack-cli": "^3.3.1" "webpack-cli": "^3.3.9"
}, },
"resolutions": { "resolutions": {
"noble-mac": "Timeular/noble-mac#pull/38/head",
"xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head" "xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head"
} }
} }

View File

@ -1,5 +1,5 @@
import { Peripheral } from "@abandonware/noble";
import compareVersion from "compare-versions"; import compareVersion from "compare-versions";
import { Peripheral } from "noble";
import { LPF2Hub } from "./lpf2hub"; import { LPF2Hub } from "./lpf2hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,5 +1,4 @@
import compareVersion from "compare-versions"; import { Peripheral } from "@abandonware/noble";
import { Peripheral } from "noble";
import { LPF2Hub } from "./lpf2hub"; import { LPF2Hub } from "./lpf2hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,4 +1,4 @@
import { Peripheral } from "noble"; import { Peripheral } from "@abandonware/noble";
import { LPF2Hub } from "./lpf2hub"; import { LPF2Hub } from "./lpf2hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,4 +1,4 @@
import { Peripheral } from "noble"; import { Peripheral } from "@abandonware/noble";
import { Hub } from "./hub"; import { Hub } from "./hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,4 +1,4 @@
import { Characteristic, Peripheral, Service } from "noble"; import { Characteristic, Peripheral, Service } from "@abandonware/noble";
import Debug = require("debug"); import Debug = require("debug");
import { EventEmitter } from "events"; import { EventEmitter } from "events";

View File

@ -1,5 +1,5 @@
import { Peripheral } from "@abandonware/noble";
import compareVersion from "compare-versions"; import compareVersion from "compare-versions";
import { Peripheral } from "noble";
import { LPF2Hub } from "./lpf2hub"; import { LPF2Hub } from "./lpf2hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,4 +1,4 @@
import { Peripheral } from "noble"; import { Peripheral } from "@abandonware/noble";
import { LPF2Hub } from "./lpf2hub"; import { LPF2Hub } from "./lpf2hub";
import { Port } from "./port"; import { Port } from "./port";

View File

@ -1,4 +1,4 @@
import { Peripheral } from "noble"; import { Peripheral } from "@abandonware/noble";
import { Hub } from "./hub"; import { Hub } from "./hub";
import { Port } from "./port"; import { Port } from "./port";
@ -315,7 +315,7 @@ export class WeDo2SmartHub extends Hub {
const keys = Object.keys(Consts.BLECharacteristic); const keys = Object.keys(Consts.BLECharacteristic);
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
const key = keys[i]; const key = keys[i];
if (Consts.BLECharacteristic[key as any] === uuid) { if (Consts.BLECharacteristic[key as keyof typeof Consts.BLECharacteristic] === uuid) {
return key; return key;
} }
} }