14 #define MAX_STR_LEN 1000
23 for (
int i = 0; i < len; i++) {
25 charIndex += sprintf (tempStr + charIndex,
"%02X ", buffer[i]);
32 void initWiFi (uint8_t channel,
const char* networkName,
const char* networkKey, uint8_t role) {
33 DEBUG_DBG (
"initWifi");
38 if ((err_ok = esp_wifi_set_promiscuous (
true))) {
39 DEBUG_ERROR (
"Error setting promiscuous mode: %s", esp_err_to_name (err_ok));
41 if ((err_ok = esp_wifi_set_channel (channel, WIFI_SECOND_CHAN_NONE))) {
42 DEBUG_ERROR (
"Error setting wifi channel: %s", esp_err_to_name (err_ok));
44 if ((err_ok = esp_wifi_set_promiscuous (
false))) {
45 DEBUG_ERROR (
"Error setting promiscuous mode off: %s", esp_err_to_name (err_ok));
50 wifi_set_channel (channel);
52 DEBUG_DBG (
"Mode set to STA. Channel %u", channel);
55 WiFi.softAP (networkName, networkKey, channel);
56 DEBUG_DBG (
"Mode set to AP in channel %u", channel);
59 DEBUG_INFO (
"AP MAC address of this device is %s", WiFi.softAPmacAddress ().c_str ());
60 DEBUG_INFO (
"STA MAC address of this device is %s", WiFi.macAddress ().c_str ());
65 uint32_t crc = 0xffffffff;
68 for (uint32_t i = 0x80; i > 0; i >>= 1) {
69 bool bit = crc & 0x80000000;
83 #define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
85 char*
mac2str (
const uint8_t* mac,
char* extBuffer) {
90 buffer = staticBuffer;
104 uint8_t*
str2mac (
const char* macAddrString, uint8_t* macBytes) {
105 const char cSep =
':';
111 for (
int i = 0; i < 6; ++i) {
112 unsigned int iNumber = 0;
116 ch = tolower (*macAddrString++);
118 if ((ch < '0' || ch >
'9') && (ch < 'a' || ch >
'f')) {
126 iNumber = isdigit (ch) ? (ch -
'0') : (ch -
'a' + 10);
127 ch = tolower (*macAddrString);
129 if ((i < 5 && ch != cSep) ||
130 (i == 5 && ch !=
'\0' && !isspace (ch))) {
133 if ((ch < '0' || ch >
'9') && (ch < 'a' || ch >
'f')) {
138 iNumber += isdigit (ch) ? (ch -
'0') : (ch -
'a' + 10);
141 if (i < 5 && ch != cSep) {
146 macBytes[i] = (
unsigned char)iNumber;
154 const char* IRAM_ATTR extractFileName (
const char* path) {
157 char* p = (
char*)path;
160 if (*p ==
'/' || *p ==
'\\') {
170 unsigned int index = 0;
171 size_t len = strlen (input);
177 while (index < len) {
178 if (!isDigit (input[index])) {
187 unsigned int index = 0;
193 while (input[index] !=
'\0' && index < len) {
194 if (!isDigit (input[index])) {
203 unsigned int index = 0;
204 size_t len = input.length ();
210 while (index < len) {
211 if (!isDigit (input[index])) {