using ::bluetooth::hci::Address; using ::bluetooth::hci::AddressType; using ::bluetooth::hci::AuthenticationEnable; using ::bluetooth::hci::ErrorCode; using ::bluetooth::hci::FilterAcceptListAddressType; using ::bluetooth::hci::OpCode; using ::bluetooth::hci::PageScanRepetitionMode; using rootcanal::apcf::ApcfScanner;
// Create an address with type Public Device Address or Random Device Address.
AddressWithType PeerDeviceAddress(Address address, PeerAddressType peer_address_type); // Create an address with type Public Identity Address or Random Identity // address.
AddressWithType PeerIdentityAddress(Address address, PeerAddressType peer_address_type);
// HCI command Disconnect (Vol 4, Part E § 7.1.6). // \p host_reason is taken from the Disconnect command, and sent over // to the remote as disconnect error. \p controller_reason is the code // used in the DisconnectionComplete event.
ErrorCode Disconnect(
uint16_t handle, ErrorCode host_reason,
ErrorCode controller_reason = ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST);
// HCI command Read Remote Version Information (Vol 4, Part E § 7.1.23).
ErrorCode ReadRemoteVersionInformation(uint16_t connection_handle);
// Internal task scheduler. // This scheduler is driven by the tick function only, // hence the precision of the scheduler is within a tick period. class Task; using TaskId = uint32_t; using TaskCallback = std::function<void(void)>; static constexpr TaskId kInvalidTaskId = 0;
/// Schedule a task to be executed \p delay ms in the future.
TaskId ScheduleTask(std::chrono::milliseconds delay, TaskCallback task_callback);
/// Schedule a task to be executed every \p period ms starting /// \p delay ms in the future. Note that the task will be executed /// at most once per \ref Tick() invocation, hence the period /// cannot be lower than the \ref Tick() period.
TaskId SchedulePeriodicTask(std::chrono::milliseconds delay, std::chrono::milliseconds period,
TaskCallback task_callback);
/// Cancel the selected task. void CancelScheduledTask(TaskId task_id);
// Execute tasks that are pending at the current time. void RunPendingTasks();
/// Send disconnection events for all connected links, with the provided /// reason. Does not remove the local connection contexts. void DisconnectAll(ErrorCode reason);
// Set the callbacks for sending packets to the HCI. void RegisterEventChannel( const std::function<void(std::shared_ptr<bluetooth::hci::EventBuilder>)>& send_event);
enum IrkSelection {
Peer, // Use Peer IRK for RPA resolution or generation.
Local // Use Local IRK for RPA resolution or generation.
};
// If the selected address is a Resolvable Private Address, then // resolve the address using the resolving list. If the address cannot // be resolved none is returned. If the address is not a Resolvable // Private Address, the original address is returned.
std::optional<AddressWithType> ResolvePrivateAddress(AddressWithType address);
// Returns true if the input address resolves with the local IRK // associated with the given peer identity address. bool ResolveTargetA(AddressWithType target_a, AddressWithType adv_a);
// Returns true if either: // • TargetA is identical to the device address, or // • TargetA is a resolvable private address, address // resolution is enabled, and the address is resolved successfully bool ValidateTargetA(AddressWithType target_a, AddressWithType adv_a);
// Generate a Resolvable Private for the selected peer. // If the address is not found in the resolving list none is returned. // `local` indicates whether to use the local (true) or peer (false) IRK when // generating the Resolvable Private Address.
std::optional<AddressWithType> GenerateResolvablePrivateAddress(AddressWithType address,
IrkSelection irk);
// Check if the selected address matches one of the controller's device // addresses (public or random static). bool IsLocalPublicOrRandomAddress(AddressWithType address) { switch (address.GetAddressType()) { case AddressType::PUBLIC_DEVICE_ADDRESS: return address.GetAddress() == address_; case AddressType::RANDOM_DEVICE_ADDRESS: return address.GetAddress() == random_address_; default: returnfalse;
}
}
// HCI Read Rssi command (Vol 4, Part E § 7.5.4).
ErrorCode ReadRssi(uint16_t connection_handle, int8_t* rssi);
// HCI LE Read Remote Features (Vol 4, Part E § 7.8.21).
ErrorCode LeReadRemoteFeaturesPage0(uint16_t connection_handle);
// HCI LE Set Random Address command (Vol 4, Part E § 7.8.4).
ErrorCode LeSetRandomAddress(Address random_address);
// HCI LE Set Resolvable Private Address Timeout command // (Vol 4, Part E § 7.8.45).
ErrorCode LeSetResolvablePrivateAddressTimeout(uint16_t rpa_timeout);
// HCI LE Read Phy command (Vol 4, Part E § 7.8.47).
ErrorCode LeReadPhy(uint16_t connection_handle, bluetooth::hci::PhyType* tx_phy,
bluetooth::hci::PhyType* rx_phy);
// HCI LE Create Connection Cancel command (Vol 4, Part E § 7.8.12).
ErrorCode LeCreateConnectionCancel();
// Extended Connection
// HCI LE Extended Create Connection command (Vol 4, Part E § 7.8.66).
ErrorCode LeExtendedCreateConnection(
bluetooth::hci::InitiatorFilterPolicy initiator_filter_policy,
bluetooth::hci::OwnAddressType own_address_type, AddressWithType peer_address,
uint8_t initiating_phys,
std::vector<bluetooth::hci::InitiatingPhyParameters> initiating_phy_parameters);
// Periodic Advertising
// HCI LE Set Periodic Advertising Parameters command (Vol 4, Part E // § 7.8.61).
ErrorCode LeSetPeriodicAdvertisingParameters(uint8_t advertising_handle,
uint16_t periodic_advertising_interval_min,
uint16_t periodic_advertising_interval_max, bool include_tx_power);
// HCI LE Set Periodic Advertising Data command (Vol 4, Part E § 7.8.62).
ErrorCode LeSetPeriodicAdvertisingData(uint8_t advertising_handle,
bluetooth::hci::Operation operation, const std::vector<uint8_t>& advertising_data);
// HCI LE Set Periodic Advertising Enable command (Vol 4, Part E § 7.8.63).
ErrorCode LeSetPeriodicAdvertisingEnable(bool enable, bool include_adi,
uint8_t advertising_handle);
// Periodic Sync
// HCI LE Periodic Advertising Create Sync command (Vol 4, Part E § 7.8.67).
ErrorCode LePeriodicAdvertisingCreateSync(
bluetooth::hci::PeriodicAdvertisingOptions options, uint8_t advertising_sid,
bluetooth::hci::AdvertiserAddressType advertiser_address_type, Address advertiser_address,
uint16_t skip, uint16_t sync_timeout, uint8_t sync_cte_type);
// HCI LE Periodic Advertising Create Sync Cancel command (Vol 4, Part E // § 7.8.68).
ErrorCode LePeriodicAdvertisingCreateSyncCancel();
// HCI LE Periodic Advertising Terminate Sync command (Vol 4, Part E // § 7.8.69).
ErrorCode LePeriodicAdvertisingTerminateSync(uint16_t sync_handle);
// Periodic Advertiser List
// HCI LE Add Device To Periodic Advertiser List command (Vol 4, Part E // § 7.8.70).
ErrorCode LeAddDeviceToPeriodicAdvertiserList(
bluetooth::hci::AdvertiserAddressType advertiser_address_type, Address advertiser_address,
uint8_t advertising_sid);
// HCI LE Remove Device From Periodic Advertiser List command // (Vol 4, Part E § 7.8.71).
ErrorCode LeRemoveDeviceFromPeriodicAdvertiserList(
bluetooth::hci::AdvertiserAddressType advertiser_address_type, Address advertiser_address,
uint8_t advertising_sid);
// HCI LE Clear Periodic Advertiser List command (Vol 4, Part E § 7.8.72).
ErrorCode LeClearPeriodicAdvertiserList();
// HCI LE Set Default Subrate command (Vol 4, Part E § 7.8.123).
ErrorCode LeSetDefaultSubrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency,
uint16_t continuation_number, uint16_t supervision_timeout);
// HCI LE Subrate Request command (Vol 4, Part E § 7.8.124).
ErrorCode LeSubrateRequest(uint16_t connection_handle, uint16_t subrate_min, uint16_t subrate_max,
uint16_t max_latency, uint16_t continuation_number,
uint16_t supervision_timeout);
// Host Supported Features (Vol 2, Part C § 3.3 Feature Mask Definition). // Page 1 of the LMP feature mask.
uint64_t host_supported_features_{0}; bool le_host_support_{false}; bool secure_simple_pairing_host_support_{false}; bool secure_connections_host_support_{false};
// Le Host Supported Features (Vol 4, Part E § 7.8.3). // Specifies the bits indicating Host support.
uint64_t le_host_supported_features_{0}; bool connected_isochronous_stream_host_support_{false}; bool connection_subrating_host_support_{false}; bool channel_sounding_host_support_{false};
// LE Random Address (Vol 4, Part E § 7.8.4).
Address random_address_{Address::kEmpty};
// HCI configuration parameters. // // Provide the current HCI Configuration Parameters as defined in section // Vol 4, Part E § 6 of the core specification.
// Event Mask (Vol 4, Part E § 7.3.1) and // Event Mask Page 2 (Vol 4, Part E § 7.3.69) and // LE Event Mask (Vol 4, Part E § 7.8.1).
uint64_t event_mask_{0x00001fffffffffff};
uint64_t event_mask_page_2_{0x0};
uint64_t le_event_mask_{0x01f};
// Suggested Default Data Length (Vol 4, Part E § 7.8.34).
uint16_t le_suggested_max_tx_octets_{0x001b};
uint16_t le_suggested_max_tx_time_{0x0148};
// LE Default Subrate parameters (Vol 4, Part E § 7.8.123).
LeAclSubrateParameters default_subrate_parameters_{};
// LE CS Channel Classification (Vol 4, Part E § 7.8.139).
std::array<uint8_t, 10> le_cs_channel_classification_{0xfc, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f};
std::chrono::steady_clock::time_point last_le_cs_set_channel_classification_time_{
std::chrono::steady_clock::time_point::min()};
// Resolvable Private Address Timeout (Vol 4, Part E § 7.8.45).
std::chrono::seconds resolvable_private_address_timeout_{0x0384};
AclConnectionHandler connections_;
// Callbacks to send packets back to the HCI.
std::function<void(std::shared_ptr<bluetooth::hci::AclBuilder>)> send_acl_;
std::function<void(std::shared_ptr<bluetooth::hci::EventBuilder>)> send_event_;
std::function<void(std::shared_ptr<bluetooth::hci::IsoBuilder>)> send_iso_;
// Resolvable Private Address being used by the local device. // It is the last resolvable private address generated for // this identity address.
std::optional<Address> local_resolvable_address; // Resolvable Private Address being used by the peer device. // It is the last resolvable private address received that resolved // to this identity address.
std::optional<Address> peer_resolvable_address;
};
// Flag set when any legacy advertising command has been received // since the last power-on-reset. // From Vol 4, Part E § 3.1.1 Legacy and extended advertising, // extended advertising are rejected when this bit is set. bool legacy_advertising_in_use_{false};
// Flag set when any extended advertising command has been received // since the last power-on-reset. // From Vol 4, Part E § 3.1.1 Legacy and extended advertising, // legacy advertising are rejected when this bit is set. bool extended_advertising_in_use_{false};
// Save information about the advertising PDU being scanned. struct ScanRequest { bool connectable; bool extended;
model::packets::PhyType primary_phy;
model::packets::PhyType secondary_phy;
std::chrono::steady_clock::time_point timeout;
};
// Legacy and extended scanning properties. // Legacy and extended scanning are disambiguated by the use // of legacy_advertising_in_use_ and extended_advertising_in_use_ flags. // Only one type of advertising may be used during a controller session.
Scanner scanner_{};
// APCF scanning state for Android vendor support.
ApcfScanner apcf_scanner_{};
// Save information about the ongoing connection.
Address initiating_address{}; // TODO: AddressWithType
std::optional<AddressWithType> pending_connect_request{};
// Legacy and extended initiating properties. // Legacy and extended initiating are disambiguated by the use // of legacy_advertising_in_use_ and extended_advertising_in_use_ flags. // Only one type of advertising may be used during a controller session.
Initiator initiator_{};
// Periodic advertising synchronizing and synchronized states. // Contains information for the currently established syncs, and the // pending sync.
std::optional<Synchronizing> synchronizing_{};
std::unordered_map<uint16_t, Synchronized> synchronized_{};
// Buffer to contain the ISO SDU sent from the host stack over HCI. // The SDU is forwarded to the peer only when complete.
std::vector<uint8_t> iso_sdu_{};
// Operators needed to be in a collection booloperator<(const Task& another) const { return std::make_pair(time, task_id) < std::make_pair(another.time, another.task_id);
}
// These fields should no longer be public if the class ever becomes // public or gets more complex
std::chrono::steady_clock::time_point time; constbool periodic;
std::chrono::milliseconds period{};
TaskCallback callback;
TaskId task_id;
};
private: // List currently pending tasks.
std::set<Task> task_queue_{};
TaskId task_counter_{0};
// Return the next valid unused task identifier.
TaskId NextTaskId();
};
} // namespace rootcanal
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.4 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.