30class BluetoothGATTGetServicesResponse;
50static constexpr conn_err_t GATT_NOT_CONNECTED = ble_device_base::GATT_ERR_NOT_CONNECTED;
55static constexpr bool SUPPORTS_PAIRING =
true;
56static constexpr bool SUPPORTS_CACHE_CLEARING =
true;
57#elif defined(USE_RP2040_BLE) && defined(USE_BLE_GATT_CLIENT)
61static constexpr bool SUPPORTS_PAIRING =
true;
62static constexpr bool SUPPORTS_CACHE_CLEARING =
false;
64static constexpr bool SUPPORTS_PAIRING =
false;
65static constexpr bool SUPPORTS_CACHE_CLEARING =
false;
69#if (defined(USE_ESP32) || defined(USE_RP2040_BLE)) && defined(USE_BLE_GATT_CLIENT)
74#if defined(USE_ESP32) && defined(USE_BLE_GATT_CLIENT)
81static constexpr int DONE_SENDING_SERVICES = -2;
82static constexpr int INIT_SENDING_SERVICES = -3;
83static constexpr int SERVICES_DONE_PENDING = -4;
86static_assert(DONE_SENDING_SERVICES < 0 && INIT_SENDING_SERVICES < 0 && SERVICES_DONE_PENDING < 0);
87static_assert(DONE_SENDING_SERVICES != GATT_NOT_CONNECTED && INIT_SENDING_SERVICES != GATT_NOT_CONNECTED &&
88 SERVICES_DONE_PENDING != GATT_NOT_CONNECTED);
92static constexpr uint8_t SERVICES_DONE_RETRY_LIMIT = 30;
96static constexpr uint16_t PENDING_ACK_RETRY_LIMIT = 250;
101static constexpr size_t MAX_PACKET_SIZE = 1360;
104static constexpr uint8_t SERVICE_OVERHEAD_LEGACY = 25;
105static constexpr uint8_t SERVICE_OVERHEAD_EFFICIENT = 10;
106static constexpr uint8_t CHAR_SIZE_128BIT = 35;
107static constexpr uint8_t DESC_SIZE_128BIT = 25;
108static constexpr uint8_t DESC_PER_CHAR = 1;
114 size_t service_overhead = use_efficient_uuids ? SERVICE_OVERHEAD_EFFICIENT : SERVICE_OVERHEAD_LEGACY;
115 return service_overhead + (CHAR_SIZE_128BIT + DESC_SIZE_128BIT * DESC_PER_CHAR) * char_count;
126 const uint8_t *u = uuid.
uuid128();
135 out[0] = ((uint64_t) value << 32) | 0x00001000ULL;
136 out[1] = 0x800000805F9B34FBULL;
148 short_uuid = uuid.
uuid16();
150 short_uuid = uuid.
uuid32();
154#ifdef USE_BLUETOOTH_PROXY_CONNECTIONS
165 uint8_t connection_index,
const char *address_str);
std::vector< uint8_t > & out
conn_err_t unpair_device(uint64_t address)
size_t estimate_service_size(uint16_t char_count, bool use_efficient_uuids)
Estimate the wire size of a service (service overhead + its characteristics, assuming 128-bit UUIDs a...
void fill_128bit_uuid_array(std::array< uint64_t, 2 > &out, const ble_device_base::ESPBTUUID &uuid)
BatchClose
Result of close_service_batch: keep filling the batch or send it now.
BatchClose close_service_batch(api::BluetoothGATTGetServicesResponse &resp, size_t ¤t_size, int16_t &send_service, uint8_t connection_index, const char *address_str)
Close out the service just packed into resp (account its actual wire size, advance the cursor) and de...
void fill_gatt_uuid(std::array< uint64_t, 2 > &uuid_128, uint32_t &short_uuid, const ble_device_base::ESPBTUUID &uuid, bool use_efficient_uuids)
Fill the UUID in the appropriate wire format based on client support and UUID type (128-bit array for...
conn_err_t clear_gatt_cache(uint64_t address)
constexpr T encode_value_le(const uint8_t *bytes)
Encode a value from its constituent bytes (from least to most significant) in an array with length si...