1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
//
// Open Service Platform
// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// @file FNetBtBluetoothDevice.cpp
// @brief This is the implementation file for the BluetoothDevice class.
//
#include <FNetBtBluetoothTypes.h>
#include <FNetBtBluetoothDevice.h>
#include <FAppAppControl.h>
#include <FBaseColArrayList.h>
#include <FBaseColIList.h>
#include <FBaseColIMap.h>
#include <FBaseBoolean.h>
#include <FBaseInteger.h>
#include <FBaseLong.h>
#include <FBaseShort.h>
#include <FBaseSysLog.h>
#include "FNetBt_BluetoothDeviceImpl.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Base::Runtime;
namespace Tizen { namespace Net { namespace Bluetooth
{
// The serial port profile UUID. (00001101-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The LAN access profile UUID. (00001102-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_LAP[] = {0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The dial-up networking profile UUID. (00001103-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_DUN[] = {0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The synchronization profile UUID. (00001104-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_SYNC[] = {0x00, 0x00, 0x11, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The object push profile UUID. (00001105-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_OPP[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The file transfer profile UUID. (00001106-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_FTP[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The synchronization profile UUID. (00001107-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_SYNC_COMMAND[] = {0x00, 0x00, 0x11, 0x07, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The headset profile UUID. (00001108-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HSP[] = {0x00, 0x00, 0x11, 0x08, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The cordless telephony profile UUID. (00001109-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_CTP[] = {0x00, 0x00, 0x11, 0x09, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The advanced audio distribution profile - source UUID. (0000110A-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_A2DP_SOURCE[] = {0x00, 0x00, 0x11, 0x0A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The advanced audio distribution profile - sink UUID. (0000110B-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_A2DP_SINK[] = {0x00, 0x00, 0x11, 0x0B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The audio/video remote control profile - target UUID. (0000110C-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_AVRCP_TARGET[] = {0x00, 0x00, 0x11, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The advanced audio distribution profile UUID. (0000110D-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_A2DP[] = {0x00, 0x00, 0x11, 0x0D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The audio/video remote control profile UUID. (0000110E-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_AVRCP[] = {0x00, 0x00, 0x11, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The audio/video remote control profile - controller UUID. (0000110F-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_AVRCP_CONTROLLER[] = {0x00, 0x00, 0x11, 0x0F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The intercom profile UUID. (00001110-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_ICP[] = {0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The fax profile UUID. (00001111-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_FAX[] = {0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The headset profile - audio gateway UUID. (00001112-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HSP_AG[] = {0x00, 0x00, 0x11, 0x12, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The personal area networking profile - user UUID. (00001115-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PAN_PANU[] = {0x00, 0x00, 0x11, 0x15, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The personal area networking profile - network access point UUID. (00001116-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PAN_NAP[] = {0x00, 0x00, 0x11, 0x16, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The personal area networking profile - group ad-hoc networks UUID. (00001117-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PAN_GN[] = {0x00, 0x00, 0x11, 0x17, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic printing profile - direct printing UUID. (00001118-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BPP_DIRECT_PRINTING[] = {0x00, 0x00, 0x11, 0x18, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic printing profile - reference printing UUID. (00001119-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BPP_REFERENCE_PRINTING[] = {0x00, 0x00, 0x11, 0x19, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic imaging profile UUID. (0000111A-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BIP[] = {0x00, 0x00, 0x11, 0x1A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic imaging profile - imaging responder UUID. (0000111B-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BIP_RESPONDER[] = {0x00, 0x00, 0x11, 0x1B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic imaging profile - imaging automatic archive UUID. (0000111C-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BIP_AUTOMATIC_ARCHIVE[] = {0x00, 0x00, 0x11, 0x1C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic imaging profile - imaging referenced objects UUID. (0000111D-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BIP_REFERENCED_OBJECTS[] = {0x00, 0x00, 0x11, 0x1D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The hands-free profile UUID. (0000111E-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HFP[] = {0x00, 0x00, 0x11, 0x1E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The hands-free profile - audio gateway UUID. (0000111F-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HFP_AG[] = {0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic printing profile - direct printing referenced objects UUID. (00001120-0000-1000-8000-00805F9B34FB)
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};
// The basic printing profile - reflected UI UUID. (00001121-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BPP_REFLECTED_UI[] = {0x00, 0x00, 0x11, 0x21, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic printing profile - basic printing UUID. (00001122-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BPP_BASIC_PRINTING[] = {0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The basic printing profile - printing status UUID. (00001123-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_BPP_PRINTING_STATUS[] = {0x00, 0x00, 0x11, 0x23, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The human interface device profile UUID. (00001124-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HID[] = {0x00, 0x00, 0x11, 0x24, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The hardcopy cable replacement profile UUID. (00001125-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HCRP[] = {0x00, 0x00, 0x11, 0x25, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The hardcopy cable replacement profile - print UUID. (00001126-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HCRP_PRINT[] = {0x00, 0x00, 0x11, 0x26, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The hardcopy cable replacement profile - scan UUID. (00001127-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HCRP_SCAN[] = {0x00, 0x00, 0x11, 0x27, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The SIM access profile UUID. (0000112D-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The phone book access - client equipment UUID. (0000112E-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The phone book access - server equipment UUID. (0000112F-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The phone book access UUID. (00001130-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_PBAP[] = {0x00, 0x00, 0x11, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The headset profile - headset UUID. (00001131-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HSP_HS[] = {0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The message access profile - message access server UUID. (00001132-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_MAP_ACCESS_SERVER[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The message access profile - message notification server UUID. (00001133-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_MAP_NOTIFICATION_SERVER[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The message access profile - message access profile UUID. (00001134-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_MAP_ACCESS_PROFILE[] = {0x00, 0x00, 0x11, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The device identification profile - PNP information UUID. (00001200-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_DID_PNP_INFORMATION[] = {0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The generic networking UUID. (00001201-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_GENERIC_NETWORKING[] = {0x00, 0x00, 0x12, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The generic file transfer UUID. (00001202-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_GENERIC_FILE_TRANSFER[] = {0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The generic audio UUID. (00001203-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_GENERIC_AUDIO[] = {0x00, 0x00, 0x12, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The generic telephony UUID. (00001204-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_GENERIC_TELEPHONY[] = {0x00, 0x00, 0x12, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The video distribution profile - source UUID. (00001303-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_VDP_SOURCE[] = {0x00, 0x00, 0x13, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The video distribution profile - sink UUID. (00001304-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_VDP_SINK[] = {0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The video distribution profile - distribution UUID. (00001305-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_VDP_DISTRIBUTION[] = {0x00, 0x00, 0x13, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The health device profile UUID. (00001400-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HDP[] = {0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The health device profile - source UUID. (00001401-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HDP_SOURCE[] = {0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
// The health device profile - sink UUID. (00001402-0000-1000-8000-00805F9B34FB)
const byte BT_SVC_UUID_HDP_SINK[] = {0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
BluetoothDevice::BluetoothDevice(void)
: __pImpl(null)
{
__pImpl = new (std::nothrow) _BluetoothDeviceImpl();
SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
}
BluetoothDevice::BluetoothDevice(const Tizen::Base::ByteBuffer& address, const Base::String& deviceName, BluetoothMajorDeviceClassType majorClassType, BluetoothMinorDeviceClassType minorClassType, unsigned long serviceClassList, unsigned long serviceList)
: __pImpl(null)
{
__pImpl = new (std::nothrow) _BluetoothDeviceImpl(address, deviceName, majorClassType, minorClassType, serviceClassList, serviceList);
SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
}
BluetoothDevice::BluetoothDevice(const BluetoothDevice& value)
: __pImpl(null)
{
__pImpl = new (std::nothrow) _BluetoothDeviceImpl(*value.__pImpl);
SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
}
BluetoothDevice::~BluetoothDevice(void)
{
delete __pImpl;
}
BluetoothDevice&
BluetoothDevice::operator =(const BluetoothDevice& rhs)
{
if (this != &rhs)
{
*__pImpl = *rhs.__pImpl;
}
return *this;
}
const Tizen::Base::ByteBuffer*
BluetoothDevice::GetAddress(void) const
{
return __pImpl->GetAddress();
}
result
BluetoothDevice::SetAddress(const Tizen::Base::ByteBuffer& address)
{
return __pImpl->SetAddress(address);
}
String
BluetoothDevice::GetName(void) const
{
return __pImpl->GetName();
}
bool
BluetoothDevice::IsPaired(void) const
{
return __pImpl->IsPaired();
}
int
BluetoothDevice::GetRssi(void) const
{
return __pImpl->GetRssi();
}
BluetoothMajorDeviceClassType
BluetoothDevice::GetMajorDeviceClassType(void) const
{
return __pImpl->GetMajorDeviceClassType();
}
BluetoothMinorDeviceClassType
BluetoothDevice::GetMinorDeviceClassType(void) const
{
return __pImpl->GetMinorDeviceClassType();
}
unsigned long
BluetoothDevice::GetServiceClassList(void) const
{
return __pImpl->GetServiceClassList();
}
unsigned long
BluetoothDevice::GetServiceList(void) const
{
return __pImpl->GetServiceList();
}
const Tizen::Base::Collection::IList*
BluetoothDevice::GetServiceUuidList(void) const
{
return __pImpl->GetServiceUuidList();
}
bool
BluetoothDevice::Equals(const Tizen::Base::Object& obj) const
{
const BluetoothDevice* pOther = dynamic_cast <const BluetoothDevice*>(&obj);
if (pOther == null)
{
return false;
}
if (pOther == this)
{
return true;
}
return(__pImpl->Equals(*(pOther->__pImpl)));
}
int
BluetoothDevice::GetHashCode(void) const
{
return __pImpl->GetHashCode();
}
BluetoothDevice*
BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IList& appControlResult)
{
BluetoothDevice* pNewBtDevice = null;
String* pResultStrPtr = null;
String keywordStr;
String dataStr;
ByteBuffer btAddrBytes;
String deviceName;
long majClassType = 0;
long minClassType = 0;
long svcClassType = 0;
long svcType = 0;
ClearLastResult();
if (appControlResult.GetCount() != 7)
{
goto CATCH;
}
pResultStrPtr = (String*) appControlResult.GetAt(0);
if (pResultStrPtr->Equals(String(Tizen::App::APPCONTROL_RESULT_SUCCEEDED)) == false)
{
goto CATCH;
}
// Gets the address from index 1 as a String. E.g. 00-1E-2B-72-08-DB
pResultStrPtr = (String*) appControlResult.GetAt(1);
if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("addr_val:")) == false) ||
(pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
{
goto CATCH;
}
// Convert the type of the address to ByteBuffer
btAddrBytes.Construct(6);
if (_BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes) != E_SUCCESS)
{
goto CATCH;
}
keywordStr.Clear();
dataStr.Clear();
// Gets the name from index 2
pResultStrPtr = (String*) appControlResult.GetAt(2);
if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("dev_name:")) == false) ||
(pResultStrPtr->SubString(9, deviceName) != E_SUCCESS))
{
goto CATCH;
}
keywordStr.Clear();
// Gets the major device class from index 3
pResultStrPtr = (String*) appControlResult.GetAt(3);
if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("maj_cls_type:")) == false) ||
(pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
{
goto CATCH;
}
if (Long::Decode(dataStr, majClassType) != E_SUCCESS)
{
goto CATCH;
}
keywordStr.Clear();
dataStr.Clear();
// Gets the minor device class from index 4
pResultStrPtr = (String*) appControlResult.GetAt(4);
if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("min_cls_type:")) == false) ||
(pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
{
goto CATCH;
}
if (Long::Decode(dataStr, minClassType) != E_SUCCESS)
{
goto CATCH;
}
keywordStr.Clear();
dataStr.Clear();
// Gets the service classes as a bit-mask from index 5
pResultStrPtr = (String*) appControlResult.GetAt(5);
if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("svc_cls_type:")) == false) ||
(pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
{
goto CATCH;
}
if (Long::Decode(dataStr, svcClassType) != E_SUCCESS)
{
goto CATCH;
}
keywordStr.Clear();
dataStr.Clear();
// Gets the service types as a bit-mask from index 6
pResultStrPtr = (String*) appControlResult.GetAt(6);
if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
(keywordStr.Equals(String("svc_type:")) == false) ||
(pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
{
goto CATCH;
}
if (Long::Decode(dataStr, svcType) != E_SUCCESS)
{
goto CATCH;
}
// Create an instance of BluetoothDevice.
pNewBtDevice =
new (std::nothrow) BluetoothDevice(btAddrBytes, deviceName, (BluetoothMajorDeviceClassType) majClassType,
(BluetoothMinorDeviceClassType) minClassType, svcClassType,
svcType);
if (pNewBtDevice == null)
{
SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
SetLastResult(E_OUT_OF_MEMORY);
}
return pNewBtDevice;
CATCH:
SysLogException(NID_NET_BT, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.");
SetLastResult(E_INVALID_ARG);
return null;
}
BluetoothDevice*
BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IMap& appControlResult)
{
result r = E_SUCCESS;
BluetoothDevice* pNewBtDevice = null;
_BluetoothDeviceImpl* pNewBtDeviceImpl = null;
String* pResultStrPtr = null;
String dataStr;
ByteBuffer btAddrBytes;
String deviceName;
int rssi = 0;
bool isPaired = false;
long majClassType = 0;
long minClassType = 0;
long svcClassType = 0;
long svcType = 0;
ArrayList* pUuidList = null;
ClearLastResult();
// Gets the address as a String. E.g. 00-1E-2B-72-08-DB
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/address"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
// Convert the type of the address to ByteBuffer
btAddrBytes.Construct(6);
r = _BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Clear();
// Gets the name
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/name"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
deviceName.Insert(*pResultStrPtr, 0);
// Gets the rssi value
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/rssi"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
r = Integer::Decode(dataStr, rssi);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Clear();
// Gets the ispaired
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/is_paired"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
isPaired = Boolean::Parse(dataStr);
dataStr.Clear();
// Gets the major device class
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/major_class"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
r = Long::Decode(dataStr, majClassType);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Clear();
// Gets the minor device class
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/minor_class"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
r = Long::Decode(dataStr, minClassType);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Clear();
// Gets the service classes as a bit-mask
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_class"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
r = Long::Decode(dataStr, svcClassType);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Clear();
// Gets the service types as a bit-mask
pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_type"));
SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
dataStr.Insert(*pResultStrPtr, 0);
r = Long::Decode(dataStr, svcType);
SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
// Gets the service UUID list
pUuidList = (ArrayList*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/uuid_list"));
SysTryReturn(NID_NET_BT, pUuidList != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
// Create an instance of BluetoothDevice.
pNewBtDevice = new (std::nothrow) BluetoothDevice();
if (pNewBtDevice == null)
{
SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
SetLastResult(E_OUT_OF_MEMORY);
return null;
}
pNewBtDeviceImpl = _BluetoothDeviceImpl::GetInstance(*pNewBtDevice);
pNewBtDeviceImpl->SetAddress(btAddrBytes);
pNewBtDeviceImpl->SetName(deviceName);
pNewBtDeviceImpl->SetPaired(isPaired);
pNewBtDeviceImpl->SetRssi(rssi);
pNewBtDeviceImpl->SetMajorDeviceClassType((BluetoothMajorDeviceClassType) majClassType);
pNewBtDeviceImpl->SetMinorDeviceClassType((BluetoothMinorDeviceClassType) minClassType);
pNewBtDeviceImpl->SetServiceClassList(svcClassType);
pNewBtDeviceImpl->SetServiceList(svcType);
pNewBtDeviceImpl->SetServiceUuidList(pUuidList, true);
return pNewBtDevice;
}
} } } // Tizen::Net::Bluetooth
|