1 /* 2 * Copyright (C) 2024 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_WIFI_DATA_PARSER_H 16 #define NDEF_WIFI_DATA_PARSER_H 17 18 #include <string> 19 #include "wifi_msg.h" 20 21 namespace OHOS { 22 namespace NFC { 23 namespace TAG { 24 class WifiData { 25 public: 26 bool isValid_ = false; 27 // config will be used in wifi_connection_manager.cpp 28 // this pointer should be deleted when WifiData is invalid or wifi connection is finished 29 Wifi::WifiDeviceConfig* config_ = nullptr; 30 std::string vendorPayload_ = ""; 31 }; 32 class NdefWifiDataParser { 33 public: 34 NdefWifiDataParser(); ~NdefWifiDataParser()35 ~NdefWifiDataParser() {} 36 static std::shared_ptr<WifiData> CheckWifiRecord(const std::string& msg); 37 38 private: 39 static uint16_t GetTypeFromPayload(const std::string& src, uint32_t& offset); 40 static std::string GetValueFromPayload(const std::string& payload, uint32_t& offset, uint16_t dataLen); 41 static void SetKeyMgmt(std::string& keyMgmt, uint16_t authType); 42 static std::shared_ptr<WifiData> ParseWiFiPayload(const std::string& payload); 43 }; 44 } // namespace TAG 45 } // namespace NFC 46 } // namespace OHOS 47 #endif // NDEF_WIFI_DATA_PARSER_H