Skip to content

Commit

Permalink
Make TX power configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
iranl committed Jul 25, 2024
1 parent e197499 commit 9dd3f29
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/NukiBle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ void NukiBle::initialize() {
NimBLEDevice::init(deviceName);
}

NimBLEDevice::setPower(ESP_PWR_LVL_P9);

#ifdef NUKI_ALT_CONNECT
pClient = BLEDevice::createClient();
pClient = NimBLEDevice::createClient();
pClient->setClientCallbacks(this);
#ifdef NUKI_USE_LATEST_NIMBLE
pClient->setConnectTimeout(connectTimeoutSec * 1000);
Expand All @@ -74,6 +72,14 @@ void NukiBle::initialize() {
isPaired = retrieveCredentials();
}

void NukiBle::setPower(esp_power_level_t powerLevel) {
if (!NimBLEDevice::getInitialized()) {
NimBLEDevice::init(deviceName);
}

NimBLEDevice::setPower(powerLevel);
}

void NukiBle::registerBleScanner(BleScanner::Publisher* bleScanner) {
this->bleScanner = bleScanner;
bleScanner->subscribe(this);
Expand Down
14 changes: 14 additions & 0 deletions src/NukiBle.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ class NukiBle : public BLEClientCallbacks, public BleScanner::Subscriber {
*/
void initialize();

/**
* @brief the transmission power.
* @param [in] powerLevel The power level to set, can be one of:
* * ESP_PWR_LVL_N12 = 0, Corresponding to -12dbm
* * ESP_PWR_LVL_N9 = 1, Corresponding to -9dbm
* * ESP_PWR_LVL_N6 = 2, Corresponding to -6dbm
* * ESP_PWR_LVL_N3 = 3, Corresponding to -3dbm
* * ESP_PWR_LVL_N0 = 4, Corresponding to 0dbm
* * ESP_PWR_LVL_P3 = 5, Corresponding to +3dbm
* * ESP_PWR_LVL_P6 = 6, Corresponding to +6dbm
* * ESP_PWR_LVL_P9 = 7, Corresponding to +9dbm
*/
void setPower(esp_power_level_t powerLevel);

/**
* @brief Registers the BLE scanner to be used for scanning for advertisements from the lock.
* BleScanner::Publisher is defined in dependent library https://github.com/I-Connect/BleScanner.git
Expand Down

0 comments on commit 9dd3f29

Please sign in to comment.