1 /* 2 * Copyright (C) 2023 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 #ifndef NDEF_BT_SSP_DATA_PARSER_H 16 #define NDEF_BT_SSP_DATA_PARSER_H 17 18 #include <string> 19 20 namespace OHOS { 21 namespace NFC { 22 class BtOobData { 23 public: 24 bool isValid_ = false; 25 std::string name_; 26 std::string oobData_ = ""; 27 std::string uuids_ = ""; 28 29 std::string macAddress_ = ""; 30 std::string vendorSerialNum_ = ""; 31 std::string vendorPayload_ = ""; 32 }; 33 34 class NdefBtOobDataParser { 35 public: 36 NdefBtOobDataParser(); ~NdefBtOobDataParser()37 ~NdefBtOobDataParser() {} 38 static std::shared_ptr<BtOobData> CheckBtRecord(const std::string& msg); 39 40 private: 41 static std::shared_ptr<BtOobData> ParseBtOobRecord(const std::string& payload); 42 static std::shared_ptr<BtOobData> ParseBleOobRecord(const std::string& payload); 43 static std::string GetUuidFromPayload(const std::string& payload, uint32_t& offset, uint32_t type, uint32_t len); 44 static std::string GetDataFromPayload(const std::string& payload, uint32_t& offset, uint32_t datalen); 45 static std::string GetBtMacFromPayload(const std::string& payload, uint32_t& offset); 46 47 private: 48 }; 49 } // namespace NFC 50 } // namespace OHOS 51 #endif // NDEF_BT_OOB_DATA_PARSER_H