-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
312 lines (279 loc) · 13 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!DOCTYPE html>
<html>
<head>
<title>microIPCore Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" />
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<!-- Font Awesome Link -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"
integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w=="
crossorigin="anonymous"
/>
<!-- stylesheet -->
<link
rel="stylesheet"
href="https://unpkg.com/@material-tailwind/html@latest/styles/material-tailwind.css"
/>
<script src="https://unpkg.com/@material-tailwind/html@latest/scripts/ripple.js"></script>
<style>
.bg-flat-image {
background-image: url('./img/your_flat_image.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.custom-img-height {
height: 150px;
object-fit: cover;
}
.top-padding {
padding-top: 10px;
}
</style>
</head>
<body>
<!-- Title -->
<div class="container mx-auto top-padding">
<div class="flex flex-wrap justify-between items-start">
<div class="w-full sm:w-auto">
<img class="rounded-t-lg float-right sm:float-none" src="./img/Logo-Acklio-Original-SCHC everywhere.svg" alt="logo" style="width: 150px;" />
</div>
<div class="w-full sm:w-auto">
<h1 class="text-2xl font-bold text-indigo-900">Acklio microIPCore Demo</h1>
<p class="my-5 text-gray-700">This demo showcases packets sent between two microIPCore devices.</p>
<p class="my-5 text-gray-700">This is a public microIPCore instance, all users see traffic from everyone.</p>
<p class="my-5 text-gray-700">To see the logs of the microIPCore, open your browser console.</p>
</div>
</div>
</div>
<!--
<div class="container mx-auto top-padding">
<img class="rounded-t-lg" src="./img/Logo-Acklio-Original-SCHC everywhere.svg" alt="logo" style="width: 150px;"/>
<h1 class="text-2xl font-bold text-indigo-900">Acklio microIPCore Demo</h1>
<p class="my-5 text-gray-700">This demo showcase packet sent between two microIPCore</p>
</div>
-->
<div class="container mx-auto mt-8 bg-flat-image">
<div class="flex flex-row">
<!-- Column Left -->
<div class="basis-1/5 ml-2 mr-2 mt-2 space-y-10">
<!-- Device 1 -->
<div class="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<img class="rounded-t-lg" src="./img/device.jpg" alt="" />
<div class="text-secondary flex-1 p-6">
<a>
<h5 class="mb-2 text-2xl font-bold tracking-tight text-pink-500 dark:text-white">
Device #1
</h5>
</a>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">
Enabled with SCHC library
</p>
<div class="space-y-2">
<button
class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
data-ripple-light="true"
id="device1SendButton"
>
Send uplink message
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
<div
class="inline-flex items-center px-3 py-2 text-sm text-center text-gray-900 rounded-lg bg-gray-50 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
id="device1ReceivedMessage"
>
<div class="mt-px">Downlink received</div>
</div>
</div>
</div>
</div>
<!-- Device 2 -->
<div class="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<img class="rounded-t-lg" src="./img/device.jpg" alt="" />
<div class="text-secondary flex-1 p-6">
<h5 class="mb-2 text-2xl font-bold tracking-tight text-pink-500 dark:text-white">Device #2</h5>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Enabled with SCHC library</p>
<div class="space-y-2">
<button
class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
data-ripple-light="true"
id="device2SendButton"
>
Send uplink message
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
<div
class="inline-flex items-center px-3 py-2 text-sm text-center text-gray-900 rounded-lg bg-gray-50 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
id="device2ReceivedMessage"
>
<div class="mt-px">Downlink received</div>
</div>
</div>
</div>
</div>
</div>
<!-- Middle space-->
<div class="basis-3/5 ml-2 mr-2 mt-2">
<!-- Empty space for the bg img -->
</div>
<!-- Column right -->
<div class="basis-1/4 ml-2 mr-2 mt-2">
<!-- App Server Card -->
<div class="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<img class="rounded-t-lg" src="./img/server.jpg" alt="" />
<div class="text-secondary flex-1 p-6">
<h5 class="mb-2 text-2xl font-bold tracking-tight text-pink-500 dark:text-white">Application Server</h5>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Off the shelf app server, communicating standard IP-based messages. </p>
<div class="space-y-4">
<!-- Comm with Device 1 -->
<div class="space-y-2">
<button
class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
data-ripple-light="true"
id="serverSendMessageToDevice1Button"
>
Device #1: send downlink
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
<div
class="inline-flex items-center px-3 py-2 text-sm text-center text-gray-900 rounded-lg bg-gray-50 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
id="serverReceivedMessageFromDevice1"
>
<div class="mt-px">Device #1: uplink received</div>
</div>
</div>
<!-- Comm with Device 2 -->
<div class="space-y-2">
<button
class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
data-ripple-light="true"
id="serverSendMessageToDevice2Button"
>
Device #1: send downlink
<svg aria-hidden="true" class="w-4 h-4 ml-2 -mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
<div
class="inline-flex items-center px-3 py-2 text-sm text-center text-gray-900 rounded-lg bg-gray-50 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
id="serverReceivedMessageFromDevice2"
>
<div class="mt-px">Device #2: uplink received</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container mx-auto top-padding text-center">
<p class="my-5 text-gray-700">Copyright © Acklio 2023. All rights reserved.</p>
</div>
<!-- <div class="container mx-auto">
<h1>Log</h1>
<ul id="log"></ul>
</div> -->
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<script>
var socket = io();
var sentMessage = {
// organization: "acklio",
device_id: "",
data: "",
};
var deviceId1 = "1122334455667788";
var deviceId2 = "1122334455667799";
var dataFromDevice1 = "YAObTAANEUAgARYGAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAARYzFjMADVmSaGVsbG8=";
var dataToDevice1 = "YAObTAANEUAAAAAAAAAAAAAAAAAAAAABIAEWBgAAAAAAAAAAAAAAAhYzFjMADVmSaGVsbG8=";
var dataFromDevice2 = "YAObTAANEUAgARYGAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAARYzFjMADVmSaGVsbG8=";
var dataToDevice2 = "YAObTAANEUAAAAAAAAAAAAAAAAAAAAABIAEWBgAAAAAAAAAAAAAAAxYzFjMADVmSaGVsbG8=";
var messages = document.getElementById("messages");
// remove a class from an element
function hightlightElement(id) {
var element = document.getElementById(id);
element.classList.remove("bg-gray-500");
element.classList.add("bg-green-500");
// wait 2 seconds and remove the class
setTimeout(function () {
element.classList.remove("bg-green-500");
element.classList.add("bg-gray-500");
}, 2000);
}
device1ReceivedMessage = document.getElementById(
"device1ReceivedMessage"
);
device2ReceivedMessage = document.getElementById(
"device2ReceivedMessage"
);
serverReceivedMessageFromDevice1 = document.getElementById(
"serverReceivedMessageFromDevice1"
);
serverReceivedMessageFromDevice2 = document.getElementById(
"serverReceivedMessageFromDevice2"
);
// Create a event listener for the device 1 send button
var device1SendButton = document.getElementById("device1SendButton");
device1SendButton.addEventListener("click", function (e) {
e.preventDefault();
sentMessage.device_id = deviceId1;
sentMessage.data = dataFromDevice1;
console.log("send message to server", sentMessage);
socket.emit("server", sentMessage);
});
// Create a event listener for the device 2 send button
var device2SendButton = document.getElementById("device2SendButton");
device2SendButton.addEventListener("click", function (e) {
e.preventDefault();
sentMessage.device_id = deviceId2;
sentMessage.data = dataFromDevice2;
console.log("send message to server", sentMessage);
socket.emit("server", sentMessage);
});
// Create a event listener for the server send button
var serverSendMessageToDevice1Button = document.getElementById(
"serverSendMessageToDevice1Button"
);
serverSendMessageToDevice1Button.addEventListener("click", function (e) {
e.preventDefault();
sentMessage.device_id = deviceId1;
sentMessage.data = dataToDevice1;
console.log("send message to device 1", sentMessage);
socket.emit("device", sentMessage);
});
// Create a event listener for the server send button
var serverSendMessageToDevice2Button = document.getElementById(
"serverSendMessageToDevice2Button"
);
serverSendMessageToDevice2Button.addEventListener("click", function (e) {
e.preventDefault();
sentMessage.device_id = deviceId2;
sentMessage.data = dataToDevice2;
console.log("send message to device 2", sentMessage);
socket.emit("device", sentMessage);
});
socket.on("server_packet", function (msg) {
if (msg.device_id == deviceId1) {
hightlightElement("serverReceivedMessageFromDevice1");
} else {
hightlightElement("serverReceivedMessageFromDevice2");
}
});
socket.on("device_packet", function (msg) {
if (msg.device_id == deviceId1) {
hightlightElement("device1ReceivedMessage");
} else {
hightlightElement("device2ReceivedMessage");
}
});
socket.on("micro-ipcore-log", function (msg) {
// log the message comming from the micro-ipcore
console.log("micro-ipcore-log", msg);
});
</script>
</body>
</html>