1 /* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Bluetooth 18 * @{ 19 * 20 * @brief Defines ble advertiser, peripheral deviceand central manager functions, 21 * including scan settings and filters, advertise settings and data etc. 22 * 23 * @since 6 24 */ 25 26 /** 27 * @file ble_data.h 28 * 29 * @brief Ble data class. 30 * 31 * @since 6 32 */ 33 34 #ifndef BLE_PARCEL_DATA_H 35 #define BLE_PARCEL_DATA_H 36 37 #include <map> 38 #include <vector> 39 40 #include "ble_service_data.h" 41 #include "bt_uuid.h" 42 #include "raw_address.h" 43 #include "securec.h" 44 45 namespace OHOS { 46 namespace bluetooth { 47 class AdvertiserData { 48 public: 49 /** 50 * @brief A constructor used to create a <b>BleAdvertiserData</b> instance. 51 * 52 * @since 6 53 */ AdvertiserData()54 AdvertiserData(){}; 55 56 /** 57 * @brief A destructor used to delete the <b>BleAdvertiserData</b> instance. 58 * 59 * @since 6 60 */ ~AdvertiserData()61 virtual ~AdvertiserData(){}; 62 GetManufacturerData()63 std::map<uint16_t, std::string> GetManufacturerData() const 64 { 65 return manufacturerSpecificData_; 66 } 67 68 /** 69 * @brief Get service data. 70 * 71 * @return Returns service data. 72 * @since 6 73 */ GetServiceData()74 std::map<Uuid, std::string> GetServiceData() const 75 { 76 return serviceData_; 77 } 78 79 /** 80 * @brief Get service uuids. 81 * 82 * @return Returns service uuids. 83 * @since 6 84 */ GetServiceUuids()85 std::vector<Uuid> GetServiceUuids() const 86 { 87 return serviceUuids_; 88 } 89 90 /** 91 * @brief Get advertiser flag. 92 * 93 * @return Returns advertiser flag. 94 * @since 6 95 */ GetAdvFlag()96 uint8_t GetAdvFlag() const 97 { 98 return advFlag_; 99 } 100 101 /** 102 * @brief Get payload. 103 * 104 * @return Returns payload. 105 * @since 6 106 */ GetPayload()107 std::string GetPayload() const 108 { 109 return payload_; 110 } 111 112 /** 113 * @brief Set advertiser flag. 114 * 115 * @param flag Advertiser flag. 116 * @since 6 117 */ SetAdvFlag(uint8_t flag)118 void SetAdvFlag(uint8_t flag) 119 { 120 advFlag_ = flag; 121 } 122 123 /** 124 * @brief Set payload data. 125 * 126 * @param Payload payload. 127 * @since 6 128 */ SetPayload(const std::string & payload)129 void SetPayload(const std::string &payload) 130 { 131 payload_ = payload; 132 } 133 134 /** 135 * @brief Add manufacture data. 136 * 137 * @param manufacturerId Manufacture Id which addad data. 138 * @since 6 139 */ AddManufacturerData(uint16_t manufacturerId,std::string data)140 void AddManufacturerData(uint16_t manufacturerId, std::string data) 141 { 142 manufacturerSpecificData_.insert(std::make_pair(manufacturerId, data)); 143 } 144 145 /** 146 * @brief Add service data. 147 * 148 * @param uuid Uuid of service data. 149 * @param serviceData Service data. 150 * @since 6 151 */ AddServiceData(bluetooth::Uuid uuid,std::string serviceData)152 void AddServiceData(bluetooth::Uuid uuid, std::string serviceData) 153 { 154 serviceData_.insert(std::make_pair(uuid, serviceData)); 155 } 156 157 /** 158 * @brief Add service uuid. 159 * 160 * @param serviceUuid Service uuid. 161 * @since 6 162 */ AddServiceUuid(const bluetooth::Uuid & serviceUuid)163 void AddServiceUuid(const bluetooth::Uuid &serviceUuid) 164 { 165 serviceUuids_.push_back(serviceUuid); 166 } 167 168 /** 169 * @brief Get whether the device name will be included in the advertisement packet. 170 * 171 * @return Returns includeDeviceName flag. 172 * @since 6 173 */ GetIncludeDeviceName()174 bool GetIncludeDeviceName() const 175 { 176 return includeDeviceName_; 177 } 178 179 /** 180 * @brief Set whether the device name will be included in the advertisement packet. 181 * 182 * @param flag includeDeviceName flag. 183 * @since 6 184 */ SetIncludeDeviceName(bool flag)185 void SetIncludeDeviceName(bool flag) 186 { 187 includeDeviceName_ = flag; 188 } 189 190 /** 191 * @brief Get whether the txpower will be included in the advertisement packet. 192 * 193 * @return Returns includeTxPower flag. 194 * @since 10 195 */ GetIncludeTxPower()196 bool GetIncludeTxPower() const 197 { 198 return includeTxPower_; 199 } 200 201 /** 202 * @brief Set whether the txpower will be included in the advertisement packet. 203 * 204 * @param flag includeTxPower flag. 205 * @since 10 206 */ SetIncludeTxPower(bool flag)207 void SetIncludeTxPower(bool flag) 208 { 209 includeTxPower_ = flag; 210 } 211 212 public: 213 std::vector<Uuid> serviceUuids_ {}; 214 std::map<uint16_t, std::string> manufacturerSpecificData_ {}; 215 std::map<Uuid, std::string> serviceData_ {}; 216 uint8_t advFlag_ {}; 217 std::string payload_ = ""; 218 bool includeDeviceName_ = false; 219 bool includeTxPower_ = false; 220 }; 221 222 /** 223 * @brief Represents advertise settings. 224 * 225 * @since 6 226 */ 227 class AdvertiserSettings { 228 public: 229 /** 230 * @brief A constructor used to create a <b>BleAdvertiseSettings</b> instance. 231 * 232 * @since 6 233 */ AdvertiserSettings()234 AdvertiserSettings(){}; 235 236 /** 237 * @brief A destructor used to delete the <b>BleAdvertiseSettings</b> instance. 238 * 239 * @since 6 240 */ ~AdvertiserSettings()241 virtual ~AdvertiserSettings(){}; 242 243 /** 244 * @brief Check if device service is connectable. 245 * 246 * @return Returns <b>true</b> if device service is connectable; 247 * returns <b>false</b> if device service is not connectable. 248 * @since 6 249 */ IsConnectable()250 bool IsConnectable() const 251 { 252 return connectable_; 253 } 254 255 /** 256 * @brief Check if advertiser is legacy mode. 257 * 258 * @return Returns <b>true</b> if advertiser is legacy mode; 259 * returns <b>false</b> if advertiser is not legacy mode. 260 * @since 6 261 */ IsLegacyMode()262 bool IsLegacyMode() const 263 { 264 return legacyMode_; 265 } 266 267 /** 268 * @brief Get advertise interval. 269 * 270 * @return Returns advertise interval. 271 * @since 6 272 */ GetInterval()273 int GetInterval() const 274 { 275 return interval_; 276 } 277 278 /** 279 * @brief Get Tx power. 280 * 281 * @return Returns Tx power. 282 * @since 6 283 */ GetTxPower()284 int8_t GetTxPower() const 285 { 286 return txPower_; 287 } 288 289 /** 290 * @brief Set connectable. 291 * 292 * @param connectable Whether it is connectable. 293 * @since 6 294 */ SetConnectable(bool connectable)295 void SetConnectable(bool connectable) 296 { 297 connectable_ = connectable; 298 } 299 300 /** 301 * @brief Set legacyMode. 302 * 303 * @param connectable Whether it is legacyMode. 304 * @since 6 305 */ SetLegacyMode(bool legacyMode)306 void SetLegacyMode(bool legacyMode) 307 { 308 legacyMode_ = legacyMode; 309 } 310 311 /** 312 * @brief Set advertise interval. 313 * 314 * @param interval Advertise interval. 315 * @since 6 316 */ SetInterval(uint16_t interval)317 void SetInterval(uint16_t interval) 318 { 319 interval_ = interval; 320 } 321 322 /** 323 * @brief Set Tx power. 324 * 325 * @param txPower Tx power. 326 * @since 6 327 */ SetTxPower(int8_t txPower)328 void SetTxPower(int8_t txPower) 329 { 330 txPower_ = txPower; 331 } 332 333 /** 334 * @brief Get primary phy. 335 * 336 * @return Returns primary phy. 337 * @since 6 338 */ GetPrimaryPhy()339 int GetPrimaryPhy() const 340 { 341 return primaryPhy_; 342 } 343 344 /** 345 * @brief Set primary phy. 346 * 347 * @param primaryPhy Primary phy. 348 * @since 6 349 */ SetPrimaryPhy(int primaryPhy)350 void SetPrimaryPhy(int primaryPhy) 351 { 352 primaryPhy_ = primaryPhy; 353 } 354 355 /** 356 * @brief Get second phy. 357 * 358 * @return Returns primary phy. 359 * @since 6 360 */ GetSecondaryPhy()361 int GetSecondaryPhy() const 362 { 363 return secondaryPhy_; 364 } 365 366 /** 367 * @brief Set second phy. 368 * 369 * @param secondaryPhy Second phy. 370 * @since 6 371 */ SetSecondaryPhy(int secondaryPhy)372 void SetSecondaryPhy(int secondaryPhy) 373 { 374 secondaryPhy_ = secondaryPhy; 375 } 376 377 /** 378 * @brief Get own address. 379 * 380 * @param addr Own address. 381 * @since 6 382 */ GetOwnAddr()383 std::array<uint8_t, RawAddress::BT_ADDRESS_BYTE_LEN> GetOwnAddr() const 384 { 385 return ownAddr_; 386 } 387 388 /** 389 * @brief Set own address. 390 * 391 * @param addr Own address. 392 * @since 6 393 */ SetOwnAddr(const std::array<uint8_t,RawAddress::BT_ADDRESS_BYTE_LEN> & addr)394 void SetOwnAddr(const std::array<uint8_t, RawAddress::BT_ADDRESS_BYTE_LEN>& addr) 395 { 396 ownAddr_ = addr; 397 } 398 399 /** 400 * @brief Get own address type. 401 * 402 * @return Returns own address type. 403 * @since 6 404 */ GetOwnAddrType()405 int8_t GetOwnAddrType() const 406 { 407 return ownAddrType_; 408 } 409 410 /** 411 * @brief Set own address type. 412 * 413 * @param addrType Own address type. 414 * @since 6 415 */ SetOwnAddrType(int8_t addrType)416 void SetOwnAddrType(int8_t addrType) 417 { 418 ownAddrType_ = addrType; 419 } 420 421 public: 422 bool connectable_ {}; 423 bool legacyMode_ {}; 424 uint16_t interval_ {}; 425 int8_t txPower_ {}; 426 int primaryPhy_ {}; 427 int secondaryPhy_ {}; 428 std::array<uint8_t, RawAddress::BT_ADDRESS_BYTE_LEN> ownAddr_ = {}; 429 int8_t ownAddrType_ = -1; 430 }; 431 432 class ScanResult { 433 public: 434 /** 435 * @brief A constructor used to create a <b>BleScanResult</b> instance. 436 * 437 * @since 6 438 */ ScanResult()439 ScanResult(){}; 440 441 explicit ScanResult(const BleScanResultImpl &other); 442 443 /** 444 * @brief A destructor used to delete the <b>BleScanResult</b> instance. 445 * 446 * @since 6 447 */ ~ScanResult()448 virtual ~ScanResult(){}; 449 450 /** 451 * @brief Get service uuids. 452 * 453 * @return Returns service uuids. 454 * @since 6 455 */ GetServiceUuids()456 std::vector<Uuid> GetServiceUuids() const 457 { 458 return serviceUuids_; 459 } 460 461 /** 462 * @brief Get manufacture data. 463 * 464 * @return Returns manufacture data. 465 * @since 6 466 */ GetManufacturerData()467 std::map<uint16_t, std::string> GetManufacturerData() const 468 { 469 return manufacturerSpecificData_; 470 } 471 472 /** 473 * @brief Get service data. 474 * 475 * @return Returns service data. 476 * @since 6 477 */ GetServiceData()478 std::map<Uuid, std::string> GetServiceData() const 479 { 480 return serviceData_; 481 } 482 483 /** 484 * @brief Get peripheral device. 485 * 486 * @return Returns peripheral device pointer. 487 * @since 6 488 */ GetPeripheralDevice()489 const RawAddress &GetPeripheralDevice() const 490 { 491 return addr_; 492 } 493 494 /** 495 * @brief Get peer device rssi. 496 * 497 * @return Returns peer device rssi. 498 * @since 6 499 */ GetRssi()500 int8_t GetRssi() const 501 { 502 return rssi_; 503 } 504 505 /** 506 * @brief Check if device is connectable. 507 * 508 * @return Returns <b>true</b> if device is connectable; 509 * returns <b>false</b> if device is not connectable. 510 * @since 6 511 */ IsConnectable()512 bool IsConnectable() const 513 { 514 return connectable_; 515 } 516 517 /** 518 * @brief Get advertiser flag. 519 * 520 * @return Returns advertiser flag. 521 * @since 6 522 */ GetAdvertiseFlag()523 uint8_t GetAdvertiseFlag() const 524 { 525 return advertiseFlag_; 526 } 527 528 /** 529 * @brief Add manufacture data. 530 * 531 * @param manufacturerId Manufacture Id which addad data. 532 * @since 6 533 */ AddManufacturerData(uint16_t manufacturerId,std::string data)534 void AddManufacturerData(uint16_t manufacturerId, std::string data) 535 { 536 manufacturerSpecificData_.insert(std::make_pair(manufacturerId, data)); 537 } 538 539 /** 540 * @brief Add service data. 541 * 542 * @param uuid Uuid of service data. 543 * @param serviceData Service data. 544 * @since 6 545 */ AddServiceData(Uuid uuid,std::string serviceData)546 void AddServiceData(Uuid uuid, std::string serviceData) 547 { 548 serviceData_.insert(std::make_pair(uuid, serviceData)); 549 } 550 551 /** 552 * @brief Add service uuid. 553 * 554 * @param serviceUuid Service uuid. 555 * @since 6 556 */ AddServiceUuid(const Uuid & serviceUuid)557 void AddServiceUuid(const Uuid &serviceUuid) 558 { 559 serviceUuids_.push_back(serviceUuid); 560 } 561 562 /** 563 * @brief Set peripheral device. 564 * 565 * @param device Remote device. 566 * @since 6 567 */ SetPeripheralDevice(const RawAddress & device)568 void SetPeripheralDevice(const RawAddress &device) 569 { 570 addr_ = device; 571 } 572 573 /** 574 * @brief Set peer device rssi. 575 * 576 * @param rssi Peer device rssi. 577 * @since 6 578 */ SetRssi(int8_t rssi)579 void SetRssi(int8_t rssi) 580 { 581 rssi_ = rssi; 582 } 583 584 /** 585 * @brief Set connectable. 586 * 587 * @param connectable Whether it is connectable. 588 * @since 6 589 */ SetConnectable(bool connectable)590 void SetConnectable(bool connectable) 591 { 592 connectable_ = connectable; 593 } 594 595 /** 596 * @brief Set advertiser flag. 597 * 598 * @param flag Advertiser flag. 599 * @since 6 600 */ SetAdvertiseFlag(uint8_t flag)601 void SetAdvertiseFlag(uint8_t flag) 602 { 603 advertiseFlag_ = flag; 604 } 605 SetPayload(const std::string & payload)606 void SetPayload(const std::string &payload) 607 { 608 payload_ = payload; 609 } 610 GetPayload()611 std::string GetPayload() const 612 { 613 return payload_; 614 } 615 SetName(const std::string & name)616 void SetName(const std::string &name) 617 { 618 name_ = name; 619 } 620 GetName(void)621 std::string GetName(void) const 622 { 623 return name_; 624 } 625 SetEventType(uint16_t eventType)626 void SetEventType(uint16_t eventType) 627 { 628 eventType_ = eventType; 629 } 630 GetEventType()631 uint16_t GetEventType() const 632 { 633 return eventType_; 634 } 635 636 public: 637 std::vector<Uuid> serviceUuids_ {}; 638 std::map<uint16_t, std::string> manufacturerSpecificData_ {}; 639 std::map<Uuid, std::string> serviceData_ {}; 640 RawAddress addr_ {}; 641 int8_t rssi_ {}; 642 bool connectable_ {}; 643 uint8_t advertiseFlag_ {}; 644 std::string payload_ {}; 645 std::string name_ {}; 646 uint16_t eventType_{}; 647 }; 648 649 /** 650 * @brief Represents Scan settings. 651 * 652 * @since 6 653 */ 654 class ScanSettings { 655 public: 656 /** 657 * @brief A constructor used to create a <b>BleScanSettings</b> instance. 658 * 659 * @since 6 660 */ ScanSettings()661 ScanSettings(){}; 662 663 /** 664 * @brief A destructor used to delete the <b>BleScanSettings</b> instance. 665 * 666 * @since 6 667 */ ~ScanSettings()668 virtual ~ScanSettings(){}; 669 670 /** 671 * @brief Set report delay time. 672 * 673 * @param reportDelayMillis Report delay time. 674 * @since 6 675 */ SetReportDelay(long reportDelayMillis)676 void SetReportDelay(long reportDelayMillis) 677 { 678 reportDelayMillis_ = reportDelayMillis; 679 } 680 681 /** 682 * @brief Get report delay time. 683 * 684 * @return Returns Report delay time. 685 * @since 6 686 */ GetReportDelayMillisValue()687 long GetReportDelayMillisValue() const 688 { 689 return reportDelayMillis_; 690 } 691 692 /** 693 * @brief Set scan mode. 694 * 695 * @param scanMode Scan mode. 696 * @return If the scanMode is invalid. 697 * @since 6 698 */ SetScanMode(int scanMode)699 void SetScanMode(int scanMode) 700 { 701 scanMode_ = scanMode; 702 } 703 704 /** 705 * @brief Get scan mode. 706 * 707 * @return Scan mode. 708 * @since 6 709 */ GetScanMode()710 int GetScanMode() const 711 { 712 return scanMode_; 713 } 714 715 /** 716 * @brief Set legacy flag. 717 * 718 * @param legacy Legacy value. 719 * @since 6 720 */ SetLegacy(bool legacy)721 void SetLegacy(bool legacy) 722 { 723 legacy_ = legacy; 724 } 725 726 /** 727 * @brief Get legacy flag. 728 * 729 * @return Legacy flag. 730 * @since 6 731 */ GetLegacy()732 bool GetLegacy() const 733 { 734 return legacy_; 735 } 736 737 /** 738 * @brief Set phy value. 739 * 740 * @param phy Phy value. 741 * @since 6 742 */ SetPhy(int phy)743 void SetPhy(int phy) 744 { 745 phy_ = phy; 746 } 747 748 /** 749 * @brief Get phy value. 750 * 751 * @return Phy value. 752 * @since 6 753 */ GetPhy()754 int GetPhy() const 755 { 756 return phy_; 757 } 758 759 /** 760 * @brief Set callback type. 761 * 762 * @param callbackType callback type. 763 * @since 12 764 */ SetCallbackType(uint8_t callbackType)765 void SetCallbackType(uint8_t callbackType) 766 { 767 callbackType_ = callbackType; 768 } 769 770 /** 771 * @brief Get callback type. 772 * 773 * @return callback type value. 774 * @since 12 775 */ GetCallbackType()776 uint8_t GetCallbackType() const 777 { 778 return callbackType_; 779 } 780 781 /** 782 * @brief Set match track adv type for total number of advertisers to track per filter. 783 * 784 * @param matchTrackAdvType match track adv type value. 785 * @since 12 786 */ SetMatchTrackAdvType(uint8_t matchTrackAdvType)787 void SetMatchTrackAdvType(uint8_t matchTrackAdvType) 788 { 789 matchTrackAdvType_ = matchTrackAdvType; 790 } 791 792 /** 793 * @brief Get match track adv type. 794 * 795 * @return match track adv type value. 796 * @since 12 797 */ GetMatchTrackAdvType()798 uint8_t GetMatchTrackAdvType() const 799 { 800 return matchTrackAdvType_; 801 } 802 803 public: 804 long reportDelayMillis_ = 0; 805 int scanMode_ = 0; 806 bool legacy_ = true; 807 int phy_ = 255; 808 uint8_t callbackType_ = BLE_SCAN_CALLBACK_TYPE_ALL_MATCH; 809 uint8_t matchTrackAdvType_ = MAX_MATCH_TRACK_ADV; 810 }; 811 812 /** 813 * @brief Represents Scan filter. 814 * 815 */ 816 class ScanFilter { 817 public: 818 /** 819 * @brief A constructor used to create a <b>BleScanFilter</b> instance. 820 * 821 */ ScanFilter()822 ScanFilter() {} 823 824 /** 825 * @brief A destructor used to delete the <b>BleScanFilter</b> instance. 826 * 827 */ ~ScanFilter()828 virtual ~ScanFilter() {} 829 830 /** 831 * @brief Set device id. 832 * 833 * @param deviceId device id. 834 */ SetDeviceId(const std::string & deviceId)835 void SetDeviceId(const std::string &deviceId) 836 { 837 deviceId_ = deviceId; 838 } 839 840 /** 841 * @brief Get device id. 842 * 843 * @return Returns device id. 844 */ GetDeviceId()845 std::string GetDeviceId() const 846 { 847 return deviceId_; 848 } 849 SetName(const std::string & name)850 void SetName(const std::string &name) 851 { 852 name_ = name; 853 } 854 GetName()855 std::string GetName() const 856 { 857 return name_; 858 } 859 SetServiceUuid(const Uuid & uuid)860 void SetServiceUuid(const Uuid &uuid) 861 { 862 serviceUuid_ = uuid; 863 hasServiceUuid_ = true; 864 } 865 HasServiceUuid()866 bool HasServiceUuid() const 867 { 868 return hasServiceUuid_; 869 } 870 GetServiceUuid()871 Uuid GetServiceUuid() const 872 { 873 return serviceUuid_; 874 } 875 SetServiceUuidMask(const Uuid & serviceUuidMask)876 void SetServiceUuidMask(const Uuid &serviceUuidMask) 877 { 878 serviceUuidMask_ = serviceUuidMask; 879 hasServiceUuidMask_ = true; 880 } 881 HasServiceUuidMask()882 bool HasServiceUuidMask() const 883 { 884 return hasServiceUuidMask_; 885 } 886 GetServiceUuidMask()887 Uuid GetServiceUuidMask() const 888 { 889 return serviceUuidMask_; 890 } 891 SetServiceSolicitationUuid(const Uuid & serviceSolicitationUuid)892 void SetServiceSolicitationUuid(const Uuid &serviceSolicitationUuid) 893 { 894 serviceSolicitationUuid_ = serviceSolicitationUuid; 895 hasSolicitationUuid_ = true; 896 } 897 HasSolicitationUuid()898 bool HasSolicitationUuid() const 899 { 900 return hasSolicitationUuid_; 901 } 902 GetServiceSolicitationUuid()903 Uuid GetServiceSolicitationUuid() const 904 { 905 return serviceSolicitationUuid_; 906 } 907 SetServiceSolicitationUuidMask(const Uuid & serviceSolicitationUuidMask)908 void SetServiceSolicitationUuidMask(const Uuid &serviceSolicitationUuidMask) 909 { 910 serviceSolicitationUuidMask_ = serviceSolicitationUuidMask; 911 hasSolicitationUuidMask_ = true; 912 } 913 HasSolicitationUuidMask()914 bool HasSolicitationUuidMask() const 915 { 916 return hasSolicitationUuidMask_; 917 } 918 GetServiceSolicitationUuidMask()919 Uuid GetServiceSolicitationUuidMask() const 920 { 921 return serviceSolicitationUuidMask_; 922 } 923 SetServiceData(const std::vector<uint8_t> & serviceData)924 void SetServiceData(const std::vector<uint8_t> &serviceData) 925 { 926 serviceData_ = serviceData; 927 } 928 GetServiceData()929 std::vector<uint8_t> GetServiceData() const 930 { 931 return serviceData_; 932 } 933 SetServiceDataMask(const std::vector<uint8_t> & serviceDataMask)934 void SetServiceDataMask(const std::vector<uint8_t> &serviceDataMask) 935 { 936 serviceDataMask_ = serviceDataMask; 937 } 938 GetServiceDataMask()939 std::vector<uint8_t> GetServiceDataMask() const 940 { 941 return serviceDataMask_; 942 } 943 SetManufacturerId(uint16_t manufacturerId)944 void SetManufacturerId(uint16_t manufacturerId) 945 { 946 manufacturerId_ = manufacturerId; 947 } 948 GetManufacturerId()949 uint16_t GetManufacturerId() const 950 { 951 return manufacturerId_; 952 } 953 SetManufactureData(const std::vector<uint8_t> & manufactureData)954 void SetManufactureData(const std::vector<uint8_t> &manufactureData) 955 { 956 manufactureData_ = manufactureData; 957 } 958 GetManufactureData()959 std::vector<uint8_t> GetManufactureData() const 960 { 961 return manufactureData_; 962 } 963 SetManufactureDataMask(const std::vector<uint8_t> & manufactureDataMask)964 void SetManufactureDataMask(const std::vector<uint8_t> &manufactureDataMask) 965 { 966 manufactureDataMask_ = manufactureDataMask; 967 } 968 GetManufactureDataMask()969 std::vector<uint8_t> GetManufactureDataMask() const 970 { 971 return manufactureDataMask_; 972 } 973 SetAdvIndReportFlag(bool advIndReport)974 void SetAdvIndReportFlag(bool advIndReport) 975 { 976 advIndReport_ = advIndReport; 977 } 978 GetAdvIndReportFlag()979 bool GetAdvIndReportFlag() 980 { 981 return advIndReport_; 982 } 983 984 public: 985 std::string deviceId_; 986 std::string name_; 987 988 Uuid serviceUuid_; 989 Uuid serviceUuidMask_; 990 Uuid serviceSolicitationUuid_; 991 Uuid serviceSolicitationUuidMask_; 992 bool hasServiceUuid_ = false; 993 bool hasServiceUuidMask_ = false; 994 bool hasSolicitationUuid_ = false; 995 bool hasSolicitationUuidMask_ = false; 996 997 std::vector<uint8_t> serviceData_; 998 std::vector<uint8_t> serviceDataMask_; 999 1000 uint16_t manufacturerId_ = 0; 1001 std::vector<uint8_t> manufactureData_; 1002 std::vector<uint8_t> manufactureDataMask_; 1003 bool advIndReport_ = false; 1004 }; 1005 } // namespace bluetooth 1006 } // namespace OHOS 1007 1008 #endif /// BLE_PARCEL_DATA_H 1009