@robotical/webapp-types 3.7.8 → 3.7.9
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 +24 -1
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +222 -0
- package/dist-types/src/application/RAFTs/Marty/CalibrationManager.d.ts +11 -0
- package/dist-types/src/application/RAFTs/Marty/CalibrationManager.js +153 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +6 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +9 -0
- package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.d.ts +13 -0
- package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.js +253 -0
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.d.ts +19 -0
- package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.js +272 -0
- package/dist-types/src/application/RAFTs/RAFT.d.ts +1 -0
- package/dist-types/src/application/RAFTs/RAFT.js +46 -2
- package/dist-types/src/components/modals/LEDLightsOrQRVerificationModal/index.js +1 -1
- package/dist-types/src/store/SelectedRaftContext.d.ts +2 -0
- package/dist-types/src/store/SelectedRaftContext.js +10 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +3 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +2 -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 -28
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +16 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.js +47 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +36 -13
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.d.ts +19 -0
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.js +461 -0
- package/package.json +1 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
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 };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RICConfiguredAddOns, RICHWElemList_Str } from "@robotical/roboticaljs";
|
|
38
|
+
import Logger from "../../../services/logger/Logger";
|
|
39
|
+
import { RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR } from "@robotical/ricjs-robotical-addons/dist/RICRoboticalAddOns";
|
|
40
|
+
var SHOW_LOGS = true;
|
|
41
|
+
var TAG = "MartyAddonsManager";
|
|
42
|
+
var MartyAddonsManager = /** @class */ (function () {
|
|
43
|
+
function MartyAddonsManager(marty) {
|
|
44
|
+
this.marty = marty;
|
|
45
|
+
this._connectedAddOns = new Array();
|
|
46
|
+
this.marty = marty;
|
|
47
|
+
}
|
|
48
|
+
MartyAddonsManager.prototype.getHWElemList = function (filterByType) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var reqList, fullListOfElems, _i, reqList_1, reqType, hwElemList_Str, hwElems, hwElemList, error_1;
|
|
51
|
+
var _a;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
switch (_b.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
reqList = [];
|
|
56
|
+
if (!filterByType) {
|
|
57
|
+
reqList.push("SmartServo");
|
|
58
|
+
reqList.push("RSAddOn");
|
|
59
|
+
reqList.push("BusPixels");
|
|
60
|
+
reqList.push("!SmartServo,RSAddOn,BusPixels"); // not SmartServo or RSAddOn or BusPixels
|
|
61
|
+
}
|
|
62
|
+
else if (filterByType === "RSAddOn") {
|
|
63
|
+
// we treat BusPixels as an RSAddOn
|
|
64
|
+
// (batch 4 led eye add-ons have type BusPixels)
|
|
65
|
+
reqList.push("RSAddOn");
|
|
66
|
+
reqList.push("BusPixels");
|
|
67
|
+
this._connectedAddOns = new Array();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
reqList.push(filterByType);
|
|
71
|
+
}
|
|
72
|
+
fullListOfElems = new Array();
|
|
73
|
+
this._connectedAddOns = [];
|
|
74
|
+
_i = 0, reqList_1 = reqList;
|
|
75
|
+
_b.label = 1;
|
|
76
|
+
case 1:
|
|
77
|
+
if (!(_i < reqList_1.length)) return [3 /*break*/, 9];
|
|
78
|
+
reqType = reqList_1[_i];
|
|
79
|
+
_b.label = 2;
|
|
80
|
+
case 2:
|
|
81
|
+
_b.trys.push([2, 7, , 8]);
|
|
82
|
+
return [4 /*yield*/, this.marty.sendRestMessage("hwstatus/strstat?filterByType=".concat(reqType))];
|
|
83
|
+
case 3:
|
|
84
|
+
hwElemList_Str = _b.sent();
|
|
85
|
+
hwElems = hwElemList_Str.hw;
|
|
86
|
+
hwElemList = void 0;
|
|
87
|
+
if (!hwElems.length) return [3 /*break*/, 6];
|
|
88
|
+
if (!(typeof hwElems[0] !== "object")) return [3 /*break*/, 5];
|
|
89
|
+
return [4 /*yield*/, this.marty.sendRestMessage("hwstatus?filterByType=".concat(reqType))];
|
|
90
|
+
case 4:
|
|
91
|
+
// we are on an older version
|
|
92
|
+
hwElemList = (_b.sent());
|
|
93
|
+
return [3 /*break*/, 6];
|
|
94
|
+
case 5:
|
|
95
|
+
// we are on the fw version that supports strstat
|
|
96
|
+
hwElemList = RICHWElemList_Str.expand(hwElemList_Str);
|
|
97
|
+
_b.label = 6;
|
|
98
|
+
case 6:
|
|
99
|
+
if (hwElemList && hwElemList.rslt && hwElemList.rslt === "ok") {
|
|
100
|
+
fullListOfElems.push.apply(fullListOfElems, hwElemList.hw);
|
|
101
|
+
if (reqType === "RSAddOn") {
|
|
102
|
+
this._connectedAddOns = hwElemList.hw;
|
|
103
|
+
Logger.info(SHOW_LOGS, TAG, "getHWElemList: found ".concat(hwElemList.hw.length, " addons/buspixels"));
|
|
104
|
+
}
|
|
105
|
+
else if (reqType === "BusPixels") {
|
|
106
|
+
// BusPixels are treated as an RSAddOn
|
|
107
|
+
(_a = this._connectedAddOns).push.apply(_a, hwElemList.hw);
|
|
108
|
+
Logger.info(SHOW_LOGS, TAG, "getHWElemList: found ".concat(hwElemList.hw.length, " addons/buspixels"));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return [3 /*break*/, 8];
|
|
112
|
+
case 7:
|
|
113
|
+
error_1 = _b.sent();
|
|
114
|
+
Logger.info(SHOW_LOGS, TAG, "getHWElemList failed to get ".concat(reqType, " ").concat(error_1));
|
|
115
|
+
return [2 /*return*/, new Array()];
|
|
116
|
+
case 8:
|
|
117
|
+
_i++;
|
|
118
|
+
return [3 /*break*/, 1];
|
|
119
|
+
case 9:
|
|
120
|
+
// return the full list of elements
|
|
121
|
+
return [2 /*return*/, fullListOfElems];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
MartyAddonsManager.prototype.getAddOnConfigs = function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var addOnList, error_2;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
_a.trys.push([0, 2, , 3]);
|
|
133
|
+
return [4 /*yield*/, this.marty.sendRestMessage("addon/list")];
|
|
134
|
+
case 1:
|
|
135
|
+
addOnList = _a.sent();
|
|
136
|
+
Logger.info(SHOW_LOGS, TAG, "getAddOnConfigs returned " + JSON.stringify(addOnList));
|
|
137
|
+
return [2 /*return*/, addOnList];
|
|
138
|
+
case 2:
|
|
139
|
+
error_2 = _a.sent();
|
|
140
|
+
Logger.error(SHOW_LOGS, TAG, "getAddOnConfigs Failed to get list of add-ons ".concat(error_2));
|
|
141
|
+
return [2 /*return*/, new RICConfiguredAddOns()];
|
|
142
|
+
case 3: return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
MartyAddonsManager.prototype.identifyAddOn = function (name) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var error_3;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
_a.trys.push([0, 2, , 3]);
|
|
154
|
+
return [4 /*yield*/, this.marty.sendRestMessage("elem/".concat(name, "/json?cmd=raw&hexWr=F8"))];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
return [2 /*return*/, true];
|
|
158
|
+
case 2:
|
|
159
|
+
error_3 = _a.sent();
|
|
160
|
+
Logger.warn(SHOW_LOGS, TAG, "identifyAddOn error ".concat(error_3));
|
|
161
|
+
return [3 /*break*/, 3];
|
|
162
|
+
case 3: return [2 /*return*/, false];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
MartyAddonsManager.prototype.setAddOnConfig = function (serialNo, newName) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
+
var error_4;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
_a.trys.push([0, 2, , 3]);
|
|
174
|
+
return [4 /*yield*/, this.marty.sendRestMessage("addon/set?SN=".concat(serialNo, "&name=").concat(newName))];
|
|
175
|
+
case 1:
|
|
176
|
+
_a.sent();
|
|
177
|
+
return [2 /*return*/, true];
|
|
178
|
+
case 2:
|
|
179
|
+
error_4 = _a.sent();
|
|
180
|
+
Logger.warn(SHOW_LOGS, TAG, "setAddOnConfig error ".concat(error_4));
|
|
181
|
+
return [3 /*break*/, 3];
|
|
182
|
+
case 3: return [2 /*return*/, false];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
MartyAddonsManager.prototype.deleteAddOn = function (serialNo) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var error_5;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
_a.trys.push([0, 2, , 3]);
|
|
194
|
+
return [4 /*yield*/, this.marty.sendRestMessage("addon/del?SN=".concat(serialNo))];
|
|
195
|
+
case 1:
|
|
196
|
+
_a.sent();
|
|
197
|
+
return [2 /*return*/, true];
|
|
198
|
+
case 2:
|
|
199
|
+
error_5 = _a.sent();
|
|
200
|
+
Logger.warn(SHOW_LOGS, TAG, "deleteAddOn error ".concat(error_5));
|
|
201
|
+
return [3 /*break*/, 3];
|
|
202
|
+
case 3: return [2 /*return*/, false];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
MartyAddonsManager.prototype.getConnectedColourSensors = function () {
|
|
208
|
+
var _a;
|
|
209
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
210
|
+
var names, hwElemList_Str, hwElems, hwElemList, _i, _b, hwElem, e_1;
|
|
211
|
+
return __generator(this, function (_c) {
|
|
212
|
+
switch (_c.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
names = [];
|
|
215
|
+
_c.label = 1;
|
|
216
|
+
case 1:
|
|
217
|
+
_c.trys.push([1, 6, , 7]);
|
|
218
|
+
return [4 /*yield*/, this.marty.sendRestMessage("hwstatus/strstat/?filterByType=".concat(RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR))];
|
|
219
|
+
case 2:
|
|
220
|
+
hwElemList_Str = _c.sent();
|
|
221
|
+
hwElems = hwElemList_Str.hw;
|
|
222
|
+
hwElemList = void 0;
|
|
223
|
+
if (!hwElems.length) return [3 /*break*/, 5];
|
|
224
|
+
if (!(typeof hwElems[0] !== "object")) return [3 /*break*/, 4];
|
|
225
|
+
return [4 /*yield*/, this.marty.sendRestMessage("hwstatus?filterByType=".concat(RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR))];
|
|
226
|
+
case 3:
|
|
227
|
+
// we are on a fw version that doesn't supports strstat
|
|
228
|
+
hwElemList = (_c.sent());
|
|
229
|
+
return [3 /*break*/, 5];
|
|
230
|
+
case 4:
|
|
231
|
+
// we are on the fw version that supports strstat
|
|
232
|
+
hwElemList = RICHWElemList_Str.expand(hwElemList_Str);
|
|
233
|
+
_c.label = 5;
|
|
234
|
+
case 5:
|
|
235
|
+
if ((hwElemList === null || hwElemList === void 0 ? void 0 : hwElemList.rslt) === "ok" && ((_a = hwElemList.hw) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
236
|
+
for (_i = 0, _b = hwElemList.hw; _i < _b.length; _i++) {
|
|
237
|
+
hwElem = _b[_i];
|
|
238
|
+
names.push(hwElem.name);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return [2 /*return*/, names];
|
|
242
|
+
case 6:
|
|
243
|
+
e_1 = _c.sent();
|
|
244
|
+
new Error("Error getting colour sensor names: " + JSON.stringify(e_1));
|
|
245
|
+
return [2 /*return*/, []];
|
|
246
|
+
case 7: return [2 /*return*/];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
return MartyAddonsManager;
|
|
252
|
+
}());
|
|
253
|
+
export default MartyAddonsManager;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RaftOKFail, RaftWifiConnStatus, RaftWifiScanResults } from "@robotical/raftjs";
|
|
2
|
+
import Marty from "./Marty";
|
|
3
|
+
export declare class MartyWifiManager {
|
|
4
|
+
marty: Marty;
|
|
5
|
+
private _wifiConnStatus;
|
|
6
|
+
private _defaultWiFiHostname;
|
|
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>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
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 };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RaftWifiConnState, RaftWifiConnStatus } from "@robotical/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, 2, , 3]);
|
|
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
|
+
this.getWiFiConnStatus();
|
|
123
|
+
return [2 /*return*/, true];
|
|
124
|
+
case 2:
|
|
125
|
+
error_2 = _a.sent();
|
|
126
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiDisconnect clearing unsuccessful ".concat(error_2));
|
|
127
|
+
return [3 /*break*/, 3];
|
|
128
|
+
case 3: return [2 /*return*/, false];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
MartyWifiManager.prototype.getWiFiConnStatus = function () {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
+
var ricSysModInfoWiFi, error_3;
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0:
|
|
139
|
+
_a.trys.push([0, 2, , 3]);
|
|
140
|
+
return [4 /*yield*/, this.marty.sendRestMessage("sysmodinfo/NetMan")];
|
|
141
|
+
case 1:
|
|
142
|
+
ricSysModInfoWiFi = _a.sent();
|
|
143
|
+
Logger.info(SHOW_LOGS, TAG, "wifiConnStatus rslt ".concat(ricSysModInfoWiFi.rslt, " isConn ").concat(ricSysModInfoWiFi.isConn, " paused ").concat(ricSysModInfoWiFi.isPaused));
|
|
144
|
+
// Check status indicates WiFi connected
|
|
145
|
+
if (ricSysModInfoWiFi.rslt === "ok") {
|
|
146
|
+
this._wifiConnStatus.connState =
|
|
147
|
+
ricSysModInfoWiFi.isConn !== 0
|
|
148
|
+
? RaftWifiConnState.WIFI_CONN_CONNECTED
|
|
149
|
+
: RaftWifiConnState.WIFI_CONN_NONE;
|
|
150
|
+
this._wifiConnStatus.isPaused = ricSysModInfoWiFi.isPaused !== 0;
|
|
151
|
+
this._wifiConnStatus.ipAddress = ricSysModInfoWiFi.IP;
|
|
152
|
+
this._wifiConnStatus.hostname = ricSysModInfoWiFi.Hostname;
|
|
153
|
+
this._wifiConnStatus.ssid = ricSysModInfoWiFi.SSID;
|
|
154
|
+
this._wifiConnStatus.bssid = ricSysModInfoWiFi.WiFiMAC;
|
|
155
|
+
this._wifiConnStatus.validMs = Date.now();
|
|
156
|
+
return [2 /*return*/, (ricSysModInfoWiFi.isConn !== 0 || ricSysModInfoWiFi.isPaused !== 0)];
|
|
157
|
+
}
|
|
158
|
+
return [3 /*break*/, 3];
|
|
159
|
+
case 2:
|
|
160
|
+
error_3 = _a.sent();
|
|
161
|
+
Logger.info(SHOW_LOGS, TAG, "[DEBUG]: wifiConnStatus sysmodinfo failed ".concat(error_3));
|
|
162
|
+
this._wifiConnStatus.validMs = 0;
|
|
163
|
+
return [3 /*break*/, 3];
|
|
164
|
+
case 3:
|
|
165
|
+
this._wifiConnStatus.connState = RaftWifiConnState.WIFI_CONN_NONE;
|
|
166
|
+
this._wifiConnStatus.isPaused = false;
|
|
167
|
+
return [2 /*return*/, null];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
MartyWifiManager.prototype.pauseWifiConnection = function (pause) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var error_4;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
_a.trys.push([0, 5, , 6]);
|
|
179
|
+
if (!pause) return [3 /*break*/, 2];
|
|
180
|
+
return [4 /*yield*/, this.marty.sendRestMessage("wifipause/pause")];
|
|
181
|
+
case 1:
|
|
182
|
+
_a.sent();
|
|
183
|
+
return [3 /*break*/, 4];
|
|
184
|
+
case 2: return [4 /*yield*/, this.marty.sendRestMessage("wifipause/resume")];
|
|
185
|
+
case 3:
|
|
186
|
+
_a.sent();
|
|
187
|
+
_a.label = 4;
|
|
188
|
+
case 4: return [2 /*return*/, true];
|
|
189
|
+
case 5:
|
|
190
|
+
error_4 = _a.sent();
|
|
191
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiConnect wifi pause ".concat(error_4));
|
|
192
|
+
return [2 /*return*/, false];
|
|
193
|
+
case 6: return [2 /*return*/];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
MartyWifiManager.prototype._wifiScanResults = function () {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
try {
|
|
202
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiScanResults");
|
|
203
|
+
return [2 /*return*/, this.marty.sendRestMessage("wifiscan/results")];
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils wifiScanResults unsuccessful ".concat(error));
|
|
207
|
+
}
|
|
208
|
+
return [2 /*return*/, false];
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
MartyWifiManager.prototype._wifiScanStart = function () {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
var error_5;
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0:
|
|
218
|
+
_a.trys.push([0, 2, , 3]);
|
|
219
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils _wifiScanStart");
|
|
220
|
+
return [4 /*yield*/, this.marty.sendRestMessage("wifiscan/start")];
|
|
221
|
+
case 1:
|
|
222
|
+
_a.sent();
|
|
223
|
+
return [2 /*return*/, true];
|
|
224
|
+
case 2:
|
|
225
|
+
error_5 = _a.sent();
|
|
226
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils _wifiScanStart unsuccessful ".concat(error_5));
|
|
227
|
+
return [3 /*break*/, 3];
|
|
228
|
+
case 3: return [2 /*return*/, false];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
MartyWifiManager.prototype.getCachedWifiStatus = function () {
|
|
234
|
+
return this._wifiConnStatus;
|
|
235
|
+
};
|
|
236
|
+
MartyWifiManager.prototype.getWifiScanResults = function () {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
+
var resultsTimeout, results;
|
|
239
|
+
var _this = this;
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0: return [4 /*yield*/, this._wifiScanStart()];
|
|
243
|
+
case 1:
|
|
244
|
+
_a.sent();
|
|
245
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
246
|
+
return (resultsTimeout = setTimeout(function () {
|
|
247
|
+
_this._wifiScanResults()
|
|
248
|
+
.then(function (wifiscanMsgResults) {
|
|
249
|
+
if (typeof wifiscanMsgResults !== "boolean") {
|
|
250
|
+
resolve(wifiscanMsgResults);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
reject("Something went wrong");
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
.catch(function (err) { return reject(err); })
|
|
257
|
+
.finally(function () { return clearTimeout(resultsTimeout); });
|
|
258
|
+
}, _this._wifiScanDuration));
|
|
259
|
+
})];
|
|
260
|
+
case 2:
|
|
261
|
+
results = _a.sent();
|
|
262
|
+
if (results.hasOwnProperty("wifi")) {
|
|
263
|
+
return [2 /*return*/, results];
|
|
264
|
+
}
|
|
265
|
+
return [2 /*return*/, false];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
return MartyWifiManager;
|
|
271
|
+
}());
|
|
272
|
+
export { MartyWifiManager };
|
|
@@ -38,6 +38,9 @@ import { AppSentMessage } from "../../types/communication-between-apps/wrapper-c
|
|
|
38
38
|
import { RaftTypeE } from "../../types/raft";
|
|
39
39
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
40
40
|
import { RaftConnEvent, RaftPublishEvent, } from "@robotical/raftjs";
|
|
41
|
+
import Logger from "../../services/logger/Logger";
|
|
42
|
+
var SHOW_LOGS = true;
|
|
43
|
+
var TAG = "RAFT";
|
|
41
44
|
var RAFT = /** @class */ (function () {
|
|
42
45
|
function RAFT(id) {
|
|
43
46
|
this.id = id;
|
|
@@ -112,11 +115,17 @@ var RAFT = /** @class */ (function () {
|
|
|
112
115
|
*/
|
|
113
116
|
RAFT.prototype.getRaftName = function () {
|
|
114
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
-
var raftName;
|
|
118
|
+
var vResponse, raftName;
|
|
116
119
|
return __generator(this, function (_a) {
|
|
117
120
|
switch (_a.label) {
|
|
118
|
-
case 0: return [4 /*yield*/,
|
|
121
|
+
case 0: return [4 /*yield*/, this.sendRestMessage('friendlyname')];
|
|
119
122
|
case 1:
|
|
123
|
+
vResponse = _a.sent();
|
|
124
|
+
if (vResponse && vResponse.rslt && vResponse.rslt.toLowerCase() === "ok") {
|
|
125
|
+
return [2 /*return*/, vResponse.friendlyName];
|
|
126
|
+
}
|
|
127
|
+
return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_GET_NAME, { raftId: this.id })];
|
|
128
|
+
case 2:
|
|
120
129
|
raftName = _a.sent();
|
|
121
130
|
return [2 /*return*/, raftName];
|
|
122
131
|
}
|
|
@@ -249,6 +258,41 @@ var RAFT = /** @class */ (function () {
|
|
|
249
258
|
var _a;
|
|
250
259
|
return (_a = this.systemInfo) === null || _a === void 0 ? void 0 : _a.Friendly;
|
|
251
260
|
};
|
|
261
|
+
RAFT.prototype.setRaftName = function (newName) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
var friendlyName, error_1;
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
switch (_a.label) {
|
|
266
|
+
case 0:
|
|
267
|
+
friendlyName = null;
|
|
268
|
+
_a.label = 1;
|
|
269
|
+
case 1:
|
|
270
|
+
_a.trys.push([1, 3, , 4]);
|
|
271
|
+
return [4 /*yield*/, this.sendRestMessage("friendlyname/".concat(newName))];
|
|
272
|
+
case 2:
|
|
273
|
+
friendlyName = (_a.sent());
|
|
274
|
+
if (friendlyName) {
|
|
275
|
+
friendlyName.friendlyNameIsSet = false;
|
|
276
|
+
friendlyName.validMs = Date.now();
|
|
277
|
+
if (friendlyName &&
|
|
278
|
+
friendlyName.rslt &&
|
|
279
|
+
friendlyName.rslt.toLowerCase() === "ok") {
|
|
280
|
+
friendlyName.friendlyNameIsSet = true;
|
|
281
|
+
}
|
|
282
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils setRaftName returned " + JSON.stringify(friendlyName));
|
|
283
|
+
return [2 /*return*/, true];
|
|
284
|
+
}
|
|
285
|
+
return [2 /*return*/, false];
|
|
286
|
+
case 3:
|
|
287
|
+
error_1 = _a.sent();
|
|
288
|
+
Logger.info(SHOW_LOGS, TAG, "RaftSystemUtils setRaftName Failed to set name ".concat(error_1));
|
|
289
|
+
friendlyName = null;
|
|
290
|
+
return [2 /*return*/, false];
|
|
291
|
+
case 4: return [2 /*return*/];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
};
|
|
252
296
|
/**
|
|
253
297
|
* Stream audio to the RAFT
|
|
254
298
|
*/
|
|
@@ -70,7 +70,7 @@ var options = [
|
|
|
70
70
|
];
|
|
71
71
|
export default function LEDLightsOrQRVerificationModal() {
|
|
72
72
|
var _this = this;
|
|
73
|
-
var _a = useState(
|
|
73
|
+
var _a = useState(true), qrSelected = _a[0], setQRSelected = _a[1];
|
|
74
74
|
var _b = useState(undefined), serialNoFromQR = _b[0], setSerialNoFromQR = _b[1];
|
|
75
75
|
var _c = useState(false), isButtonToConnectVisible = _c[0], setIsButtonToConnectVisible = _c[1];
|
|
76
76
|
useEffect(function () {
|
|
@@ -12,8 +12,10 @@ export declare const ConnectedRaftContentProvider: ({ children }: {
|
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare const useConnectedRafts: () => {
|
|
15
|
+
nameUpdatedState: number;
|
|
15
16
|
connectedRafts: ConnectedRaftItem[];
|
|
16
17
|
addConnectedRaft: (connectedRaft: ConnectedRaftItem) => void;
|
|
17
18
|
removeConnectedRaft: (connectedRaftId: string) => void;
|
|
18
19
|
setSelectedRaft: (connectedRaftId: string) => void;
|
|
20
|
+
nameUpdated: () => void;
|
|
19
21
|
};
|