Skip to content

Commit 291f69d

Browse files
committed
Adding tests file and adjusting meshblu definitions
1 parent b562f0a commit 291f69d

File tree

2 files changed

+132
-9
lines changed

2 files changed

+132
-9
lines changed

meshblu/meshblu-tests.ts

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/// <reference path="meshblu.d.ts" />
2+
3+
import Meshblu = require('meshblu');
4+
5+
var UUID = "26de691f-8068-4cdc-907a-4cb5961a1aba";
6+
var TOKEN = "4cb5961a1aba26de691f80684cdc907a";
7+
8+
var meshblu = Meshblu.createConnection({
9+
uuid: UUID,
10+
token: TOKEN
11+
});
12+
13+
meshblu.data({
14+
uuid: UUID,
15+
online: true,
16+
x: -53,
17+
y: 234
18+
}, function(result) {
19+
console.log(result);
20+
});
21+
22+
meshblu.device({
23+
uuid: UUID
24+
}, function(result) {
25+
console.log(result);
26+
});
27+
28+
meshblu.devices({
29+
color: "green"
30+
}, function(result) {
31+
console.log(result);
32+
});
33+
34+
meshblu.generateAndStoreToken({
35+
uuid: UUID
36+
}, function(result) {
37+
console.log(result);
38+
});
39+
40+
meshblu.getdata({
41+
uuid: UUID,
42+
start: "2015-04-23T18:25:43.511Z",
43+
finish: "2015-04-24T18:25:43.511Z",
44+
limit: 10
45+
}, function(result) {
46+
console.log(result);
47+
});
48+
49+
meshblu.identify();
50+
51+
meshblu.message({
52+
devices: [UUID],
53+
topic: "status",
54+
payload: {
55+
online: true
56+
}
57+
}, function(result) {
58+
console.log(result);
59+
});
60+
61+
meshblu.register({
62+
type: "drone"
63+
}, function(result) {
64+
console.log(result);
65+
});
66+
67+
meshblu.revokeToken({
68+
uuid: UUID,
69+
token: TOKEN
70+
}, function(result) {
71+
console.log(result);
72+
});
73+
74+
meshblu.subscribe({
75+
uuid: UUID
76+
}, function(result) {
77+
console.log(result);
78+
});
79+
80+
meshblu.subscribe({
81+
uuid: UUID,
82+
types: ["sent", "received"]
83+
}, function(result) {
84+
console.log(result);
85+
});
86+
87+
meshblu.subscribe({
88+
uuid: UUID,
89+
types: ["sent", "received"],
90+
topics: ["device*", "-*status"]
91+
}, function(result) {
92+
console.log(result);
93+
});
94+
95+
meshblu.unsubscribe({
96+
uuid: UUID
97+
}, function(result) {
98+
console.log(result);
99+
});
100+
101+
meshblu.unsubscribe({
102+
uuid: UUID,
103+
types: ["sent", "broadcast"]
104+
}, function(result) {
105+
console.log(result);
106+
});
107+
108+
meshblu.update({
109+
uuid: UUID,
110+
color: "blue"
111+
}, function(result) {
112+
console.log(result);
113+
});
114+
115+
meshblu.whoami({}, function(result) {
116+
console.log(result);
117+
});
118+
119+
meshblu.unregister({
120+
uuid: UUID
121+
}, function(result) {
122+
console.log(result);
123+
});

meshblu/meshblu.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ declare module Meshblu {
2626

2727
interface Connection {
2828

29-
/**
30-
*
31-
* @param uuid
32-
* @param fn The callback to be called. It should take one parameter, err,
33-
* which will be null if there was no problem, and one parameter, publicKey,
34-
* of type NodeRSA.
35-
*/
36-
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
37-
3829
/**
3930
* Authenticate with Meshblu.
4031
* @returns This Connection.
@@ -166,6 +157,15 @@ declare module Meshblu {
166157
*/
167158
revokeToken(data: ConnectionOptions, fn:(result: Device) => void): void
168159

160+
/**
161+
*
162+
* @param uuid
163+
* @param fn The callback to be called. It should take one parameter, err,
164+
* which will be null if there was no problem, and one parameter, publicKey,
165+
* of type NodeRSA.
166+
*/
167+
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
168+
169169
/*
170170
* Lack of documentation about these api functions.
171171
*/

0 commit comments

Comments
 (0)