@robotical/webapp-types 3.18.13 → 3.19.1
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-types/src/application/ApplicationManager/ApplicationManager.d.ts +21 -10
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +297 -83
- package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +2 -0
- package/dist-types/src/application/RAFTs/Cog/Cog.js +3 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +7 -3
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.d.ts +6 -18
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.js +25 -274
- package/dist-types/src/application/RAFTs/RAFT.d.ts +8 -2
- package/dist-types/src/application/RAFTs/RAFT.js +23 -4
- package/dist-types/src/application/RAFTs/RaftWifiManager.d.ts +24 -0
- package/dist-types/src/application/RAFTs/RaftWifiManager.js +329 -0
- package/dist-types/src/application/communicators/WrapperCommunicator.js +7 -3
- package/dist-types/src/components/modals/VerificationModal/index.js +4 -1
- package/dist-types/src/components/modals/WifiConnectionModal/index.d.ts +6 -0
- package/dist-types/src/components/modals/WifiConnectionModal/index.js +41 -0
- package/dist-types/src/i18n.js +43 -3
- package/dist-types/src/store/ConnectionMethodPreference.d.ts +7 -0
- package/dist-types/src/store/ConnectionMethodPreference.js +44 -0
- package/dist-types/src/store/SelectedRaftContext.d.ts +3 -1
- package/dist-types/src/store/SelectedRaftContext.js +1 -1
- package/dist-types/src/types/raft.d.ts +23 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +2 -1
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +26 -22
- package/dist-types/src/utils/wifi-connection.d.ts +18 -0
- package/dist-types/src/utils/wifi-connection.js +97 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +3 -2
- package/dist-types/src/wrapper-app/WrapperAppManager.js +149 -45
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +1 -1
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.d.ts +1 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.js +15 -11
- package/package.json +1 -1
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private _maxSecsToWaitForWiFiConn;
|
|
8
|
-
private _wifiScanDuration;
|
|
9
|
-
constructor(marty: Marty);
|
|
10
|
-
_getHostnameFromFriendlyName(): string;
|
|
11
|
-
wifiConnect(ssid: string, password: string): Promise<boolean>;
|
|
12
|
-
wifiDisconnect(): Promise<boolean>;
|
|
13
|
-
getWiFiConnStatus(): Promise<boolean | null>;
|
|
14
|
-
pauseWifiConnection(pause: boolean): Promise<boolean>;
|
|
15
|
-
_wifiScanResults(): Promise<boolean | RaftOKFail | RaftWifiScanResults>;
|
|
16
|
-
_wifiScanStart(): Promise<boolean>;
|
|
17
|
-
getCachedWifiStatus(): RaftWifiConnStatus;
|
|
18
|
-
getWifiScanResults(): Promise<boolean | RaftOKFail | RaftWifiScanResults>;
|
|
1
|
+
import { RaftWifiManager } from "../RaftWifiManager";
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility alias for code that still imports the old Marty-specific
|
|
4
|
+
* manager. Wi-Fi provisioning now uses the common RAFT NetMan contract.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MartyWifiManager extends RaftWifiManager {
|
|
19
7
|
}
|
|
@@ -1,277 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { RaftWifiManager } from "../RaftWifiManager";
|
|
17
|
+
/**
|
|
18
|
+
* Compatibility alias for code that still imports the old Marty-specific
|
|
19
|
+
* manager. Wi-Fi provisioning now uses the common RAFT NetMan contract.
|
|
20
|
+
*/
|
|
21
|
+
var MartyWifiManager = /** @class */ (function (_super) {
|
|
22
|
+
__extends(MartyWifiManager, _super);
|
|
23
|
+
function MartyWifiManager() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
25
|
}
|
|
36
|
-
};
|
|
37
|
-
import { RaftWifiConnState, RaftWifiConnStatus } from "@robdobsn/raftjs";
|
|
38
|
-
import Logger from "../../../services/logger/Logger";
|
|
39
|
-
var SHOW_LOGS = true;
|
|
40
|
-
var TAG = "MartyWifiManager";
|
|
41
|
-
var MartyWifiManager = /** @class */ (function () {
|
|
42
|
-
function MartyWifiManager(marty) {
|
|
43
|
-
this.marty = marty;
|
|
44
|
-
this._wifiConnStatus = new RaftWifiConnStatus();
|
|
45
|
-
this._defaultWiFiHostname = "Raft";
|
|
46
|
-
this._maxSecsToWaitForWiFiConn = 20;
|
|
47
|
-
this._wifiScanDuration = 10000; // ms
|
|
48
|
-
this.marty = marty;
|
|
49
|
-
}
|
|
50
|
-
MartyWifiManager.prototype._getHostnameFromFriendlyName = function () {
|
|
51
|
-
var friendlyName = this.marty.getFriendlyName();
|
|
52
|
-
if (!friendlyName) {
|
|
53
|
-
return this._defaultWiFiHostname;
|
|
54
|
-
}
|
|
55
|
-
var hostname = friendlyName;
|
|
56
|
-
hostname = hostname === null || hostname === void 0 ? void 0 : hostname.replace(/ /g, "-");
|
|
57
|
-
hostname = hostname.replace(/\W+/g, "");
|
|
58
|
-
return hostname;
|
|
59
|
-
};
|
|
60
|
-
MartyWifiManager.prototype.wifiConnect = function (ssid, password) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var RaftRESTURL_wifiCredentials, error_1, timeoutCount, connStat;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils Connect to WiFi ".concat(ssid, " password ").concat(password));
|
|
67
|
-
_a.label = 1;
|
|
68
|
-
case 1:
|
|
69
|
-
_a.trys.push([1, 3, , 4]);
|
|
70
|
-
RaftRESTURL_wifiCredentials = "w/" +
|
|
71
|
-
ssid +
|
|
72
|
-
"/" +
|
|
73
|
-
password +
|
|
74
|
-
"/" +
|
|
75
|
-
this._getHostnameFromFriendlyName();
|
|
76
|
-
Logger.info(SHOW_LOGS, TAG, "wifiConnect attempting to connect to wifi ".concat(RaftRESTURL_wifiCredentials));
|
|
77
|
-
return [4 /*yield*/, this.marty.sendRestMessage(RaftRESTURL_wifiCredentials)];
|
|
78
|
-
case 2:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [3 /*break*/, 4];
|
|
81
|
-
case 3:
|
|
82
|
-
error_1 = _a.sent();
|
|
83
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiConnect failed ".concat(error_1));
|
|
84
|
-
return [2 /*return*/, false];
|
|
85
|
-
case 4:
|
|
86
|
-
timeoutCount = 0;
|
|
87
|
-
_a.label = 5;
|
|
88
|
-
case 5:
|
|
89
|
-
if (!(timeoutCount < this._maxSecsToWaitForWiFiConn)) return [3 /*break*/, 9];
|
|
90
|
-
// Wait a little before checking
|
|
91
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
|
|
92
|
-
case 6:
|
|
93
|
-
// Wait a little before checking
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [4 /*yield*/, this.getWiFiConnStatus()];
|
|
96
|
-
case 7:
|
|
97
|
-
connStat = _a.sent();
|
|
98
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiConnect connStat ".concat(connStat));
|
|
99
|
-
if (connStat) {
|
|
100
|
-
return [2 /*return*/, true];
|
|
101
|
-
}
|
|
102
|
-
_a.label = 8;
|
|
103
|
-
case 8:
|
|
104
|
-
timeoutCount++;
|
|
105
|
-
return [3 /*break*/, 5];
|
|
106
|
-
case 9: return [2 /*return*/, false];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
MartyWifiManager.prototype.wifiDisconnect = function () {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
-
var error_2;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0:
|
|
117
|
-
_a.trys.push([0, 4, , 5]);
|
|
118
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiDisconnect clearing wifi info");
|
|
119
|
-
return [4 /*yield*/, this.marty.sendRestMessage("wc")];
|
|
120
|
-
case 1:
|
|
121
|
-
_a.sent();
|
|
122
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
|
|
123
|
-
case 2:
|
|
124
|
-
_a.sent();
|
|
125
|
-
return [4 /*yield*/, this.getWiFiConnStatus()];
|
|
126
|
-
case 3:
|
|
127
|
-
_a.sent();
|
|
128
|
-
return [2 /*return*/, true];
|
|
129
|
-
case 4:
|
|
130
|
-
error_2 = _a.sent();
|
|
131
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiDisconnect clearing unsuccessful ".concat(error_2));
|
|
132
|
-
return [3 /*break*/, 5];
|
|
133
|
-
case 5: return [2 /*return*/, false];
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
MartyWifiManager.prototype.getWiFiConnStatus = function () {
|
|
139
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
var ricSysModInfoWiFi, error_3;
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
switch (_a.label) {
|
|
143
|
-
case 0:
|
|
144
|
-
_a.trys.push([0, 2, , 3]);
|
|
145
|
-
return [4 /*yield*/, this.marty.sendRestMessage("sysmodinfo/NetMan")];
|
|
146
|
-
case 1:
|
|
147
|
-
ricSysModInfoWiFi = _a.sent();
|
|
148
|
-
Logger.info(SHOW_LOGS, TAG, "wifiConnStatus rslt ".concat(ricSysModInfoWiFi.rslt, " isConn ").concat(ricSysModInfoWiFi.isConn, " paused ").concat(ricSysModInfoWiFi.isPaused));
|
|
149
|
-
// Check status indicates WiFi connected
|
|
150
|
-
if (ricSysModInfoWiFi.rslt === "ok") {
|
|
151
|
-
this._wifiConnStatus.connState =
|
|
152
|
-
ricSysModInfoWiFi.isConn !== 0
|
|
153
|
-
? RaftWifiConnState.WIFI_CONN_CONNECTED
|
|
154
|
-
: RaftWifiConnState.WIFI_CONN_NONE;
|
|
155
|
-
this._wifiConnStatus.isPaused = ricSysModInfoWiFi.isPaused !== 0;
|
|
156
|
-
this._wifiConnStatus.ipAddress = ricSysModInfoWiFi.IP;
|
|
157
|
-
this._wifiConnStatus.hostname = ricSysModInfoWiFi.Hostname;
|
|
158
|
-
this._wifiConnStatus.ssid = ricSysModInfoWiFi.SSID;
|
|
159
|
-
this._wifiConnStatus.bssid = ricSysModInfoWiFi.WiFiMAC;
|
|
160
|
-
this._wifiConnStatus.validMs = Date.now();
|
|
161
|
-
return [2 /*return*/, (ricSysModInfoWiFi.isConn !== 0 || ricSysModInfoWiFi.isPaused !== 0)];
|
|
162
|
-
}
|
|
163
|
-
return [3 /*break*/, 3];
|
|
164
|
-
case 2:
|
|
165
|
-
error_3 = _a.sent();
|
|
166
|
-
Logger.info(SHOW_LOGS, TAG, "[DEBUG]: wifiConnStatus sysmodinfo failed ".concat(error_3));
|
|
167
|
-
this._wifiConnStatus.validMs = 0;
|
|
168
|
-
return [3 /*break*/, 3];
|
|
169
|
-
case 3:
|
|
170
|
-
this._wifiConnStatus.connState = RaftWifiConnState.WIFI_CONN_NONE;
|
|
171
|
-
this._wifiConnStatus.isPaused = false;
|
|
172
|
-
return [2 /*return*/, null];
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
MartyWifiManager.prototype.pauseWifiConnection = function (pause) {
|
|
178
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
-
var error_4;
|
|
180
|
-
return __generator(this, function (_a) {
|
|
181
|
-
switch (_a.label) {
|
|
182
|
-
case 0:
|
|
183
|
-
_a.trys.push([0, 5, , 6]);
|
|
184
|
-
if (!pause) return [3 /*break*/, 2];
|
|
185
|
-
return [4 /*yield*/, this.marty.sendRestMessage("wifipause/pause")];
|
|
186
|
-
case 1:
|
|
187
|
-
_a.sent();
|
|
188
|
-
return [3 /*break*/, 4];
|
|
189
|
-
case 2: return [4 /*yield*/, this.marty.sendRestMessage("wifipause/resume")];
|
|
190
|
-
case 3:
|
|
191
|
-
_a.sent();
|
|
192
|
-
_a.label = 4;
|
|
193
|
-
case 4: return [2 /*return*/, true];
|
|
194
|
-
case 5:
|
|
195
|
-
error_4 = _a.sent();
|
|
196
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiConnect wifi pause ".concat(error_4));
|
|
197
|
-
return [2 /*return*/, false];
|
|
198
|
-
case 6: return [2 /*return*/];
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
};
|
|
203
|
-
MartyWifiManager.prototype._wifiScanResults = function () {
|
|
204
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
-
return __generator(this, function (_a) {
|
|
206
|
-
try {
|
|
207
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiScanResults");
|
|
208
|
-
return [2 /*return*/, this.marty.sendRestMessage("wifiscan/results")];
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiScanResults unsuccessful ".concat(error));
|
|
212
|
-
}
|
|
213
|
-
return [2 /*return*/, false];
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
MartyWifiManager.prototype._wifiScanStart = function () {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
-
var error_5;
|
|
220
|
-
return __generator(this, function (_a) {
|
|
221
|
-
switch (_a.label) {
|
|
222
|
-
case 0:
|
|
223
|
-
_a.trys.push([0, 2, , 3]);
|
|
224
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils _wifiScanStart");
|
|
225
|
-
return [4 /*yield*/, this.marty.sendRestMessage("wifiscan/start")];
|
|
226
|
-
case 1:
|
|
227
|
-
_a.sent();
|
|
228
|
-
return [2 /*return*/, true];
|
|
229
|
-
case 2:
|
|
230
|
-
error_5 = _a.sent();
|
|
231
|
-
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils _wifiScanStart unsuccessful ".concat(error_5));
|
|
232
|
-
return [3 /*break*/, 3];
|
|
233
|
-
case 3: return [2 /*return*/, false];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
MartyWifiManager.prototype.getCachedWifiStatus = function () {
|
|
239
|
-
return this._wifiConnStatus;
|
|
240
|
-
};
|
|
241
|
-
MartyWifiManager.prototype.getWifiScanResults = function () {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
-
var resultsTimeout, results;
|
|
244
|
-
var _this = this;
|
|
245
|
-
return __generator(this, function (_a) {
|
|
246
|
-
switch (_a.label) {
|
|
247
|
-
case 0: return [4 /*yield*/, this._wifiScanStart()];
|
|
248
|
-
case 1:
|
|
249
|
-
_a.sent();
|
|
250
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
251
|
-
return (resultsTimeout = setTimeout(function () {
|
|
252
|
-
_this._wifiScanResults()
|
|
253
|
-
.then(function (wifiscanMsgResults) {
|
|
254
|
-
if (typeof wifiscanMsgResults !== "boolean") {
|
|
255
|
-
resolve(wifiscanMsgResults);
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
reject("Something went wrong");
|
|
259
|
-
}
|
|
260
|
-
})
|
|
261
|
-
.catch(function (err) { return reject(err); })
|
|
262
|
-
.finally(function () { return clearTimeout(resultsTimeout); });
|
|
263
|
-
}, _this._wifiScanDuration));
|
|
264
|
-
})];
|
|
265
|
-
case 2:
|
|
266
|
-
results = _a.sent();
|
|
267
|
-
if (results.hasOwnProperty("wifi")) {
|
|
268
|
-
return [2 /*return*/, results];
|
|
269
|
-
}
|
|
270
|
-
return [2 /*return*/, false];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
26
|
return MartyWifiManager;
|
|
276
|
-
}());
|
|
27
|
+
}(RaftWifiManager));
|
|
277
28
|
export { MartyWifiManager };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RestMessageOptions } from "../../types/communication-between-apps/wrapper-communication";
|
|
2
|
-
import { ConnectionAttemptResults, RaftConnectionMethod, RaftTypeE } from "../../types/raft";
|
|
2
|
+
import { ConnectableRaftType, ConnectionAttemptResults, RaftConnectionMethod, RaftTypeE } from "../../types/raft";
|
|
3
3
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
4
4
|
import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
|
|
5
5
|
import RICInterface from "./RAFTInterface";
|
|
@@ -18,6 +18,12 @@ export default class RAFT implements RICInterface {
|
|
|
18
18
|
systemInfo: RaftSystemInfo | null;
|
|
19
19
|
raftStateInfo: RICStateInfo | SimplifiedCogStateInfo | null;
|
|
20
20
|
isVerified: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Transport metadata belongs to the host RAFT entity so every embedded
|
|
23
|
+
* platform sees the same connection, regardless of how it was established.
|
|
24
|
+
*/
|
|
25
|
+
connectionMethod: RaftConnectionMethod | null;
|
|
26
|
+
connectionLocator: string;
|
|
21
27
|
private _verificationDecision;
|
|
22
28
|
hasVerifiedConnection(): boolean;
|
|
23
29
|
/**
|
|
@@ -34,7 +40,7 @@ export default class RAFT implements RICInterface {
|
|
|
34
40
|
* Connect to a RAFT
|
|
35
41
|
* We first connect, then we discover the raft type, and then we create the appopriate raft instance
|
|
36
42
|
*/
|
|
37
|
-
static connect(method: RaftConnectionMethod, uuids: string[]): Promise<ConnectionAttemptResults>;
|
|
43
|
+
static connect(method: RaftConnectionMethod, uuids: string[], locator?: string, expectedRaftType?: ConnectableRaftType): Promise<ConnectionAttemptResults>;
|
|
38
44
|
/**
|
|
39
45
|
* Disconnect from a RAFT
|
|
40
46
|
*/
|
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { AppSentMessage } from "../../types/communication-between-apps/wrapper-communication";
|
|
38
|
-
import { RaftTypeE } from "../../types/raft";
|
|
38
|
+
import { RaftTypeE, } from "../../types/raft";
|
|
39
39
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
40
40
|
import { RaftConnEvent, RaftPublishEvent, } from "@robdobsn/raftjs";
|
|
41
41
|
import Logger from "../../services/logger/Logger";
|
|
@@ -58,6 +58,12 @@ var RAFT = /** @class */ (function () {
|
|
|
58
58
|
// RAFT State Info
|
|
59
59
|
this.raftStateInfo = null;
|
|
60
60
|
this.isVerified = false;
|
|
61
|
+
/**
|
|
62
|
+
* Transport metadata belongs to the host RAFT entity so every embedded
|
|
63
|
+
* platform sees the same connection, regardless of how it was established.
|
|
64
|
+
*/
|
|
65
|
+
this.connectionMethod = null;
|
|
66
|
+
this.connectionLocator = "";
|
|
61
67
|
this._verificationDecision = null;
|
|
62
68
|
}
|
|
63
69
|
RAFT.prototype.hasVerifiedConnection = function () {
|
|
@@ -95,14 +101,27 @@ var RAFT = /** @class */ (function () {
|
|
|
95
101
|
* Connect to a RAFT
|
|
96
102
|
* We first connect, then we discover the raft type, and then we create the appopriate raft instance
|
|
97
103
|
*/
|
|
98
|
-
RAFT.connect = function (method, uuids) {
|
|
104
|
+
RAFT.connect = function (method, uuids, locator, expectedRaftType) {
|
|
105
|
+
if (locator === void 0) { locator = ""; }
|
|
99
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
var connectResults;
|
|
107
|
+
var request, connectResults;
|
|
101
108
|
return __generator(this, function (_a) {
|
|
102
109
|
switch (_a.label) {
|
|
103
|
-
case 0:
|
|
110
|
+
case 0:
|
|
111
|
+
request = {
|
|
112
|
+
method: method,
|
|
113
|
+
locator: locator,
|
|
114
|
+
uuids: uuids,
|
|
115
|
+
expectedRaftType: expectedRaftType,
|
|
116
|
+
};
|
|
117
|
+
return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_CONNECT, request)];
|
|
104
118
|
case 1:
|
|
105
119
|
connectResults = _a.sent();
|
|
120
|
+
if (!connectResults ||
|
|
121
|
+
typeof connectResults !== "object" ||
|
|
122
|
+
typeof connectResults.success !== "boolean") {
|
|
123
|
+
throw new Error("The connection bridge did not return a valid result.");
|
|
124
|
+
}
|
|
106
125
|
return [2 /*return*/, connectResults];
|
|
107
126
|
}
|
|
108
127
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RaftOKFail, RaftWifiConnStatus, RaftWifiScanResults } from "@robdobsn/raftjs";
|
|
2
|
+
import RAFT from "./RAFT";
|
|
3
|
+
/**
|
|
4
|
+
* Wi-Fi provisioning is implemented by the common RAFT NetMan endpoints, so
|
|
5
|
+
* it is shared by Marty and Cog. The manager deliberately owns no transport:
|
|
6
|
+
* commands continue over the RAFT's current BLE or WebSocket connection.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RaftWifiManager {
|
|
9
|
+
raft: RAFT;
|
|
10
|
+
private readonly _defaultWiFiHostname;
|
|
11
|
+
private _wifiConnStatus;
|
|
12
|
+
private readonly _maxSecsToWaitForWiFiConn;
|
|
13
|
+
private readonly _wifiScanDuration;
|
|
14
|
+
constructor(raft: RAFT, _defaultWiFiHostname?: string);
|
|
15
|
+
private _getHostnameFromFriendlyName;
|
|
16
|
+
wifiConnect(ssid: string, password: string): Promise<boolean>;
|
|
17
|
+
wifiDisconnect(): Promise<boolean>;
|
|
18
|
+
getWiFiConnStatus(): Promise<boolean | null>;
|
|
19
|
+
pauseWifiConnection(pause: boolean): Promise<boolean>;
|
|
20
|
+
private _wifiScanResults;
|
|
21
|
+
private _wifiScanStart;
|
|
22
|
+
getCachedWifiStatus(): RaftWifiConnStatus;
|
|
23
|
+
getWifiScanResults(): Promise<RaftOKFail | RaftWifiScanResults | false>;
|
|
24
|
+
}
|