Update snapshot(2017-12-06)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / camanager / bt_le_manager / tizen / caleconnectionmanager.c
1 /* ****************************************************************
2  *
3  * Copyright 2016 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 #include <bluetooth.h>
22 #include <bluetooth_type.h>
23 #include <bluetooth_internal.h>
24
25 #include "camanagerleinterface.h"
26 #include "cacommon.h"
27 #include "camessagehandler.h"
28 #include "caleserver.h"
29 #include "cagattservice.h"
30 #include "logger.h"
31
32 #define TAG "OIC_CA_MANAGER_TZ_LE"
33
34 static CAAdapterStateChangedCB g_adapterStateCB = NULL;
35 static CAConnectionStateChangedCB g_connStateCB = NULL;
36
37 static void CAManagerAdapterMonitorHandler(const CAEndpoint_t *info, CANetworkStatus_t status);
38 static void CAManagerConnectionMonitorHandler(CATransportAdapter_t adapter,
39                                               const char *remoteAddress, bool connected);
40
41 void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
42                                     CAConnectionStateChangedCB connStateCB)
43 {
44     (void)adapterStateCB;
45     (void)connStateCB;
46     OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
47 }
48
49 CAResult_t CAManagerLEStartAdvertising()
50 {
51     OIC_LOG(DEBUG, TAG, "CAManagerLEStartAdvertising");
52
53     CAResult_t res = CALEStartAdvertise();
54     if (CA_STATUS_OK != res)
55     {
56         OIC_LOG_V(ERROR, TAG, "Failed to start le advertising [%d]", res);
57         return res;
58     }
59     return res;
60 }
61
62 CAResult_t CAManagerLEStopAdvertising()
63 {
64     OIC_LOG(DEBUG, TAG, "CAManagerLEStopAdvertising");
65
66     CAResult_t res = CALEStopAdvertise();
67     if (CA_STATUS_OK != res)
68     {
69         OIC_LOG_V(ERROR, TAG, "Failed to stop le advertising [%d]", res);
70         return res;
71     }
72     return res;
73 }
74
75 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
76 {
77     OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
78     (void)address;
79     return CA_NOT_SUPPORTED;
80 }
81
82 CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
83 {
84     OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
85     (void)address;
86     return CA_NOT_SUPPORTED;
87 }
88 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
89 CAResult_t CAManagerLEServerSetAdvertisementData(const char *data, int length)
90 {
91
92     CAResult_t res =  CAsetServerAdvertisementData(data, length);
93
94     if (CA_STATUS_OK != res)
95     {
96         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAManagerLEServerSetAdvertisementData [%d]", res);
97         return;
98     }
99 }
100
101 CAResult_t CAManagerLEServerSetScanResponseData(const char *data, int length)
102 {
103
104     CAResult_t res =  CAsetServerSanResponseData(data, length);
105
106     if (CA_STATUS_OK != res)
107     {
108         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAsetServerSanResponseData [%d]", res);
109         return;
110     }
111 }
112 #endif