Skip to content

Commit 685fb5e

Browse files
committed
Update non-esp setPower method to send command through the controller.
1 parent a302fea commit 685fb5e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/NimBLEDevice.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,19 @@ int NimBLEDevice::getPower(esp_ble_power_type_t powerType) {
428428
#else
429429

430430
void NimBLEDevice::setPower(int dbm) {
431-
ble_phy_txpwr_set(dbm);
431+
struct ble_hci_vs_set_tx_pwr_cp cmd;
432+
struct ble_hci_vs_set_tx_pwr_rp rsp;
433+
int rc;
434+
435+
cmd.tx_power = dbm;
436+
rc = ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_TX_PWR, &cmd, sizeof(cmd), &rsp, sizeof(rsp));
437+
if (rc) {
438+
NIMBLE_LOGE(LOG_TAG, "failed to set TX power, rc: %04x\n", rc);
439+
return;
440+
}
441+
442+
NIMBLE_LOGD(LOG_TAG, "TX power set to %d dBm\n", rsp.tx_power);
443+
return;
432444
}
433445

434446

0 commit comments

Comments
 (0)