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 BT_SENSING_INFO_H 16 #define BT_SENSING_INFO_H 17 18 #include <string> 19 #include "bt_def.h" 20 21 namespace OHOS { 22 namespace bluetooth { 23 constexpr const char *INVALID_UUID_STRING = "00000000-0000-0000-0000-000000000000"; 24 constexpr const char *INVALID_PKGNAME = "invalid_name"; 25 constexpr const char *INVALID_BUSSINESS_TYPE = "0x00"; 26 27 struct BleAdvData { BleAdvDataBleAdvData28 BleAdvData(const std::string &uuid, bool connectable, int payloadLen, const std::string &bussinessType) 29 : uuid_(uuid), connectable_(connectable), payloadLen_(payloadLen), bussinessType_(bussinessType) 30 {} 31 std::string uuid_; 32 bool connectable_; 33 int payloadLen_; 34 std::string bussinessType_; 35 }; 36 37 struct SensingInfo { SensingInfoSensingInfo38 SensingInfo() 39 : addr_(INVALID_MAC_ADDRESS), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(INVALID_PKGNAME), 40 isServer_(false), interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 41 scanMode_(0) 42 {} ~SensingInfoSensingInfo43 ~SensingInfo() {} 44 45 // used by ble fastest conn decision SensingInfoSensingInfo46 explicit SensingInfo(const std::string &addr) 47 : addr_(addr), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(INVALID_PKGNAME), isServer_(false), 48 interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), scanMode_(0) 49 {} 50 // used by gatt connect SensingInfo construct SensingInfoSensingInfo51 explicit SensingInfo(uint32_t resourceId) 52 : addr_(INVALID_MAC_ADDRESS), uuid_(INVALID_UUID_STRING), resourceId_(resourceId), pkgName_(INVALID_PKGNAME), 53 isServer_(false), interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 54 scanMode_(0) 55 {} SensingInfoSensingInfo56 SensingInfo(const std::string &addr, uint32_t resourceId) 57 : addr_(addr), uuid_(INVALID_UUID_STRING), resourceId_(resourceId), pkgName_(INVALID_PKGNAME), 58 isServer_(false), interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 59 scanMode_(0) 60 {} 61 // used by gatt pkgName SensingInfo construct SensingInfoSensingInfo62 SensingInfo(const std::string &pkgName, bool isServer) 63 : addr_(INVALID_MAC_ADDRESS), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(pkgName), 64 isServer_(isServer), interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 65 scanMode_(0) 66 {} SensingInfoSensingInfo67 SensingInfo(const std::string &addr, const std::string &pkgName, bool isServer) 68 : addr_(addr), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(pkgName), isServer_(isServer), 69 interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), scanMode_(0) 70 {} 71 // used by socket pkgName SensingInfo construct SensingInfoSensingInfo72 SensingInfo(const std::string uuid, const std::string pkgName) 73 : addr_(INVALID_MAC_ADDRESS), uuid_(uuid), resourceId_(0), pkgName_(pkgName), isServer_(false), interval_(0), 74 connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), scanMode_(0) 75 {} 76 // used by ble conn interval update SensingInfoSensingInfo77 SensingInfo(const std::string &addr, uint16_t interval) 78 : addr_(addr), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(INVALID_PKGNAME), isServer_(false), 79 interval_(interval), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 80 scanMode_(0) 81 {} 82 // used by stack sensing info transfer SensingInfoSensingInfo83 SensingInfo(const std::string &addr, const std::string &uuid, uint32_t resourceId, uint16_t interval) 84 : addr_(addr), uuid_(uuid), resourceId_(resourceId), pkgName_(INVALID_PKGNAME), isServer_(false), 85 interval_(interval), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 86 scanMode_(0) 87 {} 88 // used by ble adv sensing info transfer SensingInfoSensingInfo89 SensingInfo(const BleAdvData &bleAdvData, uint32_t resourceId, uint16_t interval) 90 : addr_(INVALID_MAC_ADDRESS), uuid_(bleAdvData.uuid_), resourceId_(resourceId), pkgName_(INVALID_PKGNAME), 91 isServer_(false), interval_(interval), connectable_(bleAdvData.connectable_), 92 payloadLen_(bleAdvData.payloadLen_), bussinessType_(bleAdvData.bussinessType_), scanMode_(0) 93 {} 94 // used by ble scan sensing info transfer SensingInfoSensingInfo95 SensingInfo(int scanMode, int scanStatus) 96 : addr_(INVALID_MAC_ADDRESS), uuid_(INVALID_UUID_STRING), resourceId_(0), pkgName_(INVALID_PKGNAME), 97 isServer_(false), interval_(0), connectable_(false), payloadLen_(0), bussinessType_(INVALID_BUSSINESS_TYPE), 98 scanMode_(scanMode) 99 {} 100 101 std::string addr_; 102 std::string uuid_; 103 uint32_t resourceId_; 104 std::string pkgName_; 105 bool isServer_; 106 uint16_t interval_; 107 bool connectable_; 108 int payloadLen_; 109 std::string bussinessType_; 110 int scanMode_; 111 }; 112 } 113 } 114 115 #endif //BT_SENSING_INFO_H