2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <Commons/FunctionDefinition.h>
21 #include <Commons/FunctionDeclaration.h>
22 #include <Commons/Exception.h>
23 #include "plugin_config.h"
25 #define BLUETOOTH_FEATURE_API "http://tizen.org/api/bluetooth"
26 #define BLUETOOTH_FEATURE_API_GAP "http://tizen.org/api/bluetooth.gap"
27 #define BLUETOOTH_FEATURE_API_SPP "http://tizen.org/api/bluetooth.spp"
29 #define BLUETOOTH_DEVICE_CAP_GAP "bluetooth.gap"
30 #define BLUETOOTH_DEVICE_CAP_SPP "bluetooth.spp"
35 const char* bluetoothExportedNames[] =
47 "registerRFCOMMServiceByUUID",
48 "unregisterRFCOMMService",
49 "connectToServiceByUUID",
57 static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions();
59 static WrtDeviceApis::Commons::FunctionMapping BluetoothFunctions =
60 createBluetoothFunctions();
62 DEFINE_FUNCTION_GETTER(Bluetooth, BluetoothFunctions);
64 static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions()
66 using namespace WrtDeviceApis::Commons;
68 ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_GAP, BLUETOOTH_DEVICE_CAP_GAP);
69 ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_SPP, BLUETOOTH_DEVICE_CAP_SPP);
71 ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
73 ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_GAP);
74 ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_GAP, DEVICE_CAP_BLUETOOTH_GAP);
76 ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_SPP);
77 ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_SPP, DEVICE_CAP_BLUETOOTH_SPP);
79 ACE_CREATE_FEATURE(FEATURE_BLUETOOTH, BLUETOOTH_FEATURE_API);
80 ACE_CREATE_FEATURE(FEATURE_GAP, BLUETOOTH_FEATURE_API_GAP);
81 ACE_CREATE_FEATURE(FEATURE_SPP, BLUETOOTH_FEATURE_API_SPP);
83 ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP);
84 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_BLUETOOTH);
85 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_GAP);
86 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_SPP);
88 ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_GAP);
89 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_BLUETOOTH);
90 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_GAP);
92 ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP);
93 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_BLUETOOTH);
94 ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_SPP);
97 FunctionMapping BluetoothFunctions;
99 AceFunction adapter = ACE_CREATE_FUNCTION(
101 bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
102 BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP,
105 BluetoothFunctions.insert(std::make_pair(
106 bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
109 for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED;
110 index <= BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM; index++)
112 AceFunction gapLoopFunc = ACE_CREATE_FUNCTION(
113 FUNCTION_GAP_DUMMY_FUNC_ID,
114 bluetoothExportedNames[index],
115 BLUETOOTH_FEATURES_BLUETOOTH_GAP,
116 DEVICE_LIST_BLUETOOTH_GAP);
118 BluetoothFunctions.insert(std::make_pair(
119 bluetoothExportedNames[index],
123 for (int index = BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE;
124 index <= BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE; index++)
126 AceFunction sppLoopFunc = ACE_CREATE_FUNCTION(
127 FUNCTION_SPP_DUMMY_FUNC_ID,
128 bluetoothExportedNames[index],
129 BLUETOOTH_FEATURES_BLUETOOTH_SPP,
130 DEVICE_LIST_BLUETOOTH_SPP);
132 BluetoothFunctions.insert(std::make_pair(
133 bluetoothExportedNames[index],
137 return BluetoothFunctions;
142 #undef BLUETOOTH_FEATURE_API
143 #undef BLUETOOTH_FEATURE_API_GAP
144 #undef BLUETOOTH_FEATURE_API_SPP
145 #undef BLUETOOTH_DEVICE_CAP_GAP
146 #undef BLUETOOTH_DEVICE_CAP_SPP