Utils Boards  1.0.2
Utility functions and macros to uniform the usage of the WiFi and I2C across different boards
UtilsBoards.cpp File Reference
#include <Arduino.h>
#include <Utils.h>
#include <UtilsBoards.h>

Functions

void showBoardType (Print &pr)
 Show the board name. More...
 
void blinkInternalLed (int onTime, int offTime)
 Blink the internal LED of the board. More...
 
void initInternalLed ()
 Initialize the internal LED. More...
 
bool initWiFi (const char *ssid, const char *password, const bool resetIfNoWiFi, const bool blinkInternal, const char *hostName, Print &pr)
 Initialize the WiFi. More...
 
bool initWiFi (PtrWiFiMultiEntry creds, int sizeOfCreds, const bool resetIfNoWiFi, const bool blinkInternal, const char *hostName, Print &pr)
 Initialize the WiFi. More...
 

Variables

const int ConnSleepTimeOn = 250
 
const int ConnSleepTimeOff = 250
 
const int ConnectionTimeOut = 30
 
const int ConnSleepTime = (ConnSleepTimeOn+ConnSleepTimeOff)
 
const int ConnectionSteps = ( 1000 / ConnSleepTime)*ConnectionTimeOut
 

Function Documentation

◆ blinkInternalLed()

void blinkInternalLed ( int  onTime,
int  offTime 
)

Blink the internal LED of the board.

Function to blink the internal LED of the board. Internally uses the delay(...) function.

Parameters
onTimethe amount of time to maintain the internal LED ON
offTimethe amount of time to maintain the internal LED OFF

◆ initInternalLed()

void initInternalLed ( )

Initialize the internal LED.

This function configures the pin associatied with the internal LED to a digital output and turns off the internal LED.

◆ initWiFi() [1/2]

bool initWiFi ( const char *  ssid,
const char *  password,
const bool  resetIfNoWiFi = true,
const bool  blinkInternal = false,
const char *  hostName = NULL,
Print &  pr = Serial 
)

Initialize the WiFi.

Function to initialize the WiFi component of the board in station mode (WIFI_STA).

Beasides the authentication credentials (name of the SSID and corresponding password) this function accepts a set of aditional arguments that can be used to:

  • Reset the board if no connection could be established.
  • Blink the internal LED while wainting for the establishment of the WiFi connection.
  • Set the DNS host name of the board.
  • Specify a Print object to show debug messages.
Parameters
ssidname of the network
passwordthe matching password for the specified SSID
resetIfNoWiFiboolean flag that can be used to reset the board if no connection could be done within 30 seconds. This is the default behavior
blinkInternalboolean flag that can be used to controll the blinking of the interal LED while waiting for the establishment of the WiFi connection. The default behavior is to not blink the internal LED
hostNameDNS name of the board. By default the DNS name is not set.
prArduino Print object that suports the print and println methods. By default these messages are shown in the default Serial port
Returns
true if it was possible to connect the the specified network. In case of failure, if the flag resetIfNoWiFi is set to true the board is reset, else the value false is returned.

◆ initWiFi() [2/2]

bool initWiFi ( PtrWiFiMultiEntry  creds,
int  sizeOfCreds,
const bool  resetIfNoWiFi = true,
const bool  blinkInternal = false,
const char *  hostName = NULL,
Print &  pr = Serial 
)

Initialize the WiFi.

Function to initialize the WiFi component of the board in station mode (WIFI_STA).

This function receives a set of authentication credentials (name of the SSID and corresponding password). Thus board tries to establish a connection with every networs in the list until establish a connection.

This function also accepts a set of aditional arguments that can be used to:

  • Reset the board if no connection could be established.
  • Blink the internal LED while wainting for the establishment of the WiFi connection.
  • Set the DNS host name of the board.
  • Specify a Print object to show debug messages.
Parameters
credsset of authentication credentials
sizeOfCredsnumber of authentication credentials
resetIfNoWiFiboolean flag that can be used to reset the board if no connection could be done within 30 seconds. This is the default behavior
blinkInternalboolean flag that can be used to controll the blinking of the interal LED while waiting for the establishment of the WiFi connection. The default behavior is to not blink the internal LED
hostNameDNS name of the board. By default the DNS name is not set.
prArduino Print object that suports the print and println methods. By default these messages are shown in the default Serial port

◆ showBoardType()

void showBoardType ( Print &  pr = Serial)

Show the board name.

Utility function to show the name of the current board. By default the board name is printed to the default Serial port.

Parameters
prArduino Print object that suports the print and println methods

Variable Documentation

◆ ConnectionSteps

const int ConnectionSteps = ( 1000 / ConnSleepTime)*ConnectionTimeOut

◆ ConnectionTimeOut

const int ConnectionTimeOut = 30

◆ ConnSleepTime

const int ConnSleepTime = (ConnSleepTimeOn+ConnSleepTimeOff)

◆ ConnSleepTimeOff

const int ConnSleepTimeOff = 250

◆ ConnSleepTimeOn

const int ConnSleepTimeOn = 250