Skip to content

Commit 417fd31

Browse files
committed
SiliconLabsGH-43: Updated User Credential implementation
Forwarded: SiliconLabs#43 Bug-SiliconLabs: UIC-3222 Bug-Github: SiliconLabs#43
1 parent cf9a4fc commit 417fd31

32 files changed

+10381
-4405
lines changed

applications/dev_ui/dev_gui/src/App.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ class App extends Component<{}, AppState> {
149149
this.setState({ CommissionableDevices: list });
150150
}
151151

152+
handleEvents(data: any) {
153+
var toastType = toast.TYPE.DEFAULT;
154+
switch (data.level) {
155+
case 1:
156+
toastType = toast.TYPE.INFO;
157+
break;
158+
case 2:
159+
toastType = toast.TYPE.WARNING;
160+
break;
161+
case 3:
162+
case 4:
163+
toastType = toast.TYPE.ERROR;
164+
break;
165+
}
166+
toast(data.message, { type: toastType })
167+
}
168+
152169
handleUPTIChange(list: any[]) {
153170
let upti = this.state.UPTI;
154171
upti.List = list;
@@ -414,6 +431,9 @@ class App extends Component<{}, AppState> {
414431
case "commissionable-device":
415432
this.handleCommissionableDevices(mes.data);
416433
break;
434+
case "event":
435+
this.handleEvents(mes.data);
436+
break;
417437
}
418438
}
419439

applications/dev_ui/dev_gui/src/dev-gui-api/handler.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ exports.processSmartStart = (topic, message) => {
4040
}
4141
}
4242

43+
exports.processEvent = (topic, message) => {
44+
console.log(`Received Event : '${message}'`);
45+
if (message.toString() == "")
46+
return;
47+
try {
48+
return {
49+
type: "event",
50+
data: JSON.parse(message)
51+
};
52+
} catch (error) {
53+
return getErrorResponse(topic, message, error);
54+
}
55+
}
56+
4357
exports.processCluster = (topic, message) => {
4458
let index = -1;
4559
let match = topic.match(/ucl\/by-unid\/(.*)\/(ep\d+)\/(.*)/)

applications/dev_ui/dev_gui/src/dev-gui-api/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ let topics = ["ucl/SmartStart/List",
3333
"ucl/UPTICap/#",
3434
"ucl/by-machine-id/+/SystemMetrics/SupportedCommands",
3535
"ucl/by-machine-id/+/SystemMetrics/Attributes/#",
36-
"ucl/by-mqtt-client/+/ApplicationMonitoring/Attributes/#"
36+
"ucl/by-mqtt-client/+/ApplicationMonitoring/Attributes/#",
37+
"ucl/Event"
3738
];
3839
Object.keys(supportedClusters).forEach((i) => {
3940
topics.push(`ucl/by-unid/+/+/${i}/SupportedCommands`);
@@ -282,6 +283,8 @@ function onMqttMessage(topic, message) {
282283
response = handler.processAppMonitoringList(topic, message);
283284
} else if (topic.match(/ucl\/SmartStart\/CommissionableDevice\/(.*)/)) {
284285
response = handler.processCommissionableDevices(topic, message);
286+
} else if (topic === "ucl/Event") {
287+
response = handler.processEvent(topic, message);
285288
}
286289
if (response && Object.keys(response).length > 0)
287290
handler.addToQueue(response.type, response.data);

0 commit comments

Comments
 (0)