added tweaks to filter
This commit is contained in:
51
bt_test/bt_test.ino
Normal file
51
bt_test/bt_test.ino
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <BluetoothSerial.h>
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_bt_device.h"
|
||||
|
||||
BluetoothSerial SerialBT;
|
||||
|
||||
void setBluetoothTxPower(esp_power_level_t powerLevel) {
|
||||
esp_err_t err = esp_bredr_tx_power_set(powerLevel, powerLevel);
|
||||
if (err != ESP_OK) {
|
||||
Serial.printf("Failed to set TX Power: %s\n", esp_err_to_name(err));
|
||||
} else {
|
||||
Serial.printf("TX Power set to level %d\n", powerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("Initializing Bluetooth...");
|
||||
|
||||
if (!btStart()) {
|
||||
Serial.println("Failed to start BT controller");
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable and re-enable the classic BT stack to safely set TX power
|
||||
esp_bluedroid_disable();
|
||||
esp_bluedroid_deinit();
|
||||
|
||||
// Set Classic BT TX power (e.g., ESP_PWR_LVL_P9 = highest)
|
||||
//setBluetoothTxPower(ESP_PWR_LVL_P9);
|
||||
setBluetoothTxPower(ESP_PWR_LVL_N12);
|
||||
|
||||
|
||||
esp_bluedroid_init();
|
||||
esp_bluedroid_enable();
|
||||
|
||||
if (!SerialBT.begin("ESP32-TXPowerTest")) {
|
||||
Serial.println("Bluetooth Serial failed to start");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("Bluetooth initialized and ready!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
SerialBT.println("Hello from ESP32 with boosted TX power!");
|
||||
delay(1);
|
||||
}
|
||||
Reference in New Issue
Block a user