2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // @file FNetBtBluetoothDevice.cpp
18 // @brief This is the implementation file for the BluetoothDevice class.
21 #include <FNetBtBluetoothTypes.h>
22 #include <FNetBtBluetoothDevice.h>
23 #include <FAppAppControl.h>
24 #include <FBaseColIList.h>
25 #include <FBaseColIMap.h>
26 #include <FBaseBoolean.h>
27 #include <FBaseInteger.h>
28 #include <FBaseLong.h>
29 #include <FBaseShort.h>
30 #include <FBaseSysLog.h>
31 #include "FNetBt_BluetoothDeviceImpl.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Runtime;
36 namespace Tizen { namespace Net { namespace Bluetooth
39 // The serial port profile UUID. (00001101-0000-1000-8000-00805F9B34FB)
40 const byte BT_SVC_UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
42 // The LAN access profile UUID. (00001102-0000-1000-8000-00805F9B34FB)
43 const byte BT_SVC_UUID_LAP[] = {0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
45 // The dial-up networking profile UUID. (00001103-0000-1000-8000-00805F9B34FB)
46 const byte BT_SVC_UUID_DUN[] = {0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
48 // The synchronization profile UUID. (00001104-0000-1000-8000-00805F9B34FB)
49 const byte BT_SVC_UUID_SYNC[] = {0x00, 0x00, 0x11, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
51 // The object push profile UUID. (00001105-0000-1000-8000-00805F9B34FB)
52 const byte BT_SVC_UUID_OPP[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
54 // The file transfer profile UUID. (00001106-0000-1000-8000-00805F9B34FB)
55 const byte BT_SVC_UUID_FTP[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
57 // The synchronization profile UUID. (00001107-0000-1000-8000-00805F9B34FB)
58 const byte BT_SVC_UUID_SYNC_COMMAND[] = {0x00, 0x00, 0x11, 0x07, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
60 // The headset profile UUID. (00001108-0000-1000-8000-00805F9B34FB)
61 const byte BT_SVC_UUID_HSP[] = {0x00, 0x00, 0x11, 0x08, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
63 // The cordless telephony profile UUID. (00001109-0000-1000-8000-00805F9B34FB)
64 const byte BT_SVC_UUID_CTP[] = {0x00, 0x00, 0x11, 0x09, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
66 // The advanced audio distribution profile - source UUID. (0000110A-0000-1000-8000-00805F9B34FB)
67 const byte BT_SVC_UUID_A2DP_SOURCE[] = {0x00, 0x00, 0x11, 0x0A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
69 // The advanced audio distribution profile - sink UUID. (0000110B-0000-1000-8000-00805F9B34FB)
70 const byte BT_SVC_UUID_A2DP_SINK[] = {0x00, 0x00, 0x11, 0x0B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
72 // The audio/video remote control profile - target UUID. (0000110C-0000-1000-8000-00805F9B34FB)
73 const byte BT_SVC_UUID_AVRCP_TARGET[] = {0x00, 0x00, 0x11, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
75 // The advanced audio distribution profile UUID. (0000110D-0000-1000-8000-00805F9B34FB)
76 const byte BT_SVC_UUID_A2DP[] = {0x00, 0x00, 0x11, 0x0D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
78 // The audio/video remote control profile UUID. (0000110E-0000-1000-8000-00805F9B34FB)
79 const byte BT_SVC_UUID_AVRCP[] = {0x00, 0x00, 0x11, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
81 // The audio/video remote control profile - controller UUID. (0000110F-0000-1000-8000-00805F9B34FB)
82 const byte BT_SVC_UUID_AVRCP_CONTROLLER[] = {0x00, 0x00, 0x11, 0x0F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
84 // The intercom profile UUID. (00001110-0000-1000-8000-00805F9B34FB)
85 const byte BT_SVC_UUID_ICP[] = {0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
87 // The fax profile UUID. (00001111-0000-1000-8000-00805F9B34FB)
88 const byte BT_SVC_UUID_FAX[] = {0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
90 // The headset profile - audio gateway UUID. (00001112-0000-1000-8000-00805F9B34FB)
91 const byte BT_SVC_UUID_HSP_AG[] = {0x00, 0x00, 0x11, 0x12, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
93 // The personal area networking profile - user UUID. (00001115-0000-1000-8000-00805F9B34FB)
94 const byte BT_SVC_UUID_PAN_PANU[] = {0x00, 0x00, 0x11, 0x15, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
96 // The personal area networking profile - network access point UUID. (00001116-0000-1000-8000-00805F9B34FB)
97 const byte BT_SVC_UUID_PAN_NAP[] = {0x00, 0x00, 0x11, 0x16, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
99 // The personal area networking profile - group ad-hoc networks UUID. (00001117-0000-1000-8000-00805F9B34FB)
100 const byte BT_SVC_UUID_PAN_GN[] = {0x00, 0x00, 0x11, 0x17, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
102 // The basic printing profile - direct printing UUID. (00001118-0000-1000-8000-00805F9B34FB)
103 const byte BT_SVC_UUID_BPP_DIRECT_PRINTING[] = {0x00, 0x00, 0x11, 0x18, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
105 // The basic printing profile - reference printing UUID. (00001119-0000-1000-8000-00805F9B34FB)
106 const byte BT_SVC_UUID_BPP_REFERENCE_PRINTING[] = {0x00, 0x00, 0x11, 0x19, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
108 // The basic imaging profile UUID. (0000111A-0000-1000-8000-00805F9B34FB)
109 const byte BT_SVC_UUID_BIP[] = {0x00, 0x00, 0x11, 0x1A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
111 // The basic imaging profile - imaging responder UUID. (0000111B-0000-1000-8000-00805F9B34FB)
112 const byte BT_SVC_UUID_BIP_RESPONDER[] = {0x00, 0x00, 0x11, 0x1B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
114 // The basic imaging profile - imaging automatic archive UUID. (0000111C-0000-1000-8000-00805F9B34FB)
115 const byte BT_SVC_UUID_BIP_AUTOMATIC_ARCHIVE[] = {0x00, 0x00, 0x11, 0x1C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
117 // The basic imaging profile - imaging referenced objects UUID. (0000111D-0000-1000-8000-00805F9B34FB)
118 const byte BT_SVC_UUID_BIP_REFERENCED_OBJECTS[] = {0x00, 0x00, 0x11, 0x1D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
120 // The hands-free profile UUID. (0000111E-0000-1000-8000-00805F9B34FB)
121 const byte BT_SVC_UUID_HFP[] = {0x00, 0x00, 0x11, 0x1E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
123 // The hands-free profile - audio gateway UUID. (0000111F-0000-1000-8000-00805F9B34FB)
124 const byte BT_SVC_UUID_HFP_AG[] = {0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
126 // The basic printing profile - direct printing referenced objects UUID. (00001120-0000-1000-8000-00805F9B34FB)
127 const byte BT_SVC_UUID_BPP_DIRECT_PRINTING_RO[] = {0x00, 0x00, 0x11, 0x20, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
129 // The basic printing profile - reflected UI UUID. (00001121-0000-1000-8000-00805F9B34FB)
130 const byte BT_SVC_UUID_BPP_REFLECTED_UI[] = {0x00, 0x00, 0x11, 0x21, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
132 // The basic printing profile - basic printing UUID. (00001122-0000-1000-8000-00805F9B34FB)
133 const byte BT_SVC_UUID_BPP_BASIC_PRINTING[] = {0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
135 // The basic printing profile - printing status UUID. (00001123-0000-1000-8000-00805F9B34FB)
136 const byte BT_SVC_UUID_BPP_PRINTING_STATUS[] = {0x00, 0x00, 0x11, 0x23, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
138 // The human interface device profile UUID. (00001124-0000-1000-8000-00805F9B34FB)
139 const byte BT_SVC_UUID_HID[] = {0x00, 0x00, 0x11, 0x24, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
141 // The hardcopy cable replacement profile UUID. (00001125-0000-1000-8000-00805F9B34FB)
142 const byte BT_SVC_UUID_HCRP[] = {0x00, 0x00, 0x11, 0x25, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
144 // The hardcopy cable replacement profile - print UUID. (00001126-0000-1000-8000-00805F9B34FB)
145 const byte BT_SVC_UUID_HCRP_PRINT[] = {0x00, 0x00, 0x11, 0x26, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
147 // The hardcopy cable replacement profile - scan UUID. (00001127-0000-1000-8000-00805F9B34FB)
148 const byte BT_SVC_UUID_HCRP_SCAN[] = {0x00, 0x00, 0x11, 0x27, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
150 // The SIM access profile UUID. (0000112D-0000-1000-8000-00805F9B34FB)
151 const byte BT_SVC_UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
153 // The phone book access - client equipment UUID. (0000112E-0000-1000-8000-00805F9B34FB)
154 const byte BT_SVC_UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
156 // The phone book access - server equipment UUID. (0000112F-0000-1000-8000-00805F9B34FB)
157 const byte BT_SVC_UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
159 // The phone book access UUID. (00001130-0000-1000-8000-00805F9B34FB)
160 const byte BT_SVC_UUID_PBAP[] = {0x00, 0x00, 0x11, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
162 // The headset profile - headset UUID. (00001131-0000-1000-8000-00805F9B34FB)
163 const byte BT_SVC_UUID_HSP_HS[] = {0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
165 // The message access profile - message access server UUID. (00001132-0000-1000-8000-00805F9B34FB)
166 const byte BT_SVC_UUID_MAP_ACCESS_SERVER[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
168 // The message access profile - message notification server UUID. (00001133-0000-1000-8000-00805F9B34FB)
169 const byte BT_SVC_UUID_MAP_NOTIFICATION_SERVER[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
171 // The message access profile - message access profile UUID. (00001134-0000-1000-8000-00805F9B34FB)
172 const byte BT_SVC_UUID_MAP_ACCESS_PROFILE[] = {0x00, 0x00, 0x11, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
174 // The device identification profile - PNP information UUID. (00001200-0000-1000-8000-00805F9B34FB)
175 const byte BT_SVC_UUID_DID_PNP_INFORMATION[] = {0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
177 // The generic networking UUID. (00001201-0000-1000-8000-00805F9B34FB)
178 const byte BT_SVC_UUID_GENERIC_NETWORKING[] = {0x00, 0x00, 0x12, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
180 // The generic file transfer UUID. (00001202-0000-1000-8000-00805F9B34FB)
181 const byte BT_SVC_UUID_GENERIC_FILE_TRANSFER[] = {0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
183 // The generic audio UUID. (00001203-0000-1000-8000-00805F9B34FB)
184 const byte BT_SVC_UUID_GENERIC_AUDIO[] = {0x00, 0x00, 0x12, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
186 // The generic telephony UUID. (00001204-0000-1000-8000-00805F9B34FB)
187 const byte BT_SVC_UUID_GENERIC_TELEPHONY[] = {0x00, 0x00, 0x12, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
189 // The video distribution profile - source UUID. (00001303-0000-1000-8000-00805F9B34FB)
190 const byte BT_SVC_UUID_VDP_SOURCE[] = {0x00, 0x00, 0x13, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
192 // The video distribution profile - sink UUID. (00001304-0000-1000-8000-00805F9B34FB)
193 const byte BT_SVC_UUID_VDP_SINK[] = {0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
195 // The video distribution profile - distribution UUID. (00001305-0000-1000-8000-00805F9B34FB)
196 const byte BT_SVC_UUID_VDP_DISTRIBUTION[] = {0x00, 0x00, 0x13, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
198 // The health device profile UUID. (00001400-0000-1000-8000-00805F9B34FB)
199 const byte BT_SVC_UUID_HDP[] = {0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
201 // The health device profile - source UUID. (00001401-0000-1000-8000-00805F9B34FB)
202 const byte BT_SVC_UUID_HDP_SOURCE[] = {0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
204 // The health device profile - sink UUID. (00001402-0000-1000-8000-00805F9B34FB)
205 const byte BT_SVC_UUID_HDP_SINK[] = {0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
208 BluetoothDevice::BluetoothDevice(void)
211 __pImpl = new (std::nothrow) _BluetoothDeviceImpl();
212 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
215 BluetoothDevice::BluetoothDevice(const Tizen::Base::ByteBuffer& address, const Base::String& deviceName, BluetoothMajorDeviceClassType majorClassType, BluetoothMinorDeviceClassType minorClassType, unsigned long serviceClassList, unsigned long serviceList)
218 __pImpl = new (std::nothrow) _BluetoothDeviceImpl(address, deviceName, majorClassType, minorClassType, serviceClassList, serviceList);
219 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
222 BluetoothDevice::BluetoothDevice(const BluetoothDevice& value)
225 __pImpl = new (std::nothrow) _BluetoothDeviceImpl(*value.__pImpl);
226 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
229 BluetoothDevice::~BluetoothDevice(void)
235 BluetoothDevice::operator =(const BluetoothDevice& rhs)
239 *__pImpl = *rhs.__pImpl;
245 const Tizen::Base::ByteBuffer*
246 BluetoothDevice::GetAddress(void) const
248 return __pImpl->GetAddress();
252 BluetoothDevice::SetAddress(const Tizen::Base::ByteBuffer& address)
254 return __pImpl->SetAddress(address);
258 BluetoothDevice::GetName(void) const
260 return __pImpl->GetName();
264 BluetoothDevice::IsPaired(void) const
266 return __pImpl->IsPaired();
270 BluetoothDevice::GetRssi(void) const
272 return __pImpl->GetRssi();
275 BluetoothMajorDeviceClassType
276 BluetoothDevice::GetMajorDeviceClassType(void) const
278 return __pImpl->GetMajorDeviceClassType();
281 BluetoothMinorDeviceClassType
282 BluetoothDevice::GetMinorDeviceClassType(void) const
284 return __pImpl->GetMinorDeviceClassType();
288 BluetoothDevice::GetServiceClassList(void) const
290 return __pImpl->GetServiceClassList();
294 BluetoothDevice::GetServiceList(void) const
296 return __pImpl->GetServiceList();
299 const Tizen::Base::Collection::IList*
300 BluetoothDevice::GetServiceUuidList(void) const
302 return __pImpl->GetServiceUuidList();
306 BluetoothDevice::Equals(const Tizen::Base::Object& obj) const
308 const BluetoothDevice* pOther = dynamic_cast <const BluetoothDevice*>(&obj);
320 return(__pImpl->Equals(*(pOther->__pImpl)));
324 BluetoothDevice::GetHashCode(void) const
326 return __pImpl->GetHashCode();
330 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IList& appControlResult)
332 BluetoothDevice* pNewBtDevice = null;
333 String* pResultStrPtr = null;
336 ByteBuffer btAddrBytes;
338 long majClassType = 0;
339 long minClassType = 0;
340 long svcClassType = 0;
345 if (appControlResult.GetCount() != 7)
350 pResultStrPtr = (String*) appControlResult.GetAt(0);
351 if (pResultStrPtr->Equals(String(Tizen::App::APPCONTROL_RESULT_SUCCEEDED)) == false)
356 // Gets the address from index 1 as a String. E.g. 00-1E-2B-72-08-DB
357 pResultStrPtr = (String*) appControlResult.GetAt(1);
358 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
359 (keywordStr.Equals(String("addr_val:")) == false) ||
360 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
365 // Convert the type of the address to ByteBuffer
366 btAddrBytes.Construct(6);
367 if (_BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes) != E_SUCCESS)
375 // Gets the name from index 2
376 pResultStrPtr = (String*) appControlResult.GetAt(2);
377 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
378 (keywordStr.Equals(String("dev_name:")) == false) ||
379 (pResultStrPtr->SubString(9, deviceName) != E_SUCCESS))
386 // Gets the major device class from index 3
387 pResultStrPtr = (String*) appControlResult.GetAt(3);
388 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
389 (keywordStr.Equals(String("maj_cls_type:")) == false) ||
390 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
395 if (Long::Decode(dataStr, majClassType) != E_SUCCESS)
403 // Gets the minor device class from index 4
404 pResultStrPtr = (String*) appControlResult.GetAt(4);
405 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
406 (keywordStr.Equals(String("min_cls_type:")) == false) ||
407 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
412 if (Long::Decode(dataStr, minClassType) != E_SUCCESS)
420 // Gets the service classes as a bit-mask from index 5
421 pResultStrPtr = (String*) appControlResult.GetAt(5);
422 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
423 (keywordStr.Equals(String("svc_cls_type:")) == false) ||
424 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
429 if (Long::Decode(dataStr, svcClassType) != E_SUCCESS)
437 // Gets the service types as a bit-mask from index 6
438 pResultStrPtr = (String*) appControlResult.GetAt(6);
439 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
440 (keywordStr.Equals(String("svc_type:")) == false) ||
441 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
446 if (Long::Decode(dataStr, svcType) != E_SUCCESS)
451 // Create an instance of BluetoothDevice.
453 new (std::nothrow) BluetoothDevice(btAddrBytes, deviceName, (BluetoothMajorDeviceClassType) majClassType,
454 (BluetoothMinorDeviceClassType) minClassType, svcClassType,
456 if (pNewBtDevice == null)
458 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
459 SetLastResult(E_OUT_OF_MEMORY);
466 SysLogException(NID_NET_BT, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.");
467 SetLastResult(E_INVALID_ARG);
473 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IMap& appControlResult)
475 result r = E_SUCCESS;
476 BluetoothDevice* pNewBtDevice = null;
477 _BluetoothDeviceImpl* pNewBtDeviceImpl = null;
478 String* pResultStrPtr = null;
480 ByteBuffer btAddrBytes;
483 bool isPaired = false;
484 long majClassType = 0;
485 long minClassType = 0;
486 long svcClassType = 0;
491 // Gets the address as a String. E.g. 00-1E-2B-72-08-DB
492 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/address"));
493 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
495 dataStr.Insert(*pResultStrPtr, 0);
497 // Convert the type of the address to ByteBuffer
498 btAddrBytes.Construct(6);
499 r = _BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes);
500 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
505 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/name"));
506 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
507 deviceName.Insert(*pResultStrPtr, 0);
509 // Gets the rssi value
510 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/rssi"));
511 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
512 dataStr.Insert(*pResultStrPtr, 0);
514 r = Integer::Decode(dataStr, rssi);
515 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
520 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/is_paired"));
521 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
522 dataStr.Insert(*pResultStrPtr, 0);
524 isPaired = Boolean::Parse(dataStr);
528 // Gets the major device class
529 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/major_class"));
530 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
531 dataStr.Insert(*pResultStrPtr, 0);
533 r = Long::Decode(dataStr, majClassType);
534 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
538 // Gets the minor device class
539 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/minor_class"));
540 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
541 dataStr.Insert(*pResultStrPtr, 0);
543 r = Long::Decode(dataStr, minClassType);
544 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
548 // Gets the service classes as a bit-mask
549 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_class"));
550 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
551 dataStr.Insert(*pResultStrPtr, 0);
553 r = Long::Decode(dataStr, svcClassType);
554 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
558 // Gets the service types as a bit-mask
559 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_type"));
560 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
561 dataStr.Insert(*pResultStrPtr, 0);
563 r = Long::Decode(dataStr, svcType);
564 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
566 // Create an instance of BluetoothDevice.
567 pNewBtDevice = new (std::nothrow) BluetoothDevice();
568 if (pNewBtDevice == null)
570 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
571 SetLastResult(E_OUT_OF_MEMORY);
575 pNewBtDeviceImpl = _BluetoothDeviceImpl::GetInstance(*pNewBtDevice);
577 pNewBtDeviceImpl->SetAddress(btAddrBytes);
578 pNewBtDeviceImpl->SetName(deviceName);
579 pNewBtDeviceImpl->SetPaired(isPaired);
580 pNewBtDeviceImpl->SetRssi(rssi);
581 pNewBtDeviceImpl->SetMajorDeviceClassType((BluetoothMajorDeviceClassType) majClassType);
582 pNewBtDeviceImpl->SetMinorDeviceClassType((BluetoothMinorDeviceClassType) minClassType);
583 pNewBtDeviceImpl->SetServiceClassList(svcClassType);
584 pNewBtDeviceImpl->SetServiceList(svcType);
589 } } } // Tizen::Net::Bluetooth