83560988a509b1e205c34aead057961c7626c988
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SampleApp / arduino / Reference_Thing / include / bleLib.h
1 /*
2  * bleLib.h
3  *
4  *  Created on: 2014. 11. 5.
5  *      Author: eunseok
6  */
7
8 #ifndef BLELIB_H_
9 #define BLELIB_H_
10
11 #include "Arduino.h"
12
13 #define BLE_NOCHANGE    -1
14 #define BLE_MASTER              1
15 #define BLE_SLAVER              0
16
17 #define BLE_DISCON              200
18 #define BLE_NODATA              100
19
20
21 /***************************************
22  *
23  *      HM-10 BLE Module Control Class.
24  *      Target Board : Arduino-Mega.
25  *
26  **************************************/
27 class Cble
28 {
29 public :
30         /***
31          * BLE Control Function.
32          */
33         // BLE initialization ( COM baud rate , BLE Master , Slave setting. )
34         void init(long baudRate, int ble_mode, char* SelfMaxAddr);
35
36         void StatusRead( void );
37
38         bool IsSelfArduino( void );
39
40         bool IsConnected( void );
41
42         bool pollingConnect( const char* maxAddr );
43
44         void pollingDisconnect( void );
45         // Get RSSI by BLE communication. (polling method.)
46         int pollingGetRSSI( void );
47         // Send Request to BLE Module. And, Get the response. (polling method.)
48         bool pollingRequest(const char* request, char* data, int dataLen);
49
50         int mustHaveRequest(const char* request, char* data, int dataLen);
51
52         void streamDummy( char* data, int dataLen);
53
54         /***
55          * Debug COM port to BLE COM port.
56          * BLE COM port to Debug COM port.
57          */
58         // BLE Module to Debug Serial port.
59         void BLE2Debug( int autoDiscon );
60         // Debug Serial port to BLE Module.
61         char* Debug2BLE( int BLEwrite );
62
63         /***
64          * If you first setting, you need next-function.
65          */
66         // Restore to factory setting data.
67         void FactoryReset( void );
68         // First setting of COM port.
69         void firstUartSetting( void );
70 };
71
72
73
74 #if 0
75 #define debug_printf(...)       {                                                       \
76         char* __temp__ = (char*)malloc(sizeof(char)*2048);              \
77         sprintf(__temp__, __VA_ARGS__ );                                        \
78         Serial.print(__temp__);                                                                 \
79         free(__temp__);                                                                                                 \
80 }
81 #else
82 #define debug_printf(...)
83 #endif
84
85
86
87 #endif /* BLELIB_H_ */