# LightHub: utils.h File Reference

utils.h File Reference
`#include <Arduino.h>`
`#include <IPAddress.h>`
`#include "aJSON.h"`
`#include "options.h"`
`#include "item.h"`
`#include "Streaming.h"`
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | Q(x) #x
#define | QUOTE(x) Q(x)
#define | VALUE_TO_STRING(x) #x
#define | VALUE(x) VALUE_TO_STRING(x)
#define | VAR_NAME_VALUE(var) #var "=" VALUE(var)

## Enumerations

enum | topicType { T_DEV = 1, T_BCST = 2, T_OUT = 3 }

## Functions

void | PrintBytes (uint8_t *addr, uint8_t count, bool newline)
void | SetBytes (uint8_t *addr, uint8_t count, char *out)
void | SetAddr (char *out, uint8_t *addr)
uint8_t | HEX2DEC (char i)
int | getInt (char **chan)
unsigned long | freeRam ()
void | parseBytes (const char *str, char separator, byte *bytes, int maxBytes, int base)
int | log (const char *str,...)
void | printFloatValueToStr (float value, char *valstr)
void | ReadUniqueID (uint32_t *pdwUniqueID)
int | inet_aton (const char *aIPAddrString, IPAddress &aResult)
char * | inet_ntoa_r (IPAddress addr, char *buf, int buflen)
void | printIPAddress (IPAddress ipAddress)
char * | setTopic (char *buf, int8_t buflen, topicType tt, const char *suffix=NULL)
void | printUlongValueToStr (char *valstr, unsigned long value)
void | scan_i2c_bus ()
void | softRebootFunc ()
bool | isTimeOver (uint32_t timestamp, uint32_t currTime, uint32_t time, uint32_t modulo=0xFFFFFFFF)
bool | executeCommand (aJsonObject *cmd, int8_t toggle=-1)
bool | executeCommand (aJsonObject *cmd, int8_t toggle, itemCmd _itemCmd)
itemCmd | mapInt (int32_t arg, aJsonObject *map)

## Macro Definition Documentation

## Q

#define Q | ( |  | x | ) | #x

## QUOTE

#define QUOTE | ( |  | x | ) | Q(x)

## VALUE

#define VALUE | ( |  | x | ) | VALUE_TO_STRING(x)

## VALUE_TO_STRING

#define VALUE_TO_STRING | ( |  | x | ) | #x

## VAR_NAME_VALUE

#define VAR_NAME_VALUE | ( |  | var | ) | #var "=" VALUE(var)

## Enumeration Type Documentation

## topicType

enum topicType

Enumerator
T_DEV |
T_BCST |
T_OUT |

## Function Documentation

## executeCommand() [1/2]

bool executeCommand | ( | aJsonObject * | cmd,
|  | int8_t | toggle,
|  | itemCmd | _itemCmd
| ) |  |

## executeCommand() [2/2]

bool executeCommand | ( | aJsonObject * | cmd,
|  | int8_t | toggle = `-1`
| ) |  |

## freeRam()

unsigned long freeRam | ( |  | ) |

## getInt()

int getInt | ( | char ** | chan | ) |

## HEX2DEC()

uint8_t HEX2DEC | ( | char | i | ) |

## inet_aton()

int inet_aton | ( | const char * | aIPAddrString,
|  | IPAddress & | aResult
| ) |  |

## inet_ntoa_r()

char* inet_ntoa_r | ( | IPAddress | addr,
|  | char * | buf,
|  | int | buflen
| ) |  |

Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.

Parameters

  addr | ip address in network order to convert
  buf | target buffer where the string is stored
  buflen | length of buf

Returns
  either pointer to buf which now holds the ASCII representation of addr or NULL if buf was too small

## isTimeOver()

bool isTimeOver | ( | uint32_t | timestamp,
|  | uint32_t | currTime,
|  | uint32_t | time,
|  | uint32_t | modulo = `0xFFFFFFFF`
| ) |  |

## log()

int log | ( | const char * | str,
|  |  | ...
| ) |  |

## mapInt()

itemCmd mapInt | ( | int32_t | arg,
|  | aJsonObject * | map
| ) |  |

## parseBytes()

void parseBytes | ( | const char * | str,
|  | char | separator,
|  | byte * | bytes,
|  | int | maxBytes,
|  | int | base
| ) |  |

## PrintBytes()

void PrintBytes | ( | uint8_t * | addr,
|  | uint8_t | count,
|  | bool | newline
| ) |  |

## printFloatValueToStr()

void printFloatValueToStr | ( | float | value,
|  | char * | valstr
| ) |  |

## printIPAddress()

void printIPAddress | ( | IPAddress | ipAddress | ) |

## printUlongValueToStr()

void printUlongValueToStr | ( | char * | valstr,
|  | unsigned long | value
| ) |  |

## ReadUniqueID()

void ReadUniqueID | ( | uint32_t * | pdwUniqueID | ) |

## scan_i2c_bus()

void scan_i2c_bus | ( |  | ) |

## SetAddr()

void SetAddr | ( | char * | out,
|  | uint8_t * | addr
| ) |  |

## SetBytes()

void SetBytes | ( | uint8_t * | addr,
|  | uint8_t | count,
|  | char * | out
| ) |  |

## setTopic()

char* setTopic | ( | char * | buf,
|  | int8_t | buflen,
|  | topicType | tt,
|  | const char * | suffix = `NULL`
| ) |  |

## softRebootFunc()

void softRebootFunc | ( |  | ) |