[SSM] Modify ommited arduino sample and soft sensor sample
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SoftSensorPlugin / IndoorTrajectorySensor / include / tizen_proximity.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 TIZEN_PROXIMITY_H_
22 #define TIZEN_PROXIMITY_H_
23
24 #include <bluetooth.h>
25 #include <map>
26 #include "tizen_CbleDevice.h"
27
28 void proximity_loop( void *param );
29 void what_return_value( bt_error_e returnValue );
30
31 #define JOB_NONE                0
32 #define JOB_GET_RSSI        1
33 #define JOB_GET_PROX        2
34 #define JOB_PUT_OUTPUT  3
35 #define JOB_BUSY                4
36
37 class CRSSI
38 {
39     public:
40         int cnt;
41         int *rssi;
42
43         CRSSI() : cnt(0), rssi(0) {}
44         CRSSI( int count ) : cnt(0), rssi(0) {   init(count);    }
45         ~CRSSI()
46         {
47             if ( rssi )
48             {
49                 cnt = 0;
50                 delete [] rssi;
51                 rssi = 0;
52             }
53         }
54
55         void init( int count )
56         {
57             if ( rssi == NULL )
58             {
59                 rssi = new int[count];
60                 cnt = count;
61             }
62         }
63
64 };
65
66 class CProximity
67 {
68     public :
69         typedef void *(*workfunc)( void *);
70         typedef std::map<std::string, CRSSI>    rssiMAP;
71     private :
72         static int loop_flag;
73         static int get_rssi_cnt;
74         static int num_set_rssi;
75         static rssiMAP map_rssi;
76
77         workfunc threadFunc;
78
79         int reference_ea;
80         float *m_distance;
81         int *m_proximity;
82     public :
83         pthread_t Thandle;
84
85         CProximity( workfunc func );
86
87         ~CProximity( void );
88
89         static bool find_referenceThing( bt_adapter_device_discovery_info_s *discovery_info ,
90                                          CbleDevice *pdevice );
91
92         static void CB_discover_state_change(int result,
93                                              bt_adapter_device_discovery_state_e discovery_state, \
94                                              bt_adapter_device_discovery_info_s *discovery_info, void *user_data);
95
96         bool GetRSSI(CbleDevice *pdevice);
97
98         void GetProximity(CbleDevice *pdevice);
99
100         bool set_threadFunc(workfunc func);
101
102         workfunc get_threadFunc(void);
103
104         void set_output( CbleDevice *pdevice );
105
106         void prox_first_setting( int reference_ea );
107
108         friend void proximity_loop( void *param );
109 };
110
111
112
113 #endif /* TIZEN_PROXIMITY_H_ */