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 ******************************************************************/
24 #include <bluetooth.h>
25 #include "tizen_CbleDevice.h"
27 void what_return_value( bt_error_e returnValue );
30 #define PROCESS_FREE 0
31 #define PROCESS_TRYING 1
32 #define PROCESS_FOUND 2
33 #define PROCESS_COMPLETE 3
38 typedef void (*workfunc)( void *);
41 static CbleBGthread *singleton;
43 static bool ble_adapter_flag;
44 static int ble_discover_flag;
45 static int ble_bond_flag;
46 static int reg_bond_cnt;
47 static workfunc workProcess;
49 static bool ble_discovery( void );
51 static bool find_referenceThing( bt_adapter_device_discovery_info_s *discovery_info ,
52 CbleDevice *pdevice );
55 static bool isThreadRun;
56 static pthread_t Thandle;
58 CbleBGthread( workfunc func );
60 ~CbleBGthread( void );
62 static CbleBGthread *GetInstance( workfunc func );
64 // ETC. function List.
65 // static void set_workProcess(workfunc func);
66 static void set_adapter_state_flag(void);
70 static void *ble_thread(void *param);
72 static void CB_adapter_state_change(int result, bt_adapter_state_e adapter_state, void *user_data);
73 static void CB_discover_state_change(int result,
74 bt_adapter_device_discovery_state_e discovery_state,
75 bt_adapter_device_discovery_info_s *discovery_info, void *user_data);
76 static void CB_bond_create(int result, bt_device_info_s *device_info, void *user_data);
81 //#define BT_ERROR_CHECK( _FUNC_ ) { \
82 // bt_error_e __err__ = (bt_error_e)(_FUNC_); \
83 // if ( __err__ != BT_ERROR_NONE ) \
85 // what_return_value( __err__ ); \
91 #endif /* BLE_LIB_H_ */