• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 report mode.
717      *
718      * @param reportMode Report mode.
719      * @return If the reportMode is invalid.
720      * @since 19
721      */
SetReportMode(int reportMode)722     void SetReportMode(int reportMode)
723     {
724         reportMode_ = reportMode;
725     }
726 
727     /**
728      * @brief Get report mode.
729      *
730      * @return Report mode.
731      * @since 19
732      */
GetReportMode()733     int GetReportMode() const
734     {
735         return reportMode_;
736     }
737 
738     /**
739      * @brief Set legacy flag.
740      *
741      * @param legacy Legacy value.
742      * @since 6
743      */
SetLegacy(bool legacy)744     void SetLegacy(bool legacy)
745     {
746         legacy_ = legacy;
747     }
748 
749     /**
750      * @brief Get legacy flag.
751      *
752      * @return Legacy flag.
753      * @since 6
754      */
GetLegacy()755     bool GetLegacy() const
756     {
757         return legacy_;
758     }
759 
760     /**
761      * @brief Set phy value.
762      *
763      * @param phy Phy value.
764      * @since 6
765      */
SetPhy(int phy)766     void SetPhy(int phy)
767     {
768         phy_ = phy;
769     }
770 
771     /**
772      * @brief Get phy value.
773      *
774      * @return Phy value.
775      * @since 6
776      */
GetPhy()777     int GetPhy() const
778     {
779         return phy_;
780     }
781 
782     /**
783      * @brief Set callback type.
784      *
785      * @param callbackType callback type.
786      * @since 12
787      */
SetCallbackType(uint8_t callbackType)788     void SetCallbackType(uint8_t callbackType)
789     {
790         callbackType_ = callbackType;
791     }
792 
793     /**
794      * @brief Get callback type.
795      *
796      * @return callback type value.
797      * @since 12
798      */
GetCallbackType()799     uint8_t GetCallbackType() const
800     {
801         return callbackType_;
802     }
803 
804     /**
805      * @brief Set sensitivity mode.
806      *
807      * @param sensitivityMode sensitivity mode.
808      * @since 15
809      */
SetSensitivityMode(uint8_t sensitivityMode)810     void SetSensitivityMode(uint8_t sensitivityMode)
811     {
812         sensitivityMode_ = sensitivityMode;
813     }
814 
815     /**
816      * @brief Get sensitivity mode.
817      *
818      * @return sensitivity mode value.
819      * @since 15
820      */
GetSensitivityMode()821     uint8_t GetSensitivityMode() const
822     {
823         return sensitivityMode_;
824     }
825 
826     /**
827      * @brief Set match track adv type for total number of advertisers to track per filter.
828      *
829      * @param matchTrackAdvType match track adv type value.
830      * @since 12
831      */
SetMatchTrackAdvType(uint8_t matchTrackAdvType)832     void SetMatchTrackAdvType(uint8_t matchTrackAdvType)
833     {
834         matchTrackAdvType_ = matchTrackAdvType;
835     }
836 
837     /**
838      * @brief Get match track adv type.
839      *
840      * @return match track adv type value.
841      * @since 12
842      */
GetMatchTrackAdvType()843     uint8_t GetMatchTrackAdvType() const
844     {
845         return matchTrackAdvType_;
846     }
847 
848 public:
849     long reportDelayMillis_ = 0;
850     int scanMode_ = 0;
851     int reportMode_ = 1;
852     bool legacy_ = true;
853     int phy_ = 255;
854     uint8_t callbackType_ = BLE_SCAN_CALLBACK_TYPE_ALL_MATCH;
855     uint8_t sensitivityMode_ = SENSITIVITY_MODE_HIGH;
856     uint8_t matchTrackAdvType_ = MAX_MATCH_TRACK_ADV;
857 };
858 
859 /**
860  * @brief Represents Scan filter.
861  *
862  */
863 class ScanFilter {
864 public:
865     /**
866      * @brief A constructor used to create a <b>BleScanFilter</b> instance.
867      *
868      */
ScanFilter()869     ScanFilter() {}
870 
871     /**
872      * @brief A destructor used to delete the <b>BleScanFilter</b> instance.
873      *
874      */
~ScanFilter()875     virtual ~ScanFilter() {}
876 
877     /**
878      * @brief Set device id.
879      *
880      * @param deviceId device id.
881      */
SetDeviceId(const std::string & deviceId)882     void SetDeviceId(const std::string &deviceId)
883     {
884         deviceId_ = deviceId;
885     }
886 
887     /**
888      * @brief Get device id.
889      *
890      * @return Returns device id.
891      */
GetDeviceId()892     std::string GetDeviceId() const
893     {
894         return deviceId_;
895     }
896 
SetName(const std::string & name)897     void SetName(const std::string &name)
898     {
899         name_ = name;
900     }
901 
GetName()902     std::string GetName() const
903     {
904         return name_;
905     }
906 
SetServiceUuid(const Uuid & uuid)907     void SetServiceUuid(const Uuid &uuid)
908     {
909         serviceUuid_ = uuid;
910         hasServiceUuid_ = true;
911     }
912 
HasServiceUuid()913     bool HasServiceUuid() const
914     {
915         return hasServiceUuid_;
916     }
917 
GetServiceUuid()918     Uuid GetServiceUuid() const
919     {
920         return serviceUuid_;
921     }
922 
SetServiceUuidMask(const Uuid & serviceUuidMask)923     void SetServiceUuidMask(const Uuid &serviceUuidMask)
924     {
925         serviceUuidMask_ = serviceUuidMask;
926         hasServiceUuidMask_ = true;
927     }
928 
HasServiceUuidMask()929     bool HasServiceUuidMask() const
930     {
931         return hasServiceUuidMask_;
932     }
933 
GetServiceUuidMask()934     Uuid GetServiceUuidMask() const
935     {
936         return serviceUuidMask_;
937     }
938 
SetServiceSolicitationUuid(const Uuid & serviceSolicitationUuid)939     void SetServiceSolicitationUuid(const Uuid &serviceSolicitationUuid)
940     {
941         serviceSolicitationUuid_ = serviceSolicitationUuid;
942         hasSolicitationUuid_ = true;
943     }
944 
HasSolicitationUuid()945     bool HasSolicitationUuid() const
946     {
947         return hasSolicitationUuid_;
948     }
949 
GetServiceSolicitationUuid()950     Uuid GetServiceSolicitationUuid() const
951     {
952         return serviceSolicitationUuid_;
953     }
954 
SetServiceSolicitationUuidMask(const Uuid & serviceSolicitationUuidMask)955     void SetServiceSolicitationUuidMask(const Uuid &serviceSolicitationUuidMask)
956     {
957         serviceSolicitationUuidMask_ = serviceSolicitationUuidMask;
958         hasSolicitationUuidMask_ = true;
959     }
960 
HasSolicitationUuidMask()961     bool HasSolicitationUuidMask() const
962     {
963         return hasSolicitationUuidMask_;
964     }
965 
GetServiceSolicitationUuidMask()966     Uuid GetServiceSolicitationUuidMask() const
967     {
968         return serviceSolicitationUuidMask_;
969     }
970 
SetServiceData(const std::vector<uint8_t> & serviceData)971     void SetServiceData(const std::vector<uint8_t> &serviceData)
972     {
973         serviceData_ = serviceData;
974     }
975 
GetServiceData()976     std::vector<uint8_t> GetServiceData() const
977     {
978         return serviceData_;
979     }
980 
SetServiceDataMask(const std::vector<uint8_t> & serviceDataMask)981     void SetServiceDataMask(const std::vector<uint8_t> &serviceDataMask)
982     {
983         serviceDataMask_ = serviceDataMask;
984     }
985 
GetServiceDataMask()986     std::vector<uint8_t> GetServiceDataMask() const
987     {
988         return serviceDataMask_;
989     }
990 
SetManufacturerId(uint16_t manufacturerId)991     void SetManufacturerId(uint16_t manufacturerId)
992     {
993         manufacturerId_ = manufacturerId;
994     }
995 
GetManufacturerId()996     uint16_t GetManufacturerId() const
997     {
998         return manufacturerId_;
999     }
1000 
SetManufactureData(const std::vector<uint8_t> & manufactureData)1001     void SetManufactureData(const std::vector<uint8_t> &manufactureData)
1002     {
1003         manufactureData_ = manufactureData;
1004     }
1005 
GetManufactureData()1006     std::vector<uint8_t> GetManufactureData() const
1007     {
1008         return manufactureData_;
1009     }
1010 
SetManufactureDataMask(const std::vector<uint8_t> & manufactureDataMask)1011     void SetManufactureDataMask(const std::vector<uint8_t> &manufactureDataMask)
1012     {
1013         manufactureDataMask_ = manufactureDataMask;
1014     }
1015 
GetManufactureDataMask()1016     std::vector<uint8_t> GetManufactureDataMask() const
1017     {
1018         return manufactureDataMask_;
1019     }
1020 
SetAdvIndReportFlag(bool advIndReport)1021     void SetAdvIndReportFlag(bool advIndReport)
1022     {
1023         advIndReport_ = advIndReport;
1024     }
1025 
GetAdvIndReportFlag()1026     bool GetAdvIndReportFlag()
1027     {
1028         return advIndReport_;
1029     }
1030 
SetFilterIndex(uint8_t index)1031     void SetFilterIndex(uint8_t index)
1032     {
1033         filterIndex_ = index;
1034     }
1035 
GetFilterIndex()1036     uint8_t GetFilterIndex() const
1037     {
1038         return filterIndex_;
1039     }
1040 
1041 public:
1042     std::string deviceId_;
1043     std::string name_;
1044 
1045     Uuid serviceUuid_;
1046     Uuid serviceUuidMask_;
1047     Uuid serviceSolicitationUuid_;
1048     Uuid serviceSolicitationUuidMask_;
1049     bool hasServiceUuid_ = false;
1050     bool hasServiceUuidMask_ = false;
1051     bool hasSolicitationUuid_ = false;
1052     bool hasSolicitationUuidMask_ = false;
1053 
1054     std::vector<uint8_t> serviceData_;
1055     std::vector<uint8_t> serviceDataMask_;
1056 
1057     uint16_t manufacturerId_ = 0;
1058     std::vector<uint8_t> manufactureData_;
1059     std::vector<uint8_t> manufactureDataMask_;
1060     bool advIndReport_ = false;
1061     uint8_t filterIndex_ = 0;
1062 };
1063 }  // namespace bluetooth
1064 }  // namespace OHOS
1065 
1066 #endif  /// BLE_PARCEL_DATA_H
1067