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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
|
//
// 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 FNetBt_BluetoothAdapterUtility.cpp
// @brief This is the implementation file for the _BluetoothAdapterUtility class.
//
#include <unique_ptr.h>
#include <FBaseColAllElementsDeleter.h>
#include <FBaseByteBuffer.h>
#include <FBaseUuId.h>
#include <FBaseInteger.h>
#include <FBaseSysLog.h>
#include <FBaseLong.h>
#include <FBaseColHashMap.h>
#include <FBaseUtilStringUtil.h>
#include <FNetBtBluetoothDevice.h>
#include <FNetBtBluetoothTypes.h>
#include <FNetBtBluetoothDevice.h>
#include <FBase_StringConverter.h>
#include <FNetBt_BluetoothDeviceImpl.h>
#include "FNetBt_BluetoothAdapterUtility.h"
using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Base::Utility;
namespace Tizen { namespace Net { namespace Bluetooth
{
class _BluetoothUuidMap;
static _BluetoothUuidMap* pMapSingleton = null;
/*
* @class _BluetoothUuidMap
* @brief The _BluetoothUuidMap class provides the method which converts UUID string to the long type value of
* BluetoothServiceType defined "FNetBtBluetoothTypes.h".
*/
class _BluetoothUuidMap
: public Tizen::Base::Object
{
public:
_BluetoothUuidMap(void) {}
virtual ~_BluetoothUuidMap(void)
{
//Clear all entries in the map
(void) __uuidMap.RemoveAll(true);
}
static _BluetoothUuidMap* GetInstance(void)
{
static _BluetoothUuidMap uuidMap;
// TODO: this singleton pattern to use a local static instance is not thread-safe.
if (!pMapSingleton)
{
if (uuidMap.Initialise() == E_SUCCESS)
{
pMapSingleton = &uuidMap;
}
}
return pMapSingleton;
}
long GetUuidLong(const Tizen::Base::String& uuidString) const
{
UuId uuid;
UuId::Parse(uuidString, uuid);
const Long* pUuidLongValue = null;
pUuidLongValue = dynamic_cast<const Long*> (__uuidMap.GetValue(uuid));
SysTryReturn(NID_NET_BT, pUuidLongValue != null, 0, E_SYSTEM,
"Getting UUID(%ls) value from <UUID string, UUID enum type> map has failed.", uuidString.GetPointer());
return pUuidLongValue->ToLong();
}
private:
_BluetoothUuidMap(const _BluetoothUuidMap& value);
_BluetoothUuidMap& operator =(const _BluetoothUuidMap& value);
result Initialise(void)
{
result r = E_SUCCESS;
r = __uuidMap.Construct();
SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Construction of <UUID string, UUID enum type> map has failed.");
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_SPP)), *(new Long((long)(BT_SVC_SPP_SERVICE))));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_LAP)), *(new Long((long) BT_SVC_LAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_DUN)), *(new Long((long) BT_SVC_DUN_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_SYNC)), *(new Long((long) BT_SVC_SYNC_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_OPP)), *(new Long((long) BT_SVC_OPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_FTP)), *(new Long((long) BT_SVC_FTP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_SYNC_COMMAND)), *(new Long((long) BT_SVC_SYNC_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HSP)), *(new Long((long) BT_SVC_HSP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_CTP)), *(new Long((long) BT_SVC_CTP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_A2DP_SOURCE)), *(new Long((long) BT_SVC_A2DP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_A2DP_SINK)), *(new Long((long) BT_SVC_A2DP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_AVRCP_TARGET)), *(new Long((long) BT_SVC_AVRCP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_A2DP)), *(new Long((long) BT_SVC_A2DP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_AVRCP)), *(new Long((long) BT_SVC_AVRCP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_AVRCP_CONTROLLER)), *(new Long((long) BT_SVC_AVRCP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_ICP)), *(new Long((long) BT_SVC_ICP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_FAX)), *(new Long((long) BT_SVC_FAX_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HSP_AG)), *(new Long((long) BT_SVC_HSP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PAN_PANU)), *(new Long((long) BT_SVC_PANU_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PAN_NAP)), *(new Long((long) BT_SVC_NAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PAN_GN)), *(new Long((long) BT_SVC_GN_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_DIRECT_PRINTING)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_REFERENCE_PRINTING)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BIP)), *(new Long((long) BT_SVC_BIP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BIP_RESPONDER)), *(new Long((long) BT_SVC_BIP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BIP_AUTOMATIC_ARCHIVE)), *(new Long((long) BT_SVC_BIP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BIP_REFERENCED_OBJECTS)), *(new Long((long) BT_SVC_BIP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HFP)), *(new Long((long) BT_SVC_HFP_HS_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HFP_AG)), *(new Long((long) BT_SVC_HFP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_DIRECT_PRINTING_RO)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_REFLECTED_UI)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_BASIC_PRINTING)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_BPP_PRINTING_STATUS)), *(new Long((long) BT_SVC_BPP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HID)), *(new Long((long) BT_SVC_HID_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HCRP)), *(new Long((long) BT_SVC_HCRP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HCRP_PRINT)), *(new Long((long) BT_SVC_HCRP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HCRP_SCAN)), *(new Long((long) BT_SVC_HCRP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_SAP)), *(new Long((long) BT_SVC_SAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PBAP_PCE)), *(new Long((long) BT_SVC_PBAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PBAP_PSE)), *(new Long((long) BT_SVC_PBAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_PBAP)), *(new Long((long) BT_SVC_PBAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HSP_HS)), *(new Long((long) BT_SVC_HSP_HS_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_MAP_ACCESS_SERVER)), *(new Long((long) BT_SVC_MAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_MAP_NOTIFICATION_SERVER)), *(new Long((long) BT_SVC_MAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_MAP_ACCESS_PROFILE)), *(new Long((long) BT_SVC_MAP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_DID_PNP_INFORMATION)), *(new Long((long) BT_SVC_DID_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_GENERIC_NETWORKING)), *(new Long((long) BT_SVC_NONE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_GENERIC_FILE_TRANSFER)), *(new Long((long) BT_SVC_NONE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_GENERIC_AUDIO)), *(new Long((long) BT_SVC_NONE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_GENERIC_TELEPHONY)), *(new Long((long) BT_SVC_NONE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_VDP_SOURCE)), *(new Long((long) BT_SVC_VDP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_VDP_SINK)), *(new Long((long) BT_SVC_VDP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_VDP_DISTRIBUTION)), *(new Long((long) BT_SVC_VDP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HDP)), *(new Long((long) BT_SVC_HDP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HDP_SOURCE)), *(new Long((long) BT_SVC_HDP_SERVICE)));
__uuidMap.Add(*(new Tizen::Base::UuId(BT_SVC_UUID_HDP_SINK)), *(new Long((long) BT_SVC_HDP_SERVICE)));
return E_SUCCESS;
}
private:
Tizen::Base::Collection::HashMap __uuidMap;
}; //_BluetoothUuidMap
// defines local methods
void PrintMajorDeviceClass(BluetoothMajorDeviceClassType type);
void PrintMinorDeviceClass(BluetoothMajorDeviceClassType majType, BluetoothMinorDeviceClassType minType);
void PrintServiceClassList(unsigned long type);
_BluetoothAdapterUtility::_BluetoothAdapterUtility(void)
{
}
_BluetoothAdapterUtility::~_BluetoothAdapterUtility(void)
{
}
BluetoothMajorDeviceClassType
_BluetoothAdapterUtility::ConvertToMajorDeviceClassType(bt_major_device_class_e majorClass)
{
BluetoothMajorDeviceClassType convertedType = BT_COD_MAJ_DEV_CLS_UNCLASSIFIED;
switch (majorClass)
{
case BT_MAJOR_DEVICE_CLASS_MISC:
convertedType = BT_COD_MAJ_DEV_CLS_MISC;
break;
case BT_MAJOR_DEVICE_CLASS_COMPUTER:
convertedType = BT_COD_MAJ_DEV_CLS_COMPUTER;
break;
case BT_MAJOR_DEVICE_CLASS_PHONE:
convertedType = BT_COD_MAJ_DEV_CLS_PHONE;
break;
case BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT:
convertedType = BT_COD_MAJ_DEV_CLS_LAN_ACCESS_POINT;
break;
case BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO:
convertedType = BT_COD_MAJ_DEV_CLS_AUDIO;
break;
case BT_MAJOR_DEVICE_CLASS_PERIPHERAL:
convertedType = BT_COD_MAJ_DEV_CLS_PERIPHERAL;
break;
case BT_MAJOR_DEVICE_CLASS_IMAGING:
convertedType = BT_COD_MAJ_DEV_CLS_IMAGING;
break;
case BT_MAJOR_DEVICE_CLASS_WEARABLE:
case BT_MAJOR_DEVICE_CLASS_TOY:
case BT_MAJOR_DEVICE_CLASS_HEALTH:
case BT_MAJOR_DEVICE_CLASS_UNCATEGORIZED:
default:
convertedType = BT_COD_MAJ_DEV_CLS_UNCLASSIFIED;
break;
}
return convertedType;
}
BluetoothMinorDeviceClassType
_BluetoothAdapterUtility::ConvertToMinorDeviceClassType(bt_major_device_class_e majorClass, bt_minor_device_class_e minorClass)
{
BluetoothMinorDeviceClassType convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
if (majorClass == BT_MAJOR_DEVICE_CLASS_COMPUTER)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_COMPUTER_DESKTOP_WORKSTATION:
convertedType = BT_COD_MIN_DEV_CLS_DESKTOP_WORKSTATION;
break;
case BT_MINOR_DEVICE_CLASS_COMPUTER_SERVER_CLASS:
convertedType = BT_COD_MIN_DEV_CLS_SERVER_CLASS_COMPUTER;
break;
case BT_MINOR_DEVICE_CLASS_COMPUTER_LAPTOP:
convertedType = BT_COD_MIN_DEV_CLS_LAPTOP;
break;
case BT_MINOR_DEVICE_CLASS_COMPUTER_HANDHELD_PC_OR_PDA:
convertedType = BT_COD_MIN_DEV_CLS_HANDHELD_PC_OR_PDA;
break;
case BT_MINOR_DEVICE_CLASS_COMPUTER_PALM_SIZED_PC_OR_PDA:
convertedType = BT_COD_MIN_DEV_CLS_PALM_SIZED_PC_OR_PDA;
break;
case BT_MINOR_DEVICE_CLASS_COMPUTER_WEARABLE_COMPUTER:
convertedType = BT_COD_MIN_DEV_CLS_WEARABLE_COMPUTER;
break;
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_PHONE)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_PHONE_CELLULAR:
convertedType = BT_COD_MIN_DEV_CLS_CELLULAR;
break;
case BT_MINOR_DEVICE_CLASS_PHONE_CORDLESS:
convertedType = BT_COD_MIN_DEV_CLS_CORDLESS;
break;
case BT_MINOR_DEVICE_CLASS_PHONE_SMART_PHONE:
convertedType = BT_COD_MIN_DEV_CLS_SMART_PHONE;
break;
case BT_MINOR_DEVICE_CLASS_PHONE_WIRED_MODEM_OR_VOICE_GATEWAY:
convertedType = BT_COD_MIN_DEV_CLS_WIRED_MODEM_OR_VOICE_GATEWAY;
break;
case BT_MINOR_DEVICE_CLASS_PHONE_COMMON_ISDN_ACCESS:
convertedType = BT_COD_MIN_DEV_CLS_COMMON_ISDN_ACCESS;
break;
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_FULLY_AVAILABLE:
convertedType = BT_COD_MIN_DEV_CLS_FULLY_AVAILABLE;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_1_TO_17_PERCENT_UTILIZED:
convertedType = BT_COD_MIN_DEV_CLS_1_TO_17_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_17_TO_33_PERCENT_UTILIZED:
convertedType = BT_COD_MIN_DEV_CLS_17_TO_33_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_33_TO_50_PERCENT_UTILIZED :
convertedType = BT_COD_MIN_DEV_CLS_33_TO_50_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_50_to_67_PERCENT_UTILIZED:
convertedType = BT_COD_MIN_DEV_CLS_50_to_67_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_67_TO_83_PERCENT_UTILIZED:
convertedType = BT_COD_MIN_DEV_CLS_67_TO_83_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_83_TO_99_PERCENT_UTILIZED:
convertedType = BT_COD_MIN_DEV_CLS_83_TO_99_PERCENT_UTILIZED;
break;
case BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_NO_SERVICE_AVAILABLE :
convertedType = BT_COD_MIN_DEV_CLS_NO_SERVICE_AVAILABLE;
break;
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_WEARABLE_HEADSET:
convertedType = BT_COD_MIN_DEV_CLS_HEADSET_PROFILE;
break;
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HANDS_FREE :
convertedType = BT_COD_MIN_DEV_CLS_HANDSFREE;
break;
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_MICROPHONE:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_LOUDSPEAKER:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HEADPHONES:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_PORTABLE_AUDIO:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAR_AUDIO:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_SET_TOP_BOX:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HIFI_AUDIO_DEVICE:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VCR:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CAMERA:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAMCORDER :
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_MONITOR:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_DISPLAY_LOUDSPEAKER:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CONFERENCING:
case BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_GAMING_TOY:
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_PERIPHERAL)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_KEY_BOARD:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_POINTING_DEVICE:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_COMBO_KEYBOARD_POINTING_DEVICE :
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_JOYSTICK:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_GAME_PAD:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_REMOTE_CONTROL:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_SENSING_DEVICE:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITIZER_TABLET:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_CARD_READER:
convertedType = BT_COD_MIN_DEV_CLS_SIM_CARD_READER;
break;
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITAL_PEN:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_SCANNER:
case BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_GESTURAL_INPUT_DEVICE :
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_IMAGING)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_IMAGING_DISPLAY:
case BT_MINOR_DEVICE_CLASS_IMAGING_CAMERA:
case BT_MINOR_DEVICE_CLASS_IMAGING_SCANNER:
case BT_MINOR_DEVICE_CLASS_IMAGING_PRINTER:
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_WEARABLE)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_WEARABLE_WRIST_WATCH:
case BT_MINOR_DEVICE_CLASS_WEARABLE_PAGER:
case BT_MINOR_DEVICE_CLASS_WEARABLE_JACKET:
case BT_MINOR_DEVICE_CLASS_WEARABLE_HELMET:
case BT_MINOR_DEVICE_CLASS_WEARABLE_GLASSES:
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_TOY)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_TOY_ROBOT:
case BT_MINOR_DEVICE_CLASS_TOY_VEHICLE:
case BT_MINOR_DEVICE_CLASS_TOY_DOLL_ACTION:
case BT_MINOR_DEVICE_CLASS_TOY_CONTROLLER:
case BT_MINOR_DEVICE_CLASS_TOY_GAME:
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else if (majorClass == BT_MAJOR_DEVICE_CLASS_HEALTH)
{
switch (minorClass)
{
case BT_MINOR_DEVICE_CLASS_HEATH_BLOOD_PRESSURE_MONITOR:
case BT_MINOR_DEVICE_CLASS_HEATH_THERMOMETER :
case BT_MINOR_DEVICE_CLASS_HEATH_WEIGHING_SCALE:
case BT_MINOR_DEVICE_CLASS_HEATH_GLUCOSE_METER:
case BT_MINOR_DEVICE_CLASS_HEATH_PULSE_OXIMETER:
case BT_MINOR_DEVICE_CLASS_HEATH_HEART_PULSE_RATE_MONITOR:
case BT_MINOR_DEVICE_CLASS_HEATH_DATA_DISPLAY:
case BT_MINOR_DEVICE_CLASS_HEATH_STEP_COUNTER:
case BT_MINOR_DEVICE_CLASS_HEATH_BODY_COMPOSITION_ANALYZER:
case BT_MINOR_DEVICE_CLASS_HEATH_PEAK_FLOW_MONITOR:
case BT_MINOR_DEVICE_CLASS_HEATH_MEDICATION_MONITOR :
case BT_MINOR_DEVICE_CLASS_HEATH_KNEE_PROSTHESIS:
case BT_MINOR_DEVICE_CLASS_HEATH_ANKLE_PROSTHESIS:
default:
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
break;
}
}
else
{
convertedType = BT_COD_MIN_DEV_CLS_UNCLASSIFIED;
}
return convertedType;
}
unsigned long
_BluetoothAdapterUtility::ConvertToServiceClassList(int serviceClass)
{
unsigned long serviceClassMask = 0;
bt_major_service_class_e origianlClassList[] =
{
BT_MAJOR_SERVICE_CLASS_INFORMATION,
BT_MAJOR_SERVICE_CLASS_TELEPHONY,
BT_MAJOR_SERVICE_CLASS_AUDIO,
BT_MAJOR_SERVICE_CLASS_OBJECT_TRANSFER,
BT_MAJOR_SERVICE_CLASS_CAPTURING,
BT_MAJOR_SERVICE_CLASS_RENDERING,
BT_MAJOR_SERVICE_CLASS_NETWORKING,
BT_MAJOR_SERVICE_CLASS_POSITIONING,
BT_MAJOR_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE
};
BluetoothServiceClassType convertedClassList[] =
{
BT_COD_SVC_INFORMATION,
BT_COD_SVC_TELEPHONY,
BT_COD_SVC_AUDIO,
BT_COD_SVC_OBJECT_TRANSFER,
BT_COD_SVC_CAPTURING,
BT_COD_SVC_RENDERING,
BT_COD_SVC_NETWORKING,
BT_COD_SVC_POSITIONING,
BT_COD_SVC_LIMITED_DISCOVERABLE_MODE
};
for (int i = 0; i < 9; i++)
{
// checks the input value, 'serviceClass', has each value of the class list using bit masking
if (origianlClassList[i] == (serviceClass & origianlClassList[i]))
{
serviceClassMask += convertedClassList[i];
}
}
return serviceClassMask;
}
unsigned long
_BluetoothAdapterUtility::ConvertToServiceList(char** pServiceUuid, int& serviceUuidCount)
{
unsigned long serviceListMask = 0;
_BluetoothUuidMap* pMap = null;
pMap = _BluetoothUuidMap::GetInstance();
SysTryReturn(NID_NET_BT, pMap != null, 0, E_SYSTEM, "Converting UUID strings to a masked BluetoothServiceType value faild.");
for (int i = 0; i < serviceUuidCount; i++)
{
String uuidString(pServiceUuid[i]);
long uuidLongValue = pMap->GetUuidLong(uuidString);
serviceListMask |= uuidLongValue;
}
return serviceListMask;
}
Tizen::Base::Collection::IList*
_BluetoothAdapterUtility::ConvertServiceUuidListN(char** pServiceUuid, int& serviceUuidCount)
{
unique_ptr<ArrayList, AllElementsDeleter> pList;
UuId* pUuid = null;
pList.reset(new (std::nothrow) ArrayList());
SysTryReturn(NID_NET_BT, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
for (int i = 0; i < serviceUuidCount; i++)
{
String uuidString(pServiceUuid[i]);
pUuid = new (std::nothrow) UuId();
SysTryReturn(NID_NET_BT, pUuid != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
uuidString.ToUpperCase();
UuId::Parse(uuidString, *pUuid);
pList->Add(*pUuid);
}
return pList.release();
}
void
_BluetoothAdapterUtility::PrintDeviceInfo(const BluetoothDevice& device)
{
SysLog(NID_NET_BT, "Bluetooth Device Information =============");
SysLog(NID_NET_BT, "+ Address: [%ls]", _BluetoothDeviceImpl::GetAddressString(*(device.GetAddress())).GetPointer());
SysLog(NID_NET_BT, "+ Name: %ls", device.GetName().GetPointer());
SysLog(NID_NET_BT, "+ %s", device.IsPaired() ? "Paired" : "Not Paired");
SysLog(NID_NET_BT, "+ RSSI: %d", device.GetRssi());
PrintMajorDeviceClass(device.GetMajorDeviceClassType());
PrintMinorDeviceClass(device.GetMajorDeviceClassType(), device.GetMinorDeviceClassType());
PrintServiceClassList(device.GetServiceClassList());
PrintServiceList(device.GetServiceList());
PrintServiceUuidList(device.GetServiceUuidList());
}
void
_BluetoothAdapterUtility::PrintServiceList(unsigned long type)
{
int index = 0;
unsigned long typeList[] =
{
BT_SVC_MAP_SERVICE,
BT_SVC_HDP_SERVICE,
BT_SVC_DID_SERVICE,
BT_SVC_HCRP_SERVICE,
BT_SVC_HFP_HS_SERVICE,
BT_SVC_HSP_HS_SERVICE,
BT_SVC_PBAP_SERVICE,
BT_SVC_VDP_SERVICE,
BT_SVC_HID_SERVICE,
BT_SVC_AVRCP_SERVICE,
BT_SVC_A2DP_SERVICE,
BT_SVC_SAP_SERVICE,
BT_SVC_GN_SERVICE,
BT_SVC_NAP_SERVICE,
BT_SVC_PANU_SERVICE,
BT_SVC_BIP_SERVICE,
BT_SVC_BPP_SERVICE,
BT_SVC_SYNC_SERVICE,
BT_SVC_ICP_SERVICE,
BT_SVC_CTP_SERVICE,
BT_SVC_FTP_SERVICE,
BT_SVC_OPP_SERVICE,
BT_SVC_HFP_SERVICE,
BT_SVC_HSP_SERVICE,
BT_SVC_LAP_SERVICE,
BT_SVC_FAX_SERVICE,
BT_SVC_DUN_SERVICE,
BT_SVC_SPP_SERVICE,
BT_SVC_RES_SERVICE
};
const char* typeStrList[] =
{
"BT_SVC_MAP_SERVICE",
"BT_SVC_HDP_SERVICE",
"BT_SVC_DID_SERVICE",
"BT_SVC_HCRP_SERVICE",
"BT_SVC_HFP_HS_SERVICE",
"BT_SVC_HSP_HS_SERVICE",
"BT_SVC_PBAP_SERVICE",
"BT_SVC_VDP_SERVICE",
"BT_SVC_HID_SERVICE",
"BT_SVC_AVRCP_SERVICE",
"BT_SVC_A2DP_SERVICE",
"BT_SVC_SAP_SERVICE",
"BT_SVC_GN_SERVICE",
"BT_SVC_NAP_SERVICE",
"BT_SVC_PANU_SERVICE",
"BT_SVC_BIP_SERVICE",
"BT_SVC_BPP_SERVICE",
"BT_SVC_SYNC_SERVICE",
"BT_SVC_ICP_SERVICE",
"BT_SVC_CTP_SERVICE",
"BT_SVC_FTP_SERVICE",
"BT_SVC_OPP_SERVICE",
"BT_SVC_HFP_SERVICE",
"BT_SVC_HSP_SERVICE",
"BT_SVC_LAP_SERVICE",
"BT_SVC_FAX_SERVICE",
"BT_SVC_DUN_SERVICE",
"BT_SVC_SPP_SERVICE",
"BT_SVC_RES_SERVICE"
};
for (int i = 0; i < 29; i++)
{
// checks the input value, 'type', has each value of the service list using bit masking
if (typeList[i] == (type & typeList[i]))
{
SysLog(NID_NET_BT, "+ Service List[%d]: %s", index++, typeStrList[i]);
}
}
}
void
_BluetoothAdapterUtility::PrintServiceUuidList(const Tizen::Base::Collection::IList* pList)
{
int count = 0;
const UuId* pUuid = null;
if (pList == null)
{
SysLog(NID_NET_BT, "+ No Service UUID (with error)");
}
else
{
count = pList->GetCount();
if (count == 0)
{
SysLog(NID_NET_BT, "+ No Service UUID");
}
for (int i = 0; i < count; i++)
{
pUuid = dynamic_cast<const UuId*>(pList->GetAt(i));
if (pUuid != null)
{
SysLog(NID_NET_BT, "+ Service UUID[%d]: %ls", i, pUuid->ToString().GetPointer());
}
}
}
}
void PrintMajorDeviceClass(BluetoothMajorDeviceClassType type)
{
const char* pTypeString = null;
switch (type)
{
case BT_COD_MAJ_DEV_CLS_MISC:
pTypeString = "BT_COD_MAJ_DEV_CLS_MISC";
break;
case BT_COD_MAJ_DEV_CLS_COMPUTER:
pTypeString = "BT_COD_MAJ_DEV_CLS_COMPUTER";
break;
case BT_COD_MAJ_DEV_CLS_PHONE:
pTypeString = "BT_COD_MAJ_DEV_CLS_PHONE";
break;
case BT_COD_MAJ_DEV_CLS_LAN_ACCESS_POINT:
pTypeString = "BT_COD_MAJ_DEV_CLS_LAN_ACCESS_POINT";
break;
case BT_COD_MAJ_DEV_CLS_AUDIO:
pTypeString = "BT_COD_MAJ_DEV_CLS_AUDIO";
break;
case BT_COD_MAJ_DEV_CLS_PERIPHERAL:
pTypeString = "BT_COD_MAJ_DEV_CLS_PERIPHERAL";
break;
case BT_COD_MAJ_DEV_CLS_IMAGING:
pTypeString = "BT_COD_MAJ_DEV_CLS_IMAGING";
break;
case BT_COD_MAJ_DEV_CLS_UNCLASSIFIED:
pTypeString = "BT_COD_MAJ_DEV_CLS_UNCLASSIFIED";
break;
default:
pTypeString = "Unknown";
break;
}
SysLog(NID_NET_BT, "+ Major Device Type: %s", pTypeString);
}
void PrintMinorDeviceClass(BluetoothMajorDeviceClassType majType, BluetoothMinorDeviceClassType minType)
{
const char* pTypeString = null;
switch (majType)
{
case BT_COD_MAJ_DEV_CLS_COMPUTER:
switch (minType)
{
case BT_COD_MIN_DEV_CLS_DESKTOP_WORKSTATION:
pTypeString = "BT_COD_MIN_DEV_CLS_DESKTOP_WORKSTATION";
break;
case BT_COD_MIN_DEV_CLS_SERVER_CLASS_COMPUTER:
pTypeString = "BT_COD_MIN_DEV_CLS_SERVER_CLASS_COMPUTER";
break;
case BT_COD_MIN_DEV_CLS_LAPTOP:
pTypeString = "BT_COD_MIN_DEV_CLS_LAPTOP";
break;
case BT_COD_MIN_DEV_CLS_HANDHELD_PC_OR_PDA:
pTypeString = "BT_COD_MIN_DEV_CLS_HANDHELD_PC_OR_PDA";
break;
case BT_COD_MIN_DEV_CLS_PALM_SIZED_PC_OR_PDA:
pTypeString = "BT_COD_MIN_DEV_CLS_PALM_SIZED_PC_OR_PDA";
break;
case BT_COD_MIN_DEV_CLS_WEARABLE_COMPUTER:
pTypeString = "BT_COD_MIN_DEV_CLS_WEARABLE_COMPUTER";
break;
default:
pTypeString = "Unclassified";
break;
}
break;
case BT_COD_MAJ_DEV_CLS_PHONE:
switch (minType)
{
case BT_COD_MIN_DEV_CLS_CELLULAR:
pTypeString = "BT_COD_MIN_DEV_CLS_CELLULAR";
break;
case BT_COD_MIN_DEV_CLS_CORDLESS:
pTypeString = "BT_COD_MIN_DEV_CLS_CORDLESS";
break;
case BT_COD_MIN_DEV_CLS_SMART_PHONE:
pTypeString = "BT_COD_MIN_DEV_CLS_SMART_PHONE";
break;
case BT_COD_MIN_DEV_CLS_WIRED_MODEM_OR_VOICE_GATEWAY:
pTypeString = "BT_COD_MIN_DEV_CLS_WIRED_MODEM_OR_VOICE_GATEWAY";
break;
case BT_COD_MIN_DEV_CLS_COMMON_ISDN_ACCESS:
pTypeString = "BT_COD_MIN_DEV_CLS_COMMON_ISDN_ACCESS";
break;
default:
pTypeString = "Unclassified";
break;
}
break;
case BT_COD_MAJ_DEV_CLS_LAN_ACCESS_POINT:
switch (minType)
{
case BT_COD_MIN_DEV_CLS_FULLY_AVAILABLE:
pTypeString = "BT_COD_MAJ_DEV_CLS_LAN_ACCESS_POINT";
break;
case BT_COD_MIN_DEV_CLS_1_TO_17_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_1_TO_17_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_17_TO_33_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_17_TO_33_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_33_TO_50_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_33_TO_50_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_50_to_67_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_50_to_67_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_67_TO_83_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_67_TO_83_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_83_TO_99_PERCENT_UTILIZED:
pTypeString = "BT_COD_MIN_DEV_CLS_83_TO_99_PERCENT_UTILIZED";
break;
case BT_COD_MIN_DEV_CLS_NO_SERVICE_AVAILABLE:
pTypeString = "BT_COD_MIN_DEV_CLS_NO_SERVICE_AVAILABLE";
break;
default:
pTypeString = "Unclassified";
break;
}
break;
case BT_COD_MAJ_DEV_CLS_AUDIO:
switch (minType)
{
case BT_COD_MIN_DEV_CLS_HEADSET_PROFILE:
pTypeString = "BT_COD_MIN_DEV_CLS_HEADSET_PROFILE";
break;
case BT_COD_MIN_DEV_CLS_HANDSFREE:
pTypeString = "BT_COD_MIN_DEV_CLS_HANDSFREE";
break;
default:
pTypeString = "Unclassified";
break;
}
break;
case BT_COD_MAJ_DEV_CLS_PERIPHERAL:
switch (minType)
{
case BT_COD_MIN_DEV_CLS_SIM_CARD_READER:
pTypeString = "BT_COD_MIN_DEV_CLS_SIM_CARD_READER";
break;
default:
pTypeString = "Unclassified";
break;
}
break;
case BT_COD_MAJ_DEV_CLS_IMAGING:
case BT_COD_MAJ_DEV_CLS_MISC:
case BT_COD_MAJ_DEV_CLS_UNCLASSIFIED:
default:
pTypeString = "Unclassified";
break;
}
SysLog(NID_NET_BT, "+ Minor Device Type: %s", pTypeString);
}
void PrintServiceClassList(unsigned long type)
{
int index = 0;
unsigned long typeList[] =
{
BT_COD_SVC_INFORMATION,
BT_COD_SVC_TELEPHONY,
BT_COD_SVC_AUDIO,
BT_COD_SVC_OBJECT_TRANSFER,
BT_COD_SVC_CAPTURING,
BT_COD_SVC_RENDERING,
BT_COD_SVC_NETWORKING,
BT_COD_SVC_POSITIONING,
BT_COD_SVC_LIMITED_DISCOVERABLE_MODE
};
const char* typeStrList[] =
{
"BT_COD_SVC_INFORMATION",
"BT_COD_SVC_TELEPHONY",
"BT_COD_SVC_AUDIO",
"BT_COD_SVC_OBJECT_TRANSFER",
"BT_COD_SVC_CAPTURING",
"BT_COD_SVC_RENDERING",
"BT_COD_SVC_NETWORKING",
"BT_COD_SVC_POSITIONING",
"BT_COD_SVC_LIMITED_DISCOVERABLE_MODE"
};
for (int i = 0; i < 9; i++)
{
if (typeList[i] == (type & typeList[i]))
{
// checks the input value, 'type', has each value of the service class list using bit masking
SysLog(NID_NET_BT, "+ Service Class List[%d]: %s", index++, typeStrList[i]);
}
}
}
} } } // Tizen::Net::Bluetooth
|