diff --git a/noble/noble-tests.ts b/noble/noble-tests.ts index 46851ab523..4b1d396564 100644 --- a/noble/noble-tests.ts +++ b/noble/noble-tests.ts @@ -33,10 +33,17 @@ peripheral.advertisement = { manufacturerData: new Buffer(1), serviceUuids: ["0x180a", "0x180d"] }; +peripheral.connect(); peripheral.connect((error: string): void => {}); +peripheral.disconnect(); peripheral.disconnect((): void => {}); +peripheral.updateRssi(); +peripheral.updateRssi((error: string, rssi: number): void => {}); +peripheral.discoverServices(["180d"]); peripheral.discoverServices(["180d"], (error: string, services: noble.Service[]): void => {}); +peripheral.discoverAllServicesAndCharacteristics(); peripheral.discoverAllServicesAndCharacteristics((error: string, services: noble.Service[], characteristics: noble.Characteristic[]): void => {}); +peripheral.discoverSomeServicesAndCharacteristics(["180d"], ["2a38"]); peripheral.discoverSomeServicesAndCharacteristics(["180d"], ["2a38"], (error: string, services: noble.Service[], characteristics: noble.Characteristic[]): void => {}); peripheral.readHandle(new Buffer(1), (error: string, data: NodeBuffer): void => {}); peripheral.writeHandle(new Buffer(1), new Buffer(1), true, (error: string): void => {}); @@ -50,7 +57,9 @@ service.uuid = "180a"; service.name = ""; service.type = ""; service.includedServiceUuids = ["180d"]; +service.discoverIncludedServices(["180d"]); service.discoverIncludedServices(["180d"], (error: string, includedServiceUuids: string[]): void => {}); +service.discoverCharacteristics(["2a38"]); service.discoverCharacteristics(["2a38"], (error: string, characteristics: noble.Characteristic[]): void => {}); service.on("includedServicesDiscover", (includedServiceUuids: string[]): void => {}); service.on("characteristicsDiscover", (characteristics: noble.Characteristic[]): void => {}); @@ -60,10 +69,15 @@ characteristic.uuid = "2a37"; characteristic.name = ""; characteristic.type = ""; characteristic.properties = ["read", "notify"]; +characteristic.read(); characteristic.read((error: string, data: NodeBuffer): void => {}); +characteristic.write(new Buffer(1), true); characteristic.write(new Buffer(1), true, (error: string): void => {}); +characteristic.broadcast(true); characteristic.broadcast(true, (error: string): void => {}); +characteristic.notify(true); characteristic.notify(true, (error: string): void => {}); +characteristic.discoverDescriptors(); characteristic.discoverDescriptors((error: string, descriptors: noble.Descriptor[]): void => {}); characteristic.on("read", (data: NodeBuffer, isNotification: boolean): void => {}); characteristic.on("write", true, (error: string): void => {}); @@ -75,7 +89,9 @@ var descriptor: noble.Descriptor = new noble.Descriptor(); descriptor.uuid = ""; descriptor.name = ""; descriptor.type = ""; +descriptor.readValue(); descriptor.readValue((error: string, data: NodeBuffer): void => {}); +descriptor.writeValue(new Buffer(1)); descriptor.writeValue(new Buffer(1), (error: string): void => {}); descriptor.on("valueRead", (error: string, data: NodeBuffer): void => {}); descriptor.on("valueWrite", (error: string): void => {}); diff --git a/noble/noble.d.ts b/noble/noble.d.ts index f9c833bd13..fb0a7a491f 100644 --- a/noble/noble.d.ts +++ b/noble/noble.d.ts @@ -25,11 +25,12 @@ declare module "noble" { rssi: number; services: string[]; - connect(callback: (error: string) => void): void; - disconnect(callback: () => void): void; - discoverServices(serviceUUIDs: string[], listener: (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; + 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: NodeBuffer, callback: (error: string, data: NodeBuffer) => void): void; writeHandle(handle: NodeBuffer, data: NodeBuffer, withoutResponse: boolean, callback: (error: string) => void): void; @@ -57,8 +58,8 @@ declare module "noble" { includedServiceUuids: string[]; characteristics: Characteristic[]; - discoverIncludedServices(serviceUUIDs: string[], callback: (error: string, includedServiceUuids: string[]) => void): void; - discoverCharacteristics(characteristicUUIDs: string[], callback: (error: string, characteristics: Characteristic[]) => void): void; + discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void; + discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void; toString(): string; on(event: string, listener: Function): events.EventEmitter; @@ -73,11 +74,11 @@ declare module "noble" { properties: string[]; descriptors: Descriptor[]; - read(callback: (error: string, data: NodeBuffer) => void): void; - write(data: NodeBuffer, 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; + read(callback?: (error: string, data: NodeBuffer) => void): void; + write(data: NodeBuffer, 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; on(event: string, listener: Function): events.EventEmitter; @@ -94,8 +95,8 @@ declare module "noble" { name: string; type: string; - readValue(callback: (error: string, data: NodeBuffer) => void): void; - writeValue(data: NodeBuffer, callback: (error: string) => void): void; + readValue(callback?: (error: string, data: NodeBuffer) => void): void; + writeValue(data: NodeBuffer, callback?: (error: string) => void): void; toString(): string; on(event: string, listener: Function): events.EventEmitter;