mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-29 07:37:48 +01:00
a bit higher tx power
This commit is contained in:
@@ -10,10 +10,10 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
#include "host/ble_att.h"
|
||||||
#include "host/ble_gap.h"
|
#include "host/ble_gap.h"
|
||||||
#include "host/ble_gatt.h"
|
#include "host/ble_gatt.h"
|
||||||
#include "host/ble_hs.h"
|
#include "host/ble_hs.h"
|
||||||
#include "host/ble_att.h"
|
|
||||||
#include "host/ble_hs_mbuf.h"
|
#include "host/ble_hs_mbuf.h"
|
||||||
#include "host/util/util.h"
|
#include "host/util/util.h"
|
||||||
#include "nimble/nimble_port.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 kPreferredConnLatency = 2;
|
||||||
constexpr std::uint16_t kPreferredSupervisionTimeout = BLE_GAP_SUPERVISION_TIMEOUT_MS(5000); // 5 s
|
constexpr std::uint16_t kPreferredSupervisionTimeout = BLE_GAP_SUPERVISION_TIMEOUT_MS(5000); // 5 s
|
||||||
|
|
||||||
constexpr float connIntervalUnitsToMs(std::uint16_t units) {
|
constexpr float connIntervalUnitsToMs(std::uint16_t units) { return static_cast<float>(units) * 1.25f; }
|
||||||
return static_cast<float>(units) * 1.25f;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr float supervisionUnitsToMs(std::uint16_t units) {
|
constexpr float supervisionUnitsToMs(std::uint16_t units) { return static_cast<float>(units) * 10.0f; }
|
||||||
return static_cast<float>(units) * 10.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 128-bit UUIDs (little-endian order for NimBLE macros)
|
// 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,
|
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 intervalMs = connIntervalUnitsToMs(desc.conn_itvl);
|
||||||
const float timeoutMs = supervisionUnitsToMs(desc.supervision_timeout);
|
const float timeoutMs = supervisionUnitsToMs(desc.supervision_timeout);
|
||||||
|
|
||||||
ESP_LOGI(kLogTag,
|
ESP_LOGI(kLogTag, "%s params: interval=%.1f ms latency=%u supervision=%.0f ms", context, intervalMs,
|
||||||
"%s params: interval=%.1f ms latency=%u supervision=%.0f ms",
|
static_cast<unsigned>(desc.conn_latency), timeoutMs);
|
||||||
context,
|
|
||||||
intervalMs,
|
|
||||||
static_cast<unsigned>(desc.conn_latency),
|
|
||||||
timeoutMs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyPreferredConnectionParams(uint16_t connHandle) {
|
void applyPreferredConnectionParams(uint16_t connHandle) {
|
||||||
@@ -993,12 +985,9 @@ void applyPreferredConnectionParams(uint16_t connHandle) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(kLogTag,
|
ESP_LOGI(kLogTag, "Requested conn params: interval=%.0f-%.0f ms latency=%u supervision=%.0f ms",
|
||||||
"Requested conn params: interval=%.0f-%.0f ms latency=%u supervision=%.0f ms",
|
connIntervalUnitsToMs(kPreferredConnIntervalMin), connIntervalUnitsToMs(kPreferredConnIntervalMax),
|
||||||
connIntervalUnitsToMs(kPreferredConnIntervalMin),
|
kPreferredConnLatency, supervisionUnitsToMs(kPreferredSupervisionTimeout));
|
||||||
connIntervalUnitsToMs(kPreferredConnIntervalMax),
|
|
||||||
kPreferredConnLatency,
|
|
||||||
supervisionUnitsToMs(kPreferredSupervisionTimeout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startAdvertising() {
|
void startAdvertising() {
|
||||||
@@ -1066,13 +1055,13 @@ void onSync() {
|
|||||||
ESP_LOGW(kLogTag, "Failed to set preferred PHY (rc=%d)", rc);
|
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");
|
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");
|
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");
|
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) {
|
if (event->conn_update.status == 0) {
|
||||||
logConnectionParams(event->conn_update.conn_handle, "Updated");
|
logConnectionParams(event->conn_update.conn_handle, "Updated");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(kLogTag,
|
ESP_LOGW(kLogTag, "Connection update failed; status=%d handle=%u", event->conn_update.status,
|
||||||
"Connection update failed; status=%d handle=%u",
|
|
||||||
event->conn_update.status,
|
|
||||||
static_cast<unsigned>(event->conn_update.conn_handle));
|
static_cast<unsigned>(event->conn_update.conn_handle));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1133,11 +1120,8 @@ int gapEventHandler(struct ble_gap_event* event, void* /*arg*/) {
|
|||||||
params.min_ce_len = 0;
|
params.min_ce_len = 0;
|
||||||
params.max_ce_len = 0;
|
params.max_ce_len = 0;
|
||||||
|
|
||||||
ESP_LOGI(kLogTag,
|
ESP_LOGI(kLogTag, "Peer update request -> interval %.1f-%.1f ms latency %u timeout %.0f ms",
|
||||||
"Peer update request -> interval %.1f-%.1f ms latency %u timeout %.0f ms",
|
connIntervalUnitsToMs(params.itvl_min), connIntervalUnitsToMs(params.itvl_max), params.latency,
|
||||||
connIntervalUnitsToMs(params.itvl_min),
|
|
||||||
connIntervalUnitsToMs(params.itvl_max),
|
|
||||||
params.latency,
|
|
||||||
supervisionUnitsToMs(params.supervision_timeout));
|
supervisionUnitsToMs(params.supervision_timeout));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user