EnigmaIOT  0.9.3
Secure sensor and gateway platform based on ESP8266 and ESP32
Macros | Functions
helperFunctions.cpp File Reference

Auxiliary function definition. More...

#include "helperFunctions.h"

Go to the source code of this file.

Macros

#define MAX_STR_LEN   1000
 Key length used by selected crypto algorythm. More...
 
#define MACSTR   "%02X:%02X:%02X:%02X:%02X:%02X"
 

Functions

char * printHexBuffer (const uint8_t *buffer, uint16_t len)
 Debug helper function that generates a string that represent a buffer hexadecimal values. More...
 
void initWiFi (uint8_t channel, const char *networkName, const char *networkKey, uint8_t role)
 Initalizes WiFi interfaces on ESP8266 or ESP32. More...
 
uint32_t calculateCRC32 (const uint8_t *data, size_t length)
 Calculates CRC32 of a buffer. More...
 
char * mac2str (const uint8_t *mac, char *buffer)
 Debug helper function that generates a string that represent a MAC address. More...
 
uint8_t * str2mac (const char *macAddrString, uint8_t *macBytes)
 Debug helper function that creates MAC address byte array from text representation. More...
 

Detailed Description

Auxiliary function definition.

Version
0.9.3
Date
14/07/2020
Author
German Martin

Definition in file helperFunctions.cpp.

Macro Definition Documentation

◆ MACSTR

#define MACSTR   "%02X:%02X:%02X:%02X:%02X:%02X"

Definition at line 83 of file helperFunctions.cpp.

◆ MAX_STR_LEN

#define MAX_STR_LEN   1000

Key length used by selected crypto algorythm.

Definition at line 16 of file helperFunctions.cpp.

Function Documentation

◆ calculateCRC32()

uint32_t calculateCRC32 ( const uint8_t *  data,
size_t  length 
)

Calculates CRC32 of a buffer.

Parameters
dataInput buffer
lengthInput length
Returns
CRC32 value

Definition at line 63 of file helperFunctions.cpp.

◆ initWiFi()

void initWiFi ( uint8_t  channel,
const char *  networkName,
const char *  networkKey = NULL,
uint8_t  role = 0 
)

Initalizes WiFi interfaces on ESP8266 or ESP32.

Parameters
channelWiFi channel for interface initialization
role0 for node, 1 for gateway
networkNameName that gateway AP will take

Definition at line 31 of file helperFunctions.cpp.

◆ mac2str()

char* mac2str ( const uint8_t *  mac,
char *  buffer 
)

Debug helper function that generates a string that represent a MAC address.

Parameters
macPointer to the MAC address
bufferBuffer that will store resulting address. It must be 18 bytes long at least
Returns
Returns a pointer to input buffer after writting MAC address on human readable format

Definition at line 84 of file helperFunctions.cpp.

◆ printHexBuffer()

char* printHexBuffer ( const uint8_t *  buffer,
uint16_t  len 
)

Debug helper function that generates a string that represent a buffer hexadecimal values.

Parameters
bufferPointer to the buffer
lenBuffer length in number of bytes
Returns
Returns a pointer to the generated string.

String has to be used inmediatelly. At least before calling printHexBuffer() again as it uses a static buffer to hold string. It will be overwritten on next call.

Definition at line 17 of file helperFunctions.cpp.

◆ str2mac()

uint8_t* str2mac ( const char *  mac,
uint8_t *  values 
)

Debug helper function that creates MAC address byte array from text representation.

Parameters
macPointer to the MAC address string
valuesBuffer that will store byte array. It must be 6 bytes long at least
Returns
Returns a pointer to values input buffer after writting MAC address

Definition at line 94 of file helperFunctions.cpp.