65a7e8e801562e5eb4bd496d89189c038b6aa3d7
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / common / oal-utils.c
1 /*
2  * Open Adaptation Layer (OAL)
3  *
4  * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *                         http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22
23 #include <dlog.h>
24 #include <string.h>
25 #include <bluetooth.h>
26 #include "oal-utils.h"
27
28 char *bdt_bd2str(const bt_address_t *bdaddr, bdstr_t *bdstr)
29 {
30         const uint8_t *addr = bdaddr->addr;
31
32         if (bdaddr == NULL) {
33                 *bdstr[0] = 0;
34                 return *bdstr;
35         }
36
37         snprintf(*bdstr, sizeof(bdstr_t), "%02x:%02x:%02x:%02x:%02x:%02x",
38                         addr[0], addr[1], addr[2],
39                         addr[3], addr[4], addr[5]);
40         return *bdstr;
41 }
42
43 char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf)
44 {
45         const uint8_t *p;
46
47         if (!bd_addr)
48                 return strncpy(buf, "NULL", sizeof("NULL"));
49         p = bd_addr->address;
50
51         snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
52                         p[0], p[1], p[2], p[3], p[4], p[5]);
53
54         return buf;
55 }
56
57 char *bdaddr_2_str(const bt_bdaddr_t *bd_addr)
58 {
59         static char buf[18];
60         return convert_bdaddr_2_str(bd_addr, buf);
61 }
62
63 void string_to_uuid(char *str, service_uuid_t *p_uuid)
64 {
65         uint32_t uuid0, uuid4;
66         uint16_t uuid1, uuid2, uuid3, uuid5;
67
68         sscanf(str, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
69                         &uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5);
70
71         uuid0 = htonl(uuid0);
72         uuid1 = htons(uuid1);
73         uuid2 = htons(uuid2);
74         uuid3 = htons(uuid3);
75         uuid4 = htonl(uuid4);
76         uuid5 = htons(uuid5);
77
78         memcpy(&(p_uuid->uuid[0]), &uuid0, 4);
79         memcpy(&(p_uuid->uuid[4]), &uuid1, 2);
80         memcpy(&(p_uuid->uuid[6]), &uuid2, 2);
81         memcpy(&(p_uuid->uuid[8]), &uuid3, 2);
82         memcpy(&(p_uuid->uuid[10]), &uuid4, 4);
83         memcpy(&(p_uuid->uuid[14]), &uuid5, 2);
84
85         return;
86 }
87
88 void oal_print_device_address_t(const bt_address_t *addr)
89 {
90         BT_INFO("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", addr->addr[0], addr->addr[1], addr->addr[2],
91                         addr->addr[3], addr->addr[4], addr->addr[5]);
92 }
93
94 void oal_convert_addr_string_to_type(unsigned char *addr,
95                 const char *address)
96 {
97         int i;
98         char *ptr = NULL;
99
100         for (i = 0; i < BT_ADDRESS_BYTES_NUM; i++) {
101                 addr[i] = strtol(address, &ptr, 16);
102                 if (ptr != NULL) {
103                         if (ptr[0] != ':')
104                                 return;
105                         address = ptr + 1;
106                 }
107         }
108 }
109
110 int oal_is_address_zero(unsigned char *addr1)
111 {
112         int i;
113         for (i = 0; i < BT_ADDRESS_BYTES_NUM; i++) {
114                 if (addr1[i] == 0)
115                         continue;
116
117                 break;
118         }
119         if (i == BT_ADDRESS_BYTES_NUM)
120                 return 1;
121         else
122                 return 0;
123 }
124
125 void uuid_to_string(service_uuid_t *p_uuid, char *str)
126 {
127         uint32_t uuid0, uuid4;
128         uint16_t uuid1, uuid2, uuid3, uuid5;
129
130         memcpy(&uuid0, &(p_uuid->uuid[0]), 4);
131         memcpy(&uuid1, &(p_uuid->uuid[4]), 2);
132         memcpy(&uuid2, &(p_uuid->uuid[6]), 2);
133         memcpy(&uuid3, &(p_uuid->uuid[8]), 2);
134         memcpy(&uuid4, &(p_uuid->uuid[10]), 4);
135         memcpy(&uuid5, &(p_uuid->uuid[14]), 2);
136
137         snprintf((char *)str, BT_UUID_STRING_MAX, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
138                         ntohl(uuid0), ntohs(uuid1),
139                         ntohs(uuid2), ntohs(uuid3),
140                         ntohl(uuid4), ntohs(uuid5));
141 }
142
143 void uuid_to_stringname(service_uuid_t *p_uuid, char *str)
144 {
145         uint32_t uuid0, uuid4;
146         uint16_t uuid1, uuid2, uuid3, uuid5;
147         const char *uuid_name;
148         const char *uuid_name1;
149
150         memcpy(&uuid0, &(p_uuid->uuid[0]), 4);
151         memcpy(&uuid1, &(p_uuid->uuid[4]), 2);
152         memcpy(&uuid2, &(p_uuid->uuid[6]), 2);
153         memcpy(&uuid3, &(p_uuid->uuid[8]), 2);
154         memcpy(&uuid4, &(p_uuid->uuid[10]), 4);
155         memcpy(&uuid5, &(p_uuid->uuid[14]), 2);
156
157
158         uuid_name = dump_uuid_name(ntohl(uuid0));
159         uuid_name1 = dump_uuid_name((ntohl(uuid4) >> 16));
160
161         BT_DBG("UUID Name [%s]", uuid_name);
162         BT_DBG("UUID Name Shifted [%s]", uuid_name1);
163
164         snprintf((char *)str, 2*BT_UUID_STRING_MAX, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x--%s",
165                         ntohl(uuid0), ntohs(uuid1),
166                         ntohs(uuid2), ntohs(uuid3),
167                         ntohl(uuid4), ntohs(uuid5),
168                         !(g_strcmp0(dump_uuid_name(ntohl(uuid0)), "--")) ? dump_uuid_name(((uuid4) >> 16)) : uuid_name);
169 }
170
171 int hex2bin(const char *s)
172 {
173         int ret = 0;
174         int i;
175         for (i = 0; i < 2; i++) {
176                 char c = *s++;
177                 int n = 0;
178                 if ('0' <= c && c <= '9')
179                         n = c-'0';
180                 else if ('a' <= c && c <= 'f')
181                         n = 10 + c-'a';
182                 else if ('A' <= c && c <= 'F')
183                         n = 10 + c-'A';
184                 ret = n + ret*16;
185         }
186         return ret;
187 }
188
189 void convert_str_2_hex(unsigned char out[], char in[])
190 {
191         int i = 0;
192         for (i = 0; i < 62; i++) {
193                 out[i] = hex2bin(in); \
194                          in += 2; \
195         }
196 }
197
198 void convert_hex_2_str(unsigned char * hex, int len, char * str_out)
199 {
200         int i = 0;
201
202         for (i = 0; i < len; i++)
203                 snprintf(str_out + (i * 3), 3*(len - i), "%02x ", hex[i]);
204
205         str_out[3*len] = 0;
206 }
207
208 void print_bt_properties(int num_properties, bt_property_t *properties)
209 {
210         int i;
211         for (i = 0; i < num_properties; i++) {
212                 bt_property_t prop;
213                 memcpy(&prop, properties + i, sizeof(prop));
214                 BT_INFO("prop: %s\n", convert_bt_property_2_str(&prop));
215         }
216 }
217
218 char* convert_scan_mode_2_str(bt_scan_mode_t scan_mode)
219 {
220         switch (scan_mode) {
221         case BT_SCAN_MODE_NONE:
222                 return "Non Scannable";
223         case BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE:
224                 return "Connectable And Discoverable";
225         case BT_SCAN_MODE_CONNECTABLE:
226                 return "Connectable";
227         default:
228                 return "Unknown Scan Mode";
229         }
230
231 }
232
233 char* convert_device_type_2_str(bt_device_type_t device_type)
234 {
235         switch (device_type) {
236         case BT_DEVICE_DEVTYPE_BREDR:
237                 return "BREDR Device";
238         case BT_DEVICE_DEVTYPE_BLE:
239                 return "BLE Device";
240         case BT_DEVICE_DEVTYPE_DUAL:
241                 return "Dual Device";
242         default:
243                 return "Unknown Device Type";
244         }
245 }
246
247 char *convert_bt_property_2_str(const bt_property_t *property)
248 {
249         static char buf[4096];
250         char *p;
251
252         p = buf + snprintf(buf, 4096, "type=%s len=%d val=",
253                         convert_property_type_2_str(property->type),
254                         property->len);
255
256         switch (property->type) {
257         case BT_PROPERTY_BDNAME:
258         case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
259                 snprintf(p, property->len + 1, "%s",
260                                 ((bt_bdname_t *) property->val)->name);
261                 break;
262         case BT_PROPERTY_BDADDR:
263                 sprintf(p, "%s", bdaddr_2_str((bt_bdaddr_t *) property->val));
264                 break;
265         case BT_PROPERTY_CLASS_OF_DEVICE:
266                 sprintf(p, "%06x", *((unsigned int *) property->val));
267                 break;
268         case BT_PROPERTY_TYPE_OF_DEVICE:
269                 sprintf(p, "%s", convert_device_type_2_str(
270                                         *((bt_device_type_t *) property->val)));
271                 break;
272         case BT_PROPERTY_REMOTE_RSSI:
273                 sprintf(p, "%d", *((char *) property->val));
274                 break;
275         case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
276                 sprintf(p, "%d", *((unsigned int *) property->val));
277                 break;
278         case BT_PROPERTY_ADAPTER_SCAN_MODE:
279                 sprintf(p, "%s",
280                                 convert_scan_mode_2_str(*((bt_scan_mode_t *) property->val)));
281                 break;
282         case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
283                 break;
284         case BT_PROPERTY_UUIDS:
285                 break;
286         case BT_PROPERTY_SERVICE_RECORD:
287                 break;
288                 /* Tizen BlueZ specific Device properties */
289         case BT_PROPERTY_REMOTE_PAIRED:
290                 sprintf(p, "%d", *((uint8_t *) property->val));
291                 break;
292         case BT_PROPERTY_REMOTE_CONNECTED:
293                 sprintf(p, "%d", *((unsigned int *) property->val));
294                 break;
295         case BT_PROPERTY_REMOTE_TRUST:
296                 sprintf(p, "%d", *((uint8_t *) property->val));
297                 break;
298         case BT_PROPERTY_PAIRABLE:
299                 sprintf(p, "%d", *((uint8_t *) property->val));
300                 break;
301         case BT_PROPERTY_VERSION:
302                 snprintf(p, property->len + 1, "%s",
303                                 ((char *) property->val));
304                 break;
305         case BT_PROPERTY_LOCAL_LE_FEATURES:
306                 local_le_feat_2_string(p, property->val);
307                 break;
308         case BT_PROPERTY_PAIRABLE_TIMEOUT:
309                 sprintf(p, "%d", *((unsigned int *) property->val));
310                 break;
311         case BT_PROPERTY_IPSP_INITIALIZED:
312                 sprintf(p, "%d", *((uint8_t *) property->val));
313                 break;
314         case BT_PROPERTY_MODALIAS:
315                 snprintf(p, property->len + 1, "%s",
316                                 ((char *) property->val));
317                 break;
318         case BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA_LEN:
319                 sprintf(p, "%d", *((unsigned int *) property->val));
320                 break;
321         case BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA: {
322                 int indx;
323                 char *pppp = property->val;
324                 for (indx = 0; indx < property->len; indx++)
325                         p += sprintf(p, " %2.2X", pppp[indx]);
326                 break;
327         }
328         case BT_PROPERTY_REMOTE_BLE_ADV_DATA: {
329                 int indx;
330                 char *pppp = property->val;
331                 for (indx = 0; indx < property->len; indx++)
332                         p += sprintf(p, " %2.2X", pppp[indx]);
333                 break;
334         }
335         case BT_PROPERTY_REMOTE_IS_ALIAS_SET: {
336                 sprintf(p, "%d", *((uint8_t *) property->val));
337                 break;
338         }
339         /* End of Tizen BlueZ specific device propeties */
340         case BT_PROPERTY_REMOTE_VERSION_INFO:
341         case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
342         default:
343                 sprintf(p, "%p", property->val);
344                 break;
345         }
346         return buf;
347 }
348
349 char *dump_char_prop(uint8_t prop)
350 {
351         switch (prop) {
352         CASE_RETURN_STR(BROADCAST);
353         CASE_RETURN_STR(READ);
354         CASE_RETURN_STR(WRITE_NR);
355         CASE_RETURN_STR(WRITE);
356         CASE_RETURN_STR(NOTIFY);
357         CASE_RETURN_STR(INDICATE);
358         CASE_RETURN_STR(AUTH);
359         CASE_RETURN_STR(EXT_PROP);
360         default:
361                 return "--";
362         }
363 }
364
365 char *dump_char_perm(uint8_t perm)
366 {
367         switch (perm) {
368         CASE_RETURN_STR(RD);
369         CASE_RETURN_STR(WR);
370         CASE_RETURN_STR(ENCRYPT_RD);
371         CASE_RETURN_STR(ENCRYPT_WR);
372         CASE_RETURN_STR(ENC_AUTH_RD);
373         CASE_RETURN_STR(ENC_AUTH_WR);
374         default:
375                 return "--";
376         }
377 }
378
379 char *char_prop_to_string(uint8_t prop, char *str)
380 {
381         int i, ret = 0;
382         char *ptr = str;
383
384         for (i = 0; i < 8; i++) {
385                 if (prop & (1 << i)) {
386                         ret = snprintf(ptr, 11, "%s|", dump_char_prop(prop & (1 << i)));
387                         ptr += ret;
388                 }
389         }
390         --ptr;
391         *ptr = '\0';
392         return str;
393 }
394
395 char *char_perm_to_string(uint8_t perm, char *str)
396 {
397         int i, ret = 0;
398         char *ptr = str;
399
400         for (i = 0; i < 6; i++) {
401                 if (perm & (1 << i)) {
402                         ret = snprintf(ptr, 13, "%s|", dump_char_perm(perm & (1 << i)));
403                         ptr += ret;
404                 }
405         }
406         --ptr;
407         *ptr = '\0';
408         return str;
409 }
410
411 void local_le_feat_2_string(char *str, const bt_local_le_features_t *f)
412 {
413         uint16_t scan_num;
414
415         str += snprintf(str, strlen(str), "{\n");
416
417         str += sprintf(str, "Privacy supported: %s,\n",
418                         f->local_privacy_enabled ? "TRUE" : "FALSE");
419
420         str += sprintf(str, "Num of advertising instances: %u,\n",
421                         f->max_adv_instance);
422
423         str += sprintf(str, "PRA offloading support: %s,\n",
424                         f->rpa_offload_supported ? "TRUE" : "FALSE");
425
426         str += sprintf(str, "Num of offloaded IRKs: %u,\n",
427                         f->max_irk_list_size);
428
429         str += sprintf(str, "Num of offloaded scan filters: %u,\n",
430                         f->max_adv_filter_supported);
431
432         scan_num = f->scan_result_storage_size;
433
434         str += sprintf(str, "Num of offloaded scan results: %u,\n", scan_num);
435
436         str += sprintf(str, "Activity & energy report support: %s\n",
437                         f->activity_energy_info_supported ? "TRUE" : "FALSE");
438
439         str += sprintf(str, "LE 2M PHY support: %s\n",
440                         f->le_2m_phy_supported ? "TRUE" : "FALSE");
441
442         str += sprintf(str, "LE Coded PHY support: %s\n",
443                         f->le_coded_phy_supported ? "TRUE" : "FALSE");
444
445         sprintf(str, "}");
446 }
447
448 char* convert_property_type_2_str(bt_property_type_t prop_type)
449 {
450         switch (prop_type) {
451         case BT_PROPERTY_BDNAME:
452                 return "[Bluetooth Name]";
453         case BT_PROPERTY_BDADDR:
454                 return "[Bluetooth Address]";
455         case BT_PROPERTY_UUIDS:
456                 return "[UUIDS]";
457         case BT_PROPERTY_CLASS_OF_DEVICE:
458                 return "[Class of Device]";
459         case BT_PROPERTY_TYPE_OF_DEVICE:
460                 return "[Bluetooth Type of Device]";
461         case BT_PROPERTY_SERVICE_RECORD:
462                 return "[Bluetooth Service record]";
463         case BT_PROPERTY_ADAPTER_SCAN_MODE:
464                 return "[Bluetooth Adapter Scan Mode]";
465         case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
466                 return "[Bluetooth Bonded Devices]";
467         case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
468                 return "[Bluetooth Adapter Discovery Timeout]";
469         case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
470                 return "[Bluetooth Friendly Name]";
471         case BT_PROPERTY_REMOTE_RSSI:
472                 return "[Bluetooth Rmote RSSI]";
473         case BT_PROPERTY_REMOTE_VERSION_INFO:
474                 return "[Bluetooth Version Info]";
475         case BT_PROPERTY_LOCAL_LE_FEATURES:
476                 return "[Bluetooth LE Features]";
477         case BT_PROPERTY_REMOTE_PAIRED:
478                 return "[Bluetooth Remote Paired]";
479         case BT_PROPERTY_REMOTE_CONNECTED:
480                 return "[Bluetooth Remote Connected]";
481         case BT_PROPERTY_REMOTE_TRUST:
482                 return "[Bluetooth Remote TRUST]";
483         case BT_PROPERTY_PAIRABLE:
484                 return "[Bluetooth Pairable]";
485         case BT_PROPERTY_PAIRABLE_TIMEOUT:
486                 return "[Bluetooth Pairable Timeout]";
487         case BT_PROPERTY_VERSION:
488                 return "[Bluetooth Version]";
489         case BT_PROPERTY_IPSP_INITIALIZED:
490                 return "[Bluetooth IPSP Initialized]";
491         case BT_PROPERTY_MODALIAS:
492                 return "[Bluetooth ModAlias]";
493         case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
494                 return "[Bluetooth Remote Device Timestamp]";
495         case BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA_LEN:
496                 return "[Bluetooth Remote Device Manufacturer Data Len]";
497         case BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA:
498                 return "[Bluetooth Remote Device Manufacturer Data]";
499         case BT_PROPERTY_REMOTE_BLE_ADV_DATA:
500                 return "[Bluetooth Remote Device LE Advertising Data]";
501         default:
502                 return "[Default Property]";
503         }
504 }
505
506 const char *dump_uuid_name(int uuid_no)
507 {
508         switch (uuid_no) {
509         CASE_RETURN_STR(BASE)
510         CASE_RETURN_STR(SDP)
511         CASE_RETURN_STR(UDP)
512         CASE_RETURN_STR(RFCOMM)
513         CASE_RETURN_STR(TCP)
514         CASE_RETURN_STR(TCS_BIN)
515         CASE_RETURN_STR(TCS_AT)
516         CASE_RETURN_STR(ATT)
517         CASE_RETURN_STR(OBEX)
518         CASE_RETURN_STR(IP)
519         CASE_RETURN_STR(FTP)
520         CASE_RETURN_STR(HTTP)
521         CASE_RETURN_STR(WSP)
522         CASE_RETURN_STR(BNEP)
523         CASE_RETURN_STR(UPNP)
524         CASE_RETURN_STR(HIDP)
525         CASE_RETURN_STR(HardcopyControlChannel)
526         CASE_RETURN_STR(HardcopyDataChannel)
527         CASE_RETURN_STR(HardcopyNotification)
528         CASE_RETURN_STR(AVCTP)
529         CASE_RETURN_STR(AVDTP)
530         CASE_RETURN_STR(CMTP)
531         CASE_RETURN_STR(MCAPControlChannel)
532         CASE_RETURN_STR(MCAPDataChannel)
533         CASE_RETURN_STR(L2CAP)
534         CASE_RETURN_STR(ServiceDiscoveryServerServiceClassID)
535         CASE_RETURN_STR(BrowseGroupDescriptorServiceClassID)
536         CASE_RETURN_STR(SerialPort)
537         CASE_RETURN_STR(LANAccessUsingPPP)
538         CASE_RETURN_STR(DialupNetworking)
539         CASE_RETURN_STR(IrMCSync)
540         CASE_RETURN_STR(OBEXObjectPush)
541         CASE_RETURN_STR(OBEXFileTransfer)
542         CASE_RETURN_STR(IrMCSyncCommand)
543         CASE_RETURN_STR(Headset)
544         CASE_RETURN_STR(CordlessTelephony)
545         CASE_RETURN_STR(AudioSource)
546         CASE_RETURN_STR(AudioSink)
547         CASE_RETURN_STR(AV_RemoteControlTarget)
548         CASE_RETURN_STR(AdvancedAudioDistribution)
549         CASE_RETURN_STR(AV_RemoteControl)
550         CASE_RETURN_STR(AV_RemoteControlController)
551         CASE_RETURN_STR(Intercom)
552         CASE_RETURN_STR(Fax)
553         CASE_RETURN_STR(Headset_Audio_Gateway)
554         CASE_RETURN_STR(WAP)
555         CASE_RETURN_STR(WAP_CLIENT)
556         CASE_RETURN_STR(PANU)
557         CASE_RETURN_STR(NAP)
558         CASE_RETURN_STR(GN)
559         CASE_RETURN_STR(DirectPrinting)
560         CASE_RETURN_STR(ReferencePrinting)
561         CASE_RETURN_STR(Basic_Imaging_Profile)
562         CASE_RETURN_STR(ImagingResponder)
563         CASE_RETURN_STR(ImagingAutomaticArchive)
564         CASE_RETURN_STR(ImagingReferencedObjects)
565         CASE_RETURN_STR(Handsfree)
566         CASE_RETURN_STR(HandsfreeAudioGateway)
567         CASE_RETURN_STR(DirectPrintingReferenceObjectsService)
568         CASE_RETURN_STR(ReflectedUI)
569         CASE_RETURN_STR(BasicPrinting)
570         CASE_RETURN_STR(PrintingStatus)
571         CASE_RETURN_STR(HumanInterfaceDeviceService)
572         CASE_RETURN_STR(HardcopyCableReplacement)
573         CASE_RETURN_STR(HCR_Print)
574         CASE_RETURN_STR(HCR_Scan)
575         CASE_RETURN_STR(Common_ISDN_Access)
576         CASE_RETURN_STR(SIM_Access)
577         CASE_RETURN_STR(Phonebook_Access_PCE)
578         CASE_RETURN_STR(Phonebook_Access_PSE)
579         CASE_RETURN_STR(Phonebook_Access)
580         CASE_RETURN_STR(Headset_HS)
581         CASE_RETURN_STR(Message_Access_Server)
582         CASE_RETURN_STR(Message_Notification_Server)
583         CASE_RETURN_STR(Message_Access_Profile)
584         CASE_RETURN_STR(GNSS)
585         CASE_RETURN_STR(GNSS_Server)
586         CASE_RETURN_STR(ThreeD_Display)
587         CASE_RETURN_STR(ThreeD_Glasses)
588         CASE_RETURN_STR(ThreeD_Synchronization)
589         CASE_RETURN_STR(MPS_Profile)
590         CASE_RETURN_STR(MPS_SC)
591         CASE_RETURN_STR(CTN_Access_Service)
592         CASE_RETURN_STR(CTN_Notification_Service)
593         CASE_RETURN_STR(CTN_Profile)
594         CASE_RETURN_STR(PnPInformation)
595         CASE_RETURN_STR(GenericNetworking)
596         CASE_RETURN_STR(GenericFileTransfer)
597         CASE_RETURN_STR(GenericAudio)
598         CASE_RETURN_STR(GenericTelephony)
599         CASE_RETURN_STR(UPNP_Service)
600         CASE_RETURN_STR(UPNP_IP_Service)
601         CASE_RETURN_STR(ESDP_UPNP_IP_PAN)
602         CASE_RETURN_STR(ESDP_UPNP_IP_LAP)
603         CASE_RETURN_STR(ESDP_UPNP_L2CAP)
604         CASE_RETURN_STR(VideoSource)
605         CASE_RETURN_STR(VideoSink)
606         CASE_RETURN_STR(VideoDistribution)
607         CASE_RETURN_STR(HDP)
608         CASE_RETURN_STR(HDP_Source)
609         CASE_RETURN_STR(HDP_Sink)
610         CASE_RETURN_STR(Generic_Access)
611         CASE_RETURN_STR(Generic_Attribute)
612         CASE_RETURN_STR(Immediate_Alert)
613         CASE_RETURN_STR(Link_Loss)
614         CASE_RETURN_STR(Tx_Power)
615         CASE_RETURN_STR(Current_Time)
616         CASE_RETURN_STR(Reference_Time_Update)
617         CASE_RETURN_STR(Next_Dst_Change)
618         CASE_RETURN_STR(Glucose)
619         CASE_RETURN_STR(Health_Thermometer)
620         CASE_RETURN_STR(Device_Information)
621         CASE_RETURN_STR(Heart_Rate)
622         CASE_RETURN_STR(Phone_Alert_Status)
623         CASE_RETURN_STR(Battery_Service)
624         CASE_RETURN_STR(Blood_Pressure)
625         CASE_RETURN_STR(Alert_Notification)
626         CASE_RETURN_STR(Human_Interface_Device)
627         CASE_RETURN_STR(Scan_Parameters)
628         CASE_RETURN_STR(Running_Speed_And_Cadence)
629         CASE_RETURN_STR(Automation_IO)
630         CASE_RETURN_STR(Cycling_Speed_And_Cadence)
631         CASE_RETURN_STR(Cycling_Power)
632         CASE_RETURN_STR(Location_And_Navigation)
633         CASE_RETURN_STR(Environmental_Sensing)
634         CASE_RETURN_STR(Body_Composition)
635         CASE_RETURN_STR(User_Data)
636         CASE_RETURN_STR(Weight_Scale)
637         CASE_RETURN_STR(Bond_Management)
638         CASE_RETURN_STR(Continuous_Glucose_Monitoring)
639         CASE_RETURN_STR(Internet_Protocol_Support)
640         CASE_RETURN_STR(Indoor_Positioning)
641         CASE_RETURN_STR(Pulse_Oximeter)
642         CASE_RETURN_STR(Http_Proxy)
643         CASE_RETURN_STR(Transport_Discovery)
644         CASE_RETURN_STR(Object_Transfer)
645         CASE_RETURN_STR(Gap_Device_Name)
646         CASE_RETURN_STR(Gap_Appearance)
647         CASE_RETURN_STR(Gap_Peripheral_Privacy_Flag)
648         CASE_RETURN_STR(Gap_Reconnection_Address)
649         CASE_RETURN_STR(Gap_Peripheral_Preferred_Connection_Parameters)
650         CASE_RETURN_STR(Gatt_Service_Changed)
651         CASE_RETURN_STR(Alert_Level)
652         CASE_RETURN_STR(Tx_Power_Level)
653         CASE_RETURN_STR(Date_Time)
654         CASE_RETURN_STR(Day_Of_Week)
655         CASE_RETURN_STR(Day_Date_Time)
656         CASE_RETURN_STR(Exact_Time_256)
657         CASE_RETURN_STR(Dst_Offset)
658         CASE_RETURN_STR(Time_Zone)
659         CASE_RETURN_STR(Local_Time_Information)
660         CASE_RETURN_STR(Time_With_Dst)
661         CASE_RETURN_STR(Time_Accuracy)
662         CASE_RETURN_STR(Time_Source)
663         CASE_RETURN_STR(Reference_Time_Information)
664         CASE_RETURN_STR(Time_Update_Control_Point)
665         CASE_RETURN_STR(Time_Update_State)
666         CASE_RETURN_STR(Glucose_Measurement)
667         CASE_RETURN_STR(Battery_Level)
668         CASE_RETURN_STR(Temperature_Measurement)
669         CASE_RETURN_STR(Temperature_Type)
670         CASE_RETURN_STR(Intermediate_Temperature)
671         CASE_RETURN_STR(Measurement_Interval)
672         CASE_RETURN_STR(Boot_Keyboard_Input_Report)
673         CASE_RETURN_STR(System_Id)
674         CASE_RETURN_STR(Model_Number_String)
675         CASE_RETURN_STR(Serial_Number_String)
676         CASE_RETURN_STR(Firmware_Revision_String)
677         CASE_RETURN_STR(Hardware_Revision_String)
678         CASE_RETURN_STR(Software_Revision_String)
679         CASE_RETURN_STR(Manufacturer_Name_String)
680         CASE_RETURN_STR(Regulatory_Certification_Data_List)
681         CASE_RETURN_STR(Current_Time_Charac)
682         CASE_RETURN_STR(Magnetic_Declination)
683         CASE_RETURN_STR(Scan_Refresh)
684         CASE_RETURN_STR(Boot_Keyboard_Output_Report)
685         CASE_RETURN_STR(Boot_Mouse_Input_Report)
686         CASE_RETURN_STR(Glucose_Measurement_Context)
687         CASE_RETURN_STR(Blood_Pressure_Measurement)
688         CASE_RETURN_STR(Intermediate_Cuff_Pressure)
689         CASE_RETURN_STR(Heart_Rate_Measurement)
690         CASE_RETURN_STR(Body_Sensor_Location)
691         CASE_RETURN_STR(Heart_Rate_Control_Point)
692         CASE_RETURN_STR(Alert_Status)
693         CASE_RETURN_STR(Ringer_Control_Point)
694         CASE_RETURN_STR(Ringer_Setting)
695         CASE_RETURN_STR(Alert_Category_Id_Bit_Mask)
696         CASE_RETURN_STR(Alert_Category_Id)
697         CASE_RETURN_STR(Alert_Notification_Control_Point)
698         CASE_RETURN_STR(Unread_Alert_Status)
699         CASE_RETURN_STR(New_Alert)
700         CASE_RETURN_STR(Supported_New_Alert_Category)
701         CASE_RETURN_STR(Supported_Unread_Alert_Category)
702         CASE_RETURN_STR(Blood_Pressure_Feature)
703         CASE_RETURN_STR(Hid_Information)
704         CASE_RETURN_STR(Report_Map)
705         CASE_RETURN_STR(Hid_Control_Point)
706         CASE_RETURN_STR(Report)
707         CASE_RETURN_STR(Protocol_Mode)
708         CASE_RETURN_STR(Scan_Interval_Window)
709         CASE_RETURN_STR(Pnp_Id)
710         CASE_RETURN_STR(Glucose_Feature)
711         CASE_RETURN_STR(Record_Access_Control_Point)
712         CASE_RETURN_STR(Rsc_Measurement)
713         CASE_RETURN_STR(Rsc_Feature)
714         CASE_RETURN_STR(Sc_Control_Point)
715         CASE_RETURN_STR(Digital)
716         CASE_RETURN_STR(Analog)
717         CASE_RETURN_STR(Aggregate)
718         CASE_RETURN_STR(Csc_Measurement)
719         CASE_RETURN_STR(Csc_Feature)
720         CASE_RETURN_STR(Sensor_Location)
721         CASE_RETURN_STR(Plx_Spot_Check_Measurement)
722         CASE_RETURN_STR(Plx_Continuous_Measurement)
723         CASE_RETURN_STR(Plx_Features)
724         CASE_RETURN_STR(Cycling_Power_Measurement)
725         CASE_RETURN_STR(Cycling_Power_Vector)
726         CASE_RETURN_STR(Cycling_Power_Feature)
727         CASE_RETURN_STR(Cycling_Power_Control_Point)
728         CASE_RETURN_STR(Location_And_Speed)
729         CASE_RETURN_STR(Navigation)
730         CASE_RETURN_STR(Position_Quality)
731         CASE_RETURN_STR(Ln_Feature)
732         CASE_RETURN_STR(Ln_Control_Point)
733         CASE_RETURN_STR(Elevation)
734         CASE_RETURN_STR(Pressure)
735         CASE_RETURN_STR(Temperature)
736         CASE_RETURN_STR(Humidity)
737         CASE_RETURN_STR(True_Wind_Speed)
738         CASE_RETURN_STR(True_Wind_Direction)
739         CASE_RETURN_STR(Apparent_Wind_Speed)
740         CASE_RETURN_STR(Apparent_Wind_Direction)
741         CASE_RETURN_STR(Gust_Factor)
742         CASE_RETURN_STR(Pollen_Concentration)
743         CASE_RETURN_STR(Uv_Index)
744         CASE_RETURN_STR(Irradiance)
745         CASE_RETURN_STR(Rainfall)
746         CASE_RETURN_STR(Wind_Chill)
747         CASE_RETURN_STR(Heat_Index)
748         CASE_RETURN_STR(Dew_Point)
749         CASE_RETURN_STR(Descriptor_Value_Changed)
750         CASE_RETURN_STR(Aerobic_Threshold)
751         CASE_RETURN_STR(Age)
752         CASE_RETURN_STR(Anaerobic_Heart_Rate_Lower_Limit)
753         CASE_RETURN_STR(Anaerobic_Heart_Rate_Upper_Limit)
754         CASE_RETURN_STR(Anaerobic_Threshold)
755         CASE_RETURN_STR(Aerobic_Heart_Rate_Upper_Limit)
756         CASE_RETURN_STR(Date_Of_Birth)
757         CASE_RETURN_STR(Date_Of_Threshold_Assessment)
758         CASE_RETURN_STR(Email_Address)
759         CASE_RETURN_STR(Fat_Burn_Heart_Rate_Lower_Limit)
760         CASE_RETURN_STR(Fat_Burn_Heart_Rate_Upper_Limit)
761         CASE_RETURN_STR(First_Name)
762         CASE_RETURN_STR(Five_Zone_Heart_Rate_Limits)
763         CASE_RETURN_STR(Gender)
764         CASE_RETURN_STR(Heart_Rate_Max)
765         CASE_RETURN_STR(Height)
766         CASE_RETURN_STR(Hip_Circumference)
767         CASE_RETURN_STR(Last_Name)
768         CASE_RETURN_STR(Maximum_Recommended_Heart_Rate)
769         CASE_RETURN_STR(Resting_Heart_Rate)
770         CASE_RETURN_STR(Sport_Type_For_Aerobic_And_Anaerobic_Thresholds)
771         CASE_RETURN_STR(Three_Zone_Heart_Rate_Limits)
772         CASE_RETURN_STR(Two_Zone_Heart_Rate_Limit)
773         CASE_RETURN_STR(Vo2_Max)
774         CASE_RETURN_STR(Waist_Circumference)
775         CASE_RETURN_STR(Weight)
776         CASE_RETURN_STR(Database_Change_Increment)
777         CASE_RETURN_STR(User_Index)
778         CASE_RETURN_STR(Body_Composition_Feature)
779         CASE_RETURN_STR(Body_Composition_Measurement)
780         CASE_RETURN_STR(Weight_Measurement)
781         CASE_RETURN_STR(Weight_Scale_Feature)
782         CASE_RETURN_STR(User_Control_Point)
783         CASE_RETURN_STR(Magnetic_Flux_Density_2D)
784         CASE_RETURN_STR(Magnetic_Flux_Density_3D)
785         CASE_RETURN_STR(Language)
786         CASE_RETURN_STR(Barometric_Pressure_Trend)
787         CASE_RETURN_STR(Bond_Management_Control_Point)
788         CASE_RETURN_STR(Bond_Management_Feature)
789         CASE_RETURN_STR(Gap_Central_Address_Resolution_Support)
790         CASE_RETURN_STR(Cgm_Measurement)
791         CASE_RETURN_STR(Cgm_Feature)
792         CASE_RETURN_STR(Cgm_Status)
793         CASE_RETURN_STR(Cgm_Session_Start_Time)
794         CASE_RETURN_STR(Cgm_Session_Run_Time)
795         CASE_RETURN_STR(Cgm_Specific_Ops_Control_Point)
796         CASE_RETURN_STR(Indoor_Positioning_Configuration)
797         CASE_RETURN_STR(Latitude)
798         CASE_RETURN_STR(Longitude)
799         CASE_RETURN_STR(Local_North_Coordinate)
800         CASE_RETURN_STR(Local_East_Coordinate)
801         CASE_RETURN_STR(Floor_Number)
802         CASE_RETURN_STR(Altitude)
803         CASE_RETURN_STR(Uncertainty)
804         CASE_RETURN_STR(Location_Name)
805         CASE_RETURN_STR(Uri)
806         CASE_RETURN_STR(Http_Headers)
807         CASE_RETURN_STR(Http_Status_Code)
808         CASE_RETURN_STR(Http_Entity_Body)
809         CASE_RETURN_STR(Http_Control_Point)
810         CASE_RETURN_STR(Https_Security)
811         CASE_RETURN_STR(Tds_Control_Point)
812         CASE_RETURN_STR(Ots_Feature)
813         CASE_RETURN_STR(Object_Name)
814         CASE_RETURN_STR(Object_Type)
815         CASE_RETURN_STR(Object_Size)
816         CASE_RETURN_STR(Object_First_Created)
817         CASE_RETURN_STR(Object_Last_Modified)
818         CASE_RETURN_STR(Object_Id)
819         CASE_RETURN_STR(Object_Properties)
820         CASE_RETURN_STR(Object_Action_Control_Point)
821         CASE_RETURN_STR(Object_List_Control_Point)
822         CASE_RETURN_STR(Object_List_Filter)
823         CASE_RETURN_STR(Object_Changed)
824         CASE_RETURN_STR(Fitness_Machine_Control_Point)
825         CASE_RETURN_STR(Gatt_Characteristic_Extended_Properties)
826         CASE_RETURN_STR(Gatt_Characteristic_User_Description)
827         CASE_RETURN_STR(Gatt_Client_Characteristic_Configuration)
828         CASE_RETURN_STR(Gatt_Server_Characteristic_Configuration)
829         CASE_RETURN_STR(Gatt_Characteristic_Presentation_Format)
830         CASE_RETURN_STR(Gatt_Characteristic_Aggregate_Format)
831         CASE_RETURN_STR(Valid_Range)
832         CASE_RETURN_STR(External_Report_Reference)
833         CASE_RETURN_STR(Report_Reference)
834         CASE_RETURN_STR(Number_Of_Digitals)
835         CASE_RETURN_STR(Value_Trigger_Setting)
836         CASE_RETURN_STR(Es_Configuration)
837         CASE_RETURN_STR(Es_Measurement)
838         CASE_RETURN_STR(Es_Trigger_Setting)
839         CASE_RETURN_STR(Time_Trigger_Setting)
840         CASE_RETURN_STR(Gatt_Primary_Service_Declaration)
841         CASE_RETURN_STR(Gatt_Secondary_Service_Declaration)
842         CASE_RETURN_STR(Gatt_Include_Declaration)
843         CASE_RETURN_STR(Gatt_Characteristic_Declaration)
844         default:
845                 return "--";
846         }
847 }