hhs utility
Functions
hhsUtility.h File Reference
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <Ticker.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266HTTPUpdateServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
Include dependency graph for hhsUtility.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

String formatBytes (size_t bytes)
 Utility function Original code found here: https://tttapa.github.io/ESP8266/Chap16%20-%20Data%20Logging.html Converts bytes to KB and MB. More...
 
void printFloat (float value, int places)
 Utility function: Prints value with places of decimal places determine by precision. More...
 
boolean isNumeric (String str)
 Utility function Checks if a string is numeric. Original code found here: http://tripsintech.com/arduino-isnumeric-function/. More...
 
int errorState (int state, int ledRed, int ledGreen)
 Utility function Visual error indication via LED at pin D2 This is a dead end. You will need to fix the error and reset the device. Alocated states: State 1: No WiFi connection available State 2: Could not connect to MQTT broker // State 3: No temperature sensor found. // 200/600: Refrigerator, Temp measure State 4: Not possible to start SPIFFS. // 600/200: Refrigerator State 5: Could not transmit data to emoncms. // Refrigerator. More...
 
void keypressWait (void)
 Utility function Halt the program and wait for "key press" at the serial port. For DEBUG purpose only. More...
 
void ICACHE_RAM_ATTR lwdtcb (void)
 Utility function lwdTicker callback routine Code found here: https://www.sigmdel.ca/michel/program/esp8266/arduino/watchdogs2_en.html. More...
 
void lwdtFeedInit (void)
 Utility function Initializes the loop watchdog interrupt routine. To be used in setup() at the end. More...
 
void lwdtFeed (void)
 Utility function Resets the loop watchdog counter also known as "kicking the watchdog". More...
 
int getBootDevice (void)
 Utility function See https://www.sigmdel.ca/michel/program/esp8266/arduino/watchdogs2_en.html for documentation
More...
 
int startWiFi (IPAddress _ip, IPAddress _dns, IPAddress _gateway, IPAddress _subnet, char *_ssid, char *_password, char *_host)
 Utility function Starts everything related to WiFi and Internet connections. More...
 
void showWiFiStatus (int i)
 Utility function Display WiFi status in clear text. More...
 
bool doWifiConnect (char *_ssid, char *_password)
 Utility function Tries to reconnect the WiFi connection Software found here: https://github.com/esp8266/Arduino/issues/4060. More...
 
int MQTT_connect (Adafruit_MQTT_Client *_mqtt)
 Utility function Function to connect and reconnect as necessary to the MQTT server. More...
 

Detailed Description

Author
Hans Henrik Skovgaard ()

Definition in file hhsUtility.h.

Function Documentation

◆ doWifiConnect()

bool doWifiConnect ( char *  _ssid,
char *  _password 
)

Utility function Tries to reconnect the WiFi connection Software found here: https://github.com/esp8266/Arduino/issues/4060.

Parameters
[in]charSSID WiFi SSID
[in]charpassword WiFi password
Returns
success or failure

Definition at line 346 of file hhsUtility.cpp.

Here is the call graph for this function:

◆ errorState()

int errorState ( int  state,
int  ledRed,
int  ledGreen 
)

Utility function Visual error indication via LED at pin D2 This is a dead end. You will need to fix the error and reset the device. Alocated states: State 1: No WiFi connection available State 2: Could not connect to MQTT broker // State 3: No temperature sensor found. // 200/600: Refrigerator, Temp measure State 4: Not possible to start SPIFFS. // 600/200: Refrigerator State 5: Could not transmit data to emoncms. // Refrigerator.

Parameters
[in]intstate Error
[in]intledRed
[in]intledGreen
Returns
true or false. Is the errorstate defined.

Definition at line 122 of file hhsUtility.cpp.

◆ formatBytes()

String formatBytes ( size_t  bytes)

Utility function Original code found here: https://tttapa.github.io/ESP8266/Chap16%20-%20Data%20Logging.html Converts bytes to KB and MB.

Parameters
size_tbytes: the bytes to convert.
Returns
string with bytes converted to KB or MB.

Definition at line 20 of file hhsUtility.cpp.

◆ getBootDevice()

int getBootDevice ( void  )

Utility function See https://www.sigmdel.ca/michel/program/esp8266/arduino/watchdogs2_en.html for documentation

Parameters
[in]none
Returns
bootmode

Definition at line 256 of file hhsUtility.cpp.

◆ isNumeric()

boolean isNumeric ( String  str)

Utility function Checks if a string is numeric. Original code found here: http://tripsintech.com/arduino-isnumeric-function/.

Parameters
[in]Stringstr string to verify.
Returns
true or false.

Definition at line 105 of file hhsUtility.cpp.

◆ keypressWait()

void keypressWait ( void  )

Utility function Halt the program and wait for "key press" at the serial port. For DEBUG purpose only.

Parameters
[in]none
Returns
none

Definition at line 219 of file hhsUtility.cpp.

◆ lwdtcb()

void ICACHE_RAM_ATTR lwdtcb ( void  )

Utility function lwdTicker callback routine Code found here: https://www.sigmdel.ca/michel/program/esp8266/arduino/watchdogs2_en.html.

Parameters
[in]none
Returns
none

Definition at line 226 of file hhsUtility.cpp.

Here is the caller graph for this function:

◆ lwdtFeed()

void lwdtFeed ( void  )

Utility function Resets the loop watchdog counter also known as "kicking the watchdog".

Parameters
[in]none
Returns
none

Definition at line 250 of file hhsUtility.cpp.

Here is the caller graph for this function:

◆ lwdtFeedInit()

void lwdtFeedInit ( void  )

Utility function Initializes the loop watchdog interrupt routine. To be used in setup() at the end.

Parameters
[in]none
Returns
none

Definition at line 244 of file hhsUtility.cpp.

Here is the call graph for this function:

◆ MQTT_connect()

int MQTT_connect ( Adafruit_MQTT_Client *  _mqtt)

Utility function Function to connect and reconnect as necessary to the MQTT server.

Parameters
[in]Adafruit_MQTT_ClientMQTT client to reconnect.
Returns
success or failure.

Definition at line 373 of file hhsUtility.cpp.

◆ printFloat()

void printFloat ( float  value,
int  places 
)

Utility function: Prints value with places of decimal places determine by precision.

Parameters
[in]floatvalue decimal value to be printed
[in]placesis a number indicating the desired decimal places Original code found here: https://playground.arduino.cc/Code/PrintFloats

Definition at line 39 of file hhsUtility.cpp.

◆ showWiFiStatus()

void showWiFiStatus ( int  i)

Utility function Display WiFi status in clear text.

Parameters
[in]indicating the WiFi status to display in text.
Returns
none

Definition at line 312 of file hhsUtility.cpp.

Here is the caller graph for this function:

◆ startWiFi()

int startWiFi ( IPAddress  _ip,
IPAddress  _dns,
IPAddress  _gateway,
IPAddress  _subnet,
char *  _ssid,
char *  _password,
char *  _host 
)

Utility function Starts everything related to WiFi and Internet connections.

Parameters
[in]IPAddress_ip Static IP address of the device
[in]IPAddress_dns DNS IP address
[in]IPAddress_gateway Gateway IP address
[in]IPAddress_subnet Subnet.
[in]char*_ssid WiFi SSID
[in]char*_password WiFi password
[in]char*_host Unique host name of the device.
Returns
success or failure

Definition at line 269 of file hhsUtility.cpp.

Here is the call graph for this function: