From 3260c6464e02c20dda562c43a01a21f8c6457156 Mon Sep 17 00:00:00 2001 From: h2zero Date: Wed, 28 Feb 2024 10:13:11 -0700 Subject: [PATCH] Update non-esp setPower method to send command through the controller. --- src/NimBLEDevice.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 0c7b45d0..8b143c9a 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -428,7 +428,19 @@ int NimBLEDevice::getPower(esp_ble_power_type_t powerType) { #else void NimBLEDevice::setPower(int dbm) { - ble_phy_txpwr_set(dbm); + struct ble_hci_vs_set_tx_pwr_cp cmd; + struct ble_hci_vs_set_tx_pwr_rp rsp; + int rc; + + cmd.tx_power = dbm; + rc = ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_TX_PWR, &cmd, sizeof(cmd), &rsp, sizeof(rsp)); + if (rc) { + NIMBLE_LOGE(LOG_TAG, "failed to set TX power, rc: %04x\n", rc); + return; + } + + NIMBLE_LOGD(LOG_TAG, "TX power set to %d dBm\n", rsp.tx_power); + return; }