IoTeX client
ESP8266TrueRandom.h
1#ifdef ESP8266
2
3/*
4 * TrueRandom - A true random number generator for Arduino.
5 * This is variant of original work originally implemented as:
6 * https://code.google.com/archive/p/tinkerit/
7 * https://github.com/Cathedrow/TrueRandom Copyright (c) 2010 Peter Knight,
8 * Tinker.it! All rights reserved. Now modified for the ESP8266
9 */
10
11#ifndef ESP8266TrueRandom_h
12#define ESP8266TrueRandom_h
13
14#include <Arduino.h>
15#include <inttypes.h>
16
17class ESP8266TrueRandomClass
18{
19 public:
20 ICACHE_FLASH_ATTR ESP8266TrueRandomClass();
21 ICACHE_FLASH_ATTR int rand();
22 ICACHE_FLASH_ATTR long random();
23 ICACHE_FLASH_ATTR long random(long howBig);
24 ICACHE_FLASH_ATTR long random(long howsmall, long how);
25 ICACHE_FLASH_ATTR int randomBit(void);
26 ICACHE_FLASH_ATTR char randomByte(void);
27 ICACHE_FLASH_ATTR void memfill(char* location, int size);
28 ICACHE_FLASH_ATTR void mac(uint8_t* macLocation);
29 ICACHE_FLASH_ATTR void uuid(uint8_t* uuidLocation);
30 ICACHE_FLASH_ATTR String uuidToString(uint8_t* uuidLocation);
31 bool useRNG;
32
33 private:
34 unsigned long lastYield;
35 ICACHE_FLASH_ATTR int randomBitRaw(void);
36 ICACHE_FLASH_ATTR int randomBitRaw2(void);
37};
38extern ESP8266TrueRandomClass ESP8266TrueRandom;
39#endif
40
41#endif