noble: Respect optional parameters

This commit is contained in:
Seon-Wook Park
2014-06-25 22:40:55 +09:00
parent 9886325bf6
commit c10ae26f0a
2 changed files with 30 additions and 0 deletions
+15
View File
@@ -33,11 +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 => {});
@@ -51,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 => {});
@@ -61,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 => {});
@@ -76,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 => {});
+15
View File
@@ -25,11 +25,17 @@ declare module "noble" {
rssi: number;
services: string[];
connect(): void;
connect(callback: (error: string) => void): void;
disconnect(): void;
disconnect(callback: () => void): void;
updateRssi(): void;
updateRssi(callback: (error: string, rssi: number) => void): void;
discoverServices(serviceUUIDs: string[]): void;
discoverServices(serviceUUIDs: string[], listener: (error: string, services: Service[]) => void): void;
discoverAllServicesAndCharacteristics(): void;
discoverAllServicesAndCharacteristics(callback: (error: string, services: Service[], characteristics: Characteristic[]) => void): void;
discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[]): 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;
@@ -58,7 +64,9 @@ declare module "noble" {
includedServiceUuids: string[];
characteristics: Characteristic[];
discoverIncludedServices(serviceUUIDs: string[]): void;
discoverIncludedServices(serviceUUIDs: string[], callback: (error: string, includedServiceUuids: string[]) => void): void;
discoverCharacteristics(characteristicUUIDs: string[]): void;
discoverCharacteristics(characteristicUUIDs: string[], callback: (error: string, characteristics: Characteristic[]) => void): void;
toString(): string;
@@ -74,10 +82,15 @@ declare module "noble" {
properties: string[];
descriptors: Descriptor[];
read(): void;
read(callback: (error: string, data: NodeBuffer) => void): void;
write(data: NodeBuffer, notify: boolean): void;
write(data: NodeBuffer, notify: boolean, callback: (error: string) => void): void;
broadcast(broadcast: boolean): void;
broadcast(broadcast: boolean, callback: (error: string) => void): void;
notify(notify: boolean): void;
notify(notify: boolean, callback: (error: string) => void): void;
discoverDescriptors(): void;
discoverDescriptors(callback: (error: string, descriptors: Descriptor[]) => void): void;
toString(): string;
@@ -95,7 +108,9 @@ declare module "noble" {
name: string;
type: string;
readValue(): void;
readValue(callback: (error: string, data: NodeBuffer) => void): void;
writeValue(data: NodeBuffer): void;
writeValue(data: NodeBuffer, callback: (error: string) => void): void;
toString(): string;