Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SoftSensorPlugin / IndoorTrajectorySensor / include / tizen_ble_bgthread.h
1 /******************************************************************
2 *
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
4 *
5 *
6 *
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
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 ******************************************************************/
20
21 #ifndef BLE_LIB_H_
22 #define BLE_LIB_H_
23
24 #include <bluetooth.h>
25 #include "tizen_CbleDevice.h"
26
27 void what_return_value( bt_error_e returnValue );
28
29
30 #define PROCESS_FREE                0
31 #define PROCESS_TRYING          1
32 #define PROCESS_FOUND               2
33 #define PROCESS_COMPLETE        3
34
35 class CbleBGthread
36 {
37     public :
38         typedef void (*workfunc)( void *);
39
40     private :
41         static CbleBGthread *singleton;
42
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;
48
49         static bool ble_discovery( void );
50
51         static bool find_referenceThing( bt_adapter_device_discovery_info_s *discovery_info ,
52                                          CbleDevice *pdevice );
53
54     public :
55         static bool isThreadRun;
56         static pthread_t Thandle;
57
58         CbleBGthread( workfunc func );
59
60         ~CbleBGthread( void );
61
62         static CbleBGthread *GetInstance( workfunc func );
63
64         // ETC. function List.
65 //  static void set_workProcess(workfunc func);
66         static void set_adapter_state_flag(void);
67
68
69         // Thread List.
70         static void *ble_thread(void *param);
71         // Callback List.
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);
77
78 };
79
80
81 //#define BT_ERROR_CHECK( _FUNC_ )      {                               \
82 //      bt_error_e __err__ = (bt_error_e)(_FUNC_);      \
83 //  if ( __err__ != BT_ERROR_NONE )                             \
84 //  {                                                                                                   \
85 //      what_return_value( __err__ );                               \
86 //      goto BT_ERROR;                                              \
87 //  }                                                                               \
88 //}
89
90
91 #endif /* BLE_LIB_H_ */