Added --hex option to MeshCtrl.js listdevicegroups.
Ylian Saint-Hilaire committed
Jul 15, 2020 at 15:12 UTC
b9aed71a5c5c0f84161935cd44a0c2be8fbedbc4
1 file changed
+4
-1
meshctrl.js
+4
-1
@@ -252,6 +252,7 @@ if (args['_'].length == 0) {
252
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
253
console.log(" --nameexists [name] - Return id if name exists.");
254
console.log(" --emailexists [email] - Return id if email exists.");
255
+ console.log(" --hex - Display meshid in hex format.");
256
console.log(" --json - Show result as JSON.");
257
break;
258
}
@@ -1020,7 +1021,9 @@ function serverConnect() {
1021
console.log('id, name\r\n---------------');
1022
for (var i in data.meshes) {
1023
const m = data.meshes[i];
1023
- var t = "\"" + m._id.split('/')[2] + "\", \"" + m.name + "\"";
1024
+ var mid = m._id.split('/')[2];
1025
+ if (args.hex) { mid = Buffer.from(mid.replace(/\@/g, '+').replace(/\$/g, '/'), 'base64').toString('hex').toUpperCase(); }
1026
+ var t = "\"" + mid + "\", \"" + m.name + "\"";
1027
console.log(t);
1028
}
1029
}