@wiotp/sdk 0.7.8 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseClient.js +36 -82
- package/dist/BaseConfig.js +24 -36
- package/dist/api/ApiClient.js +60 -76
- package/dist/api/ApiErrors.js +29 -74
- package/dist/api/DscClient.js +77 -77
- package/dist/api/LecClient.js +17 -15
- package/dist/api/MgmtClient.js +17 -15
- package/dist/api/RegistryClient.js +12 -18
- package/dist/api/RulesClient.js +17 -15
- package/dist/api/StateClient.js +70 -132
- package/dist/application/ApplicationClient.js +53 -137
- package/dist/application/ApplicationConfig.js +43 -64
- package/dist/application/index.js +0 -3
- package/dist/bundled/wiotp-bundle.js +45644 -34207
- package/dist/bundled/wiotp-bundle.min.js +7 -6
- package/dist/device/DeviceClient.js +25 -54
- package/dist/device/DeviceConfig.js +37 -59
- package/dist/device/index.js +0 -3
- package/dist/gateway/GatewayClient.js +27 -61
- package/dist/gateway/GatewayConfig.js +22 -33
- package/dist/gateway/index.js +0 -3
- package/dist/index.js +14 -28
- package/dist/util.js +9 -15
- package/package.json +24 -24
- package/src/BaseClient.js +1 -1
- package/src/application/ApplicationConfig.js +1 -1
|
@@ -1,58 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
8
|
var _util = require("../util");
|
|
9
|
-
|
|
10
9
|
var _BaseClient2 = _interopRequireDefault(require("../BaseClient"));
|
|
11
|
-
|
|
12
10
|
var _ApiClient = _interopRequireDefault(require("../api/ApiClient"));
|
|
13
|
-
|
|
14
11
|
var _RegistryClient = _interopRequireDefault(require("../api/RegistryClient"));
|
|
15
|
-
|
|
16
12
|
var _MgmtClient = _interopRequireDefault(require("../api/MgmtClient"));
|
|
17
|
-
|
|
18
13
|
var _LecClient = _interopRequireDefault(require("../api/LecClient"));
|
|
19
|
-
|
|
20
14
|
var _DscClient = _interopRequireDefault(require("../api/DscClient"));
|
|
21
|
-
|
|
22
15
|
var _RulesClient = _interopRequireDefault(require("../api/RulesClient"));
|
|
23
|
-
|
|
24
16
|
var _StateClient = _interopRequireDefault(require("../api/StateClient"));
|
|
25
|
-
|
|
26
17
|
var _ApplicationConfig = _interopRequireDefault(require("./ApplicationConfig"));
|
|
27
|
-
|
|
28
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
|
-
|
|
30
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
31
|
-
|
|
32
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
41
|
-
|
|
42
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
-
|
|
46
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
47
|
-
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
49
|
-
|
|
20
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
25
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
50
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
27
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
28
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
29
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
30
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /**
|
|
33
|
+
*****************************************************************************
|
|
34
|
+
Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
|
|
35
|
+
All rights reserved. This program and the accompanying materials
|
|
36
|
+
are made available under the terms of the Eclipse Public License v1.0
|
|
37
|
+
which accompanies this distribution, and is available at
|
|
38
|
+
http://www.eclipse.org/legal/epl-v10.html
|
|
39
|
+
*****************************************************************************
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
56
42
|
var DEVICE_EVT_RE = /^iot-2\/type\/(.+)\/id\/(.+)\/evt\/(.+)\/fmt\/(.+)$/;
|
|
57
43
|
var DEVICE_CMD_RE = /^iot-2\/type\/(.+)\/id\/(.+)\/cmd\/(.+)\/fmt\/(.+)$/;
|
|
58
44
|
var DEVICE_STATE_RE = /^iot-2\/type\/(.+)\/id\/(.+)\/intf\/(.+)\/evt\/state$/;
|
|
@@ -61,24 +47,16 @@ var RULE_TRIGGER_RE = /^iot-2\/intf\/(.+)\/rule\/(.+)\/evt\/trigger$/;
|
|
|
61
47
|
var RULE_ERROR_RE = /^iot-2\/intf\/(.+)\/rule\/(.+)\/err\/data$/;
|
|
62
48
|
var DEVICE_MON_RE = /^iot-2\/type\/(.+)\/id\/(.+)\/mon$/;
|
|
63
49
|
var APP_MON_RE = /^iot-2\/app\/(.+)\/mon$/;
|
|
64
|
-
|
|
65
|
-
var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
50
|
+
var ApplicationClient = exports["default"] = /*#__PURE__*/function (_BaseClient) {
|
|
66
51
|
_inherits(ApplicationClient, _BaseClient);
|
|
67
|
-
|
|
68
|
-
var _super = _createSuper(ApplicationClient);
|
|
69
|
-
|
|
70
52
|
function ApplicationClient(config) {
|
|
71
53
|
var _this;
|
|
72
|
-
|
|
73
54
|
_classCallCheck(this, ApplicationClient);
|
|
74
|
-
|
|
75
55
|
if (!config instanceof _ApplicationConfig["default"]) {
|
|
76
56
|
throw new Error("Config must be an instance of ApplicationConfig");
|
|
77
57
|
}
|
|
78
|
-
|
|
79
|
-
_this = _super.call(this, config);
|
|
58
|
+
_this = _callSuper(this, ApplicationClient, [config]);
|
|
80
59
|
_this.useLtpa = config.auth && config.auth.useLtpa;
|
|
81
|
-
|
|
82
60
|
if (config.auth && config.auth.useLtpa || config.getOrgId() != "quickstart") {
|
|
83
61
|
_this._apiClient = new _ApiClient["default"](_this.config);
|
|
84
62
|
_this.dsc = new _DscClient["default"](_this._apiClient);
|
|
@@ -88,110 +66,80 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
88
66
|
_this.rules = new _RulesClient["default"](_this._apiClient);
|
|
89
67
|
_this.state = new _StateClient["default"](_this._apiClient);
|
|
90
68
|
}
|
|
91
|
-
|
|
92
69
|
_this.log.debug("[ApplicationClient:constructor] ApplicationClient initialized for organization : " + config.getOrgId());
|
|
93
|
-
|
|
94
70
|
return _this;
|
|
95
71
|
}
|
|
96
|
-
|
|
97
72
|
_createClass(ApplicationClient, [{
|
|
98
73
|
key: "connect",
|
|
99
74
|
value: function connect() {
|
|
100
75
|
var _this2 = this;
|
|
101
|
-
|
|
102
76
|
_get(_getPrototypeOf(ApplicationClient.prototype), "connect", this).call(this);
|
|
103
|
-
|
|
104
77
|
this.mqtt.on('message', function (topic, payload) {
|
|
105
|
-
_this2.log.trace("[ApplicationClient:onMessage] mqtt: ", topic, payload.toString());
|
|
106
|
-
// If matches, forward the payload and various fields from the topic (extracted using groups in the regexp)
|
|
78
|
+
_this2.log.trace("[ApplicationClient:onMessage] mqtt: ", topic, payload.toString());
|
|
107
79
|
|
|
80
|
+
// For each type of registered callback, check the incoming topic against a Regexp.
|
|
81
|
+
// If matches, forward the payload and various fields from the topic (extracted using groups in the regexp)
|
|
108
82
|
|
|
109
83
|
var match = DEVICE_EVT_RE.exec(topic);
|
|
110
|
-
|
|
111
84
|
if (match) {
|
|
112
85
|
_this2.emit('deviceEvent', match[1], match[2], match[3], match[4], payload, topic);
|
|
113
|
-
|
|
114
86
|
return;
|
|
115
87
|
}
|
|
116
|
-
|
|
117
88
|
var match = DEVICE_CMD_RE.exec(topic);
|
|
118
|
-
|
|
119
89
|
if (match) {
|
|
120
90
|
_this2.emit('deviceCommand', match[1], match[2], match[3], match[4], payload, topic);
|
|
121
|
-
|
|
122
91
|
return;
|
|
123
92
|
}
|
|
124
|
-
|
|
125
93
|
var match = DEVICE_STATE_RE.exec(topic);
|
|
126
|
-
|
|
127
94
|
if (match) {
|
|
128
95
|
_this2.emit('deviceState', match[1], match[2], match[3], payload, topic);
|
|
129
|
-
|
|
130
96
|
return;
|
|
131
97
|
}
|
|
132
|
-
|
|
133
98
|
var match = DEVICE_STATE_ERROR_RE.exec(topic);
|
|
134
|
-
|
|
135
99
|
if (match) {
|
|
136
100
|
_this2.emit('deviceStateError', match[1], match[2], payload, topic);
|
|
137
|
-
|
|
138
101
|
return;
|
|
139
102
|
}
|
|
140
|
-
|
|
141
103
|
var match = RULE_TRIGGER_RE.exec(topic);
|
|
142
|
-
|
|
143
104
|
if (match) {
|
|
144
105
|
_this2.emit('ruleTrigger', match[1], match[2], payload, topic);
|
|
145
|
-
|
|
146
106
|
return;
|
|
147
107
|
}
|
|
148
|
-
|
|
149
108
|
var match = RULE_ERROR_RE.exec(topic);
|
|
150
|
-
|
|
151
109
|
if (match) {
|
|
152
110
|
_this2.emit('ruleError', match[1], match[2], payload, topic);
|
|
153
|
-
|
|
154
111
|
return;
|
|
155
112
|
}
|
|
156
|
-
|
|
157
113
|
var match = DEVICE_MON_RE.exec(topic);
|
|
158
|
-
|
|
159
114
|
if (match) {
|
|
160
115
|
_this2.emit('deviceStatus', match[1], match[2], payload, topic);
|
|
161
|
-
|
|
162
116
|
return;
|
|
163
117
|
}
|
|
164
|
-
|
|
165
118
|
var match = APP_MON_RE.exec(topic);
|
|
166
|
-
|
|
167
119
|
if (match) {
|
|
168
120
|
_this2.emit('appStatus', match[1], payload, topic);
|
|
169
|
-
|
|
170
121
|
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
122
|
+
}
|
|
173
123
|
|
|
124
|
+
// catch all which logs the receipt of an unexpected message
|
|
174
125
|
_this2.log.warn("[ApplicationClient:onMessage] Message received on unexpected topic" + ", " + topic + ", " + payload);
|
|
175
126
|
});
|
|
176
|
-
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ==========================================================================
|
|
177
130
|
// Device Events
|
|
178
131
|
// ==========================================================================
|
|
179
|
-
|
|
180
132
|
}, {
|
|
181
133
|
key: "publishEvent",
|
|
182
134
|
value: function publishEvent(typeId, deviceId, eventId, format, data, qos, callback) {
|
|
183
135
|
qos = qos || 0;
|
|
184
|
-
|
|
185
136
|
if (!(0, _util.isDefined)(typeId) || !(0, _util.isDefined)(deviceId) || !(0, _util.isDefined)(eventId) || !(0, _util.isDefined)(format)) {
|
|
186
137
|
this.log.error("[ApplicationClient:publishDeviceEvent] Required params for publishDeviceEvent not present");
|
|
187
138
|
this.emit('error', "[ApplicationClient:publishDeviceEvent] Required params for publishDeviceEvent not present");
|
|
188
139
|
return;
|
|
189
140
|
}
|
|
190
|
-
|
|
191
141
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/evt/" + eventId + "/fmt/" + format;
|
|
192
|
-
|
|
193
142
|
this._publish(topic, data, qos, callback);
|
|
194
|
-
|
|
195
143
|
return this;
|
|
196
144
|
}
|
|
197
145
|
}, {
|
|
@@ -203,9 +151,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
203
151
|
format = format || '+';
|
|
204
152
|
qos = qos || 0;
|
|
205
153
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/evt/" + eventId + "/fmt/" + format;
|
|
206
|
-
|
|
207
154
|
this._subscribe(topic, qos, callback);
|
|
208
|
-
|
|
209
155
|
return this;
|
|
210
156
|
}
|
|
211
157
|
}, {
|
|
@@ -216,29 +162,24 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
216
162
|
eventId = eventId || '+';
|
|
217
163
|
format = format || '+';
|
|
218
164
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/evt/" + eventId + "/fmt/" + format;
|
|
219
|
-
|
|
220
165
|
this._unsubscribe(topic, callback);
|
|
221
|
-
|
|
222
166
|
return this;
|
|
223
|
-
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ==========================================================================
|
|
224
170
|
// Device Commands
|
|
225
171
|
// ==========================================================================
|
|
226
|
-
|
|
227
172
|
}, {
|
|
228
173
|
key: "publishCommand",
|
|
229
174
|
value: function publishCommand(typeId, deviceId, commandId, format, data, qos, callback) {
|
|
230
175
|
qos = qos || 0;
|
|
231
|
-
|
|
232
176
|
if (!(0, _util.isDefined)(typeId) || !(0, _util.isDefined)(deviceId) || !(0, _util.isDefined)(commandId) || !(0, _util.isDefined)(format)) {
|
|
233
177
|
this.log.error("[ApplicationClient:publishDeviceCommand] Required params for publishDeviceCommand not present");
|
|
234
178
|
this.emit('error', "[ApplicationClient:publishDeviceCommand] Required params for publishDeviceCommand not present");
|
|
235
179
|
return;
|
|
236
180
|
}
|
|
237
|
-
|
|
238
181
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/cmd/" + commandId + "/fmt/" + format;
|
|
239
|
-
|
|
240
182
|
this._publish(topic, data, qos, callback);
|
|
241
|
-
|
|
242
183
|
return this;
|
|
243
184
|
}
|
|
244
185
|
}, {
|
|
@@ -251,9 +192,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
251
192
|
qos = qos || 0;
|
|
252
193
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/cmd/" + commandId + "/fmt/" + format;
|
|
253
194
|
this.log.debug("[ApplicationClient:subscribeToDeviceCommands] Calling subscribe with QoS " + qos);
|
|
254
|
-
|
|
255
195
|
this._subscribe(topic, qos, callback);
|
|
256
|
-
|
|
257
196
|
return this;
|
|
258
197
|
}
|
|
259
198
|
}, {
|
|
@@ -264,14 +203,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
264
203
|
commandId = commandId || '+';
|
|
265
204
|
format = format || '+';
|
|
266
205
|
var topic = "iot-2/type/" + typeId + "/id/" + deviceId + "/cmd/" + commandId + "/fmt/" + format;
|
|
267
|
-
|
|
268
206
|
this._unsubscribe(topic, callback);
|
|
269
|
-
|
|
270
207
|
return this;
|
|
271
|
-
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ==========================================================================
|
|
272
211
|
// Device State Events
|
|
273
212
|
// ==========================================================================
|
|
274
|
-
|
|
275
213
|
}, {
|
|
276
214
|
key: "subscribeToDeviceState",
|
|
277
215
|
value: function subscribeToDeviceState(type, id, interfaceId, qos) {
|
|
@@ -281,9 +219,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
281
219
|
qos = qos || 0;
|
|
282
220
|
var topic = "iot-2/type/" + type + "/id/" + id + "/intf/" + interfaceId + "/evt/state";
|
|
283
221
|
this.log.debug("[ApplicationClient:subscribeToDeviceState] Calling subscribe with QoS " + qos);
|
|
284
|
-
|
|
285
222
|
this._subscribe(topic, qos);
|
|
286
|
-
|
|
287
223
|
return this;
|
|
288
224
|
}
|
|
289
225
|
}, {
|
|
@@ -293,14 +229,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
293
229
|
id = id || '+';
|
|
294
230
|
interfaceId = interfaceId || '+';
|
|
295
231
|
var topic = "iot-2/type/" + type + "/id/" + id + "/intf/" + interfaceId + "/evt/state";
|
|
296
|
-
|
|
297
232
|
this._unsubscribe(topic);
|
|
298
|
-
|
|
299
233
|
return this;
|
|
300
|
-
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ==========================================================================
|
|
301
237
|
// Device State Errors
|
|
302
238
|
// ==========================================================================
|
|
303
|
-
|
|
304
239
|
}, {
|
|
305
240
|
key: "subscribeToDeviceErrors",
|
|
306
241
|
value: function subscribeToDeviceErrors(type, id, qos) {
|
|
@@ -309,9 +244,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
309
244
|
qos = qos || 0;
|
|
310
245
|
var topic = "iot-2/type/" + type + "/id/" + id + "/err/data";
|
|
311
246
|
this.log.debug("[ApplicationClient:subscribeToDeviceErrors] Calling subscribe with QoS " + qos);
|
|
312
|
-
|
|
313
247
|
this._subscribe(topic, qos);
|
|
314
|
-
|
|
315
248
|
return this;
|
|
316
249
|
}
|
|
317
250
|
}, {
|
|
@@ -320,14 +253,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
320
253
|
type = type || '+';
|
|
321
254
|
id = id || '+';
|
|
322
255
|
var topic = "iot-2/type/" + type + "/id/" + id + "/err/data";
|
|
323
|
-
|
|
324
256
|
this._unsubscribe(topic);
|
|
325
|
-
|
|
326
257
|
return this;
|
|
327
|
-
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ==========================================================================
|
|
328
261
|
// Rule Triggers
|
|
329
262
|
// ==========================================================================
|
|
330
|
-
|
|
331
263
|
}, {
|
|
332
264
|
key: "subscribeToRuleTriggers",
|
|
333
265
|
value: function subscribeToRuleTriggers(interfaceId, ruleId, qos) {
|
|
@@ -336,9 +268,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
336
268
|
qos = qos || 0;
|
|
337
269
|
var topic = "iot-2/intf/" + interfaceId + "/rule/" + ruleId + "/evt/trigger";
|
|
338
270
|
this.log.debug("[ApplicationClient:subscribeToRuleTriggers] Calling subscribe with QoS " + qos);
|
|
339
|
-
|
|
340
271
|
this._subscribe(topic, qos);
|
|
341
|
-
|
|
342
272
|
return this;
|
|
343
273
|
}
|
|
344
274
|
}, {
|
|
@@ -347,14 +277,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
347
277
|
interfaceId = interfaceId || '+';
|
|
348
278
|
ruleId = ruleId || '+';
|
|
349
279
|
var topic = "iot-2/intf/" + interfaceId + "/rule/" + ruleId + "/evt/trigger";
|
|
350
|
-
|
|
351
280
|
this._unsubscribe(topic);
|
|
352
|
-
|
|
353
281
|
return this;
|
|
354
|
-
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ==========================================================================
|
|
355
285
|
// Rule Trigger Errors
|
|
356
286
|
// ==========================================================================
|
|
357
|
-
|
|
358
287
|
}, {
|
|
359
288
|
key: "subscribeToRuleErrors",
|
|
360
289
|
value: function subscribeToRuleErrors(interfaceId, ruleId, qos) {
|
|
@@ -363,9 +292,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
363
292
|
qos = qos || 0;
|
|
364
293
|
var topic = "iot-2/intf/" + interfaceId + "/rule/" + ruleId + "/err/data";
|
|
365
294
|
this.log.debug("[ApplicationClient:subscribeToRuleErrors] Calling subscribe with QoS " + qos);
|
|
366
|
-
|
|
367
295
|
this._subscribe(topic, qos);
|
|
368
|
-
|
|
369
296
|
return this;
|
|
370
297
|
}
|
|
371
298
|
}, {
|
|
@@ -374,14 +301,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
374
301
|
interfaceId = interfaceId || '+';
|
|
375
302
|
ruleId = ruleId || '+';
|
|
376
303
|
var topic = "iot-2/intf/" + interfaceId + "/rule/" + ruleId + "/err/data";
|
|
377
|
-
|
|
378
304
|
this._unsubscribe(topic);
|
|
379
|
-
|
|
380
305
|
return this;
|
|
381
|
-
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ==========================================================================
|
|
382
309
|
// Device Status
|
|
383
310
|
// ==========================================================================
|
|
384
|
-
|
|
385
311
|
}, {
|
|
386
312
|
key: "subscribeToDeviceStatus",
|
|
387
313
|
value: function subscribeToDeviceStatus(type, id, qos) {
|
|
@@ -390,9 +316,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
390
316
|
qos = qos || 0;
|
|
391
317
|
var topic = "iot-2/type/" + type + "/id/" + id + "/mon";
|
|
392
318
|
this.log.debug("[ApplicationClient:subscribeToDeviceStatus] Calling subscribe with QoS " + qos);
|
|
393
|
-
|
|
394
319
|
this._subscribe(topic, qos);
|
|
395
|
-
|
|
396
320
|
return this;
|
|
397
321
|
}
|
|
398
322
|
}, {
|
|
@@ -401,14 +325,13 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
401
325
|
type = type || '+';
|
|
402
326
|
id = id || '+';
|
|
403
327
|
var topic = "iot-2/type/" + type + "/id/" + id + "/mon";
|
|
404
|
-
|
|
405
328
|
this._unsubscribe(topic);
|
|
406
|
-
|
|
407
329
|
return this;
|
|
408
|
-
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// ==========================================================================
|
|
409
333
|
// Application Status
|
|
410
334
|
// ==========================================================================
|
|
411
|
-
|
|
412
335
|
}, {
|
|
413
336
|
key: "subscribeToAppStatus",
|
|
414
337
|
value: function subscribeToAppStatus(id, qos) {
|
|
@@ -416,9 +339,7 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
416
339
|
qos = qos || 0;
|
|
417
340
|
var topic = "iot-2/app/" + id + "/mon";
|
|
418
341
|
this.log.debug("[ApplicationClient:subscribeToAppStatus] Calling subscribe with QoS " + qos);
|
|
419
|
-
|
|
420
342
|
this._subscribe(topic, qos);
|
|
421
|
-
|
|
422
343
|
return this;
|
|
423
344
|
}
|
|
424
345
|
}, {
|
|
@@ -426,15 +347,10 @@ var ApplicationClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
426
347
|
value: function unsubscribeToAppStatus(id) {
|
|
427
348
|
id = id || '+';
|
|
428
349
|
var topic = "iot-2/app/" + id + "/mon";
|
|
429
|
-
|
|
430
350
|
this._unsubscribe(topic);
|
|
431
|
-
|
|
432
351
|
return this;
|
|
433
352
|
}
|
|
434
353
|
}]);
|
|
435
|
-
|
|
436
354
|
return ApplicationClient;
|
|
437
355
|
}(_BaseClient2["default"]);
|
|
438
|
-
|
|
439
|
-
exports["default"] = ApplicationClient;
|
|
440
356
|
;
|