Command demo on/off to hide MAC addresses

This commit is contained in:
Spacehuhn
2020-12-08 12:30:09 +01:00
parent 0a78acec80
commit ffc01d9a2a
3 changed files with 33 additions and 3 deletions

View File

@@ -1570,6 +1570,24 @@ namespace cli {
" -h: Hidden network\r\n"
" -ch: Channel (default=1)\r\n"
" -b: BSSID MAC address (default=random)");
Command cmd_demo = cli.addCommand("demo", [](cmd* c) {
Command cmd(c);
String mode { cmd.getArg("m").getValue() };
if (mode == "on") {
strh::hide_mac(true);
debugln("Demo Mode: ACTIVATED");
} else {
strh::hide_mac(false);
debugln("Demo Mode: DEACTIVATED");
}
});
cmd_demo.addPosArg("m/ode", "on");
cmd_demo.setDescription(" Demo mode\r\n"
" on: turn on demo mode\r\n"
" off: turn off demo mode");
}
void parse(const char* input) {

View File

@@ -7,6 +7,12 @@
#include "strh.h"
namespace strh {
bool hidden { false };
void hide_mac(bool mode) {
hidden = mode;
}
String whitespace(int len) {
String res;
@@ -64,8 +70,13 @@ namespace strh {
for (int i = 0; i < len; i++) {
if (i>0) str += ':';
if (b[i] < 0x10) str += '0';
str += String(b[i], HEX);
if (hidden && (i>=2) && (i<=4)) {
str += '*';
str += '*';
} else {
if (b[i] < 0x10) str += '0';
str += String(b[i], HEX);
}
}
return str;
@@ -129,7 +140,7 @@ namespace strh {
}
String boolean(bool value) {
if(value) {
if (value) {
return String(F("True"));
} else {
return String(F("False"));

View File

@@ -9,6 +9,7 @@
#include <Arduino.h> // String
namespace strh {
void hide_mac(bool mode);
String whitespace(int len);
String left(int len, String str);
String right(int len, String str);