28#ifndef _BLE_CONNECTION_HXX_
29#define _BLE_CONNECTION_HXX_
118 std::function<
void(
Connection *connection)> callback)
153 if (it->get_handle() == handle)
176 e.addrType_ == addr_type)
192 if (e.handle_ == handle)
Connection instance metadata.
bool central_
true if central role, else peripheral role
Defs::ConnHandle get_handle()
Get the connection handle.
Defs::Addr addr_
peer address
void get_addr(Defs::Addr addr, Defs::AddrType *addr_type)
Get the connection address.
Defs::AddrType addrType_
peer address type
Defs::ConnHandle handle_
handle to the connection
Connection(Defs::ConnHandle handle, Defs::Addr addr, Defs::AddrType addr_type, bool central)
Constructor.
~Connection()
Destructor. This happens when there is a disconnect.
Singleton container of all the active connections.
std::vector< Connection > connections_
All the connections managed by the container.
std::vector< std::function< void(Connection *connection)> > callbacks_
Callbacks to be called upon disconnection.
void register_connection(Defs::ConnHandle handle, Defs::Addr addr, Defs::AddrType addr_type, bool central)
Register an active connection.
void disconnect(Defs::ConnHandle handle)
Called when a connection is disconnected.
void register_disconnect_callback(std::function< void(Connection *connection)> callback)
Register a callback at disconnection.
size_t get_active_count()
Get the number of active connections being tracked by this object.
void disconnect(Connection *conn)
Called when a connection is disconnected.
Connection * lookup_by_handle(Defs::ConnHandle handle)
Find a connection by its connection handle.
Connection * lookup_by_address(Defs::Addr addr, Defs::AddrType addr_type)
Find a connection by its peer address.
Connections()
Constructor.
uint8_t AddrType
Address Type.
uint16_t ConnHandle
Connection handle.
uint8_t Addr[ADDR_LEN]
BLE address.
static constexpr uint8_t ADDR_LEN
The length of an address.