1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
26 #define BLE_NOCHANGE -1
30 #define BLE_DISCON 200
31 #define BLE_NODATA 100
34 /***************************************
36 * HM-10 BLE Module Control Class.
37 * Target Board : Arduino-Mega.
39 **************************************/
44 * BLE Control Function.
46 // BLE initialization ( COM baud rate , BLE Master , Slave setting. )
47 void init(long baudRate, int ble_mode, char *SelfMaxAddr);
49 void StatusRead( void );
51 bool IsSelfArduino( void );
53 bool IsConnected( void );
55 bool pollingConnect( const char *maxAddr );
57 void pollingDisconnect( void );
58 // Get RSSI by BLE communication. (polling method.)
59 int pollingGetRSSI( void );
60 // Send Request to BLE Module. And, Get the response. (polling method.)
61 bool pollingRequest(const char *request, char *data, int dataLen);
63 int mustHaveRequest(const char *request, char *data, int dataLen);
65 void streamDummy( char *data, int dataLen);
68 * Debug COM port to BLE COM port.
69 * BLE COM port to Debug COM port.
71 // BLE Module to Debug Serial port.
72 void BLE2Debug( int autoDiscon );
73 // Debug Serial port to BLE Module.
74 char *Debug2BLE( int BLEwrite );
77 * If you first setting, you need next-function.
79 // Restore to factory setting data.
80 void FactoryReset( void );
81 // First setting of COM port.
82 void firstUartSetting( void );
88 #define debug_printf(...) { \
89 char* __temp__ = (char*)malloc(sizeof(char)*2048); \
90 sprintf(__temp__, __VA_ARGS__ ); \
91 Serial.print(__temp__); \
95 #define debug_printf(...)
100 #endif /* BLELIB_H_ */