Blob: util.c
Blob id: fabe4283094bebe721c114546de4f9dc8b5ce945
Size: 54.5 KB
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 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 | // SPDX-License-Identifier: LGPL-2.1-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * Copyright 2023-2024 NXP * * */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> #include <ctype.h> #include <stdbool.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <dirent.h> #include <limits.h> #include <string.h> #ifdef HAVE_SYS_RANDOM_H #include <sys/random.h> #endif #include <bluetooth/bluetooth.h> /* define MAX_INPUT for musl */ #ifndef MAX_INPUT #define MAX_INPUT _POSIX_MAX_INPUT #endif #include "src/shared/util.h" void *util_malloc(size_t size) { if (__builtin_expect(!!size, 1)) { void *ptr; ptr = malloc(size); if (ptr) return ptr; fprintf(stderr, "failed to allocate %zu bytes\n", size); abort(); } return NULL; } void *util_memdup(const void *src, size_t size) { void *cpy; if (!src || !size) return NULL; cpy = util_malloc(size); if (!cpy) return NULL; memcpy(cpy, src, size); return cpy; } void util_debug_va(util_debug_func_t function, void *user_data, const char *format, va_list va) { char str[MAX_INPUT]; if (!function || !format) return; vsnprintf(str, sizeof(str), format, va); function(str, user_data); } void util_debug(util_debug_func_t function, void *user_data, const char *format, ...) { va_list ap; if (!function || !format) return; va_start(ap, format); util_debug_va(function, user_data, format, ap); va_end(ap); } void util_hexdump(const char dir, const unsigned char *buf, size_t len, util_debug_func_t function, void *user_data) { static const char hexdigits[] = "0123456789abcdef"; char str[68]; size_t i; if (!function || !len) return; str[0] = dir; for (i = 0; i < len; i++) { str[((i % 16) * 3) + 1] = ' '; str[((i % 16) * 3) + 2] = hexdigits[buf[i] >> 4]; str[((i % 16) * 3) + 3] = hexdigits[buf[i] & 0xf]; str[(i % 16) + 51] = isprint(buf[i]) ? buf[i] : '.'; if ((i + 1) % 16 == 0) { str[49] = ' '; str[50] = ' '; str[67] = '\0'; function(str, user_data); str[0] = ' '; } } if (i % 16 > 0) { size_t j; for (j = (i % 16); j < 16; j++) { str[(j * 3) + 1] = ' '; str[(j * 3) + 2] = ' '; str[(j * 3) + 3] = ' '; str[j + 51] = ' '; } str[49] = ' '; str[50] = ' '; str[67] = '\0'; function(str, user_data); } } /* Helper to print debug information of bitfields */ uint64_t util_debug_bit(const char *label, uint64_t val, const struct util_bit_debugger *table, util_debug_func_t function, void *user_data) { uint64_t mask = val; int i; for (i = 0; table[i].str; i++) { if (val & (((uint64_t) 1) << table[i].bit)) { util_debug(function, user_data, "%s%s", label, table[i].str); mask &= ~(((uint64_t) 1) << table[i].bit); } } return mask; } static const struct util_ltv_debugger* ltv_debugger(const struct util_ltv_debugger *debugger, size_t num, uint8_t type) { size_t i; if (!debugger || !num) return NULL; for (i = 0; i < num; i++) { const struct util_ltv_debugger *debug = &debugger[i]; if (debug->type == type) return debug; } return NULL; } /* Helper to itertate over LTV entries */ bool util_ltv_foreach(const uint8_t *data, uint8_t len, uint8_t *type, util_ltv_func_t func, void *user_data) { struct iovec iov; int i; if (!func || !data) return false; iov.iov_base = (void *) data; iov.iov_len = len; for (i = 0; iov.iov_len; i++) { uint8_t l, t, *v; if (!util_iov_pull_u8(&iov, &l)) return false; if (!l) { func(i, l, 0, NULL, user_data); continue; } if (!util_iov_pull_u8(&iov, &t)) return false; l--; if (l) { v = util_iov_pull_mem(&iov, l); if (!v) return false; } else v = NULL; if (!type || *type == t) func(i, l, t, v, user_data); } return true; } /* Helper to add l,t,v data in an iovec struct */ void util_ltv_push(struct iovec *output, uint8_t l, uint8_t t, void *v) { output->iov_base = realloc(output->iov_base, output->iov_len + l + 2); util_iov_push_u8(output, l + 1); util_iov_push_u8(output, t); util_iov_push_mem(output, l, v); } /* Helper to print debug information of LTV entries */ bool util_debug_ltv(const uint8_t *data, uint8_t len, const struct util_ltv_debugger *debugger, size_t num, util_debug_func_t function, void *user_data) { struct iovec iov; int i; iov.iov_base = (void *) data; iov.iov_len = len; for (i = 0; iov.iov_len; i++) { uint8_t l, t, *v; const struct util_ltv_debugger *debug; if (!util_iov_pull_u8(&iov, &l)) { util_debug(function, user_data, "Unable to pull length"); return false; } if (!l) { util_debug(function, user_data, "#%d: len 0x%02x", i, l); continue; } if (!util_iov_pull_u8(&iov, &t)) { util_debug(function, user_data, "Unable to pull type"); return false; } util_debug(function, user_data, "#%d: len 0x%02x type 0x%02x", i, l, t); l--; v = util_iov_pull_mem(&iov, l); if (!v) { util_debug(function, user_data, "Unable to pull value"); return false; } debug = ltv_debugger(debugger, num, t); if (debug) debug->func(v, l, function, user_data); else util_hexdump(' ', (void *)v, l, function, user_data); } return true; } /* Helper for getting the dirent type in case readdir returns DT_UNKNOWN */ unsigned char util_get_dt(const char *parent, const char *name) { char filename[PATH_MAX]; struct stat st; snprintf(filename, PATH_MAX, "%s/%s", parent, name); if (lstat(filename, &st) == 0 && S_ISDIR(st.st_mode)) return DT_DIR; return DT_UNKNOWN; } /* Helper for getting a random in case getrandom unavailable (glibc < 2.25) */ ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags) { #ifdef HAVE_GETRANDOM return getrandom(buf, buflen, flags); #else int fd; ssize_t bytes; fd = open("/dev/urandom", O_CLOEXEC); if (fd < 0) return -1; bytes = read(fd, buf, buflen); close(fd); return bytes; #endif } /* Helpers for bitfield operations */ /* Find unique id in range from 1 to max but no bigger than 64. */ uint8_t util_get_uid(uint64_t *bitmap, uint8_t max) { uint8_t id; id = ffsll(~*bitmap); if (!id || id > max) return 0; *bitmap |= ((uint64_t)1) << (id - 1); return id; } /* Clear id bit in bitmap */ void util_clear_uid(uint64_t *bitmap, uint8_t id) { if (!id || id > 64) return; *bitmap &= ~(((uint64_t)1) << (id - 1)); } struct iovec *util_iov_dup(const struct iovec *iov, size_t cnt) { struct iovec *dup; size_t i; if (!iov) return NULL; dup = new0(struct iovec, cnt); for (i = 0; i < cnt; i++) util_iov_memcpy(&dup[i], iov[i].iov_base, iov[i].iov_len); return dup; } int util_iov_memcmp(const struct iovec *iov1, const struct iovec *iov2) { if (!iov1) return 1; if (!iov2) return -1; if (iov1->iov_len != iov2->iov_len) return iov1->iov_len - iov2->iov_len; return memcmp(iov1->iov_base, iov2->iov_base, iov1->iov_len); } void util_iov_memcpy(struct iovec *iov, void *src, size_t len) { if (!iov || !src || !len) return; iov->iov_base = realloc(iov->iov_base, len); iov->iov_len = len; memcpy(iov->iov_base, src, len); } void util_iov_free(struct iovec *iov, size_t cnt) { size_t i; if (!iov) return; for (i = 0; i < cnt; i++) free(iov[i].iov_base); free(iov); } void *util_iov_push(struct iovec *iov, size_t len) { void *data; if (!iov) return NULL; data = iov->iov_base + iov->iov_len; iov->iov_len += len; return data; } void *util_iov_push_mem(struct iovec *iov, size_t len, const void *data) { void *p; p = util_iov_push(iov, len); if (!p) return NULL; if (data) memcpy(p, data, len); return p; } void *util_iov_push_le64(struct iovec *iov, uint64_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_le64(val, p); return p; } void *util_iov_push_be64(struct iovec *iov, uint64_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_be64(val, p); return p; } void *util_iov_push_le32(struct iovec *iov, uint32_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_le32(val, p); return p; } void *util_iov_push_be32(struct iovec *iov, uint32_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_be32(val, p); return p; } void *util_iov_push_le24(struct iovec *iov, uint32_t val) { void *p; p = util_iov_push(iov, sizeof(uint24_t)); if (!p) return NULL; put_le24(val, p); return p; } void *util_iov_push_be24(struct iovec *iov, uint32_t val) { void *p; p = util_iov_push(iov, sizeof(uint24_t)); if (!p) return NULL; put_le24(val, p); return p; } void *util_iov_push_le16(struct iovec *iov, uint16_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_le16(val, p); return p; } void *util_iov_push_be16(struct iovec *iov, uint16_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_be16(val, p); return p; } void *util_iov_push_u8(struct iovec *iov, uint8_t val) { void *p; p = util_iov_push(iov, sizeof(val)); if (!p) return NULL; put_u8(val, p); return p; } void *util_iov_append(struct iovec *iov, const void *data, size_t len) { iov->iov_base = realloc(iov->iov_base, iov->iov_len + len); return util_iov_push_mem(iov, len, data); } struct iovec *util_iov_new(void *data, size_t len) { struct iovec *iov; iov = new0(struct iovec, 1); util_iov_append(iov, data, len); return iov; } void *util_iov_pull(struct iovec *iov, size_t len) { if (!iov) return NULL; if (iov->iov_len < len) return NULL; iov->iov_base += len; iov->iov_len -= len; return iov->iov_base; } void *util_iov_pull_mem(struct iovec *iov, size_t len) { void *data = iov->iov_base; if (util_iov_pull(iov, len)) return data; return NULL; } void *util_iov_pull_le64(struct iovec *iov, uint64_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_le64(data); return data; } return NULL; } void *util_iov_pull_be64(struct iovec *iov, uint64_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_be64(data); return data; } return NULL; } void *util_iov_pull_le32(struct iovec *iov, uint32_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_le32(data); return data; } return NULL; } void *util_iov_pull_be32(struct iovec *iov, uint32_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_be32(data); return data; } return NULL; } void *util_iov_pull_le24(struct iovec *iov, uint32_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(uint24_t))) { *val = get_le24(data); return data; } return NULL; } void *util_iov_pull_be24(struct iovec *iov, uint32_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(uint24_t))) { *val = get_be24(data); return data; } return NULL; } void *util_iov_pull_le16(struct iovec *iov, uint16_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_le16(data); return data; } return NULL; } void *util_iov_pull_be16(struct iovec *iov, uint16_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_be16(data); return data; } return NULL; } void *util_iov_pull_u8(struct iovec *iov, uint8_t *val) { void *data = iov->iov_base; if (util_iov_pull(iov, sizeof(*val))) { *val = get_u8(data); return data; } return NULL; } static const struct { uint16_t uuid; const char *str; } uuid16_table[] = { { 0x0001, "SDP" }, { 0x0003, "RFCOMM" }, { 0x0005, "TCS-BIN" }, { 0x0007, "ATT" }, { 0x0008, "OBEX" }, { 0x000f, "BNEP" }, { 0x0010, "UPNP" }, { 0x0011, "HIDP" }, { 0x0012, "Hardcopy Control Channel" }, { 0x0014, "Hardcopy Data Channel" }, { 0x0016, "Hardcopy Notification" }, { 0x0017, "AVCTP" }, { 0x0019, "AVDTP" }, { 0x001b, "CMTP" }, { 0x001e, "MCAP Control Channel" }, { 0x001f, "MCAP Data Channel" }, { 0x0100, "L2CAP" }, /* 0x0101 to 0x0fff undefined */ { 0x1000, "Service Discovery Server Service Class" }, { 0x1001, "Browse Group Descriptor Service Class" }, { 0x1002, "Public Browse Root" }, /* 0x1003 to 0x1100 undefined */ { 0x1101, "Serial Port" }, { 0x1102, "LAN Access Using PPP" }, { 0x1103, "Dialup Networking" }, { 0x1104, "IrMC Sync" }, { 0x1105, "OBEX Object Push" }, { 0x1106, "OBEX File Transfer" }, { 0x1107, "IrMC Sync Command" }, { 0x1108, "Headset" }, { 0x1109, "Cordless Telephony" }, { 0x110a, "Audio Source" }, { 0x110b, "Audio Sink" }, { 0x110c, "A/V Remote Control Target" }, { 0x110d, "Advanced Audio Distribution" }, { 0x110e, "A/V Remote Control" }, { 0x110f, "A/V Remote Control Controller" }, { 0x1110, "Intercom" }, { 0x1111, "Fax" }, { 0x1112, "Headset AG" }, { 0x1113, "WAP" }, { 0x1114, "WAP Client" }, { 0x1115, "PANU" }, { 0x1116, "NAP" }, { 0x1117, "GN" }, { 0x1118, "Direct Printing" }, { 0x1119, "Reference Printing" }, { 0x111a, "Basic Imaging Profile" }, { 0x111b, "Imaging Responder" }, { 0x111c, "Imaging Automatic Archive" }, { 0x111d, "Imaging Referenced Objects" }, { 0x111e, "Handsfree" }, { 0x111f, "Handsfree Audio Gateway" }, { 0x1120, "Direct Printing Reference Objects Service" }, { 0x1121, "Reflected UI" }, { 0x1122, "Basic Printing" }, { 0x1123, "Printing Status" }, { 0x1124, "Human Interface Device Service" }, { 0x1125, "Hardcopy Cable Replacement" }, { 0x1126, "HCR Print" }, { 0x1127, "HCR Scan" }, { 0x1128, "Common ISDN Access" }, /* 0x1129 and 0x112a undefined */ { 0x112d, "SIM Access" }, { 0x112e, "Phonebook Access Client" }, { 0x112f, "Phonebook Access Server" }, { 0x1130, "Phonebook Access" }, { 0x1131, "Headset HS" }, { 0x1132, "Message Access Server" }, { 0x1133, "Message Notification Server" }, { 0x1134, "Message Access Profile" }, { 0x1135, "GNSS" }, { 0x1136, "GNSS Server" }, { 0x1137, "3D Display" }, { 0x1138, "3D Glasses" }, { 0x1139, "3D Synchronization" }, { 0x113a, "MPS Profile" }, { 0x113b, "MPS Service" }, /* 0x113c to 0x11ff undefined */ { 0x1200, "PnP Information" }, { 0x1201, "Generic Networking" }, { 0x1202, "Generic File Transfer" }, { 0x1203, "Generic Audio" }, { 0x1204, "Generic Telephony" }, { 0x1205, "UPNP Service" }, { 0x1206, "UPNP IP Service" }, { 0x1300, "UPNP IP PAN" }, { 0x1301, "UPNP IP LAP" }, { 0x1302, "UPNP IP L2CAP" }, { 0x1303, "Video Source" }, { 0x1304, "Video Sink" }, { 0x1305, "Video Distribution" }, /* 0x1306 to 0x13ff undefined */ { 0x1400, "HDP" }, { 0x1401, "HDP Source" }, { 0x1402, "HDP Sink" }, /* 0x1403 to 0x17ff undefined */ { 0x1800, "Generic Access Profile" }, { 0x1801, "Generic Attribute Profile" }, { 0x1802, "Immediate Alert" }, { 0x1803, "Link Loss" }, { 0x1804, "Tx Power" }, { 0x1805, "Current Time Service" }, { 0x1806, "Reference Time Update Service" }, { 0x1807, "Next DST Change Service" }, { 0x1808, "Glucose" }, { 0x1809, "Health Thermometer" }, { 0x180a, "Device Information" }, /* 0x180b and 0x180c undefined */ { 0x180d, "Heart Rate" }, { 0x180e, "Phone Alert Status Service" }, { 0x180f, "Battery Service" }, { 0x1810, "Blood Pressure" }, { 0x1811, "Alert Notification Service" }, { 0x1812, "Human Interface Device" }, { 0x1813, "Scan Parameters" }, { 0x1814, "Running Speed and Cadence" }, { 0x1815, "Automation IO" }, { 0x1816, "Cycling Speed and Cadence" }, /* 0x1817 undefined */ { 0x1818, "Cycling Power" }, { 0x1819, "Location and Navigation" }, { 0x181a, "Environmental Sensing" }, { 0x181b, "Body Composition" }, { 0x181c, "User Data" }, { 0x181d, "Weight Scale" }, { 0x181e, "Bond Management" }, { 0x181f, "Continuous Glucose Monitoring" }, { 0x1820, "Internet Protocol Support" }, { 0x1821, "Indoor Positioning" }, { 0x1822, "Pulse Oximeter" }, { 0x1823, "HTTP Proxy" }, { 0x1824, "Transport Discovery" }, { 0x1825, "Object Transfer" }, { 0x1826, "Fitness Machine" }, { 0x1827, "Mesh Provisioning" }, { 0x1828, "Mesh Proxy" }, { 0x1843, "Audio Input Control" }, { 0x1844, "Volume Control" }, { 0x1845, "Volume Offset Control" }, { 0x1846, "Coordinated Set Identification" }, { 0x1848, "Media Control" }, { 0x1849, "Generic Media Control" }, { 0x184b, "Telephony Bearer" }, { 0x184c, "Generic Telephony Bearer" }, { 0x184d, "Microphone Control" }, { 0x184e, "Audio Stream Control" }, { 0x184f, "Broadcast Audio Scan" }, { 0x1850, "Published Audio Capabilities" }, { 0x1851, "Basic Audio Announcement" }, { 0x1852, "Broadcast Audio Announcement" }, { 0x1853, "Common Audio" }, { 0x1854, "Hearing Aid" }, { 0x1855, "Telephony and Media Audio" }, { 0x1856, "Public Broadcast Announcement" }, { 0x1858, "Gaming Audio" }, /* 0x1857 to 0x27ff undefined */ { 0x2800, "Primary Service" }, { 0x2801, "Secondary Service" }, { 0x2802, "Include" }, { 0x2803, "Characteristic" }, /* 0x2804 to 0x28ff undefined */ { 0x2900, "Characteristic Extended Properties" }, { 0x2901, "Characteristic User Description" }, { 0x2902, "Client Characteristic Configuration" }, { 0x2903, "Server Characteristic Configuration" }, { 0x2904, "Characteristic Format" }, { 0x2905, "Characteristic Aggregate Format" }, { 0x2906, "Valid Range" }, { 0x2907, "External Report Reference" }, { 0x2908, "Report Reference" }, { 0x2909, "Number of Digitals" }, { 0x290a, "Value Trigger Setting" }, { 0x290b, "Environmental Sensing Configuration" }, { 0x290c, "Environmental Sensing Measurement" }, { 0x290d, "Environmental Sensing Trigger Setting" }, { 0x290e, "Time Trigger Setting" }, /* 0x290f to 0x29ff undefined */ { 0x2a00, "Device Name" }, { 0x2a01, "Appearance" }, { 0x2a02, "Peripheral Privacy Flag" }, { 0x2a03, "Reconnection Address" }, { 0x2a04, "Peripheral Preferred Connection Parameters" }, { 0x2a05, "Service Changed" }, { 0x2a06, "Alert Level" }, { 0x2a07, "Tx Power Level" }, { 0x2a08, "Date Time" }, { 0x2a09, "Day of Week" }, { 0x2a0a, "Day Date Time" }, /* 0x2a0b undefined */ { 0x2a0c, "Exact Time 256" }, { 0x2a0d, "DST Offset" }, { 0x2a0e, "Time Zone" }, { 0x2a0f, "Local Time Information" }, /* 0x2a10 undefined */ { 0x2a11, "Time with DST" }, { 0x2a12, "Time Accuracy" }, { 0x2a13, "Time Source" }, { 0x2a14, "Reference Time Information" }, /* 0x2a15 undefined */ { 0x2a16, "Time Update Control Point" }, { 0x2a17, "Time Update State" }, { 0x2a18, "Glucose Measurement" }, { 0x2a19, "Battery Level" }, /* 0x2a1a and 0x2a1b undefined */ { 0x2a1c, "Temperature Measurement" }, { 0x2a1d, "Temperature Type" }, { 0x2a1e, "Intermediate Temperature" }, /* 0x2a1f and 0x2a20 undefined */ { 0x2a21, "Measurement Interval" }, { 0x2a22, "Boot Keyboard Input Report" }, { 0x2a23, "System ID" }, { 0x2a24, "Model Number String" }, { 0x2a25, "Serial Number String" }, { 0x2a26, "Firmware Revision String" }, { 0x2a27, "Hardware Revision String" }, { 0x2a28, "Software Revision String" }, { 0x2a29, "Manufacturer Name String" }, { 0x2a2a, "IEEE 11073-20601 Regulatory Cert. Data List" }, { 0x2a2b, "Current Time" }, { 0x2a2c, "Magnetic Declination" }, /* 0x2a2d to 0x2a30 undefined */ { 0x2a31, "Scan Refresh" }, { 0x2a32, "Boot Keyboard Output Report" }, { 0x2a33, "Boot Mouse Input Report" }, { 0x2a34, "Glucose Measurement Context" }, { 0x2a35, "Blood Pressure Measurement" }, { 0x2a36, "Intermediate Cuff Pressure" }, { 0x2a37, "Heart Rate Measurement" }, { 0x2a38, "Body Sensor Location" }, { 0x2a39, "Heart Rate Control Point" }, /* 0x2a3a to 0x2a3e undefined */ { 0x2a3f, "Alert Status" }, { 0x2a40, "Ringer Control Point" }, { 0x2a41, "Ringer Setting" }, { 0x2a42, "Alert Category ID Bit Mask" }, { 0x2a43, "Alert Category ID" }, { 0x2a44, "Alert Notification Control Point" }, { 0x2a45, "Unread Alert Status" }, { 0x2a46, "New Alert" }, { 0x2a47, "Supported New Alert Category" }, { 0x2a48, "Supported Unread Alert Category" }, { 0x2a49, "Blood Pressure Feature" }, { 0x2a4a, "HID Information" }, { 0x2a4b, "Report Map" }, { 0x2a4c, "HID Control Point" }, { 0x2a4d, "Report" }, { 0x2a4e, "Protocol Mode" }, { 0x2a4f, "Scan Interval Window" }, { 0x2a50, "PnP ID" }, { 0x2a51, "Glucose Feature" }, { 0x2a52, "Record Access Control Point" }, { 0x2a53, "RSC Measurement" }, { 0x2a54, "RSC Feature" }, { 0x2a55, "SC Control Point" }, { 0x2a56, "Digital" }, /* 0x2a57 undefined */ { 0x2a58, "Analog" }, /* 0x2a59 undefined */ { 0x2a5a, "Aggregate" }, { 0x2a5b, "CSC Measurement" }, { 0x2a5c, "CSC Feature" }, { 0x2a5d, "Sensor Location" }, /* 0x2a5e to 0x2a62 undefined */ { 0x2a63, "Cycling Power Measurement" }, { 0x2a64, "Cycling Power Vector" }, { 0x2a65, "Cycling Power Feature" }, { 0x2a66, "Cycling Power Control Point" }, { 0x2a67, "Location and Speed" }, { 0x2a68, "Navigation" }, { 0x2a69, "Position Quality" }, { 0x2a6a, "LN Feature" }, { 0x2a6b, "LN Control Point" }, { 0x2a6c, "Elevation" }, { 0x2a6d, "Pressure" }, { 0x2a6e, "Temperature" }, { 0x2a6f, "Humidity" }, { 0x2a70, "True Wind Speed" }, { 0x2a71, "True Wind Direction" }, { 0x2a72, "Apparent Wind Speed" }, { 0x2a73, "Apparent Wind Direction" }, { 0x2a74, "Gust Factor" }, { 0x2a75, "Pollen Concentration" }, { 0x2a76, "UV Index" }, { 0x2a77, "Irradiance" }, { 0x2a78, "Rainfall" }, { 0x2a79, "Wind Chill" }, { 0x2a7a, "Heat Index" }, { 0x2a7b, "Dew Point" }, { 0x2a7c, "Trend" }, { 0x2a7d, "Descriptor Value Changed" }, { 0x2a7e, "Aerobic Heart Rate Lower Limit" }, { 0x2a7f, "Aerobic Threshold" }, { 0x2a80, "Age" }, { 0x2a81, "Anaerobic Heart Rate Lower Limit" }, { 0x2a82, "Anaerobic Heart Rate Upper Limit" }, { 0x2a83, "Anaerobic Threshold" }, { 0x2a84, "Aerobic Heart Rate Upper Limit" }, { 0x2a85, "Date of Birth" }, { 0x2a86, "Date of Threshold Assessment" }, { 0x2a87, "Email Address" }, { 0x2a88, "Fat Burn Heart Rate Lower Limit" }, { 0x2a89, "Fat Burn Heart Rate Upper Limit" }, { 0x2a8a, "First Name" }, { 0x2a8b, "Five Zone Heart Rate Limits" }, { 0x2a8c, "Gender" }, { 0x2a8d, "Heart Rate Max" }, { 0x2a8e, "Height" }, { 0x2a8f, "Hip Circumference" }, { 0x2a90, "Last Name" }, { 0x2a91, "Maximum Recommended Heart Rate" }, { 0x2a92, "Resting Heart Rate" }, { 0x2a93, "Sport Type for Aerobic/Anaerobic Thresholds" }, { 0x2a94, "Three Zone Heart Rate Limits" }, { 0x2a95, "Two Zone Heart Rate Limit" }, { 0x2a96, "VO2 Max" }, { 0x2a97, "Waist Circumference" }, { 0x2a98, "Weight" }, { 0x2a99, "Database Change Increment" }, { 0x2a9a, "User Index" }, { 0x2a9b, "Body Composition Feature" }, { 0x2a9c, "Body Composition Measurement" }, { 0x2a9d, "Weight Measurement" }, { 0x2a9e, "Weight Scale Feature" }, { 0x2a9f, "User Control Point" }, { 0x2aa0, "Magnetic Flux Density - 2D" }, { 0x2aa1, "Magnetic Flux Density - 3D" }, { 0x2aa2, "Language" }, { 0x2aa3, "Barometric Pressure Trend" }, { 0x2aa4, "Bond Management Control Point" }, { 0x2aa5, "Bond Management Feature" }, { 0x2aa6, "Central Address Resolution" }, { 0x2aa7, "CGM Measurement" }, { 0x2aa8, "CGM Feature" }, { 0x2aa9, "CGM Status" }, { 0x2aaa, "CGM Session Start Time" }, { 0x2aab, "CGM Session Run Time" }, { 0x2aac, "CGM Specific Ops Control Point" }, { 0x2aad, "Indoor Positioning Configuration" }, { 0x2aae, "Latitude" }, { 0x2aaf, "Longitude" }, { 0x2ab0, "Local North Coordinate" }, { 0x2ab1, "Local East Coordinate" }, { 0x2ab2, "Floor Number" }, { 0x2ab3, "Altitude" }, { 0x2ab4, "Uncertainty" }, { 0x2ab5, "Location Name" }, { 0x2ab6, "URI" }, { 0x2ab7, "HTTP Headers" }, { 0x2ab8, "HTTP Status Code" }, { 0x2ab9, "HTTP Entity Body" }, { 0x2aba, "HTTP Control Point" }, { 0x2abb, "HTTPS Security" }, { 0x2abc, "TDS Control Point" }, { 0x2abd, "OTS Feature" }, { 0x2abe, "Object Name" }, { 0x2abf, "Object Type" }, { 0x2ac0, "Object Size" }, { 0x2ac1, "Object First-Created" }, { 0x2ac2, "Object Last-Modified" }, { 0x2ac3, "Object ID" }, { 0x2ac4, "Object Properties" }, { 0x2ac5, "Object Action Control Point" }, { 0x2ac6, "Object List Control Point" }, { 0x2ac7, "Object List Filter" }, { 0x2ac8, "Object Changed" }, { 0x2ac9, "Resolvable Private Address Only" }, /* 0x2aca and 0x2acb undefined */ { 0x2acc, "Fitness Machine Feature" }, { 0x2acd, "Treadmill Data" }, { 0x2ace, "Cross Trainer Data" }, { 0x2acf, "Step Climber Data" }, { 0x2ad0, "Stair Climber Data" }, { 0x2ad1, "Rower Data" }, { 0x2ad2, "Indoor Bike Data" }, { 0x2ad3, "Training Status" }, { 0x2ad4, "Supported Speed Range" }, { 0x2ad5, "Supported Inclination Range" }, { 0x2ad6, "Supported Resistance Level Range" }, { 0x2ad7, "Supported Heart Rate Range" }, { 0x2ad8, "Supported Power Range" }, { 0x2ad9, "Fitness Machine Control Point" }, { 0x2ada, "Fitness Machine Status" }, { 0x2adb, "Mesh Provisioning Data In" }, { 0x2adc, "Mesh Provisioning Data Out" }, { 0x2add, "Mesh Proxy Data In" }, { 0x2ade, "Mesh Proxy Data Out" }, { 0x2b29, "Client Supported Features" }, { 0x2b2A, "Database Hash" }, { 0x2b3a, "Server Supported Features" }, { 0x2b51, "Telephony and Media Audio Profile Role" }, { 0x2b77, "Audio Input State" }, { 0x2b78, "Gain Settings Attribute" }, { 0x2b79, "Audio Input Type" }, { 0x2b7a, "Audio Input Status" }, { 0x2b7b, "Audio Input Control Point" }, { 0x2b7c, "Audio Input Description" }, { 0x2b7d, "Volume State" }, { 0x2b7e, "Volume Control Point" }, { 0x2b7f, "Volume Flags" }, { 0x2b80, "Offset State" }, { 0x2b81, "Audio Location" }, { 0x2b82, "Volume Offset Control Point" }, { 0x2b83, "Audio Output Description" }, { 0x2b84, "Set Identity Resolving Key" }, { 0x2b85, "Coordinated Set Size" }, { 0x2b86, "Set Member Lock" }, { 0x2b87, "Set Member Rank" }, { 0x2b93, "Media Player Name" }, { 0x2b94, "Media Player Icon Object ID" }, { 0x2b95, "Media Player Icon URL" }, { 0x2b96, "Track Changed" }, { 0x2b97, "Track Title" }, { 0x2b98, "Track Duration" }, { 0x2b99, "Track Position" }, { 0x2b9a, "Playback Speed" }, { 0x2b9b, "Seeking Speed" }, { 0x2b9c, "Current Track Segments Object ID" }, { 0x2b9d, "Current Track Object ID" }, { 0x2b9e, "Next Track Object ID" }, { 0x2b9f, "Parent Group Object ID" }, { 0x2ba0, "Current Group Object ID" }, { 0x2ba1, "Playing Order" }, { 0x2ba2, "Playing Orders Supported" }, { 0x2ba3, "Media State" }, { 0x2ba4, "Media Control Point" }, { 0x2ba5, "Media Control Point Opcodes Supported" }, { 0x2ba6, "Search Results Object ID" }, { 0x2ba7, "Search Control Point" }, { 0x2ba9, "Media Player Icon Object Type" }, { 0x2baa, "Track Segments Object Type" }, { 0x2bab, "Track Object Type" }, { 0x2bac, "Group Object Type" }, { 0x2bb3, "Bearer Provider Name" }, { 0x2bb4, "Bearer UCI" }, { 0x2bb5, "Bearer Technology" }, { 0x2bb6, "Bearer URI Schemes Supported List" }, { 0x2bb7, "Bearer Signal Strength" }, { 0x2bb8, "Bearer Signal Strength Reporting Interval" }, { 0x2bb9, "Bearer List Current Calls" }, { 0x2bba, "Content Control ID" }, { 0x2bbb, "Status Flags" }, { 0x2bbc, "Incoming Call Target Bearer URI" }, { 0x2bbd, "Call State" }, { 0x2bbe, "Call Control Point" }, { 0x2bbf, "Call Control Point Optional Opcodes" }, { 0x2bc0, "Termination Reason" }, { 0x2bc1, "Incoming Call" }, { 0x2bc2, "Call Friendly Name" }, { 0x2bc3, "Mute" }, { 0x2bc4, "Sink ASE" }, { 0x2bc5, "Source ASE" }, { 0x2bc6, "ASE Control Point" }, { 0x2bc7, "Broadcast Audio Scan Control Point" }, { 0x2bc8, "Broadcast Receive State" }, { 0x2bc9, "Sink PAC" }, { 0x2bca, "Sink Audio Locations" }, { 0x2bcb, "Source PAC" }, { 0x2bcc, "Source Audio Locations" }, { 0x2bcd, "Available Audio Contexts" }, { 0x2bce, "Supported Audio Contexts" }, { 0x2bda, "Hearing Aid Features" }, { 0x2bdb, "Hearing Aid Preset Control Point" }, { 0x2bdc, "Active Preset Index" }, { 0x2c00, "GMAP Role" }, { 0x2c01, "UGG Features" }, { 0x2c02, "UGT Features" }, { 0x2c03, "BGS Features" }, { 0x2c03, "BGR Features" }, /* vendor defined */ { 0xfeff, "GN Netcom" }, { 0xfefe, "GN ReSound A/S" }, { 0xfefd, "Gimbal, Inc." }, { 0xfefc, "Gimbal, Inc." }, { 0xfefb, "Telit Wireless Solutions (Formerly Stollmann E+V GmbH)" }, { 0xfefa, "PayPal, Inc." }, { 0xfef9, "PayPal, Inc." }, { 0xfef8, "Aplix Corporation" }, { 0xfef7, "Aplix Corporation" }, { 0xfef6, "Wicentric, Inc." }, { 0xfef5, "Dialog Semiconductor GmbH" }, { 0xfef4, "Google" }, { 0xfef3, "Google" }, { 0xfef2, "CSR" }, { 0xfef1, "CSR" }, { 0xfef0, "Intel" }, { 0xfeef, "Polar Electro Oy " }, { 0xfeee, "Polar Electro Oy " }, { 0xfeed, "Tile, Inc." }, { 0xfeec, "Tile, Inc." }, { 0xfeeb, "Swirl Networks, Inc." }, { 0xfeea, "Swirl Networks, Inc." }, { 0xfee9, "Quintic Corp." }, { 0xfee8, "Quintic Corp." }, { 0xfee7, "Tencent Holdings Limited." }, { 0xfee6, "Silvair, Inc." }, { 0xfee5, "Nordic Semiconductor ASA" }, { 0xfee4, "Nordic Semiconductor ASA" }, { 0xfee3, "Anki, Inc." }, { 0xfee2, "Anki, Inc." }, { 0xfee1, "Anhui Huami Information Technology Co., Ltd. " }, { 0xfee0, "Anhui Huami Information Technology Co., Ltd. " }, { 0xfedf, "Design SHIFT" }, { 0xfede, "Coin, Inc." }, { 0xfedd, "Jawbone" }, { 0xfedc, "Jawbone" }, { 0xfedb, "Perka, Inc." }, { 0xfeda, "ISSC Technologies Corp. " }, { 0xfed9, "Pebble Technology Corporation" }, { 0xfed8, "Google" }, { 0xfed7, "Broadcom" }, { 0xfed6, "Broadcom" }, { 0xfed5, "Plantronics Inc." }, { 0xfed4, "Apple, Inc." }, { 0xfed3, "Apple, Inc." }, { 0xfed2, "Apple, Inc." }, { 0xfed1, "Apple, Inc." }, { 0xfed0, "Apple, Inc." }, { 0xfecf, "Apple, Inc." }, { 0xfece, "Apple, Inc." }, { 0xfecd, "Apple, Inc." }, { 0xfecc, "Apple, Inc." }, { 0xfecb, "Apple, Inc." }, { 0xfeca, "Apple, Inc." }, { 0xfec9, "Apple, Inc." }, { 0xfec8, "Apple, Inc." }, { 0xfec7, "Apple, Inc." }, { 0xfec6, "Kocomojo, LLC" }, { 0xfec5, "Realtek Semiconductor Corp." }, { 0xfec4, "PLUS Location Systems" }, { 0xfec3, "360fly, Inc." }, { 0xfec2, "Blue Spark Technologies, Inc." }, { 0xfec1, "KDDI Corporation" }, { 0xfec0, "KDDI Corporation" }, { 0xfebf, "Nod, Inc." }, { 0xfebe, "Bose Corporation" }, { 0xfebd, "Clover Network, Inc" }, { 0xfebc, "Dexcom Inc" }, { 0xfebb, "adafruit industries" }, { 0xfeba, "Tencent Holdings Limited" }, { 0xfeb9, "LG Electronics" }, { 0xfeb8, "Facebook, Inc." }, { 0xfeb7, "Facebook, Inc." }, { 0xfeb6, "Vencer Co., Ltd" }, { 0xfeb5, "WiSilica Inc." }, { 0xfeb4, "WiSilica Inc." }, { 0xfeb3, "Taobao" }, { 0xfeb2, "Microsoft Corporation" }, { 0xfeb1, "Electronics Tomorrow Limited" }, { 0xfeb0, "Nest Labs Inc" }, { 0xfeaf, "Nest Labs Inc" }, { 0xfeae, "Nokia" }, { 0xfead, "Nokia" }, { 0xfeac, "Nokia" }, { 0xfeab, "Nokia" }, { 0xfeaa, "Google" }, { 0xfea9, "Savant Systems LLC" }, { 0xfea8, "Savant Systems LLC" }, { 0xfea7, "UTC Fire and Security" }, { 0xfea6, "GoPro, Inc." }, { 0xfea5, "GoPro, Inc." }, { 0xfea4, "Paxton Access Ltd" }, { 0xfea3, "ITT Industries" }, { 0xfea2, "Intrepid Control Systems, Inc." }, { 0xfea1, "Intrepid Control Systems, Inc." }, { 0xfea0, "Google" }, { 0xfe9f, "Google" }, { 0xfe9e, "Dialog Semiconductor B.V." }, { 0xfe9d, "Mobiquity Networks Inc" }, { 0xfe9c, "GSI Laboratories, Inc." }, { 0xfe9b, "Samsara Networks, Inc" }, { 0xfe9a, "Estimote" }, { 0xfe99, "Currant Inc" }, { 0xfe98, "Currant Inc" }, { 0xfe97, "Tesla Motors Inc." }, { 0xfe96, "Tesla Motors Inc." }, { 0xfe95, "Xiaomi Inc." }, { 0xfe94, "OttoQ In" }, { 0xfe93, "OttoQ In" }, { 0xfe92, "Jarden Safety & Security" }, { 0xfe91, "Shanghai Imilab Technology Co.,Ltd" }, { 0xfe90, "JUMA" }, { 0xfe8f, "CSR" }, { 0xfe8e, "ARM Ltd" }, { 0xfe8d, "Interaxon Inc." }, { 0xfe8c, "TRON Forum" }, { 0xfe8b, "Apple, Inc." }, { 0xfe8a, "Apple, Inc." }, { 0xfe89, "B&O Play A/S" }, { 0xfe88, "SALTO SYSTEMS S.L." }, { 0xfe87, "Qingdao Yeelink Information Technology Co., Ltd. ( 青岛亿联客信息技术有限公司 )" }, { 0xfe86, "HUAWEI Technologies Co., Ltd. ( 华为技术有限公司 )" }, { 0xfe85, "RF Digital Corp" }, { 0xfe84, "RF Digital Corp" }, { 0xfe83, "Blue Bite" }, { 0xfe82, "Medtronic Inc." }, { 0xfe81, "Medtronic Inc." }, { 0xfe80, "Doppler Lab" }, { 0xfe7f, "Doppler Lab" }, { 0xfe7e, "Awear Solutions Ltd" }, { 0xfe7d, "Aterica Health Inc." }, { 0xfe7c, "Telit Wireless Solutions (Formerly Stollmann E+V GmbH)" }, { 0xfe7b, "Orion Labs, Inc." }, { 0xfe7a, "Bragi GmbH" }, { 0xfe79, "Zebra Technologies" }, { 0xfe78, "Hewlett-Packard Company" }, { 0xfe77, "Hewlett-Packard Company" }, { 0xfe76, "TangoMe" }, { 0xfe75, "TangoMe" }, { 0xfe74, "unwire" }, { 0xfe73, "Abbott (formerly St. Jude Medical, Inc.)" }, { 0xfe72, "Abbott (formerly St. Jude Medical, Inc.)" }, { 0xfe71, "Plume Design Inc" }, { 0xfe70, "Beijing Jingdong Century Trading Co., Ltd." }, { 0xfe6f, "LINE Corporation" }, { 0xfe6e, "The University of Tokyo " }, { 0xfe6d, "The University of Tokyo " }, { 0xfe6c, "TASER International, Inc." }, { 0xfe6b, "TASER International, Inc." }, { 0xfe6a, "Kontakt Micro-Location Sp. z o.o." }, { 0xfe69, "Capsule Technologies Inc." }, { 0xfe68, "Capsule Technologies Inc." }, { 0xfe67, "Lab Sensor Solutions" }, { 0xfe66, "Intel Corporation " }, { 0xfe65, "CHIPOLO d.o.o. " }, { 0xfe64, "Siemens AG" }, { 0xfe63, "Connected Yard, Inc. " }, { 0xfe62, "Indagem Tech LLC " }, { 0xfe61, "Logitech International SA " }, { 0xfe60, "Lierda Science & Technology Group Co., Ltd." }, { 0xfe5f, "Eyefi, Inc." }, { 0xfe5e, "Plastc Corporation " }, { 0xfe5d, "Grundfos A/S " }, { 0xfe5c, "million hunters GmbH " }, { 0xfe5b, "GT-tronics HK Ltd" }, { 0xfe5a, "Cronologics Corporation" }, { 0xfe59, "Nordic Semiconductor ASA " }, { 0xfe58, "Nordic Semiconductor ASA " }, { 0xfe57, "Dotted Labs " }, { 0xfe56, "Google Inc. " }, { 0xfe55, "Google Inc. " }, { 0xfe54, "Motiv, Inc. " }, { 0xfe53, "3M" }, { 0xfe52, "SetPoint Medical " }, { 0xfe51, "SRAM " }, { 0xfe50, "Google Inc." }, { 0xfe4f, "Molekule, Inc." }, { 0xfe4e, "NTT docomo " }, { 0xfe4d, "Casambi Technologies Oy" }, { 0xfe4c, "Volkswagen AG " }, { 0xfe4b, "Signify Netherlands B.V. (formerly Philips Lighting B.V.)" }, { 0xfe4a, "OMRON HEALTHCARE Co., Ltd." }, { 0xfe49, "SenionLab AB" }, { 0xfe48, "General Motors " }, { 0xfe47, "General Motors " }, { 0xfe46, "B&O Play A/S " }, { 0xfe45, "Snapchat Inc" }, { 0xfe44, "SK Telecom " }, { 0xfe43, "Andreas Stihl AG & Co. KG" }, { 0xfe42, "Nets A/S " }, { 0xfe41, "Inugo Systems Limited" }, { 0xfe40, "Inugo Systems Limited" }, { 0xfe3f, "Friday Labs Limited" }, { 0xfe3e, "BD Medical" }, { 0xfe3d, "BD Medical" }, { 0xfe3c, "alibaba" }, { 0xfe3b, "Dobly Laboratories" }, { 0xfe3a, "TTS Tooltechnic Systems AG & Co. KG" }, { 0xfe39, "TTS Tooltechnic Systems AG & Co. KG" }, { 0xfe38, "Spaceek LTD" }, { 0xfe37, "Spaceek LTD" }, { 0xfe36, "HUAWEI Technologies Co., Ltd" }, { 0xfe35, "HUAWEI Technologies Co., Ltd" }, { 0xfe34, "SmallLoop LLC" }, { 0xfe33, "CHIPOLO d.o.o." }, { 0xfe32, "Pro-Mark, Inc." }, { 0xfe31, "Volkswagen AG" }, { 0xfe30, "Volkswagen AG" }, { 0xfe2f, "CRESCO Wireless, Inc" }, { 0xfe2e, "ERi,Inc." }, { 0xfe2d, "SMART INNOVATION Co.,Ltd" }, { 0xfe2c, "Google" }, { 0xfe2b, "ITT Industries" }, { 0xfe2a, "DaisyWorks, Inc." }, { 0xfe29, "Gibson Innovations" }, { 0xfe28, "Ayla Networks" }, { 0xfe27, "Google" }, { 0xfe26, "Google" }, { 0xfe25, "Apple, Inc. " }, { 0xfe24, "August Home Inc" }, { 0xfe23, "Zoll Medical Corporation" }, { 0xfe22, "Zoll Medical Corporation" }, { 0xfe21, "Bose Corporation" }, { 0xfe20, "Emerson" }, { 0xfe1f, "Garmin International, Inc." }, { 0xfe1e, "Smart Innovations Co., Ltd" }, { 0xfe1d, "Illuminati Instrument Corporation" }, { 0xfe1c, "NetMedia, Inc." }, { 0xfe1b, "Tyto Life LLC" }, { 0xfe1a, "Tyto Life LLC" }, { 0xfe19, "Google, Inc" }, { 0xfe18, "Runtime, Inc." }, { 0xfe17, "Telit Wireless Solutions GmbH" }, { 0xfe16, "Footmarks, Inc." }, { 0xfe15, "Amazon.com Services, Inc.." }, { 0xfe14, "Flextronics International USA Inc." }, { 0xfe13, "Apple Inc." }, { 0xfe12, "M-Way Solutions GmbH" }, { 0xfe11, "GMC-I Messtechnik GmbH" }, { 0xfe10, "Lapis Semiconductor Co., Ltd." }, { 0xfe0f, "Signify Netherlands B.V. (formerly Philips Lighting B.V.)" }, { 0xfe0e, "Setec Pty Ltd" }, { 0xfe0d, "Procter & Gamble" }, { 0xfe0c, "Procter & Gamble" }, { 0xfe0b, "ruwido austria gmbh" }, { 0xfe0a, "ruwido austria gmbh" }, { 0xfe09, "Pillsy, Inc." }, { 0xfe08, "Microsoft" }, { 0xfe07, "Sonos, Inc." }, { 0xfe06, "Qualcomm Technologies, Inc." }, { 0xfe05, "CORE Transport Technologies NZ Limited " }, { 0xfe04, "OpenPath Security Inc" }, { 0xfe03, "Amazon.com Services, Inc." }, { 0xfe02, "Robert Bosch GmbH" }, { 0xfe01, "Duracell U.S. Operations Inc." }, { 0xfe00, "Amazon.com Services, Inc." }, { 0xfdff, "OSRAM GmbH" }, { 0xfdfe, "ADHERIUM(NZ) LIMITED" }, { 0xfdfd, "RecursiveSoft Inc." }, { 0xfdfc, "Optrel AG" }, { 0xfdfb, "Tandem Diabetes Care" }, { 0xfdfa, "Tandem Diabetes Care" }, { 0xfdf9, "INIA" }, { 0xfdf8, "Onvocal" }, { 0xfdf7, "HP Inc." }, { 0xfdf6, "AIAIAI ApS" }, { 0xfdf5, "Milwaukee Electric Tools" }, { 0xfdf4, "O. E. M. Controls, Inc." }, { 0xfdf3, "Amersports" }, { 0xfdf2, "AMICCOM Electronics Corporation" }, { 0xfdf1, "LAMPLIGHT Co.,Ltd" }, { 0xfdf0, "Google Inc." }, { 0xfdef, "ART AND PROGRAM, INC." }, { 0xfdee, "Huawei Technologies Co., Ltd." }, { 0xfded, "Pole Star" }, { 0xfdec, "Mannkind Corporation" }, { 0xfdeb, "Syntronix Corporation" }, { 0xfdea, "SeeScan, Inc" }, { 0xfde9, "Spacesaver Corporation" }, { 0xfde8, "Robert Bosch GmbH" }, { 0xfde7, "SECOM Co., LTD" }, { 0xfde6, "Intelletto Technologies Inc" }, { 0xfde5, "SMK Corporation " }, { 0xfde4, "JUUL Labs, Inc." }, { 0xfde3, "Abbott Diabetes Care" }, { 0xfde2, "Google Inc." }, { 0xfde1, "Fortin Electronic Systems " }, { 0xfde0, "John Deere" }, { 0xfddf, "Harman International" }, { 0xfdde, "Noodle Technology Inc. " }, { 0xfddd, "Arch Systems Inc" }, { 0xfddc, "4iiii Innovations Inc." }, { 0xfddb, "Samsung Electronics Co., Ltd. " }, { 0xfdda, "MHCS" }, { 0xfdd9, "Jiangsu Teranovo Tech Co., Ltd." }, { 0xfdd8, "Jiangsu Teranovo Tech Co., Ltd." }, { 0xfdd7, "Emerson" }, { 0xfdd6, "Ministry of Supply " }, { 0xfdd5, "Brompton Bicycle Ltd" }, { 0xfdd4, "LX Solutions Pty Limited" }, { 0xfdd3, "FUBA Automotive Electronics GmbH" }, { 0xfdd2, "Bose Corporation" }, { 0xfdd1, "Huawei Technologies Co., Ltd " }, { 0xfdd0, "Huawei Technologies Co., Ltd " }, { 0xfdcf, "Nalu Medical, Inc" }, { 0xfdce, "SENNHEISER electronic GmbH & Co. KG" }, { 0xfdcd, "Qingping Technology (Beijing) Co., Ltd." }, { 0xfdcc, "Shoof Technologies" }, { 0xfdcb, "Meggitt SA" }, { 0xfdca, "Fortin Electronic Systems " }, { 0xfdc9, "Busch-Jaeger Elektro GmbH" }, { 0xfdc8, "Hach – Danaher" }, { 0xfdc7, "Eli Lilly and Company" }, { 0xfdc6, "Eli Lilly and Company" }, { 0xfdc5, "Automatic Labs" }, { 0xfdc4, "Simavita (Aust) Pty Ltd" }, { 0xfdc3, "Baidu Online Network Technology (Beijing) Co., Ltd" }, { 0xfdc2, "Baidu Online Network Technology (Beijing) Co., Ltd" }, { 0xfdc1, "Hunter Douglas" }, { 0xfdc0, "Hunter Douglas" }, { 0xfdbf, "California Things Inc. " }, { 0xfdbe, "California Things Inc. " }, { 0xfdbd, "Clover Network, Inc." }, { 0xfdbc, "Emerson" }, { 0xfdbb, "Profoto" }, { 0xfdba, "Comcast Cable Corporation" }, { 0xfdb9, "Comcast Cable Corporation" }, { 0xfdb8, "LivaNova USA Inc." }, { 0xfdb7, "LivaNova USA Inc." }, { 0xfdb6, "GWA Hygiene GmbH" }, { 0xfdb5, "ECSG" }, { 0xfdb4, "HP Inc" }, { 0xfdb3, "Audiodo AB" }, { 0xfdb2, "Portable Multimedia Ltd " }, { 0xfdb1, "Proxy Technologies, Inc." }, { 0xfdb0, "Proxy Technologies, Inc." }, { 0xfdaf, "Wiliot LTD" }, { 0xfdae, "Houwa System Design, k.k." }, { 0xfdad, "Houwa System Design, k.k." }, { 0xfdac, "Tentacle Sync GmbH" }, { 0xfdab, "Xiaomi Inc." }, { 0xfdaa, "Xiaomi Inc." }, { 0xfda9, "Rhombus Systems, Inc." }, { 0xfda8, "PSA Peugeot Citroën" }, { 0xfda7, "WWZN Information Technology Company Limited" }, { 0xfda6, "WWZN Information Technology Company Limited" }, { 0xfda5, "Neurostim OAB, Inc." }, { 0xfda4, "Inseego Corp." }, { 0xfda3, "Inseego Corp." }, { 0xfda2, "Groove X, Inc" }, { 0xfda1, "Groove X, Inc" }, { 0xfda0, "Secugen Corporation" }, { 0xfd9f, "VitalTech Affiliates LLC" }, { 0xfd9e, "The Coca-Cola Company" }, { 0xfd9d, "Gastec Corporation" }, { 0xfd9c, "Huawei Technologies Co., Ltd." }, { 0xfd9b, "Huawei Technologies Co., Ltd." }, { 0xfd9a, "Huawei Technologies Co., Ltd." }, { 0xfd99, "ABB Oy" }, { 0xfd98, "Disney Worldwide Services, Inc." }, { 0xfd97, "June Life, Inc." }, { 0xfd96, "Google LLC" }, { 0xfd95, "Rigado" }, { 0xfd94, "Hewlett Packard Enterprise" }, { 0xfd93, "Bayerische Motoren Werke AG" }, { 0xfd92, "Qualcomm Technologies International, Ltd. (QTIL)" }, { 0xfd91, "Groove X, Inc." }, { 0xfd90, "Guangzhou SuperSound Information Technology Co.,Ltd" }, { 0xfd8f, "Matrix ComSec Pvt. Ltd." }, { 0xfd8e, "Motorola Solutions" }, { 0xfd8d, "quip NYC Inc." }, { 0xfd8c, "Google LLC" }, { 0xfd8b, "Jigowatts Inc." }, { 0xfd8a, "Signify Netherlands B.V." }, { 0xfd89, "Urbanminded LTD" }, { 0xfd88, "Urbanminded LTD" }, { 0xfd87, "Google LLC" }, { 0xfd86, "Abbott" }, { 0xfd85, "Husqvarna AB" }, { 0xfd84, "Tile, Inc." }, { 0xfd83, "iNFORM Technology GmbH" }, { 0xfd82, "Sony Corporation" }, { 0xfd81, "CANDY HOUSE, Inc." }, { 0xfd80, "Phindex Technologies, Inc" }, { 0xfd7f, "Husqvarna AB" }, { 0xfd7e, "Samsung Electronics Co., Ltd." }, { 0xfd7d, "Center for Advanced Research Wernher Von Braun" }, { 0xfd7c, "Toshiba Information Systems(Japan) Corporation" }, { 0xfd7b, "WYZE LABS, INC." }, { 0xfd7a, "Withings" }, { 0xfd79, "Withings" }, { 0xfd78, "Withings" }, { 0xfd77, "Withings" }, { 0xfd76, "Insulet Corporation" }, { 0xfd75, "Insulet Corporation" }, { 0xfd74, "BRControls Products BV" }, { 0xfd73, "BRControls Products BV" }, { 0xfd72, "Logitech International SA" }, { 0xfd71, "GN Hearing A/S" }, { 0xfd70, "GuangDong Oppo Mobile Telecommunications Corp., Ltd." }, { 0xfd6f, "Apple, Inc." }, { 0xfd6e, "Polidea sp. z o.o." }, { 0xfd6d, "Sigma Elektro GmbH" }, { 0xfd6c, "Samsung Electronics Co., Ltd." }, { 0xfd6b, " rapitag GmbH" }, { 0xfd6a, "Emerson" }, { 0xfd69, "Samsung Electronics Co., Ltd." }, { 0xfd68, "Ubique Innovation AG" }, { 0xfd67, "Montblanc Simplo GmbH" }, { 0xfd66, "Zebra Technologies Corporation" }, { 0xfd65, "Razer Inc." }, { 0xfd64, "INRIA" }, { 0xfd63, "Fitbit, Inc." }, { 0xfd62, "Fitbit, Inc." }, { 0xfd61, "Arendi AG" }, { 0xfd60, "Sercomm Corporation" }, { 0xfd5f, "Oculus VR, LLC" }, /* SDO defined */ { 0xfccc, "Wi-Fi Easy Connect Specification" }, { 0xffef, "Wi-Fi Direct Specification" }, { 0xfff0, "Public Key Open Credential (PKOC)" }, { 0xfff1, "ICCE Digital Key" }, { 0xfff2, "Aliro" }, { 0xfff3, "FiRa Consortium" }, { 0xfff4, "FiRa Consortium" }, { 0xfff5, "Car Connectivity Consortium, LLC" }, { 0xfff6, "Matter Profile ID" }, { 0xfff7, "Zigbee Direct" }, { 0xfff8, "Mopria Alliance BLE" }, { 0xfff9, "FIDO2 Secure Client-To-Authenticator Transport" }, { 0xfffa, "ASTM Remote ID" }, { 0xfffb, "Direct Thread Commissioning" }, { 0xfffc, "Wireless Power Transfer (WPT)" }, { 0xfffd, "Universal Second Factor Authenticator" }, { 0xfffe, "Wireless Power Transfer" }, { } }; static const struct { const char *uuid; const char *str; } uuid128_table[] = { { "a3c87500-8ed3-4bdf-8a39-a01bebede295", "Eddystone Configuration Service" }, { "a3c87501-8ed3-4bdf-8a39-a01bebede295", "Capabilities" }, { "a3c87502-8ed3-4bdf-8a39-a01bebede295", "Active Slot" }, { "a3c87503-8ed3-4bdf-8a39-a01bebede295", "Advertising Interval" }, { "a3c87504-8ed3-4bdf-8a39-a01bebede295", "Radio Tx Power" }, { "a3c87505-8ed3-4bdf-8a39-a01bebede295", "(Advanced) Advertised Tx Power" }, { "a3c87506-8ed3-4bdf-8a39-a01bebede295", "Lock State" }, { "a3c87507-8ed3-4bdf-8a39-a01bebede295", "Unlock" }, { "a3c87508-8ed3-4bdf-8a39-a01bebede295", "Public ECDH Key" }, { "a3c87509-8ed3-4bdf-8a39-a01bebede295", "EID Identity Key" }, { "a3c8750a-8ed3-4bdf-8a39-a01bebede295", "ADV Slot Data" }, { "a3c8750b-8ed3-4bdf-8a39-a01bebede295", "(Advanced) Factory reset" }, { "a3c8750c-8ed3-4bdf-8a39-a01bebede295", "(Advanced) Remain Connectable" }, /* BBC micro:bit Bluetooth Profiles */ { "e95d0753-251d-470a-a062-fa1922dfa9a8", "MicroBit Accelerometer Service" }, { "e95dca4b-251d-470a-a062-fa1922dfa9a8", "MicroBit Accelerometer Data" }, { "e95dfb24-251d-470a-a062-fa1922dfa9a8", "MicroBit Accelerometer Period" }, { "e95df2d8-251d-470a-a062-fa1922dfa9a8", "MicroBit Magnetometer Service" }, { "e95dfb11-251d-470a-a062-fa1922dfa9a8", "MicroBit Magnetometer Data" }, { "e95d386c-251d-470a-a062-fa1922dfa9a8", "MicroBit Magnetometer Period" }, { "e95d9715-251d-470a-a062-fa1922dfa9a8", "MicroBit Magnetometer Bearing" }, { "e95d9882-251d-470a-a062-fa1922dfa9a8", "MicroBit Button Service" }, { "e95dda90-251d-470a-a062-fa1922dfa9a8", "MicroBit Button A State" }, { "e95dda91-251d-470a-a062-fa1922dfa9a8", "MicroBit Button B State" }, { "e95d127b-251d-470a-a062-fa1922dfa9a8", "MicroBit IO PIN Service" }, { "e95d8d00-251d-470a-a062-fa1922dfa9a8", "MicroBit PIN Data" }, { "e95d5899-251d-470a-a062-fa1922dfa9a8", "MicroBit PIN AD Configuration" }, { "e95dd822-251d-470a-a062-fa1922dfa9a8", "MicroBit PWM Control" }, { "e95dd91d-251d-470a-a062-fa1922dfa9a8", "MicroBit LED Service" }, { "e95d7b77-251d-470a-a062-fa1922dfa9a8", "MicroBit LED Matrix state" }, { "e95d93ee-251d-470a-a062-fa1922dfa9a8", "MicroBit LED Text" }, { "e95d0d2d-251d-470a-a062-fa1922dfa9a8", "MicroBit Scrolling Delay" }, { "e95d93af-251d-470a-a062-fa1922dfa9a8", "MicroBit Event Service" }, { "e95db84c-251d-470a-a062-fa1922dfa9a8", "MicroBit Requirements" }, { "e95d9775-251d-470a-a062-fa1922dfa9a8", "MicroBit Event Data" }, { "e95d23c4-251d-470a-a062-fa1922dfa9a8", "MicroBit Client Requirements" }, { "e95d5404-251d-470a-a062-fa1922dfa9a8", "MicroBit Client Events" }, { "e95d93b0-251d-470a-a062-fa1922dfa9a8", "MicroBit DFU Control Service" }, { "e95d93b1-251d-470a-a062-fa1922dfa9a8", "MicroBit DFU Control" }, { "e95d6100-251d-470a-a062-fa1922dfa9a8", "MicroBit Temperature Service" }, { "e95d1b25-251d-470a-a062-fa1922dfa9a8", "MicroBit Temperature Period" }, /* Nordic UART Port Emulation */ { "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART Service" }, { "6e400002-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART TX" }, { "6e400003-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART RX" }, /* BlueZ Experimental Features */ { "d4992530-b9ec-469f-ab01-6c481c47da1c", "BlueZ Experimental Debug" }, { "671b10b5-42c0-4696-9227-eb28d1b049d6", "BlueZ Experimental Simultaneous Central and Peripheral" }, { "15c0a148-c273-11ea-b3de-0242ac130004", "BlueZ Experimental LL privacy" }, { "330859bc-7506-492d-9370-9a6f0614037f", "BlueZ Experimental Bluetooth Quality Report" }, { "a6695ace-ee7f-4fb9-881a-5fac66c629af", "BlueZ Offload Codecs"}, { "6fbaf188-05e0-496a-9885-d6ddfdb4e03e", "BlueZ Experimental ISO Socket"}, { } }; const char *bt_uuid16_to_str(uint16_t uuid) { int i; for (i = 0; uuid16_table[i].str; i++) { if (uuid16_table[i].uuid == uuid) return uuid16_table[i].str; } return "Unknown"; } const char *bt_uuid32_to_str(uint32_t uuid) { if ((uuid & 0xffff0000) == 0x0000) return bt_uuid16_to_str(uuid & 0x0000ffff); return "Unknown"; } const char *bt_uuid128_to_str(const uint8_t uuid[16]) { char uuidstr[37]; sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x", get_le32(&uuid[12]), get_le16(&uuid[10]), get_le16(&uuid[8]), get_le16(&uuid[6]), get_le32(&uuid[2]), get_le16(&uuid[0])); return bt_uuidstr_to_str(uuidstr); } const char *bt_uuidstr_to_str(const char *uuid) { uint32_t val; size_t len; int i; if (!uuid) return NULL; len = strlen(uuid); if (len < 36) { char *endptr = NULL; val = strtol(uuid, &endptr, 0); if (!endptr || *endptr != '\0') return NULL; if (val > UINT16_MAX) return bt_uuid32_to_str(val); return bt_uuid16_to_str(val); } if (len != 36) return NULL; for (i = 0; uuid128_table[i].str; i++) { if (strcasecmp(uuid128_table[i].uuid, uuid) == 0) return uuid128_table[i].str; } if (strncasecmp(uuid + 8, "-0000-1000-8000-00805f9b34fb", 28)) return "Vendor specific"; if (sscanf(uuid, "%08x-0000-1000-8000-00805f9b34fb", &val) != 1) return NULL; return bt_uuid32_to_str(val); } static const struct { uint16_t val; bool generic; const char *str; } appearance_table[] = { { 0, true, "Unknown" }, { 64, true, "Phone" }, { 128, true, "Computer" }, { 192, true, "Watch" }, { 193, false, "Sports Watch" }, { 256, true, "Clock" }, { 320, true, "Display" }, { 384, true, "Remote Control" }, { 448, true, "Eye-glasses" }, { 512, true, "Tag" }, { 576, true, "Keyring" }, { 640, true, "Media Player" }, { 704, true, "Barcode Scanner" }, { 768, true, "Thermometer" }, { 769, false, "Thermometer: Ear" }, { 832, true, "Heart Rate Sensor" }, { 833, false, "Heart Rate Belt" }, { 896, true, "Blood Pressure" }, { 897, false, "Blood Pressure: Arm" }, { 898, false, "Blood Pressure: Wrist" }, { 960, true, "Human Interface Device" }, { 961, false, "Keyboard" }, { 962, false, "Mouse" }, { 963, false, "Joystick" }, { 964, false, "Gamepad" }, { 965, false, "Digitizer Tablet" }, { 966, false, "Card Reader" }, { 967, false, "Digital Pen" }, { 968, false, "Barcode Scanner" }, { 1024, true, "Glucose Meter" }, { 1088, true, "Running Walking Sensor" }, { 1089, false, "Running Walking Sensor: In-Shoe" }, { 1090, false, "Running Walking Sensor: On-Shoe" }, { 1091, false, "Running Walking Sensor: On-Hip" }, { 1152, true, "Cycling" }, { 1153, false, "Cycling: Cycling Computer" }, { 1154, false, "Cycling: Speed Sensor" }, { 1155, false, "Cycling: Cadence Sensor" }, { 1156, false, "Cycling: Power Sensor" }, { 1157, false, "Cycling: Speed and Cadence Sensor" }, { 1216, true, "Undefined" }, { 3136, true, "Pulse Oximeter" }, { 3137, false, "Pulse Oximeter: Fingertip" }, { 3138, false, "Pulse Oximeter: Wrist Worn" }, { 3200, true, "Weight Scale" }, { 3264, true, "Undefined" }, { 5184, true, "Outdoor Sports Activity" }, { 5185, false, "Location Display Device" }, { 5186, false, "Location and Navigation Display Device" }, { 5187, false, "Location Pod" }, { 5188, false, "Location and Navigation Pod" }, { 5248, true, "Undefined" }, { } }; const char *bt_appear_to_str(uint16_t appearance) { const char *str = NULL; int i, type = 0; for (i = 0; appearance_table[i].str; i++) { if (appearance_table[i].generic) { if (appearance < appearance_table[i].val) break; type = i; } if (appearance_table[i].val == appearance) { str = appearance_table[i].str; break; } } if (!str) str = appearance_table[type].str; return str; } char *strdelimit(char *str, char *del, char c) { char *dup; if (!str) return NULL; dup = strdup(str); if (dup[0] == '\0') return dup; while (del[0] != '\0') { char *rep = dup; while ((rep = strchr(rep, del[0]))) rep[0] = c; del++; } return dup; } int strsuffix(const char *str, const char *suffix) { int len; int suffix_len; if (!str || !suffix) return -1; if (str[0] == '\0' && suffix[0] != '\0') return -1; if (suffix[0] == '\0' && str[0] != '\0') return -1; len = strlen(str); suffix_len = strlen(suffix); if (len < suffix_len) return -1; return strncmp(str + len - suffix_len, suffix, suffix_len); } char *strstrip(char *str) { size_t size; char *end; if (!str) return NULL; size = strlen(str); if (!size) return str; end = str + size - 1; while (end >= str && isspace(*end)) end--; *(end + 1) = '\0'; while (*str && isspace(*str)) str++; return str; } size_t strnlenutf8(const char *str, size_t len) { size_t i = 0; while (i < len) { unsigned char c = str[i]; size_t size = 0; /* Check the first byte to determine the number of bytes in the * UTF-8 character. */ if ((c & 0x80) == 0x00) size = 1; else if ((c & 0xE0) == 0xC0) size = 2; else if ((c & 0xF0) == 0xE0) size = 3; else if ((c & 0xF8) == 0xF0) size = 4; else /* Invalid UTF-8 sequence */ goto done; /* Check the following bytes to ensure they have the correct * format. */ for (size_t j = 1; j < size; ++j) { if (i + j >= len || (str[i + j] & 0xC0) != 0x80) /* Invalid UTF-8 sequence */ goto done; } /* Move to the next character */ i += size; } done: return i; } bool strisutf8(const char *str, size_t len) { return strnlenutf8(str, len) == len; } bool argsisutf8(int argc, char *argv[]) { for (int i = 0; i < argc; i++) { if (!strisutf8(argv[i], strlen(argv[i]))) { printf("Invalid character in string: %s\n", argv[i]); return false; } } return true; } char *strtoutf8(char *str, size_t len) { size_t i = 0; i = strnlenutf8(str, len); if (i == len) return str; /* Truncate to the longest valid UTF-8 string */ memset(str + i, 0, len - i); return str; } |