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

Go to the source code of this file.

Classes

struct  WiFiMultiEntry
 Struct to hold the WiFi credentials. More...
 

Macros

#define BOARD_TYPE_6
 
#define BOARD_FAMILY   "Unknown"
 
#define BOARD_NAME   "Unknown"
 
#define LED_INTERNAL_PIN   1
 
#define internalLedOn()   digitalWrite( LED_INTERNAL_PIN, LOW )
 Turn inboard LED ON. More...
 
#define internalLedOff()   digitalWrite( LED_INTERNAL_PIN, HIGH )
 Turn inboard LED OFF. More...
 

Typedefs

typedef void WiFiMulti
 
typedef struct WiFiMultiEntryPtrWiFiMultiEntry
 

Functions

void initInternalLed ()
 Initialize the internal LED. More...
 
void blinkInternalLed (int onTime, int offTime)
 Blink the internal LED of the board. More...
 
void showBoardType (Print &pr=Serial)
 Show the board name. More...
 
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. More...
 
bool initWiFi (PtrWiFiMultiEntry creds, int sizeOfCreds, const bool resetIfNoWiFi=true, const bool blinkInternal=false, const char *hostName=NULL, Print &pr=Serial)
 Initialize the WiFi. More...
 

Macro Definition Documentation

◆ BOARD_FAMILY

#define BOARD_FAMILY   "Unknown"

◆ BOARD_NAME

#define BOARD_NAME   "Unknown"

◆ BOARD_TYPE_6

#define BOARD_TYPE_6

◆ internalLedOff

#define internalLedOff ( )    digitalWrite( LED_INTERNAL_PIN, HIGH )

Turn inboard LED OFF.

Utility macro to turn OFF the internal LED of the board.

◆ internalLedOn

#define internalLedOn ( )    digitalWrite( LED_INTERNAL_PIN, LOW )

Turn inboard LED ON.

Utility macro to turn ON the internal LED of the board.

◆ LED_INTERNAL_PIN

#define LED_INTERNAL_PIN   1

Typedef Documentation

◆ PtrWiFiMultiEntry

◆ WiFiMulti

typedef void WiFiMulti

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