pfodParser 5.0.1 The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections

Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
pfodMAC Class Reference

`#include <pfodMAC.h>`

## Public Member Functions
| pfodMAC ()
boolean | init (int eepromAddress)
void | setSecretKey (byte *key, int len)
void | setDebugStream (Print *out)
boolean | isValid ()
boolean | isBigEndian ()
void | noEEPROM ()
unsigned int | readSecretKey (byte *bRtn, int keyAdd)
uint8_t | eeprom_read (int address)
void | printBytesInHex (Print *out, const byte *b, size_t len)
boolean | buildChallenge (byte *challengeBytes, uint32_t mS_sinceLastConnection)
| buildChallenge – NOTE: each call to this method increments the connection counter!!! Challenge built from powerCycles + connectionCounter + mS_sinceLastConnection (limited to 31 bits) 32th bit set if last connection failed finally hashes the challange bytes (result stored in hash fn) use getHashedResult() to retrieve pointer to result when needed for checking return value More...
void | initHash ()
void | putByteToHash (byte b)
void | putBytesToHash (byte *b, int len)
void | putLongToHash (uint32_t l)
void | finishHash ()
byte * | getHashedResult ()
boolean | checkMsgHash (const byte *msgHash, uint16_t len)
| Converts msgHash from hex Digits to bytes and then compares the resulting byte[] with the current hash result. More...
void | reverseBytes (byte *b, int len)

## Static Public Member Functions
static void | resetPowerCycles (int eepromAddress=0)
| Use this call to reset the power cycles to 0xffff Then remove the call from the code for normal operation. More...
static void | eeprom_write (int address, uint8_t value)

## Static Public Attributes
static const uint8_t | msgHashByteSize = 4
static const uint8_t | challengeHashByteSize = 8
static const uint8_t | challengeByteSize = 8
static const uint8_t | PowerCyclesOffset
static const uint8_t | KeyOffset
static const uint8_t | maxKeySize = 16

## Detailed Description

Definition at line 23 of file pfodMAC.h.

## Constructor & Destructor Documentation

## ◆ pfodMAC()

pfodMAC::pfodMAC | ( |  | ) |

## Member Function Documentation

## ◆ buildChallenge()

boolean pfodMAC::buildChallenge | ( | byte * | challengeBytes,
|  | uint32_t | mS_sinceLastConnection
| ) |  |

buildChallenge – NOTE: each call to this method increments the connection counter!!! Challenge built from powerCycles + connectionCounter + mS_sinceLastConnection (limited to 31 bits) 32th bit set if last connection failed finally hashes the challange bytes (result stored in hash fn) use getHashedResult() to retrieve pointer to result when needed for checking return value

All counters stored in BigEndian format into the challenge byte array powerCycles read on start up

Parameters

  challengeBytes | byte* to array to store challenge
  mS_sinceLastConnection | mS since last connection (max value about 25days), -ve if last connection failed

returns true if isValid() is true;

## ◆ checkMsgHash()

boolean pfodMAC::checkMsgHash | ( | const byte * | msgHash,
|  | uint16_t | len
| ) |  |

Converts msgHash from hex Digits to bytes and then compares the resulting byte[] with the current hash result.

Parameters

  msgHash | null terminated ascii string of hex chars (0..9A..F) or (0..9a..f) this input is overwritten with the converted bytes
  hashSize | the number of bytes expected in the hash must be < length of msgHash since the converted bytes are store in that array.

## ◆ eeprom_read()

uint8_t pfodMAC::eeprom_read | ( | int | address | ) |

## ◆ eeprom_write()

static void pfodMAC::eeprom_write | ( | int | address,
|  | uint8_t | value
| ) |  |
| static

## ◆ finishHash()

void pfodMAC::finishHash | ( |  | ) |

## ◆ getHashedResult()

byte* pfodMAC::getHashedResult | ( |  | ) |

## ◆ init()

boolean pfodMAC::init | ( | int | eepromAddress | ) |

## ◆ initHash()

void pfodMAC::initHash | ( |  | ) |

## ◆ isBigEndian()

boolean pfodMAC::isBigEndian | ( |  | ) |

## ◆ isValid()

boolean pfodMAC::isValid | ( |  | ) |

## ◆ noEEPROM()

void pfodMAC::noEEPROM | ( |  | ) |

## ◆ printBytesInHex()

void pfodMAC::printBytesInHex | ( | Print * | out,
|  | const byte * | b,
|  | size_t | len
| ) |  |

## ◆ putBytesToHash()

void pfodMAC::putBytesToHash | ( | byte * | b,
|  | int | len
| ) |  |

## ◆ putByteToHash()

void pfodMAC::putByteToHash | ( | byte | b | ) |

## ◆ putLongToHash()

void pfodMAC::putLongToHash | ( | uint32_t | l | ) |

## ◆ readSecretKey()

unsigned int pfodMAC::readSecretKey | ( | byte * | bRtn,
|  | int | keyAdd
| ) |  |

## ◆ resetPowerCycles()

static void pfodMAC::resetPowerCycles | ( | int | eepromAddress = `0` | ) |
| static

Use this call to reset the power cycles to 0xffff Then remove the call from the code for normal operation.

Parameters

  eepromAddress | the base address on the eepromStorage, defaults to 0

## ◆ reverseBytes()

void pfodMAC::reverseBytes | ( | byte * | b,
|  | int | len
| ) |  |

## ◆ setDebugStream()

void pfodMAC::setDebugStream | ( | Print * | out | ) |

## ◆ setSecretKey()

void pfodMAC::setSecretKey | ( | byte * | key,
|  | int | len
| ) |  |

## Member Data Documentation

## ◆ challengeByteSize

const uint8_t pfodMAC::challengeByteSize = 8
| static

Definition at line 91 of file pfodMAC.h.

## ◆ challengeHashByteSize

const uint8_t pfodMAC::challengeHashByteSize = 8
| static

Definition at line 90 of file pfodMAC.h.

## ◆ KeyOffset

const uint8_t pfodMAC::KeyOffset
| static

Definition at line 93 of file pfodMAC.h.

## ◆ maxKeySize

const uint8_t pfodMAC::maxKeySize = 16
| static

Definition at line 94 of file pfodMAC.h.

## ◆ msgHashByteSize

const uint8_t pfodMAC::msgHashByteSize = 4
| static

Definition at line 89 of file pfodMAC.h.

## ◆ PowerCyclesOffset

const uint8_t pfodMAC::PowerCyclesOffset
| static

Definition at line 92 of file pfodMAC.h.