Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: base/net/web-net-script.js
- Revision:
- 132:5b2df69a4f17
- Child:
- 133:98c6bf14bc37
diff -r a9793a9721c7 -r 5b2df69a4f17 base/net/web-net-script.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/base/net/web-net-script.js Wed Mar 11 08:28:53 2020 +0000
@@ -0,0 +1,57 @@
+//Net script
+'use strict';
+
+let mac = '';
+let tcp = '';
+
+function parseTcpLine(line)
+{
+ if (line.length == 0) return;
+ let fields = line.split('\t');
+ let minutes = parseInt(fields[0], 16) / 1000 / 60;
+ let ipType = parseInt(fields[1], 16);
+ let arIndex = parseInt(fields[2], 16);
+ let locPort = parseInt(fields[3], 16);
+
+
+ tcp += Math.floor(minutes).toString().padStart(4, ' ');
+ tcp += ' ';
+
+ if (ipType == 0x0800) tcp += "IPv4";
+ else if (ipType == 0x86DD) tcp += "IPv6";
+ else tcp += fields[1];
+ tcp += ' ';
+
+ tcp += arIndex.toString();
+ tcp += ' ';
+
+ tcp += locPort.toString();
+ tcp += '\r\n';
+}
+function parseTcpLines(text)
+{
+ tcp = '';
+ text.split('\n').forEach(parseTcpLine);
+}
+function parseGenLines(text)
+{
+ let lines = text.split('\n');
+ mac = Net.makeMac(lines[ 0]);
+}
+function parse()
+{
+ let topics = Ajax.response.split('\f');
+ parseGenLines(topics[0]);
+ parseTcpLines(topics[1]);
+}
+function display()
+{
+ let elem;
+
+ elem = Ajax.getElementOrNull('ajax-tcp' ); if (elem) elem.textContent = tcp;
+ elem = Ajax.getElementOrNull('ajax-mac' ); if (elem) elem.textContent = mac;
+}
+
+Ajax.server = '/net-ajax';
+Ajax.onResponse = function() { parse(); display(); };
+Ajax.init();