1 /* 2 * Copyright (C) 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 #ifndef OPP_SDP_CLIENT_H 17 #define OPP_SDP_CLIENT_H 18 19 #include <string> 20 21 #include "sdp.h" 22 23 namespace OHOS { 24 namespace bluetooth { 25 /** 26 * @brief opp sdp client 27 * opp sdp client 28 */ 29 class OppSdpClient { 30 public: 31 /** 32 * @brief constructor 33 * @details constructor 34 * @param service 35 * @return 36 */ 37 explicit OppSdpClient(std::string address); 38 39 /** 40 * @brief deconstructor 41 * @details deconstructor 42 * @return 43 */ 44 virtual ~OppSdpClient(); 45 46 /** 47 * @brief search sdp recode 48 * @details search sdp recode 49 * @return int @c 0 success 50 * @c not 0 failure 51 */ 52 int SdpSearch(); 53 54 /** 55 * @brief Callback of SDP discovery 56 * @details Callback of SDP discovery 57 * @param addr The address of the bluetooth device 58 * @param serviceAry The serviceAry is Array of services discovered 59 * @param serviceNum The serviceNum is number of services discovered 60 * @param context The context is used to send the event in the callback 61 */ 62 static void SdpSearchCallback(const BtAddr *addr, const SdpService *serviceAry, uint16_t serviceNum, void *context); 63 64 private: 65 void SdpSearchCallback_(const BtAddr *addr, const SdpService *serviceAry, uint16_t serviceNum); 66 uint8_t FindRFCommChannel(const SdpService &serviceAry); 67 uint16_t FindL2capPSM(const SdpService &serviceAry); 68 69 private: 70 std::string address_; 71 }; 72 } // namespace bluetooth 73 } // namespace OHOS 74 #endif // OPP_SDP_CLIENT_H