From 291f69d01cd82947e5bb39faeae8a4b64e72f073 Mon Sep 17 00:00:00 2001 From: Felipe Nipo Date: Sat, 19 Sep 2015 23:59:04 -0300 Subject: [PATCH] Adding tests file and adjusting meshblu definitions --- meshblu/meshblu-tests.ts | 123 +++++++++++++++++++++++++++++++++++++++ meshblu/meshblu.d.ts | 18 +++--- 2 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 meshblu/meshblu-tests.ts diff --git a/meshblu/meshblu-tests.ts b/meshblu/meshblu-tests.ts new file mode 100644 index 0000000000..1c4bc0fb02 --- /dev/null +++ b/meshblu/meshblu-tests.ts @@ -0,0 +1,123 @@ +/// + +import Meshblu = require('meshblu'); + +var UUID = "26de691f-8068-4cdc-907a-4cb5961a1aba"; +var TOKEN = "4cb5961a1aba26de691f80684cdc907a"; + +var meshblu = Meshblu.createConnection({ + uuid: UUID, + token: TOKEN +}); + +meshblu.data({ + uuid: UUID, + online: true, + x: -53, + y: 234 +}, function(result) { + console.log(result); +}); + +meshblu.device({ + uuid: UUID +}, function(result) { + console.log(result); +}); + +meshblu.devices({ + color: "green" +}, function(result) { + console.log(result); +}); + +meshblu.generateAndStoreToken({ + uuid: UUID +}, function(result) { + console.log(result); +}); + +meshblu.getdata({ + uuid: UUID, + start: "2015-04-23T18:25:43.511Z", + finish: "2015-04-24T18:25:43.511Z", + limit: 10 +}, function(result) { + console.log(result); +}); + +meshblu.identify(); + +meshblu.message({ + devices: [UUID], + topic: "status", + payload: { + online: true + } +}, function(result) { + console.log(result); +}); + +meshblu.register({ + type: "drone" +}, function(result) { + console.log(result); +}); + +meshblu.revokeToken({ + uuid: UUID, + token: TOKEN +}, function(result) { + console.log(result); +}); + +meshblu.subscribe({ + uuid: UUID +}, function(result) { + console.log(result); +}); + +meshblu.subscribe({ + uuid: UUID, + types: ["sent", "received"] +}, function(result) { + console.log(result); +}); + +meshblu.subscribe({ + uuid: UUID, + types: ["sent", "received"], + topics: ["device*", "-*status"] +}, function(result) { + console.log(result); +}); + +meshblu.unsubscribe({ + uuid: UUID +}, function(result) { + console.log(result); +}); + +meshblu.unsubscribe({ + uuid: UUID, + types: ["sent", "broadcast"] +}, function(result) { + console.log(result); +}); + +meshblu.update({ + uuid: UUID, + color: "blue" +}, function(result) { + console.log(result); +}); + +meshblu.whoami({}, function(result) { + console.log(result); +}); + +meshblu.unregister({ + uuid: UUID +}, function(result) { + console.log(result); +}); \ No newline at end of file diff --git a/meshblu/meshblu.d.ts b/meshblu/meshblu.d.ts index 15ed7671a6..f3b9684f23 100644 --- a/meshblu/meshblu.d.ts +++ b/meshblu/meshblu.d.ts @@ -26,15 +26,6 @@ declare module Meshblu { interface Connection { - /** - * - * @param uuid - * @param fn The callback to be called. It should take one parameter, err, - * which will be null if there was no problem, and one parameter, publicKey, - * of type NodeRSA. - */ - getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void; - /** * Authenticate with Meshblu. * @returns This Connection. @@ -166,6 +157,15 @@ declare module Meshblu { */ revokeToken(data: ConnectionOptions, fn:(result: Device) => void): void + /** + * + * @param uuid + * @param fn The callback to be called. It should take one parameter, err, + * which will be null if there was no problem, and one parameter, publicKey, + * of type NodeRSA. + */ + getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void; + /* * Lack of documentation about these api functions. */