Added API to disable starting advertisement automatically
[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 "camanagerleinterface.h"
24 #include "cacommon.h"
25 #include "camessagehandler.h"
26 #include "caleserver.h"
27 #include "cagattservice.h"
28 #include "logger.h"
29
30 #define TAG "OIC_CA_MANAGER_TZ_LE"
31
32 void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
33                                     CAConnectionStateChangedCB connStateCB)
34 {
35     (void)adapterStateCB;
36     (void)connStateCB;
37     OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
38 }
39
40 CAResult_t CAManagerLEStartAdvertising()
41 {
42     OIC_LOG(DEBUG, TAG, "CAManagerLEStartAdvertising");
43
44     CAResult_t res = CALEStartAdvertise();
45     if (CA_STATUS_OK != res)
46     {
47         OIC_LOG_V(ERROR, TAG, "Failed to start le advertising [%d]", res);
48         return res;
49     }
50     return res;
51 }
52
53 CAResult_t CAManagerLEStopAdvertising()
54 {
55     OIC_LOG(DEBUG, TAG, "CAManagerLEStopAdvertising");
56
57     CAResult_t res = CALEStopAdvertise();
58     if (CA_STATUS_OK != res)
59     {
60         OIC_LOG_V(ERROR, TAG, "Failed to stop le advertising [%d]", res);
61         return res;
62     }
63     return res;
64 }
65
66 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
67 {
68     OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
69     (void)address;
70     return CA_NOT_SUPPORTED;
71 }
72
73 CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
74 {
75     OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
76     (void)address;
77     return CA_NOT_SUPPORTED;
78 }
79 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
80 CAResult_t CAManagerLEServerSetAdvertisementData(const char *data, int length)
81 {
82
83     CAResult_t res =  CAsetServerAdvertisementData(data, length);
84
85     if (CA_STATUS_OK != res)
86     {
87         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAManagerLEServerSetAdvertisementData [%d]", res);
88         return;
89     }
90 }
91
92 void CAManagerLEServerSetAdvertisementDataGetter(CAAdvertisementDataGetterCB getter)
93 {
94     return CAsetServerAdvertisementDataGetter(getter);
95 }
96
97 void CAManagerLEServerSetAutoAdvertisement(bool autoAdvertisement)
98 {
99     return CAsetServerAutoAdvertisement(autoAdvertisement);
100 }
101
102 CAResult_t CAManagerLEServerSetScanResponseData(const char *data, int length)
103 {
104
105     CAResult_t res =  CAsetServerScanResponseData(data, length);
106
107     if (CA_STATUS_OK != res)
108     {
109         OIC_LOG_V(ERROR, TAG, "Failed to stop le CAsetServerSanResponseData [%d]", res);
110         return;
111     }
112 }
113 #endif