25#ifndef DBT_CLIENT01_HPP_
26#define DBT_CLIENT01_HPP_
45 bool do_disconnect =
true;
46 bool do_disconnect_randomly =
false;
48 bool do_remove_device =
false;
50 DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY;
52 static const bool GATT_VERBOSE =
false;
53 static const bool SHOW_UPDATE_EVENTS =
false;
69 const uint8_t cmd_arg = 0x44;
78 const AdapterSetting changedmask,
const uint64_t timestamp)
override {
79 const bool initialSetting = AdapterSetting::NONE == oldmask;
80 if( initialSetting ) {
81 fprintf_td(stderr,
"****** Client SETTINGS_INITIAL: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
84 fprintf_td(stderr,
"****** Client SETTINGS_CHANGED: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
89 if( justPoweredOn && DiscoveryPolicy::AUTO_OFF != parent.discoveryPolicy && *parent.clientAdapter == a ) {
94 fprintf_td(stderr,
"Client Status BTAdapter:\n");
100 fprintf_td(stderr,
"****** Client DISCOVERING: meta %s, changed[%s, enabled %d, policy %s]: %s\n",
105 bool deviceFound(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
108 0 < parent.measurementsLeft
111 fprintf_td(stderr,
"****** Client FOUND__-0: Connecting %s\n", device->toString(
true).c_str());
114 fprintf_td(stderr,
"PERF: adapter-init -> FOUND__-0 %" PRIu64
" ms\n", td);
117 std::thread dc(&DBTClient01::connectDiscoveredDevice, &parent, device);
121 fprintf_td(stderr,
"****** Client FOUND__-1: NOP %s\n", device->toString(
true).c_str());
126 void deviceUpdated(
const BTDeviceRef& device,
const EIRDataType updateMask,
const uint64_t timestamp)
override {
132 void deviceConnected(
const BTDeviceRef& device,
const bool discovered,
const uint64_t timestamp)
override {
133 fprintf_td(stderr,
"****** Client CONNECTED (discovered %d): %s\n", discovered, device->toString(
true).c_str());
139 fprintf_td(stderr,
"****** Client PAIRING STATE: state %s, mode %s, %s\n",
143 case SMPPairingState::NONE:
146 case SMPPairingState::FAILED: {
148 fprintf_td(stderr,
"****** PAIRING_STATE: state %s; Remove key file %s, res %d\n",
152 case SMPPairingState::REQUESTED_BY_RESPONDER:
155 case SMPPairingState::FEATURE_EXCHANGE_STARTED:
158 case SMPPairingState::FEATURE_EXCHANGE_COMPLETED:
161 case SMPPairingState::PASSKEY_EXPECTED: {
163 if(
nullptr != sec && sec->
getPairingPasskey() != BTSecurityRegistry::Entry::NO_PASSKEY ) {
164 std::thread dc(&BTDevice::setPairingPasskey, device,
static_cast<uint32_t
>( sec->
getPairingPasskey() ));
167 std::thread dc(&BTDevice::setPairingPasskey, device, 0);
173 case SMPPairingState::NUMERIC_COMPARE_EXPECTED: {
175 if(
nullptr != sec ) {
179 std::thread dc(&BTDevice::setPairingNumericComparison, device,
false);
184 case SMPPairingState::OOB_EXPECTED:
187 case SMPPairingState::KEY_DISTRIBUTION:
190 case SMPPairingState::COMPLETED:
198 void disconnectDeviceRandomly(
BTDeviceRef device) {
201 static const int sleep_min = 100;
202 static const int sleep_max = 1500;
203 static std::random_device rng_hw;;
204 static std::uniform_int_distribution<int> rng_dist(sleep_min, sleep_max);
205 const int64_t sleep_dur = rng_dist(rng_hw);
207 if(
nullptr != device ) {
208 fprintf_td(stderr,
"****** Client i470 disconnectDevice(delayed %d ms): client %s\n", sleep_dur, device->toString().c_str());
209 device->disconnect();
211 fprintf_td(stderr,
"****** Client i470 disconnectDevice(delayed %d ms): client null\n", sleep_dur);
216 void deviceReady(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
219 parent.deviceReadyCount++;
220 fprintf_td(stderr,
"****** Client READY-0: Processing[%d] %s\n", parent.deviceReadyCount.
load(), device->toString(
true).c_str());
224 std::thread dc(&DBTClient01::processReadyDevice, &parent, device);
228 if( parent.do_disconnect_randomly ) {
230 std::thread disconnectThread(&MyAdapterStatusListener::disconnectDeviceRandomly,
this, device);
231 disconnectThread.detach();
236 void deviceDisconnected(
const BTDeviceRef& device,
const HCIStatusCode reason,
const uint16_t handle,
const uint64_t timestamp)
override {
237 fprintf_td(stderr,
"****** Client DISCONNECTED: Reason 0x%X (%s), old handle %s: %s\n",
238 static_cast<uint8_t
>(reason),
to_string(reason).c_str(),
239 to_hexstring(handle).c_str(), device->toString(
true).c_str());
242 parent.disconnectCount++;
245 std::thread dc(&DBTClient01::removeDevice, &parent, device);
249 std::string toString()
const noexcept override {
250 return "Client MyAdapterStatusListener[this "+
to_hexstring(
this)+
"]";
262 void notificationReceived(
BTGattCharRef charDecl,
const TROOctets& char_value,
const uint64_t timestamp)
override {
265 fprintf_td(stderr,
"** Characteristic-Notify: UUID %s, td %" PRIu64
" ******\n",
266 charDecl->value_type->toUUID128String().c_str(), (tR-timestamp));
267 fprintf_td(stderr,
"** Characteristic: %s ******\n", charDecl->toString().c_str());
271 parent.notificationsReceived++;
275 const TROOctets& char_value,
const uint64_t timestamp,
276 const bool confirmationSent)
override
280 fprintf_td(stderr,
"** Characteristic-Indication: UUID %s, td %" PRIu64
", confirmed %d ******\n",
281 charDecl->value_type->toUUID128String().c_str(), (tR-timestamp), confirmationSent);
282 fprintf_td(stderr,
"** Characteristic: %s ******\n", charDecl->toString().c_str());
286 parent.indicationsReceived++;
290 const std::string adapterShortName =
"TDev2Clt";
291 std::string adapterName =
"TestDev2_Clt";
292 EUI48 useAdapter = EUI48::ALL_DEVICE;
293 BTMode btMode = BTMode::DUAL;
295 std::shared_ptr<AdapterStatusListener> myAdapterStatusListener = std::make_shared<MyAdapterStatusListener>(*
this);
298 DBTClient01(
const std::string& adapterName_,
const EUI48 useAdapter_,
const BTMode btMode_,
const bool do_disconnect_randomly_=
false) {
299 this->adapterName = adapterName_;
300 this->useAdapter = useAdapter_;
301 this->btMode = btMode_;
302 this->do_disconnect_randomly = do_disconnect_randomly_;
306 fprintf_td(stderr,
"****** Client dtor: running_threads %zu\n", running_threads.
value());
310 std::string
getName()
override {
return adapterName; }
313 this->clientAdapter = clientAdapter_;
319 measurementsLeft = v;
322 return measurementsLeft;
325 return completedMeasurementsTotal;
328 return completedMeasurementsSuccess;
331 return disconnectCount;
341 do_remove_device = v;
345 void resetLastProcessingStats() {
346 completedGATTCommands = 0;
347 notificationsReceived = 0;
348 indicationsReceived = 0;
352 fprintf_td(stderr,
"****** Client Connecting Device: Start %s\n", device->toString().c_str());
354 resetLastProcessingStats();
357 if(
nullptr != sec ) {
358 fprintf_td(stderr,
"****** Client Connecting Device: Found SecurityDetail %s for %s\n", sec->
toString().c_str(), device->toString().c_str());
360 fprintf_td(stderr,
"****** Client Connecting Device: No SecurityDetail for %s\n", device->toString().c_str());
364 fprintf_td(stderr,
"****** Client Connecting Device: BTDevice::uploadKeys(...) result %s\n",
to_string(res).c_str());
365 if( HCIStatusCode::SUCCESS != res ) {
366 if(
nullptr != sec ) {
369 fprintf_td(stderr,
"****** Client Connecting Device: Using SecurityDetail.SEC AUTO %s, set OK %d\n", sec->
toString().c_str(), r);
372 fprintf_td(stderr,
"****** Client Connecting Device: Using SecurityDetail.Level+IOCap %s, set OK %d\n", sec->
toString().c_str(), r);
374 bool r = device->setConnSecurityAuto( SMPIOCapability::KEYBOARD_ONLY );
375 fprintf_td(stderr,
"****** Client Connecting Device: Setting SEC AUTO security detail w/ KEYBOARD_ONLY (%s) -> set OK %d\n", sec->
toString().c_str(), r);
378 bool r = device->setConnSecurityAuto( SMPIOCapability::KEYBOARD_ONLY );
379 fprintf_td(stderr,
"****** Client Connecting Device: Setting SEC AUTO security detail w/ KEYBOARD_ONLY -> set OK %d\n", r);
382 std::shared_ptr<const EInfoReport> eir = device->getEIR();
383 fprintf_td(stderr,
"Client EIR-1 %s\n", device->getEIRInd()->toString().c_str());
384 fprintf_td(stderr,
"Client EIR-2 %s\n", device->getEIRScanRsp()->toString().c_str());
385 fprintf_td(stderr,
"Client EIR-+ %s\n", eir->toString().c_str());
387 uint16_t conn_interval_min = (uint16_t)8;
388 uint16_t conn_interval_max = (uint16_t)12;
389 const uint16_t conn_latency = (uint16_t)0;
390 if( eir->isSet(EIRDataType::CONN_IVAL) ) {
391 eir->getConnInterval(conn_interval_min, conn_interval_max);
394 res = device->connectLE(le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, conn_latency, supervision_timeout);
395 fprintf_td(stderr,
"****** Client Connecting Device: End result %s of %s\n",
to_string(res).c_str(), device->toString().c_str());
400 fprintf_td(stderr,
"****** Client Processing Ready Device: Start %s\n", device->toString().c_str());
408 bool success =
false;
412 HCIStatusCode res = device->getConnectedLE_PHY(resTx, resRx);
413 fprintf_td(stderr,
"****** Client Got Connected LE PHY: status %s: Tx %s, Rx %s\n",
424 if( 0 == primServices.
size() ) {
425 fprintf_td(stderr,
"****** Client Processing Ready Device: getServices() failed %s\n", device->toString().c_str());
431 const uint64_t td00 = device->getLastDiscoveryTimestamp() - timestamp_t0;
432 const uint64_t td01 = t1 - timestamp_t0;
433 const uint64_t td05 = t5 - timestamp_t0;
434 const uint64_t tdc1 = t1 - device->getLastDiscoveryTimestamp();
435 const uint64_t tdc5 = t5 - device->getLastDiscoveryTimestamp();
436 const uint64_t td12 = t2 - t1;
437 const uint64_t td23 = t3 - t2;
438 const uint64_t td13 = t3 - t1;
439 const uint64_t td35 = t5 - t3;
441 fprintf_td(stderr,
"PERF: GATT primary-services completed\n"
442 "PERF: adapter-init to discovered %" PRIu64
" ms,\n"
443 "PERF: adapter-init to processing-start %" PRIu64
" ms,\n"
444 "PERF: adapter-init to gatt-complete %" PRIu64
" ms\n"
445 "PERF: discovered to processing-start %" PRIu64
" ms,\n"
446 "PERF: discovered to gatt-complete %" PRIu64
" ms,\n"
447 "PERF: SMPKeyBin + LE_PHY %" PRIu64
" ms (SMPKeyBin %" PRIu64
" ms, LE_PHY %" PRIu64
" ms),\n"
448 "PERF: get-gatt-services %" PRIu64
" ms,\n\n",
451 td13, td12, td23, td35);
458 fprintf_td(stderr,
"Command test: %s, resolved %d\n", cmd.
toString().c_str(), cmd_resolved);
459 POctets cmd_data(1, lb_endian_t::little);
460 cmd_data.put_uint8_nc(0, cmd_arg);
462 if( HCIStatusCode::SUCCESS == cmd_res ) {
466 completedGATTCommands++;
476 bool gattListenerError =
false;
477 std::vector<BTGattCharListenerRef> gattListener;
480 for(
size_t i=0; i<primServices.
size(); i++) {
483 fprintf_td(stderr,
" [%2.2d] Service UUID %s (%s)\n", i,
484 primService.
type->toUUID128String().c_str(),
485 primService.
type->getTypeSizeString().c_str());
489 for(
size_t j=0; j<serviceCharacteristics.
size(); j++) {
492 fprintf_td(stderr,
" [%2.2d.%2.2d] Characteristic: UUID %s (%s)\n", i, j,
493 serviceChar->value_type->toUUID128String().c_str(),
494 serviceChar->value_type->getTypeSizeString().c_str());
495 fprintf_td(stderr,
" [%2.2d.%2.2d] %s\n", i, j, serviceChar->toString().c_str());
499 if( serviceChar->readValue(value) ) {
502 fprintf_td(stderr,
" [%2.2d.%2.2d] value: %s ('%s')\n", (
int)i, (
int)j, value.toString().c_str(), sval.c_str());
507 for(
size_t k=0; k<charDescList.
size(); k++) {
510 fprintf_td(stderr,
" [%2.2d.%2.2d.%2.2d] Descriptor: UUID %s (%s)\n", i, j, k,
511 charDesc.
type->toUUID128String().c_str(),
512 charDesc.
type->getTypeSizeString().c_str());
513 fprintf_td(stderr,
" [%2.2d.%2.2d.%2.2d] %s\n", i, j, k, charDesc.
toString().c_str());
517 bool cccdEnableResult[2];
518 if( serviceChar->enableNotificationOrIndication( cccdEnableResult ) ) {
520 std::shared_ptr<BTGattCharListener> gattEventListener = std::make_shared<MyGATTEventListener>(*
this);
521 bool clAdded = serviceChar->addCharListener( gattEventListener );
523 gattListener.push_back(gattEventListener);
525 gattListenerError =
true;
526 fprintf_td(stderr,
"Client Error: Failed to add GattListener: %s @ %s, gattListener %zu\n",
527 gattEventListener->toString().c_str(), serviceChar->toString().c_str(), gattListener.size());
530 fprintf_td(stderr,
" [%2.2d.%2.2d] Characteristic-Listener: Notification(%d), Indication(%d): Added %d\n",
531 (
int)i, (
int)j, cccdEnableResult[0], cccdEnableResult[1], clAdded);
541 success = notificationsReceived >= 2 || indicationsReceived >= 2;
543 }
while( !success && device->getConnected() && !gattListenerError );
545 success = success && completedGATTCommands >= 1;
547 if( gattListenerError ) {
553 if( !device->removeCharListener(gcl) ) {
554 fprintf_td(stderr,
"Client Error: Failed to remove GattListener[%d/%zu]: %s @ %s\n",
555 i, gattListener.size(), gcl->toString().c_str(), device->toString().c_str());
562 if( device->getConnected() ) {
567 fprintf_td(stderr,
"FinalCommand test: %s, resolved %d\n", cmd.
toString().c_str(), cmd_resolved);
569 POctets cmd_data(data_sz, lb_endian_t::little);
576 if( HCIStatusCode::SUCCESS == cmd_res ) {
579 if( cmd_data.size() == resp.
size() &&
580 0 == ::memcmp(cmd_data.get_ptr(), resp.
get_ptr(), resp.
size()) )
591 }
catch ( std::exception & e ) {
592 fprintf_td(stderr,
"****** Client Processing Ready Device: Exception.2 caught for %s: %s\n", device->toString().c_str(), e.what());
596 fprintf_td(stderr,
"****** Client Processing Ready Device: End-1: Success %d on %s\n", success, device->toString().c_str());
598 if( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED == discoveryPolicy ) {
599 device->getAdapter().removeDevicePausingDiscovery(*device);
602 fprintf_td(stderr,
"****** Client Processing Ready Device: End-2: Success %d on %s\n", success, device->toString().c_str());
604 device->removeAllCharListener();
606 if( do_disconnect ) {
607 if( do_remove_device ) {
610 device->disconnect();
614 completedMeasurementsTotal++;
616 completedMeasurementsSuccess++;
617 if( 0 < measurementsLeft ) {
621 fprintf_td(stderr,
"****** Client Processing Ready Device: Success %d; Measurements completed %d"
622 ", left %d; Received notitifications %d, indications %d"
623 "; Completed GATT commands %d: %s\n",
624 success, completedMeasurementsSuccess.
load(),
625 measurementsLeft.
load(), notificationsReceived.
load(), indicationsReceived.
load(),
626 completedGATTCommands.load(), device->getAddressAndType().toString().c_str());
631 fprintf_td(stderr,
"****** Client Remove Device: removing: %s\n", device->getAddressAndType().toString().c_str());
633 if( do_remove_device ) {
639 static const bool le_scan_active =
true;
640 static const uint16_t le_scan_interval = 24;
641 static const uint16_t le_scan_window = 24;
642 static const uint8_t filter_policy = 0;
643 static const bool filter_dup =
true;
648 HCIStatusCode status = clientAdapter->startDiscovery(
nullptr, discoveryPolicy, le_scan_active, le_scan_interval, le_scan_window, filter_policy, filter_dup );
649 fprintf_td(stderr,
"****** Client Start discovery (%s) result: %s: %s\n", msg.c_str(),
to_string(status).c_str(), clientAdapter->toString().c_str());
655 fprintf_td(stderr,
"****** Client Stop discovery (%s) result: %s\n", msg.c_str(),
to_string(status).c_str());
659 void close(
const std::string& msg)
override {
660 fprintf_td(stderr,
"****** Client Close: %s\n", msg.c_str());
661 clientAdapter->stopDiscovery();
662 REQUIRE(
true == clientAdapter->removeStatusListener( myAdapterStatusListener ) );
663 fprintf_td(stderr,
"****** Client close: running_threads %zu\n", running_threads.
value());
668 if( useAdapter != EUI48::ALL_DEVICE && useAdapter != adapter->getAddressAndType().address ) {
669 fprintf_td(stderr,
"initClientAdapter: Adapter not selected: %s\n", adapter->toString().c_str());
672 adapterName = adapterName +
"-" + adapter->getAddressAndType().address.toString();
674 auto it =
std::remove( adapterName.begin(), adapterName.end(),
':');
675 adapterName.erase(it, adapterName.end());
679 if( !adapter->isInitialized() ) {
681 if( HCIStatusCode::SUCCESS != status ) {
682 fprintf_td(stderr,
"initClientAdapter: Adapter initialization failed: %s: %s\n",
683 to_string(status).c_str(), adapter->toString().c_str());
686 }
else if( !adapter->setPowered(
false ) ) {
687 fprintf_td(stderr,
"initClientAdapter: Already initialized adapter power-off failed:: %s\n", adapter->toString().c_str());
691 fprintf_td(stderr,
"initClientAdapter.1: %s\n", adapter->toString().c_str());
693 const LE_Features le_feats = adapter->getLEFeatures();
698 HCIStatusCode status = adapter->setName(adapterName, adapterShortName);
699 if( HCIStatusCode::SUCCESS == status ) {
700 fprintf_td(stderr,
"initClientAdapter: setLocalName OK: %s\n", adapter->toString().c_str());
702 fprintf_td(stderr,
"initClientAdapter: setLocalName failed: %s\n", adapter->toString().c_str());
706 if( !adapter->setPowered(
true ) ) {
707 fprintf_td(stderr,
"initClientAdapter: setPower.2 on failed: %s\n", adapter->toString().c_str());
712 fprintf_td(stderr,
"initClientAdapter.2: %s\n", adapter->toString().c_str());
715 const LE_Features le_feats = adapter->getLEFeatures();
718 if( adapter->getBTMajorVersion() > 4 ) {
719 LE_PHYs Tx { LE_PHYs::LE_2M }, Rx { LE_PHYs::LE_2M };
721 fprintf_td(stderr,
"initClientAdapter: Set Default LE PHY: status %s: Tx %s, Rx %s\n",
724 REQUIRE(
true == adapter->addStatusListener( myAdapterStatusListener ) );
This central BTRole::Master participant works with DBTServer00.
void setAdapter(BTAdapterRef clientAdapter_) override
Set the server adapter for this endpoint.
HCIStatusCode startDiscovery(const std::string &msg) override
void setProtocolSessionsLeft(const int v) override
void setDisconnectDevice(const bool v) override
Set disconnect after processing.
BTAdapterRef getAdapter() override
Return the adapter for this endpoint.
bool initAdapter(BTAdapterRef adapter) override
Initialize the given adapter for this endpoint.
DBTClient01(const std::string &adapterName_, const EUI48 useAdapter_, const BTMode btMode_, const bool do_disconnect_randomly_=false)
HCIStatusCode stopDiscovery(const std::string &msg) override
std::string getName() override
Return name of this endpoint, which becomes the adapter's name.
int getProtocolSessionsDoneSuccess() override
int getProtocolSessionsDoneTotal() override
void setRemoveDevice(const bool v) override
Set remove device when disconnecting.
int getProtocolSessionsLeft() override
int getDisconnectCount() override
void setDiscoveryPolicy(const DiscoveryPolicy v) override
Set DiscoveryPolicy.
void close(const std::string &msg) override
static const jau::uuid128_t ResponseUUID
static const jau::uuid128_t CommandUUID
static constexpr const char CLIENT_KEY_PATH[]
C++20 we could use constexpr std::string
static const std::vector< uint8_t > FailHandshakeCommandData
Fail handshake command data, where client is signaling unsuccessful completion of test to server.
static const std::vector< uint8_t > SuccessHandshakeCommandData
Success handshake command data, where client is signaling successful completion of test to server.
BTAdapter status listener for remote BTDevice discovery events: Added, updated and removed; as well a...
BTAdapter represents one local Bluetooth Controller.
std::string toString() const noexcept override
BTGattChar event listener for notification and indication events.
Class maps a GATT command and optionally its asynchronous response to a synchronous atomic operation.
void setVerbose(const bool v) noexcept
Set verbosity for UUID resolution.
HCIStatusCode send(const bool prefNoAck, const jau::TROOctets &cmd_data, const jau::fraction_i64 &timeout) noexcept
Send the command to the remote BTDevice.
bool isResolved() noexcept
Query whether all UUIDs of this commands have been resolved.
const jau::TROOctets & getResponse() const noexcept
Returns the read-only response data object for configured commands with response notification or indi...
std::string toString() const noexcept
Representing a Gatt Characteristic Descriptor object from the GATTRole::Client perspective.
std::unique_ptr< const jau::uuid_t > type
Type of descriptor.
std::string toString() const noexcept override
Representing a Gatt Service object from the GATTRole::Client perspective.
std::unique_ptr< const jau::uuid_t > type
Service type UUID.
std::string toString() const noexcept override
jau::darray< BTGattCharRef > characteristicList
List of Characteristic Declarations as shared reference.
Persistent endian aware octet data, i.e.
Transient read only and endian aware octet data, i.e.
std::string toString() const noexcept
constexpr nsize_t size() const noexcept
Returns the used memory size for read and write operations, may be zero.
constexpr uint8_t get_uint8_nc(const nsize_t i) const noexcept
constexpr uint8_t const * get_ptr() const noexcept
Implementation of a dynamic linear array storage, aka vector.
constexpr size_type size() const noexcept
Like std::vector::size().
const_reference at(size_type i) const
Like std::vector::at(size_type), immutable reference.
Inspired by std::latch of C++20.
size_t value() const noexcept
Return the current atomic internal counter.
bool wait_for(const fraction_i64 &timeout_duration) const noexcept
Blocks the calling thread until the internal counter reaches 0 or the given timeout duration has expi...
void count_down(const size_t n=1) noexcept
Atomically decrements the internal counter by n and notifies all blocked wait() threads if zero is re...
void count_up(const size_t n=1) noexcept
Atomically increments the internal counter by n, i.e.
std::shared_ptr< DBTClient01 > DBTClient01Ref
uint32_t dfa_utf8_decode(uint32_t &state, uint32_t &codep, const uint32_t byte_value)
@ little
Identifier for little endian, equivalent to endian::little.
std::string to_string(const alphabet &v) noexcept
SMPPairingState
SMP Pairing Process state definition.
Entry * getStartOf(const EUI48 &addr, const std::string &name) noexcept
Returns a matching Entry,.
BTMode
Bluetooth adapter operating mode.
LE_Features
HCI Supported Commands.
DiscoveryPolicy
Discovery policy defines the BTAdapter discovery mode after connecting a remote BTDevice:
std::shared_ptr< BTDevice > BTDeviceRef
std::shared_ptr< BTAdapter > BTAdapterRef
LE_PHYs
LE Transport PHY bit values.
ScanType
Meta ScanType as derived from BTMode, with defined value mask consisting of BDAddressType bits.
AdapterSetting
Adapter Setting Bits.
constexpr bool isAdapterSettingBitSet(const AdapterSetting mask, const AdapterSetting bit) noexcept
BTSecurityLevel
Bluetooth Security Level.
PairingMode
Bluetooth secure pairing mode.
constexpr uint16_t getHCIConnSupervisorTimeout(const uint16_t conn_latency, const uint16_t conn_interval_max_ms, const uint16_t min_result_ms=number(HCIConstInt::LE_CONN_MIN_TIMEOUT_MS), const uint16_t multiplier=10) noexcept
Defining the supervising timeout for LE connections to be a multiple of the maximum connection interv...
HCIStatusCode
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
EIRDataType
Bit mask of 'Extended Inquiry Response' (EIR) data fields, indicating a set of related data.
std::shared_ptr< BTGattCharListener > BTGattCharListenerRef
std::shared_ptr< BTGattChar > BTGattCharRef
bool remove(const std::string &path, const traverse_options topts=traverse_options::none) noexcept
Remove the given path.
constexpr uint32_t number(const iostate rhs) noexcept
std::string to_hexstring(value_type const &v) noexcept
Produce a lower-case hexadecimal string representation of the given pointer.
bool isWaitingForDevice(const EUI48 &address, const std::string &name, DeviceQueryMatchFunc m) noexcept
Returns true if the given address and/or name matches any of the BTDeviceRegistry::addToWaitForDevice...
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
int fprintf_td(const uint64_t elapsed_ms, FILE *stream, const char *format,...) noexcept
Convenient fprintf() invocation, prepending the given elapsed_ms timestamp.
uint64_t getCurrentMilliseconds() noexcept
Returns current monotonic time in milliseconds.
bool sleep_for(const fraction_timespec &relative_time, const bool monotonic=true, const bool ignore_irq=true) noexcept
sleep_for causes the current thread to block until a specific amount of time has passed.
constexpr bool isSecLevelOrIOCapSet() const noexcept
constexpr const BTSecurityLevel & getSecLevel() const noexcept
constexpr int getPairingPasskey() const noexcept
constexpr bool getPairingNumericComparison() const noexcept
constexpr const SMPIOCapability & getSecurityAutoIOCap() const noexcept
constexpr const SMPIOCapability & getIOCap() const noexcept
constexpr bool isSecurityAutoEnabled() const noexcept
std::string toString() const noexcept
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...
CXX_ALWAYS_INLINE _Tp load() const noexcept