EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
Functions
helperFunctions.h File Reference

Auxiliary function definition. More...

#include "WProgram.h"
#include "EnigmaIoTconfig.h"
#include "EnigmaIOTdebug.h"

Go to the source code of this file.

Functions

char * printHexBuffer (const uint8_t *buffer, uint16_t len)
 Debug helper function that generates a string that represent a buffer hexadecimal values. More...
 
char * mac2str (const uint8_t *mac, char *extBuffer=NULL)
 Debug helper function that generates a string that represent a MAC address. More...
 
uint8_t * str2mac (const char *mac, uint8_t *values)
 Debug helper function that creates MAC address byte array from text representation. More...
 
void initWiFi (uint8_t channel, const char *networkName, const char *networkKey=NULL, uint8_t role=0)
 Initalizes WiFi interfaces on ESP8266 or ESP32. More...
 
uint32_t calculateCRC32 (const uint8_t *data, size_t length)
 Calculates CRC32 of a buffer. More...
 
bool isNumber (const char *input)
 Checks if input string is numeric. More...
 
bool isNumber (const char *input, size_t len)
 Checks if input string is numeric. More...
 
bool isNumber (String input)
 Checks if input string is numeric. More...
 

Detailed Description

Auxiliary function definition.

Version
0.9.8
Date
15/07/2021
Author
German Martin

Definition in file helperFunctions.h.

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 64 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
networkKeyNetwork key. This is not required normally as this is provided using configuration web portal

Definition at line 32 of file helperFunctions.cpp.

◆ isNumber() [1/3]

bool isNumber ( const char *  input)

Checks if input string is numeric.

Parameters
inputString to check
Returns
true if string is a number

Definition at line 169 of file helperFunctions.cpp.

◆ isNumber() [2/3]

bool isNumber ( const char *  input,
size_t  len 
)

Checks if input string is numeric.

Parameters
inputString to check
lenString length
Returns
true if string is a number

Definition at line 186 of file helperFunctions.cpp.

◆ isNumber() [3/3]

bool isNumber ( String  input)

Checks if input string is numeric.

Parameters
inputString to check
Returns
true if string is a number

Definition at line 202 of file helperFunctions.cpp.

◆ mac2str()

char* mac2str ( const uint8_t *  mac,
char *  extBuffer = NULL 
)

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

Parameters
macPointer to the MAC address
extBufferBuffer that will store resulting address. It must be 18 bytes long at least. If it is NULL a static buffer will be used
Returns
Returns a pointer to input buffer after writting MAC address on human readable format

Definition at line 85 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 16 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 104 of file helperFunctions.cpp.