mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 15:17:48 +01:00
a bit higher tx power
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/task.h"
|
||||
#include "host/ble_att.h"
|
||||
#include "host/ble_gap.h"
|
||||
#include "host/ble_gatt.h"
|
||||
#include "host/ble_hs.h"
|
||||
#include "host/ble_att.h"
|
||||
#include "host/ble_hs_mbuf.h"
|
||||
#include "host/util/util.h"
|
||||
#include "nimble/nimble_port.h"
|
||||
@@ -49,13 +49,9 @@ constexpr std::uint16_t kPreferredConnIntervalMax = BLE_GAP_CONN_ITVL_MS(150)
|
||||
constexpr std::uint16_t kPreferredConnLatency = 2;
|
||||
constexpr std::uint16_t kPreferredSupervisionTimeout = BLE_GAP_SUPERVISION_TIMEOUT_MS(5000); // 5 s
|
||||
|
||||
constexpr float connIntervalUnitsToMs(std::uint16_t units) {
|
||||
return static_cast<float>(units) * 1.25f;
|
||||
}
|
||||
constexpr float connIntervalUnitsToMs(std::uint16_t units) { return static_cast<float>(units) * 1.25f; }
|
||||
|
||||
constexpr float supervisionUnitsToMs(std::uint16_t units) {
|
||||
return static_cast<float>(units) * 10.0f;
|
||||
}
|
||||
constexpr float supervisionUnitsToMs(std::uint16_t units) { return static_cast<float>(units) * 10.0f; }
|
||||
|
||||
// 128-bit UUIDs (little-endian order for NimBLE macros)
|
||||
static const ble_uuid128_t kTimeServiceUuid = BLE_UUID128_INIT(0x30, 0xF2, 0xD3, 0xF4, 0xC3, 0x10, 0xA6, 0xB5, 0xFD,
|
||||
@@ -969,12 +965,8 @@ void logConnectionParams(uint16_t connHandle, const char* context) {
|
||||
const float intervalMs = connIntervalUnitsToMs(desc.conn_itvl);
|
||||
const float timeoutMs = supervisionUnitsToMs(desc.supervision_timeout);
|
||||
|
||||
ESP_LOGI(kLogTag,
|
||||
"%s params: interval=%.1f ms latency=%u supervision=%.0f ms",
|
||||
context,
|
||||
intervalMs,
|
||||
static_cast<unsigned>(desc.conn_latency),
|
||||
timeoutMs);
|
||||
ESP_LOGI(kLogTag, "%s params: interval=%.1f ms latency=%u supervision=%.0f ms", context, intervalMs,
|
||||
static_cast<unsigned>(desc.conn_latency), timeoutMs);
|
||||
}
|
||||
|
||||
void applyPreferredConnectionParams(uint16_t connHandle) {
|
||||
@@ -993,12 +985,9 @@ void applyPreferredConnectionParams(uint16_t connHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGI(kLogTag,
|
||||
"Requested conn params: interval=%.0f-%.0f ms latency=%u supervision=%.0f ms",
|
||||
connIntervalUnitsToMs(kPreferredConnIntervalMin),
|
||||
connIntervalUnitsToMs(kPreferredConnIntervalMax),
|
||||
kPreferredConnLatency,
|
||||
supervisionUnitsToMs(kPreferredSupervisionTimeout));
|
||||
ESP_LOGI(kLogTag, "Requested conn params: interval=%.0f-%.0f ms latency=%u supervision=%.0f ms",
|
||||
connIntervalUnitsToMs(kPreferredConnIntervalMin), connIntervalUnitsToMs(kPreferredConnIntervalMax),
|
||||
kPreferredConnLatency, supervisionUnitsToMs(kPreferredSupervisionTimeout));
|
||||
}
|
||||
|
||||
void startAdvertising() {
|
||||
@@ -1066,13 +1055,13 @@ void onSync() {
|
||||
ESP_LOGW(kLogTag, "Failed to set preferred PHY (rc=%d)", rc);
|
||||
}
|
||||
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_N24) != ESP_OK) {
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_N12) != ESP_OK) {
|
||||
ESP_LOGW(kLogTag, "Failed to set default TX power level");
|
||||
}
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_N24) != ESP_OK) {
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_N12) != ESP_OK) {
|
||||
ESP_LOGW(kLogTag, "Failed to set advertising TX power level");
|
||||
}
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_N24) != ESP_OK) {
|
||||
if (esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_N12) != ESP_OK) {
|
||||
ESP_LOGW(kLogTag, "Failed to set scan TX power level");
|
||||
}
|
||||
|
||||
@@ -1112,9 +1101,7 @@ int gapEventHandler(struct ble_gap_event* event, void* /*arg*/) {
|
||||
if (event->conn_update.status == 0) {
|
||||
logConnectionParams(event->conn_update.conn_handle, "Updated");
|
||||
} else {
|
||||
ESP_LOGW(kLogTag,
|
||||
"Connection update failed; status=%d handle=%u",
|
||||
event->conn_update.status,
|
||||
ESP_LOGW(kLogTag, "Connection update failed; status=%d handle=%u", event->conn_update.status,
|
||||
static_cast<unsigned>(event->conn_update.conn_handle));
|
||||
}
|
||||
break;
|
||||
@@ -1133,11 +1120,8 @@ int gapEventHandler(struct ble_gap_event* event, void* /*arg*/) {
|
||||
params.min_ce_len = 0;
|
||||
params.max_ce_len = 0;
|
||||
|
||||
ESP_LOGI(kLogTag,
|
||||
"Peer update request -> interval %.1f-%.1f ms latency %u timeout %.0f ms",
|
||||
connIntervalUnitsToMs(params.itvl_min),
|
||||
connIntervalUnitsToMs(params.itvl_max),
|
||||
params.latency,
|
||||
ESP_LOGI(kLogTag, "Peer update request -> interval %.1f-%.1f ms latency %u timeout %.0f ms",
|
||||
connIntervalUnitsToMs(params.itvl_min), connIntervalUnitsToMs(params.itvl_max), params.latency,
|
||||
supervisionUnitsToMs(params.supervision_timeout));
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user