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 <FBaseColArrayList.h>
25 #include <FBaseColIList.h>
26 #include <FBaseColIMap.h>
27 #include <FBaseBoolean.h>
28 #include <FBaseInteger.h>
29 #include <FBaseLong.h>
30 #include <FBaseShort.h>
31 #include <FBaseSysLog.h>
32 #include "FNetBt_BluetoothDeviceImpl.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
38 namespace Tizen { namespace Net { namespace Bluetooth
41 // The serial port profile UUID. (00001101-0000-1000-8000-00805F9B34FB)
42 const byte BT_SVC_UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
44 // The LAN access profile UUID. (00001102-0000-1000-8000-00805F9B34FB)
45 const byte BT_SVC_UUID_LAP[] = {0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
47 // The dial-up networking profile UUID. (00001103-0000-1000-8000-00805F9B34FB)
48 const byte BT_SVC_UUID_DUN[] = {0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
50 // The synchronization profile UUID. (00001104-0000-1000-8000-00805F9B34FB)
51 const byte BT_SVC_UUID_SYNC[] = {0x00, 0x00, 0x11, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
53 // The object push profile UUID. (00001105-0000-1000-8000-00805F9B34FB)
54 const byte BT_SVC_UUID_OPP[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
56 // The file transfer profile UUID. (00001106-0000-1000-8000-00805F9B34FB)
57 const byte BT_SVC_UUID_FTP[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
59 // The synchronization profile UUID. (00001107-0000-1000-8000-00805F9B34FB)
60 const byte BT_SVC_UUID_SYNC_COMMAND[] = {0x00, 0x00, 0x11, 0x07, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
62 // The headset profile UUID. (00001108-0000-1000-8000-00805F9B34FB)
63 const byte BT_SVC_UUID_HSP[] = {0x00, 0x00, 0x11, 0x08, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
65 // The cordless telephony profile UUID. (00001109-0000-1000-8000-00805F9B34FB)
66 const byte BT_SVC_UUID_CTP[] = {0x00, 0x00, 0x11, 0x09, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
68 // The advanced audio distribution profile - source UUID. (0000110A-0000-1000-8000-00805F9B34FB)
69 const byte BT_SVC_UUID_A2DP_SOURCE[] = {0x00, 0x00, 0x11, 0x0A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
71 // The advanced audio distribution profile - sink UUID. (0000110B-0000-1000-8000-00805F9B34FB)
72 const byte BT_SVC_UUID_A2DP_SINK[] = {0x00, 0x00, 0x11, 0x0B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
74 // The audio/video remote control profile - target UUID. (0000110C-0000-1000-8000-00805F9B34FB)
75 const byte BT_SVC_UUID_AVRCP_TARGET[] = {0x00, 0x00, 0x11, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
77 // The advanced audio distribution profile UUID. (0000110D-0000-1000-8000-00805F9B34FB)
78 const byte BT_SVC_UUID_A2DP[] = {0x00, 0x00, 0x11, 0x0D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
80 // The audio/video remote control profile UUID. (0000110E-0000-1000-8000-00805F9B34FB)
81 const byte BT_SVC_UUID_AVRCP[] = {0x00, 0x00, 0x11, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
83 // The audio/video remote control profile - controller UUID. (0000110F-0000-1000-8000-00805F9B34FB)
84 const byte BT_SVC_UUID_AVRCP_CONTROLLER[] = {0x00, 0x00, 0x11, 0x0F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
86 // The intercom profile UUID. (00001110-0000-1000-8000-00805F9B34FB)
87 const byte BT_SVC_UUID_ICP[] = {0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
89 // The fax profile UUID. (00001111-0000-1000-8000-00805F9B34FB)
90 const byte BT_SVC_UUID_FAX[] = {0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
92 // The headset profile - audio gateway UUID. (00001112-0000-1000-8000-00805F9B34FB)
93 const byte BT_SVC_UUID_HSP_AG[] = {0x00, 0x00, 0x11, 0x12, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
95 // The personal area networking profile - user UUID. (00001115-0000-1000-8000-00805F9B34FB)
96 const byte BT_SVC_UUID_PAN_PANU[] = {0x00, 0x00, 0x11, 0x15, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
98 // The personal area networking profile - network access point UUID. (00001116-0000-1000-8000-00805F9B34FB)
99 const byte BT_SVC_UUID_PAN_NAP[] = {0x00, 0x00, 0x11, 0x16, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
101 // The personal area networking profile - group ad-hoc networks UUID. (00001117-0000-1000-8000-00805F9B34FB)
102 const byte BT_SVC_UUID_PAN_GN[] = {0x00, 0x00, 0x11, 0x17, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
104 // The basic printing profile - direct printing UUID. (00001118-0000-1000-8000-00805F9B34FB)
105 const byte BT_SVC_UUID_BPP_DIRECT_PRINTING[] = {0x00, 0x00, 0x11, 0x18, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
107 // The basic printing profile - reference printing UUID. (00001119-0000-1000-8000-00805F9B34FB)
108 const byte BT_SVC_UUID_BPP_REFERENCE_PRINTING[] = {0x00, 0x00, 0x11, 0x19, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
110 // The basic imaging profile UUID. (0000111A-0000-1000-8000-00805F9B34FB)
111 const byte BT_SVC_UUID_BIP[] = {0x00, 0x00, 0x11, 0x1A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
113 // The basic imaging profile - imaging responder UUID. (0000111B-0000-1000-8000-00805F9B34FB)
114 const byte BT_SVC_UUID_BIP_RESPONDER[] = {0x00, 0x00, 0x11, 0x1B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
116 // The basic imaging profile - imaging automatic archive UUID. (0000111C-0000-1000-8000-00805F9B34FB)
117 const byte BT_SVC_UUID_BIP_AUTOMATIC_ARCHIVE[] = {0x00, 0x00, 0x11, 0x1C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
119 // The basic imaging profile - imaging referenced objects UUID. (0000111D-0000-1000-8000-00805F9B34FB)
120 const byte BT_SVC_UUID_BIP_REFERENCED_OBJECTS[] = {0x00, 0x00, 0x11, 0x1D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
122 // The hands-free profile UUID. (0000111E-0000-1000-8000-00805F9B34FB)
123 const byte BT_SVC_UUID_HFP[] = {0x00, 0x00, 0x11, 0x1E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
125 // The hands-free profile - audio gateway UUID. (0000111F-0000-1000-8000-00805F9B34FB)
126 const byte BT_SVC_UUID_HFP_AG[] = {0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
128 // The basic printing profile - direct printing referenced objects UUID. (00001120-0000-1000-8000-00805F9B34FB)
129 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};
131 // The basic printing profile - reflected UI UUID. (00001121-0000-1000-8000-00805F9B34FB)
132 const byte BT_SVC_UUID_BPP_REFLECTED_UI[] = {0x00, 0x00, 0x11, 0x21, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
134 // The basic printing profile - basic printing UUID. (00001122-0000-1000-8000-00805F9B34FB)
135 const byte BT_SVC_UUID_BPP_BASIC_PRINTING[] = {0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
137 // The basic printing profile - printing status UUID. (00001123-0000-1000-8000-00805F9B34FB)
138 const byte BT_SVC_UUID_BPP_PRINTING_STATUS[] = {0x00, 0x00, 0x11, 0x23, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
140 // The human interface device profile UUID. (00001124-0000-1000-8000-00805F9B34FB)
141 const byte BT_SVC_UUID_HID[] = {0x00, 0x00, 0x11, 0x24, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
143 // The hardcopy cable replacement profile UUID. (00001125-0000-1000-8000-00805F9B34FB)
144 const byte BT_SVC_UUID_HCRP[] = {0x00, 0x00, 0x11, 0x25, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
146 // The hardcopy cable replacement profile - print UUID. (00001126-0000-1000-8000-00805F9B34FB)
147 const byte BT_SVC_UUID_HCRP_PRINT[] = {0x00, 0x00, 0x11, 0x26, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
149 // The hardcopy cable replacement profile - scan UUID. (00001127-0000-1000-8000-00805F9B34FB)
150 const byte BT_SVC_UUID_HCRP_SCAN[] = {0x00, 0x00, 0x11, 0x27, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
152 // The SIM access profile UUID. (0000112D-0000-1000-8000-00805F9B34FB)
153 const byte BT_SVC_UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
155 // The phone book access - client equipment UUID. (0000112E-0000-1000-8000-00805F9B34FB)
156 const byte BT_SVC_UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
158 // The phone book access - server equipment UUID. (0000112F-0000-1000-8000-00805F9B34FB)
159 const byte BT_SVC_UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
161 // The phone book access UUID. (00001130-0000-1000-8000-00805F9B34FB)
162 const byte BT_SVC_UUID_PBAP[] = {0x00, 0x00, 0x11, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
164 // The headset profile - headset UUID. (00001131-0000-1000-8000-00805F9B34FB)
165 const byte BT_SVC_UUID_HSP_HS[] = {0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
167 // The message access profile - message access server UUID. (00001132-0000-1000-8000-00805F9B34FB)
168 const byte BT_SVC_UUID_MAP_ACCESS_SERVER[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
170 // The message access profile - message notification server UUID. (00001133-0000-1000-8000-00805F9B34FB)
171 const byte BT_SVC_UUID_MAP_NOTIFICATION_SERVER[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
173 // The message access profile - message access profile UUID. (00001134-0000-1000-8000-00805F9B34FB)
174 const byte BT_SVC_UUID_MAP_ACCESS_PROFILE[] = {0x00, 0x00, 0x11, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
176 // The device identification profile - PNP information UUID. (00001200-0000-1000-8000-00805F9B34FB)
177 const byte BT_SVC_UUID_DID_PNP_INFORMATION[] = {0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
179 // The generic networking UUID. (00001201-0000-1000-8000-00805F9B34FB)
180 const byte BT_SVC_UUID_GENERIC_NETWORKING[] = {0x00, 0x00, 0x12, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
182 // The generic file transfer UUID. (00001202-0000-1000-8000-00805F9B34FB)
183 const byte BT_SVC_UUID_GENERIC_FILE_TRANSFER[] = {0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
185 // The generic audio UUID. (00001203-0000-1000-8000-00805F9B34FB)
186 const byte BT_SVC_UUID_GENERIC_AUDIO[] = {0x00, 0x00, 0x12, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
188 // The generic telephony UUID. (00001204-0000-1000-8000-00805F9B34FB)
189 const byte BT_SVC_UUID_GENERIC_TELEPHONY[] = {0x00, 0x00, 0x12, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
191 // The video distribution profile - source UUID. (00001303-0000-1000-8000-00805F9B34FB)
192 const byte BT_SVC_UUID_VDP_SOURCE[] = {0x00, 0x00, 0x13, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
194 // The video distribution profile - sink UUID. (00001304-0000-1000-8000-00805F9B34FB)
195 const byte BT_SVC_UUID_VDP_SINK[] = {0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
197 // The video distribution profile - distribution UUID. (00001305-0000-1000-8000-00805F9B34FB)
198 const byte BT_SVC_UUID_VDP_DISTRIBUTION[] = {0x00, 0x00, 0x13, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
200 // The health device profile UUID. (00001400-0000-1000-8000-00805F9B34FB)
201 const byte BT_SVC_UUID_HDP[] = {0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
203 // The health device profile - source UUID. (00001401-0000-1000-8000-00805F9B34FB)
204 const byte BT_SVC_UUID_HDP_SOURCE[] = {0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
206 // The health device profile - sink UUID. (00001402-0000-1000-8000-00805F9B34FB)
207 const byte BT_SVC_UUID_HDP_SINK[] = {0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
210 BluetoothDevice::BluetoothDevice(void)
213 __pImpl = new (std::nothrow) _BluetoothDeviceImpl();
214 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
217 BluetoothDevice::BluetoothDevice(const Tizen::Base::ByteBuffer& address, const Base::String& deviceName, BluetoothMajorDeviceClassType majorClassType, BluetoothMinorDeviceClassType minorClassType, unsigned long serviceClassList, unsigned long serviceList)
220 __pImpl = new (std::nothrow) _BluetoothDeviceImpl(address, deviceName, majorClassType, minorClassType, serviceClassList, serviceList);
221 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
224 BluetoothDevice::BluetoothDevice(const BluetoothDevice& value)
227 __pImpl = new (std::nothrow) _BluetoothDeviceImpl(*value.__pImpl);
228 SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
231 BluetoothDevice::~BluetoothDevice(void)
237 BluetoothDevice::operator =(const BluetoothDevice& rhs)
241 *__pImpl = *rhs.__pImpl;
247 const Tizen::Base::ByteBuffer*
248 BluetoothDevice::GetAddress(void) const
250 return __pImpl->GetAddress();
254 BluetoothDevice::SetAddress(const Tizen::Base::ByteBuffer& address)
256 return __pImpl->SetAddress(address);
260 BluetoothDevice::GetName(void) const
262 return __pImpl->GetName();
266 BluetoothDevice::IsPaired(void) const
268 return __pImpl->IsPaired();
272 BluetoothDevice::GetRssi(void) const
274 return __pImpl->GetRssi();
277 BluetoothMajorDeviceClassType
278 BluetoothDevice::GetMajorDeviceClassType(void) const
280 return __pImpl->GetMajorDeviceClassType();
283 BluetoothMinorDeviceClassType
284 BluetoothDevice::GetMinorDeviceClassType(void) const
286 return __pImpl->GetMinorDeviceClassType();
290 BluetoothDevice::GetServiceClassList(void) const
292 return __pImpl->GetServiceClassList();
296 BluetoothDevice::GetServiceList(void) const
298 return __pImpl->GetServiceList();
301 const Tizen::Base::Collection::IList*
302 BluetoothDevice::GetServiceUuidList(void) const
304 return __pImpl->GetServiceUuidList();
308 BluetoothDevice::Equals(const Tizen::Base::Object& obj) const
310 const BluetoothDevice* pOther = dynamic_cast <const BluetoothDevice*>(&obj);
322 return(__pImpl->Equals(*(pOther->__pImpl)));
326 BluetoothDevice::GetHashCode(void) const
328 return __pImpl->GetHashCode();
332 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IList& appControlResult)
334 BluetoothDevice* pNewBtDevice = null;
335 String* pResultStrPtr = null;
338 ByteBuffer btAddrBytes;
340 long majClassType = 0;
341 long minClassType = 0;
342 long svcClassType = 0;
347 if (appControlResult.GetCount() != 7)
352 pResultStrPtr = (String*) appControlResult.GetAt(0);
353 if (pResultStrPtr->Equals(String(Tizen::App::APPCONTROL_RESULT_SUCCEEDED)) == false)
358 // Gets the address from index 1 as a String. E.g. 00-1E-2B-72-08-DB
359 pResultStrPtr = (String*) appControlResult.GetAt(1);
360 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
361 (keywordStr.Equals(String("addr_val:")) == false) ||
362 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
367 // Convert the type of the address to ByteBuffer
368 btAddrBytes.Construct(6);
369 if (_BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes) != E_SUCCESS)
377 // Gets the name from index 2
378 pResultStrPtr = (String*) appControlResult.GetAt(2);
379 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
380 (keywordStr.Equals(String("dev_name:")) == false) ||
381 (pResultStrPtr->SubString(9, deviceName) != E_SUCCESS))
388 // Gets the major device class from index 3
389 pResultStrPtr = (String*) appControlResult.GetAt(3);
390 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
391 (keywordStr.Equals(String("maj_cls_type:")) == false) ||
392 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
397 if (Long::Decode(dataStr, majClassType) != E_SUCCESS)
405 // Gets the minor device class from index 4
406 pResultStrPtr = (String*) appControlResult.GetAt(4);
407 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
408 (keywordStr.Equals(String("min_cls_type:")) == false) ||
409 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
414 if (Long::Decode(dataStr, minClassType) != E_SUCCESS)
422 // Gets the service classes as a bit-mask from index 5
423 pResultStrPtr = (String*) appControlResult.GetAt(5);
424 if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
425 (keywordStr.Equals(String("svc_cls_type:")) == false) ||
426 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
431 if (Long::Decode(dataStr, svcClassType) != E_SUCCESS)
439 // Gets the service types as a bit-mask from index 6
440 pResultStrPtr = (String*) appControlResult.GetAt(6);
441 if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
442 (keywordStr.Equals(String("svc_type:")) == false) ||
443 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
448 if (Long::Decode(dataStr, svcType) != E_SUCCESS)
453 // Create an instance of BluetoothDevice.
455 new (std::nothrow) BluetoothDevice(btAddrBytes, deviceName, (BluetoothMajorDeviceClassType) majClassType,
456 (BluetoothMinorDeviceClassType) minClassType, svcClassType,
458 if (pNewBtDevice == null)
460 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
461 SetLastResult(E_OUT_OF_MEMORY);
468 SysLogException(NID_NET_BT, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.");
469 SetLastResult(E_INVALID_ARG);
475 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IMap& appControlResult)
477 result r = E_SUCCESS;
478 BluetoothDevice* pNewBtDevice = null;
479 _BluetoothDeviceImpl* pNewBtDeviceImpl = null;
480 String* pResultStrPtr = null;
482 ByteBuffer btAddrBytes;
485 bool isPaired = false;
486 long majClassType = 0;
487 long minClassType = 0;
488 long svcClassType = 0;
490 ArrayList* pUuidList = null;
494 // Gets the address as a String. E.g. 00-1E-2B-72-08-DB
495 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/address"));
496 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
498 dataStr.Insert(*pResultStrPtr, 0);
500 // Convert the type of the address to ByteBuffer
501 btAddrBytes.Construct(6);
502 r = _BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes);
503 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
508 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/name"));
509 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
510 deviceName.Insert(*pResultStrPtr, 0);
512 // Gets the rssi value
513 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/rssi"));
514 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
515 dataStr.Insert(*pResultStrPtr, 0);
517 r = Integer::Decode(dataStr, rssi);
518 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
523 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/is_paired"));
524 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
525 dataStr.Insert(*pResultStrPtr, 0);
527 isPaired = Boolean::Parse(dataStr);
531 // Gets the major device class
532 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/major_class"));
533 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
534 dataStr.Insert(*pResultStrPtr, 0);
536 r = Long::Decode(dataStr, majClassType);
537 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
541 // Gets the minor device class
542 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/minor_class"));
543 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
544 dataStr.Insert(*pResultStrPtr, 0);
546 r = Long::Decode(dataStr, minClassType);
547 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
551 // Gets the service classes as a bit-mask
552 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_class"));
553 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
554 dataStr.Insert(*pResultStrPtr, 0);
556 r = Long::Decode(dataStr, svcClassType);
557 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
561 // Gets the service types as a bit-mask
562 pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_type"));
563 SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
564 dataStr.Insert(*pResultStrPtr, 0);
566 r = Long::Decode(dataStr, svcType);
567 SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
569 // Gets the service UUID list
570 pUuidList = (ArrayList*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/uuid_list"));
571 SysTryReturn(NID_NET_BT, pUuidList != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
573 // Create an instance of BluetoothDevice.
574 pNewBtDevice = new (std::nothrow) BluetoothDevice();
575 if (pNewBtDevice == null)
577 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
578 SetLastResult(E_OUT_OF_MEMORY);
582 pNewBtDeviceImpl = _BluetoothDeviceImpl::GetInstance(*pNewBtDevice);
584 pNewBtDeviceImpl->SetAddress(btAddrBytes);
585 pNewBtDeviceImpl->SetName(deviceName);
586 pNewBtDeviceImpl->SetPaired(isPaired);
587 pNewBtDeviceImpl->SetRssi(rssi);
588 pNewBtDeviceImpl->SetMajorDeviceClassType((BluetoothMajorDeviceClassType) majClassType);
589 pNewBtDeviceImpl->SetMinorDeviceClassType((BluetoothMinorDeviceClassType) minClassType);
590 pNewBtDeviceImpl->SetServiceClassList(svcClassType);
591 pNewBtDeviceImpl->SetServiceList(svcType);
592 pNewBtDeviceImpl->SetServiceUuidList(pUuidList, true);
597 } } } // Tizen::Net::Bluetooth