100 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
101 0x01, 0x5E, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
102 0x9B, 0x23, 0x84 }, lb_endian::little);
105 0xB8 }, lb_endian::little);
108 0x14, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00,
109 0x01, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x01 , 0xed }, lb_endian::little );
127 std::make_shared<DBGattService> (
true ,
139 std::make_shared<DBGattService> (
true ,
172 const AdapterSetting changedmask,
const uint64_t timestamp)
override {
173 const bool initialSetting = AdapterSetting::NONE == oldmask;
174 if( initialSetting ) {
175 fprintf_td(stderr,
"****** SETTINGS_INITIAL: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
178 fprintf_td(stderr,
"****** SETTINGS_CHANGED: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
185 if( !initialSetting &&
195 fprintf_td(stderr,
"****** DISCOVERING: meta %s, changed[%s, enabled %d, policy %s]: %s\n",
200 bool deviceFound(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
209 fprintf_td(stderr,
"****** FOUND__-0: Connecting %s\n", device->toString(
true).c_str());
212 fprintf_td(stderr,
"PERF: adapter-init -> FOUND__-0 %" PRIu64
" ms\n", td);
219 fprintf_td(stderr,
"****** FOUND__-1: NOP %s\n", device->toString(
true).c_str());
225 void deviceUpdated(
const BTDeviceRef& device,
const EIRDataType updateMask,
const uint64_t timestamp)
override {
227 fprintf_td(stderr,
"****** UPDATED: %s of %s\n",
to_string(updateMask).c_str(), device->toString(
true).c_str());
232 void deviceConnected(
const BTDeviceRef& device,
const bool discovered,
const uint64_t timestamp)
override {
233 fprintf_td(stderr,
"****** CONNECTED (discovered %d): %s\n", discovered, device->toString(
true).c_str());
239 fprintf_td(stderr,
"****** PAIRING STATE: state %s, mode %s, %s\n",
243 case SMPPairingState::NONE:
246 case SMPPairingState::FAILED: {
248 fprintf_td(stderr,
"****** PAIRING_STATE: state %s; Remove key file %s, res %d\n",
252 case SMPPairingState::REQUESTED_BY_RESPONDER:
255 case SMPPairingState::FEATURE_EXCHANGE_STARTED:
258 case SMPPairingState::FEATURE_EXCHANGE_COMPLETED:
261 case SMPPairingState::PASSKEY_EXPECTED: {
263 if(
nullptr != sec && sec->
getPairingPasskey() != BTSecurityRegistry::Entry::NO_PASSKEY ) {
264 std::thread dc(&BTDevice::setPairingPasskey, device,
static_cast<uint32_t
>( sec->
getPairingPasskey() ));
269 std::thread dc(&BTDevice::setPairingPasskeyNegative, device);
274 case SMPPairingState::NUMERIC_COMPARE_EXPECTED: {
276 if(
nullptr != sec ) {
280 std::thread dc(&BTDevice::setPairingNumericComparison, device,
false);
285 case SMPPairingState::OOB_EXPECTED:
288 case SMPPairingState::KEY_DISTRIBUTION:
291 case SMPPairingState::COMPLETED:
299 void deviceReady(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
306 void deviceDisconnected(
const BTDeviceRef& device,
const HCIStatusCode reason,
const uint16_t handle,
const uint64_t timestamp)
override {
307 fprintf_td(stderr,
"****** DISCONNECTED: Reason 0x%X (%s), old handle %s: %s\n",
308 static_cast<uint8_t
>(reason),
to_string(reason).c_str(),
309 to_hexstring(handle).c_str(), device->toString(
true).c_str());
322 std::string toString()
const noexcept override {
323 return "MyAdapterStatusListener[this "+
to_hexstring(
this)+
"]";
340 fprintf_td(stderr,
"**[%2.2d.%2.2d] Characteristic-Notify: UUID %s, td %" PRIu64
" ******\n",
341 i, j, charDecl->value_type->toUUID128String().c_str(), (tR-timestamp));
342 fprintf_td(stderr,
"**[%2.2d.%2.2d] Characteristic: %s ******\n", i, j, charDecl->toString().c_str());
345 if(
nullptr != temp ) {
346 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value T: %s ******\n", i, j, temp->toString().c_str());
348 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value R: %s ******\n", i, j, char_value.
toString().c_str());
350 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value R: %s ******\n", i, j, char_value.
toString().c_str());
356 const TROOctets& char_value,
const uint64_t timestamp,
357 const bool confirmationSent)
override
360 fprintf_td(stderr,
"**[%2.2d.%2.2d] Characteristic-Indication: UUID %s, td %" PRIu64
", confirmed %d ******\n",
361 i, j, charDecl->value_type->toUUID128String().c_str(), (tR-timestamp), confirmationSent);
362 fprintf_td(stderr,
"**[%2.2d.%2.2d] Characteristic: %s ******\n", i, j, charDecl->toString().c_str());
365 if(
nullptr != temp ) {
366 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value T: %s ******\n", i, j, temp->toString().c_str());
368 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value R: %s ******\n", i, j, char_value.
toString().c_str());
370 fprintf_td(stderr,
"**[%2.2d.%2.2d] Value R: %s ******\n", i, j, char_value.
toString().c_str());
377 fprintf_td(stderr,
"****** Connecting Device: Start %s\n", device->toString().c_str());
380 if(
nullptr != sec ) {
381 fprintf_td(stderr,
"****** Connecting Device: Found SecurityDetail %s for %s\n", sec->
toString().c_str(), device->toString().c_str());
383 fprintf_td(stderr,
"****** Connecting Device: No SecurityDetail for %s\n", device->toString().c_str());
387 fprintf_td(stderr,
"****** Connecting Device: BTDevice::uploadKeys(...) result %s\n",
to_string(res).c_str());
388 if( HCIStatusCode::SUCCESS != res ) {
389 if(
nullptr != sec ) {
392 fprintf_td(stderr,
"****** Connecting Device: Using SecurityDetail.SEC AUTO %s, set OK %d\n", sec->
toString().c_str(), r);
395 fprintf_td(stderr,
"****** Connecting Device: Using SecurityDetail.Level+IOCap %s, set OK %d\n", sec->
toString().c_str(), r);
397 bool r = device->setConnSecurityAuto( SMPIOCapability::KEYBOARD_ONLY );
398 fprintf_td(stderr,
"****** Connecting Device: Setting SEC AUTO security detail w/ KEYBOARD_ONLY (%s) -> set OK %d\n", sec->
toString().c_str(), r);
401 bool r = device->setConnSecurityAuto( SMPIOCapability::KEYBOARD_ONLY );
402 fprintf_td(stderr,
"****** Connecting Device: Setting SEC AUTO security detail w/ KEYBOARD_ONLY -> set OK %d\n", r);
405 std::shared_ptr<const EInfoReport> eir = device->getEIR();
406 fprintf_td(stderr,
"EIR-1 %s\n", device->getEIRInd()->toString().c_str());
407 fprintf_td(stderr,
"EIR-2 %s\n", device->getEIRScanRsp()->toString().c_str());
408 fprintf_td(stderr,
"EIR-+ %s\n", eir->toString().c_str());
410 uint16_t conn_interval_min = (uint16_t)8;
411 uint16_t conn_interval_max = (uint16_t)12;
412 const uint16_t conn_latency = (uint16_t)0;
413 if( eir->isSet(EIRDataType::CONN_IVAL) ) {
414 eir->getConnInterval(conn_interval_min, conn_interval_max);
418 fprintf_td(stderr,
"****** Connecting Device: End result %s of %s\n",
to_string(res).c_str(), device->toString().c_str());
422 fprintf_td(stderr,
"****** Processing Ready Device: Start %s\n", device->toString().c_str());
430 bool success =
false;
432 if( device->getAdapter().getBTMajorVersion() > 4 ) {
433 LE_PHYs Tx { LE_PHYs::LE_2M }, Rx { LE_PHYs::LE_2M };
435 fprintf_td(stderr,
"****** Set Connected LE PHY: status %s: Tx %s, Rx %s\n",
440 HCIStatusCode res = device->getConnectedLE_PHY(resTx, resRx);
441 fprintf_td(stderr,
"****** Got Connected LE PHY: status %s: Tx %s, Rx %s\n",
448 fprintf_td(stderr,
"****** Processing Ready Device: GATT start: %s\n", device->getAddressAndType().toString().c_str());
450 device->getAdapter().printDeviceLists();
456 if( 0 == primServices.
size() ) {
457 fprintf_td(stderr,
"****** Processing Ready Device: getServices() failed %s\n", device->toString().c_str());
463 const uint64_t td00 = device->getLastDiscoveryTimestamp() -
timestamp_t0;
466 const uint64_t tdc1 = t1 - device->getLastDiscoveryTimestamp();
467 const uint64_t tdc5 = t5 - device->getLastDiscoveryTimestamp();
468 const uint64_t td12 = t2 - t1;
469 const uint64_t td23 = t3 - t2;
470 const uint64_t td13 = t3 - t1;
471 const uint64_t td35 = t5 - t3;
473 fprintf_td(stderr,
"PERF: GATT primary-services completed\n"
474 "PERF: adapter-init to discovered %" PRIu64
" ms,\n"
475 "PERF: adapter-init to processing-start %" PRIu64
" ms,\n"
476 "PERF: adapter-init to gatt-complete %" PRIu64
" ms\n"
477 "PERF: discovered to processing-start %" PRIu64
" ms,\n"
478 "PERF: discovered to gatt-complete %" PRIu64
" ms,\n"
479 "PERF: SMPKeyBin + LE_PHY %" PRIu64
" ms (SMPKeyBin %" PRIu64
" ms, LE_PHY %" PRIu64
" ms),\n"
480 "PERF: get-gatt-services %" PRIu64
" ms,\n\n",
483 td13, td12, td23, td35);
492 if( HCIStatusCode::SUCCESS != cmd_res ) {
502 if( HCIStatusCode::SUCCESS != cmd_res ) {
507 if( HCIStatusCode::SUCCESS != cmd_res ) {
514 if( response_size != resp.
size() ) {
527 if( 0 != fail_point ) {
532 std::shared_ptr<GattGenericAccessSvc> ga = device->getGattGenericAccess();
533 if(
nullptr != ga && !
QUIET ) {
534 fprintf_td(stderr,
" GenericAccess: %s\n\n", ga->toString().c_str());
537 std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
538 if(
nullptr != gatt && gatt->isConnected() ) {
539 std::shared_ptr<GattDeviceInformationSvc> di = gatt->getDeviceInformation(primServices);
540 if(
nullptr != di && !
QUIET ) {
541 fprintf_td(stderr,
" DeviceInformation: %s\n\n", di->toString().c_str());
547 for(
size_t i=0; i<primServices.
size(); i++) {
550 fprintf_td(stderr,
" [%2.2d] Service UUID %s (%s)\n", i,
551 primService.
type->toUUID128String().c_str(),
552 primService.
type->getTypeSizeString().c_str());
556 for(
size_t j=0; j<serviceCharacteristics.
size(); j++) {
559 fprintf_td(stderr,
" [%2.2d.%2.2d] Characteristic: UUID %s (%s)\n", i, j,
560 serviceChar->value_type->toUUID128String().c_str(),
561 serviceChar->value_type->getTypeSizeString().c_str());
562 fprintf_td(stderr,
" [%2.2d.%2.2d] %s\n", i, j, serviceChar->toString().c_str());
566 if( serviceChar->readValue(value) ) {
569 fprintf_td(stderr,
" [%2.2d.%2.2d] value: %s ('%s')\n", (
int)i, (
int)j, value.
toString().c_str(), sval.c_str());
574 for(
size_t k=0; k<charDescList.
size(); k++) {
577 fprintf_td(stderr,
" [%2.2d.%2.2d.%2.2d] Descriptor: UUID %s (%s)\n", i, j, k,
578 charDesc.
type->toUUID128String().c_str(),
579 charDesc.
type->getTypeSizeString().c_str());
580 fprintf_td(stderr,
" [%2.2d.%2.2d.%2.2d] %s\n", i, j, k, charDesc.
toString().c_str());
583 bool cccdEnableResult[2];
584 if( serviceChar->enableNotificationOrIndication( cccdEnableResult ) ) {
586 bool clAdded = serviceChar->addCharListener( std::make_shared<MyGATTEventListener>(i, j) );
588 fprintf_td(stderr,
" [%2.2d.%2.2d] Characteristic-Listener: Notification(%d), Indication(%d): Added %d\n",
589 (
int)i, (
int)j, cccdEnableResult[0], cccdEnableResult[1], clAdded);
599 }
catch ( std::exception & e ) {
600 fprintf_td(stderr,
"****** Processing Ready Device: Exception caught for %s: %s\n", device->toString().c_str(), e.what());
604 fprintf_td(stderr,
"****** Processing Ready Device: End-1: Success %d on %s\n", success, device->toString().c_str());
606 if( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED ==
discoveryPolicy ) {
607 device->getAdapter().removeDevicePausingDiscovery(*device);
611 while( device->pingGATT() ) {
612 fprintf_td(stderr,
"****** Processing Ready Device: pingGATT OK: %s\n", device->getAddressAndType().toString().c_str());
615 fprintf_td(stderr,
"****** Processing Ready Device: pingGATT failed, waiting for disconnect: %s\n", device->getAddressAndType().toString().c_str());
620 device->getAdapter().printDeviceLists();
623 fprintf_td(stderr,
"****** Processing Ready Device: End-2: Success %d on %s\n", success, device->toString().c_str());
630 device->removeAllCharListener();
641 fprintf_td(stderr,
"****** Processing Ready Device: MULTI_MEASUREMENTS left %d: %s\n",
MULTI_MEASUREMENTS.load(), device->getAddressAndType().toString().c_str());
646 fprintf_td(stderr,
"****** Remove Device: removing: %s\n", device->getAddressAndType().toString().c_str());
652 fprintf_td(stderr,
"****** Reset Adapter: reset[%d] start: %s\n", mode, a->
toString().c_str());
659 fprintf_td(stderr,
"****** Start discovery (%s): Adapter not selected: %s\n", msg.c_str(), a->
toString().c_str());
666 if(
nullptr != gattDevNameChar ) {
667 std::string aname = a->
getName();
668 gattDevNameChar->setValue(
reinterpret_cast<uint8_t*
>(aname.data()), aname.size(), 0);
675 return HCIStatusCode::SUCCESS == status;
680 fprintf_td(stderr,
"initAdapter: Adapter not selected: %s\n", adapter->toString().c_str());
684 if( !adapter->isInitialized() ) {
686 if( HCIStatusCode::SUCCESS != status ) {
687 fprintf_td(stderr,
"initAdapter: Adapter initialization failed: %s: %s\n",
688 to_string(status).c_str(), adapter->toString().c_str());
693 if( !adapter->setPowered(
true ) ) {
694 fprintf_td(stderr,
"initAdapter: Adapter power-on failed:: %s\n", adapter->toString().c_str());
698 fprintf_td(stderr,
"initAdapter: %s\n", adapter->toString().c_str());
700 const LE_Features le_feats = adapter->getLEFeatures();
703 if( adapter->getBTMajorVersion() > 4 ) {
704 LE_PHYs Tx { LE_PHYs::LE_2M }, Rx { LE_PHYs::LE_2M };
706 fprintf_td(stderr,
"initAdapter: Set Default LE PHY: status %s: Tx %s, Rx %s\n",
710 adapter->addStatusListener( asl );
713 adapter->removeStatusListener( asl );
724 fprintf_td(stderr,
"****** Adapter ADDED__: InitOK: %s\n", adapter->toString().c_str());
726 fprintf_td(stderr,
"****** Adapter ADDED__: Ignored: %s\n", adapter->toString().c_str());
729 fprintf_td(stderr,
"****** Adapter ADDED__: Ignored (other): %s\n", adapter->toString().c_str());
734 fprintf_td(stderr,
"****** Adapter REMOVED: %s\n", adapter->toString().c_str());
736 fprintf_td(stderr,
"****** Adapter REMOVED (other): %s\n", adapter->toString().c_str());
754 fprintf_td(stderr,
"****** EOL Test MULTI_MEASUREMENTS left %d, processed %zu/%zu\n",
771 fprintf_td(stderr,
"****** EOL Adapter's Devices - pre close: %s\n", adapter->toString().c_str());
772 adapter->printDeviceLists();
776 fprintf_td(stderr,
"****** EOL Removed ChangedAdapterSetCallback %zu\n", (
size_t)count);
781 fprintf_td(stderr,
"****** EOL Adapter's Devices - post close: %s\n", adapter->toString().c_str());
782 adapter->printDeviceLists();
788int main(
int argc,
char *argv[])
790 bool waitForEnter=
false;
792 fprintf_td(stderr,
"Direct-BT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API);
795 std::string dev_name_prefix =
"LabPad";
800 sec->
io_cap = SMPIOCapability::KEYBOARD_ONLY;
801 sec->
sec_level = BTSecurityLevel::ENC_AUTH;
804 for(
int i=1; i<argc; i++) {
805 fprintf(stderr,
"arg[%d/%d]: '%s'\n", i, argc, argv[i]);
807 if( !strcmp(
"-dbt_debug", argv[i]) && argc > (i+1) ) {
808 setenv(
"direct_bt.debug", argv[++i], 1 );
809 }
else if( !strcmp(
"-dbt_verbose", argv[i]) && argc > (i+1) ) {
810 setenv(
"direct_bt.verbose", argv[++i], 1 );
811 }
else if( !strcmp(
"-dbt_gatt", argv[i]) && argc > (i+1) ) {
812 setenv(
"direct_bt.gatt", argv[++i], 1 );
813 }
else if( !strcmp(
"-dbt_l2cap", argv[i]) && argc > (i+1) ) {
814 setenv(
"direct_bt.l2cap", argv[++i], 1 );
815 }
else if( !strcmp(
"-dbt_hci", argv[i]) && argc > (i+1) ) {
816 setenv(
"direct_bt.hci", argv[++i], 1 );
817 }
else if( !strcmp(
"-dbt_mgmt", argv[i]) && argc > (i+1) ) {
818 setenv(
"direct_bt.mgmt", argv[++i], 1 );
819 }
else if( !strcmp(
"-wait", argv[i]) ) {
821 }
else if( !strcmp(
"-show_update_events", argv[i]) ) {
823 }
else if( !strcmp(
"-quiet", argv[i]) ) {
825 }
else if( !strcmp(
"-discoveryPolicy", argv[i]) ) {
827 }
else if( !strcmp(
"-scanPassive", argv[i]) ) {
829 }
else if( !strcmp(
"-btmode", argv[i]) && argc > (i+1) ) {
831 }
else if( !strcmp(
"-adapter", argv[i]) && argc > (i+1) ) {
833 }
else if( !strcmp(
"-passkey", argv[i]) && argc > (i+1) ) {
835 sec->
passkey = atoi(argv[++i]);
836 fprintf(stderr,
"Set passkey in %s\n", sec->
toString().c_str());
841 fprintf_td(stderr,
"Run with '[-btmode LE|BREDR|DUAL] "
842 "[-disconnect] [-show_update_events] [-quiet] "
843 "[-discoveryPolicy <0-4>] "
845 "[-adapter <adapter_address>] "
846 "(-passkey <digits>)* "
847 "[-dbt_verbose true|false] "
848 "[-dbt_debug true|false|adapter.event,gatt.data,hci.event,hci.scan_ad_eir,mgmt.event] "
849 "[-dbt_mgmt cmd.timeout=3000,ringsize=64,...] "
850 "[-dbt_hci cmd.complete.timeout=10000,cmd.status.timeout=3000,ringsize=64,...] "
851 "[-dbt_gatt cmd.read.timeout=500,cmd.write.timeout=500,cmd.init.timeout=2500,ringsize=128,...] "
852 "[-dbt_l2cap reader.timeout=10000,restart.count=0,...] "
870 fprintf_td(stderr,
"Press ENTER to continue\n");
879 fprintf_td(stderr,
"****** Manager close start\n");
882 fprintf_td(stderr,
"****** Manager close end\n");
void indicationReceived(BTGattCharRef charDecl, const TROOctets &char_value, const uint64_t timestamp, const bool confirmationSent) override
Called from native BLE stack, initiated by a received indication associated with the given BTGattChar...
void notificationReceived(BTGattCharRef charDecl, const TROOctets &char_value, const uint64_t timestamp) override
Called from native BLE stack, initiated by a received notification associated with the given BTGattCh...
MyGATTEventListener(int i_, int j_)
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
HCIStatusCode reset() noexcept
Reset the adapter.
HCIStatusCode startDiscovery(const DBGattServerRef &gattServerData_=nullptr, const DiscoveryPolicy policy=DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY, const bool le_scan_active=true, const uint16_t le_scan_interval=24, const uint16_t le_scan_window=24, const uint8_t filter_policy=0x00, const bool filter_dup=true) noexcept
Starts discovery.
BDAddressAndType const & getAddressAndType() const noexcept
Returns the adapter's public BDAddressAndType, i.e.
std::string getName() const noexcept
Returns the name.
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.
bool hasResponseSet() const noexcept
Return true if a notification or indication response has been set via constructor,...
HCIStatusCode send(const bool prefNoAck, const jau::TROOctets &cmd_data, const jau::fraction_i64 &timeout) noexcept
Send the command to the remote BTDevice.
HCIStatusCode sendOnly(const bool prefNoAck, const jau::TROOctets &cmd_data) noexcept
Send the command to the remote BTDevice, only.
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...
void setResponseMinSize(jau::nsize_t v) noexcept
void setDataCallback(const DataCallback &dcb) noexcept
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.
Representing a complete list of Gatt Service objects from the GATTRole::Server perspective,...
Persistent endian aware octet data, i.e.
std::string toString() const
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 const * get_ptr() const noexcept
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.
static std::unique_ptr< uuid_t > create(TypeSize const t, uint8_t const *const buffer, lb_endian_t const le_or_be)
static bool REMOVE_DEVICE
static const uint8_t filter_policy
static std::atomic< int > deviceReadyCount
int main(int argc, char *argv[])
static const uint16_t le_scan_interval
static const POctets cmd_data2({ 0x01, 0xB8 }, lb_endian::little)
static uint64_t timestamp_t0
static bool SHOW_UPDATE_EVENTS
static const uint16_t le_scan_window
static void connectDiscoveredDevice(BTDeviceRef device)
static void processReadyDevice(const BTDeviceRef &device)
static const bool filter_dup
static bool KEEP_CONNECTED
static bool le_scan_active
static std::shared_ptr< BTAdapter > chosenAdapter
static void myChangedAdapterSetFunc(const bool added, std::shared_ptr< BTAdapter > &adapter)
static bool initAdapter(std::shared_ptr< BTAdapter > &adapter)
static bool startDiscovery(BTAdapter *a, const std::string &msg)
static std::atomic< int > MULTI_MEASUREMENTS
static void resetAdapter(BTAdapter *a, int mode)
static DiscoveryPolicy discoveryPolicy
static std::unique_ptr< uuid_t > cmd_req_uuid
static bool GATT_PING_ENABLED
DBGattServerRef dbGattServer(new DBGattServer(jau::make_darray(std::make_shared< DBGattService >(true, std::make_unique< const jau::uuid16_t >(GattServiceType::GENERIC_ACCESS), jau::make_darray(std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::DEVICE_NAME), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("Jausoft_Dev", 128), true), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::APPEARANCE), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue((uint16_t) 0)))), std::make_shared< DBGattService >(true, std::make_unique< const jau::uuid16_t >(GattServiceType::DEVICE_INFORMATION), jau::make_darray(std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::MANUFACTURER_NAME_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("Gothel Software")), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::MODEL_NUMBER_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("2.4.0-pre")), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::SERIAL_NUMBER_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("sn:0123456789")), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::HARDWARE_REVISION_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("hw:0123456789")), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::FIRMWARE_REVISION_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("fw:0123456789")), std::make_shared< DBGattChar >(std::make_unique< const jau::uuid16_t >(GattCharacteristicType::SOFTWARE_REVISION_STRING), BTGattChar::PropertyBitVal::Read, jau::darray< DBGattDescRef >(), make_gvalue("sw:0123456789")))))))
static const POctets cmd_data1({ 0x00, 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x5E, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x9B, 0x23, 0x84 }, lb_endian::little)
static int RESET_ADAPTER_EACH_CONN
static void removeDevice(BTDeviceRef device)
static const POctets resp_exp({ 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x01, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x64, 0x17, 0x01, 0xed }, lb_endian::little)
static std::unique_ptr< uuid_t > cmd_rsp_uuid
static const uuid16_t _TEMPERATURE_MEASUREMENT(GattCharacteristicType::TEMPERATURE_MEASUREMENT)
constexpr const char CLIENT_KEY_PATH[]
C++20 we could use constexpr std::string
constexpr UnaryFunction for_each_const(T &data, UnaryFunction f, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept
uint32_t dfa_utf8_decode(uint32_t &state, uint32_t &codep, const uint32_t byte_value)
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,.
Entry * getOrCreate(const std::string &addrOrNameSub) noexcept
Determines whether the given addrOrNameSub is a EUI48Sub or just a name and retrieves an 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
LE_PHYs
LE Transport PHY bit values.
Entry * get(const EUI48 &addr, const std::string &name, AddressNameEntryMatchFunc m) noexcept
Returns a matching BTSecurityRegistry::Entry with the given addr and/or name.
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
BTMode to_BTMode(const std::string &value) noexcept
Maps the specified name to a constant of BTMode.
std::string allToString() noexcept
BTSecurityLevel
Bluetooth Security Level.
PairingMode
Bluetooth secure pairing mode.
constexpr DiscoveryPolicy to_DiscoveryPolicy(const uint8_t v) noexcept
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< BTGattChar > BTGattCharRef
jau::POctets make_gvalue(const char *name)
Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values.
std::shared_ptr< DBGattServer > DBGattServerRef
std::shared_ptr< DBGattChar > DBGattCharRef
constexpr darray< First > make_darray(First &&arg1, Next &&... argsN)
Construct a darray<T> instance, initialized by move semantics from the variadic (template pack) argum...
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
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
std::string to_hexstring(value_type const &v) noexcept
Produce a lower-case hexadecimal string representation of the given pointer.
std::string getProcessedDevicesString() noexcept
void addToWaitForDevices(const std::string &addrOrNameSub) noexcept
size_t getProcessedDeviceCount() noexcept
std::string getWaitForDevicesString() noexcept
bool isDeviceProcessed(const BDAddressAndType &a) noexcept
bool areAllDevicesProcessed(DeviceQueryMatchFunc m) noexcept
Returns true if all addToWaitForDevices() awaited devices have been addToProcessedDevices() processed...
bool isWaitingForAnyDevice() noexcept
size_t getWaitForDevicesCount() noexcept
void addToProcessedDevices(const BDAddressAndType &a, const std::string &n) noexcept
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.
BTSecurityLevel sec_level
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...
std::string toString() const noexcept
@ GENERIC_ACCESS
This service contains generic information about the device.
@ DEVICE_INFORMATION
This service exposes manufacturer and/or vendor information about a device.
@ SOFTWARE_REVISION_STRING
@ MANUFACTURER_NAME_STRING
@ TEMPERATURE_MEASUREMENT
@ FIRMWARE_REVISION_STRING
@ HARDWARE_REVISION_STRING