ecb6f61ba58dd3adb2d3f835b0a84f28ff3ebe0a
[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     OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
45
46 }
47
48 CAResult_t CAManagerLEStartAdvertising()
49 {
50     OIC_LOG(DEBUG, TAG, "CAManagerLEStartAdvertising");
51
52     CAResult_t res = CALEStartAdvertise();
53     if (CA_STATUS_OK != res)
54     {
55         OIC_LOG_V(ERROR, TAG, "Failed to start le advertising [%d]", res);
56         return res;
57     }
58     return res;
59 }
60
61 CAResult_t CAManagerLEStopAdvertising()
62 {
63     OIC_LOG(DEBUG, TAG, "CAManagerLEStopAdvertising");
64
65     CAResult_t res = CALEStopAdvertise();
66     if (CA_STATUS_OK != res)
67     {
68         OIC_LOG_V(ERROR, TAG, "Failed to stop le advertising [%d]", res);
69         return res;
70     }
71     return res;
72 }
73
74 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
75 {
76     OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
77     (void)address;
78     return CA_NOT_SUPPORTED;
79 }
80
81 CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
82 {
83     OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
84     (void)address;
85     return CA_NOT_SUPPORTED;
86 }
87 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
88 CAResult_t CAManagerLEServerSetAdvertisementData(const char *data, int length)
89 {
90
91     CAResult_t res =  CAsetServerAdvertisementData(data, length);
92
93     if (CA_STATUS_OK != res)
94     {
95         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAManagerLEServerSetAdvertisementData [%d]", res);
96         return;
97     }
98 }
99
100 CAResult_t CAManagerLEServerSetScanResponseData(const char *data, int length)
101 {
102
103     CAResult_t res =  CAsetServerSanResponseData(data, length);
104
105     if (CA_STATUS_OK != res)
106     {
107         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAsetServerSanResponseData [%d]", res);
108         return;
109     }
110 }
111 #endif