已合并
新增蓝牙信道干扰扫频启停接口 #2037
新增蓝牙信道干扰扫频启停接口 #2037
已合并
tanhaoran2创建于 5 天前
8 个文件变更+51-0
Mframeworks/inner/ipc/common/bt_def.h+6-0
@@ -2028,6 +2028,12 @@ typedef enum {
2028 INNER_BLE_RANGING_APPROACH = 0X02,2028 INNER_BLE_RANGING_APPROACH = 0X02,
2029} BleAppType;2029} BleAppType;
2030 2030 
2031+enum ChannelScanInterval : uint32_t {
2032+ CHANNEL_SCAN_INTERVAL_100MS = 0x000000A0,
2033+ CHANNEL_SCAN_INTERVAL_1000MS = 0x00000640,
2034+ CHANNEL_SCAN_INTERVAL_BYPASS = 0xFFFFFFFF,
2035+};
2036+ 
2031#define INNER_BLE_RANGING_INVALID_ADVPOWER 1272037#define INNER_BLE_RANGING_INVALID_ADVPOWER 127
2032 2038 
2033#ifdef BLUETOOTH_EXPORT2039#ifdef BLUETOOTH_EXPORT
Mframeworks/inner/ipc/include/bluetooth_host_proxy.h+1-0
@@ -137,6 +137,7 @@ public:
137 int32_t IsProfileExist(const std::string &profileName, bool &isProfileExist) override;137 int32_t IsProfileExist(const std::string &profileName, bool &isProfileExist) override;
138 int32_t VerifyMultiPermissions(bool systemHapNeeded, const std::set<std::string> &permissions) override;138 int32_t VerifyMultiPermissions(bool systemHapNeeded, const std::set<std::string> &permissions) override;
139 int32_t UpdateSecondaryPhonePairMode(int32_t mode) override;139 int32_t UpdateSecondaryPhonePairMode(int32_t mode) override;
140+ int32_t SetBtChannelScan(bool isEnable, uint32_t interval) override;
140private:141private:
141 int32_t InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply);142 int32_t InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply);
142 static inline BrokerDelegator<BluetoothHostProxy> delegator_;143 static inline BrokerDelegator<BluetoothHostProxy> delegator_;
Mframeworks/inner/ipc/interface/bluetooth_service_ipc_interface_code.h+1-0
@@ -350,6 +350,7 @@ enum BluetoothHostInterfaceCode {
350 GET_VIRTUAL_ADDRESS_BY_HASH,350 GET_VIRTUAL_ADDRESS_BY_HASH,
351 BT_VERIFY_MULTI_PERMISSIONS,351 BT_VERIFY_MULTI_PERMISSIONS,
352 BT_UPDATE_PHONE_TYPE,352 BT_UPDATE_PHONE_TYPE,
353+ SET_BT_CHANNEL_SCAN,
353 // The last code, if you want to add a new code, please add it before this354 // The last code, if you want to add a new code, please add it before this
354 BT_HOST_BUTT355 BT_HOST_BUTT
355};356};
Mframeworks/inner/ipc/interface/i_bluetooth_host.h+1-0
@@ -171,6 +171,7 @@ public:
171 virtual int32_t IsProfileExist(const std::string &profileName, bool &isProfileExist) = 0;171 virtual int32_t IsProfileExist(const std::string &profileName, bool &isProfileExist) = 0;
172 virtual int32_t VerifyMultiPermissions(bool systemHapNeeded, const std::set<std::string> &permissions) = 0;172 virtual int32_t VerifyMultiPermissions(bool systemHapNeeded, const std::set<std::string> &permissions) = 0;
173 virtual int32_t UpdateSecondaryPhonePairMode(int32_t mode) = 0;173 virtual int32_t UpdateSecondaryPhonePairMode(int32_t mode) = 0;
174+ virtual int32_t SetBtChannelScan(bool isEnable, uint32_t interval) = 0;
174};175};
175} // namespace Bluetooth176} // namespace Bluetooth
176} // namespace OHOS177} // namespace OHOS
Mframeworks/inner/ipc/src/bluetooth_host_proxy.cpp+14-0
@@ -2307,5 +2307,19 @@ int32_t BluetoothHostProxy::UpdateSecondaryPhonePairMode(int32_t mode)
2307 }2307 }
2308 return reply.ReadInt32();2308 return reply.ReadInt32();
2309}2309}
2310+ 
2311+int32_t BluetoothHostProxy::SetBtChannelScan(bool isEnable, uint32_t interval)
2312+{
2313+ MessageParcel data;
2314+ CHECK_AND_RETURN_LOG_RET(data.WriteInterfaceToken(BluetoothHostProxy::GetDescriptor()), BT_ERR_IPC_TRANS_FAILED,
2315+ "WriteInterfaceToken error");
2316+ CHECK_AND_RETURN_LOG_RET(data.WriteBool(isEnable), BT_ERR_IPC_TRANS_FAILED, "Write isEnable error");
2317+ CHECK_AND_RETURN_LOG_RET(data.WriteUint32(interval), BT_ERR_IPC_TRANS_FAILED, "Write interval error");
2318+ MessageParcel reply;
2319+ MessageOption option = {MessageOption::TF_SYNC};
2320+ int32_t error = InnerTransact(BluetoothHostInterfaceCode::SET_BT_CHANNEL_SCAN, option, data, reply);
2321+ CHECK_AND_RETURN_LOG_RET((error == BT_NO_ERROR), BT_ERR_INTERNAL_ERROR, "error: %{public}d", error);
2322+ return reply.ReadInt32();
2323+}
2310} // namespace Bluetooth2324} // namespace Bluetooth
2311} // namespace OHOS2325} // namespace OHOS
Mframeworks/inner/src/bluetooth_host.cpp+10-0
@@ -1544,5 +1544,15 @@ int BluetoothHost::UpdateSecondaryPhonePairMode(int32_t mode)
1544 CHECK_AND_RETURN_LOG_RET(proxy != nullptr, BT_ERR_UNAVAILABLE_PROXY, "proxy is nullptr");1544 CHECK_AND_RETURN_LOG_RET(proxy != nullptr, BT_ERR_UNAVAILABLE_PROXY, "proxy is nullptr");
1545 return proxy->UpdateSecondaryPhonePairMode(mode);1545 return proxy->UpdateSecondaryPhonePairMode(mode);
1546}1546}
1547+ 
1548+int BluetoothHost::SetBtChannelScan(bool isEnable, uint32_t interval)
1549+{
1550+ HILOGI("isEnable: %{public}d, interval: %{public}u", isEnable, interval);
1551+ CHECK_AND_RETURN_LOG_RET(interval >= CHANNEL_SCAN_INTERVAL_100MS && interval <= CHANNEL_SCAN_INTERVAL_BYPASS,
1552+ BT_ERR_INVALID_PARAM, "invalid channel scan interval");
1553+ sptr<IBluetoothHost> proxy = GetRemoteProxy<IBluetoothHost>(BLUETOOTH_HOST);
1554+ CHECK_AND_RETURN_LOG_RET(proxy != nullptr, BT_ERR_UNAVAILABLE_PROXY, "pimpl or bluetooth host is nullptr");
1555+ return proxy->SetBtChannelScan(isEnable, interval);
1556+}
1547} // namespace Bluetooth1557} // namespace Bluetooth
1548} // namespace OHOS1558} // namespace OHOS
Minterfaces/inner_api/include/bluetooth_def.h+6-0
@@ -1883,6 +1883,12 @@ enum SetAdvDataType : int32_t {
1883 SET_ADV_DATA_ONLY_RSP1883 SET_ADV_DATA_ONLY_RSP
1884};1884};
1885 1885 
1886+enum ChannelScanInterval : uint32_t {
1887+ CHANNEL_SCAN_INTERVAL_100MS = 0x000000A0,
1888+ CHANNEL_SCAN_INTERVAL_1000MS = 0x00000640,
1889+ CHANNEL_SCAN_INTERVAL_BYPASS = 0xFFFFFFFF,
1890+};
1891+ 
1886struct BluetoothAddress {1892struct BluetoothAddress {
1887 std::string address = {};1893 std::string address = {};
1888 uint8_t addressType = AddressType::UNSET_ADDRESS;1894 uint8_t addressType = AddressType::UNSET_ADDRESS;
Minterfaces/inner_api/include/bluetooth_host.h+12-0
@@ -1021,6 +1021,18 @@ public:
1021 * @since 261021 * @since 26
1022 */1022 */
1023 int UpdateSecondaryPhonePairMode(int32_t mode);1023 int UpdateSecondaryPhonePairMode(int32_t mode);
1024+ 
1025+ /**
1026+ * @brief Set bluetooth channel scan.
1027+ *
1028+ * @param isEnable Enable/disable flag. 0 for disable, 1 for enable.
1029+ * @param interval Channel scan interval in slots (0.625ms) {@link ChannelScanInterval}.
1030+ * Should be set to CHANNEL_SCAN_INTERVAL_BYPASS in disable case.
1031+ * @return Returns {@link BT_NO_ERROR} if the operation is successful;
1032+ * returns an error code defined in {@link BtErrCode} otherwise.
1033+ * @since 26
1034+ */
1035+ int SetBtChannelScan(bool isEnable, uint32_t interval);
1024private:1036private:
1025 /**1037 /**
1026 * @brief A constructor used to create a <b>BluetoothHost</b> instance.1038 * @brief A constructor used to create a <b>BluetoothHost</b> instance.