Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / csdk / ocrandom / include / ocrandom.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5
6
7 #ifndef _RANDOM_H
8 #define _RANDOM_H
9
10 #include <stdint.h>
11 #include <stdlib.h>
12
13 #if defined(__ANDROID__) || defined(__linux__)
14 #include <time.h>
15 #elif defined ARDUINO
16 //#include <Arduino.h>
17 //#include <wiring_analog.c>
18 #define ANALOG_IN (15)
19 #endif
20
21 /** 
22  * Seed the random number generator. Seeding depends on platform.
23  * Android and Linux uses current time. Arduino uses Analog reading on pin ANALOG_IN
24  * @retval 0 for Success, otherwise some error value
25  */
26 int8_t OCSeedRandom();
27
28 /** 
29  * Generate a uniformly [0,2^32] distributed random number
30  * @retval On Success, it returns the random value.
31  */
32 uint32_t OCGetRandom();
33
34 /**
35  * Generate a uniformly [0,2^8] distributed random number
36  * @retval On Success, it returns the random value, otherwise -1 for error.
37  */
38 uint8_t OCGetRandomByte(void);
39
40 /**
41  * Generate a uniformly distributed 8-bit (byte) array random numbers
42  * @param[out] location
43  *              memory location to start filling with random bytes
44  * @param[in] len
45  *              length of array to be filled with random bytes
46  */
47 void OCFillRandomMem(uint8_t * location, uint16_t len);
48
49 #endif //_RANDOM_H