25#ifndef DBT_SERVER01_HPP_
26#define DBT_SERVER01_HPP_
46 static const bool GATT_VERBOSE =
false;
47 static const bool SHOW_UPDATE_EVENTS =
false;
49 const std::string adapterShortName =
"TDev1Srv";
50 std::string adapterName =
"TestDev1_Srv";
52 BTMode btMode = BTMode::DUAL;
62 bool do_disconnect_randomly =
false;
67 std::make_shared<DBGattService> (
true ,
79 std::make_shared<DBGattService> (
true ,
107 std::make_shared<DBGattService> (
true ,
113 std::make_shared<DBGattDesc>( BTGattDesc::TYPE_USER_DESC,
make_gvalue(
"DATA_STATIC") )
115 make_gvalue(
"Proprietary Static Data 0x00010203") ),
119 std::make_shared<DBGattDesc>( BTGattDesc::TYPE_USER_DESC,
make_gvalue(
"COMMAND") )
125 std::make_shared<DBGattDesc>( BTGattDesc::TYPE_USER_DESC,
make_gvalue(
"RESPONSE") ),
126 DBGattDesc::createClientCharConfig()
132 std::make_shared<DBGattDesc>( BTGattDesc::TYPE_USER_DESC,
make_gvalue(
"DATA_PULSE") ),
133 DBGattDesc::createClientCharConfig()
144 const std::lock_guard<std::mutex> lock(mtx_sync);
145 connectedDevice = cd;
149 const std::lock_guard<std::mutex> lock(mtx_sync);
150 return connectedDevice;
155 return nullptr != d ? (*d) == *device :
false;
165 const AdapterSetting changedmask,
const uint64_t timestamp)
override {
166 const bool initialSetting = AdapterSetting::NONE == oldmask;
167 if( initialSetting ) {
168 fprintf_td(stderr,
"****** Server SETTINGS_INITIAL: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
171 fprintf_td(stderr,
"****** Server SETTINGS_CHANGED: %s -> %s, changed %s\n",
to_string(oldmask).c_str(),
176 if( justPoweredOn && *parent.serverAdapter == a ) {
180 fprintf_td(stderr,
"Server Status BTAdapter:\n");
186 fprintf_td(stderr,
"****** Server DISCOVERING: meta %s, changed[%s, enabled %d, policy %s]: %s\n",
191 bool deviceFound(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
194 fprintf_td(stderr,
"****** Server FOUND__-1: NOP %s\n", device->toString(
true).c_str());
198 void deviceUpdated(
const BTDeviceRef& device,
const EIRDataType updateMask,
const uint64_t timestamp)
override {
199 if( SHOW_UPDATE_EVENTS ) {
200 fprintf_td(stderr,
"****** Server UPDATED: %s of %s\n",
to_string(updateMask).c_str(), device->toString(
true).c_str());
205 void deviceConnected(
const BTDeviceRef& device,
const bool discovered,
const uint64_t timestamp)
override {
206 fprintf_td(stderr,
"****** Server CONNECTED (discovered %d): %s\n", discovered, device->toString(
true).c_str());
207 const bool available =
nullptr == parent.getDevice();
209 parent.setDevice(device);
216 fprintf_td(stderr,
"****** Server PAIRING STATE: state %s, mode %s, %s\n",
220 case SMPPairingState::NONE:
223 case SMPPairingState::FAILED: {
226 case SMPPairingState::REQUESTED_BY_RESPONDER:
229 case SMPPairingState::FEATURE_EXCHANGE_STARTED:
232 case SMPPairingState::FEATURE_EXCHANGE_COMPLETED:
235 case SMPPairingState::PASSKEY_EXPECTED: {
237 if(
nullptr != sec && sec->
getPairingPasskey() != BTSecurityRegistry::Entry::NO_PASSKEY ) {
238 std::thread dc(&BTDevice::setPairingPasskey, device,
static_cast<uint32_t
>( sec->
getPairingPasskey() ));
241 std::thread dc(&BTDevice::setPairingPasskey, device, 0);
247 case SMPPairingState::NUMERIC_COMPARE_EXPECTED: {
249 if(
nullptr != sec ) {
253 std::thread dc(&BTDevice::setPairingNumericComparison, device,
false);
258 case SMPPairingState::OOB_EXPECTED:
261 case SMPPairingState::KEY_DISTRIBUTION:
264 case SMPPairingState::COMPLETED:
272 void deviceReady(
const BTDeviceRef& device,
const uint64_t timestamp)
override {
274 fprintf_td(stderr,
"****** Server READY-1: NOP %s\n", device->toString(
true).c_str());
277 void deviceDisconnected(
const BTDeviceRef& device,
const HCIStatusCode reason,
const uint16_t handle,
const uint64_t timestamp)
override {
278 fprintf_td(stderr,
"****** Server DISCONNECTED (count %zu): Reason 0x%X (%s), old handle %s: %s\n",
279 1+parent.disconnectCount.
load(),
static_cast<uint8_t
>(reason),
to_string(reason).c_str(),
280 to_hexstring(handle).c_str(), device->toString(
true).c_str());
282 const bool match = parent.matches(device);
284 parent.setDevice(
nullptr);
287 std::thread sd(&DBTServer01::processDisconnectedDevice, &parent, device);
292 std::string toString()
const noexcept override {
293 return "Server MyAdapterStatusListener[this "+
to_hexstring(
this)+
"]";
312 const BTDeviceRef connectedDevice_ = parent.getDevice();
313 const std::string connectedDeviceStr =
nullptr != connectedDevice_ ? connectedDevice_->toString() :
"n/a";
314 fprintf_td(stderr,
"****** Server GATT::PULSE Start %s\n", connectedDeviceStr.c_str());
318 if(
nullptr != connectedDevice_ && connectedDevice_->getConnected() ) {
319 if( 0 != handlePulseDataNotify || 0 != handlePulseDataIndicate ) {
320 std::string data(
"Dynamic Data Example. Elapsed Milliseconds: "+
jau::to_decstring(environment::getElapsedMillisecond(),
',', 9) );
323 if( 0 != handlePulseDataNotify ) {
325 fprintf_td(stderr,
"****** Server GATT::sendNotification: PULSE to %s\n", connectedDevice_->toString().c_str());
327 connectedDevice_->sendNotification(handlePulseDataNotify, v);
329 if( 0 != handlePulseDataIndicate ) {
331 fprintf_td(stderr,
"****** Server GATT::sendIndication: PULSE to %s\n", connectedDevice_->toString().c_str());
333 connectedDevice_->sendIndication(handlePulseDataIndicate, v);
343 const BTDeviceRef connectedDevice_ = parent.getDevice();
344 const std::string connectedDeviceStr =
nullptr != connectedDevice_ ? connectedDevice_->toString() :
"n/a";
345 fprintf_td(stderr,
"****** Server GATT::PULSE End %s\n", connectedDeviceStr.c_str());
350 if(
nullptr != connectedDevice_ && connectedDevice_->getConnected() ) {
351 if( 0 != handleResponseDataNotify || 0 != handleResponseDataIndicate ) {
352 if( 0 != handleResponseDataNotify ) {
354 fprintf_td(stderr,
"****** GATT::sendNotification: %s to %s\n",
355 data.
toString().c_str(), connectedDevice_->toString().c_str());
357 connectedDevice_->sendNotification(handleResponseDataNotify, data);
359 if( 0 != handleResponseDataIndicate ) {
361 fprintf_td(stderr,
"****** GATT::sendIndication: %s to %s\n",
362 data.
toString().c_str(), connectedDevice_->toString().c_str());
364 connectedDevice_->sendIndication(handleResponseDataIndicate, data);
371 void disconnectDeviceRandomly() {
374 static const int sleep_min = 100;
375 static const int sleep_max = 1500;
376 static std::random_device rng_hw;;
377 static std::uniform_int_distribution<int> rng_dist(sleep_min, sleep_max);
378 const int64_t sleep_dur = rng_dist(rng_hw);
381 if(
nullptr != connectedDevice_ ) {
382 fprintf_td(stderr,
"****** Server i470 disconnectDevice(delayed %d ms): client %s\n", sleep_dur, connectedDevice_->toString().c_str());
383 connectedDevice_->disconnect();
385 fprintf_td(stderr,
"****** Server i470 disconnectDevice(delayed %d ms): client null\n", sleep_dur);
399 pulse_service.
start();
403 pulse_service.
stop();
407 const std::lock_guard<std::mutex> lock(parent.mtx_sync);
409 handlePulseDataNotify = 0;
410 handlePulseDataIndicate = 0;
411 handleResponseDataNotify = 0;
412 handleResponseDataIndicate = 0;
418 void close()
noexcept {
419 pulse_service.
stop();
423 void connected(
const BTDeviceRef& device,
const uint16_t initialMTU)
override {
424 const bool match = parent.matches(device);
425 fprintf_td(stderr,
"****** Server GATT::connected(match %d): initMTU %d, %s\n",
426 match, (
int)initialMTU, device->toString().c_str());
428 const std::lock_guard<std::mutex> lock(parent.mtx_sync);
429 usedMTU = initialMTU;
433 void disconnected(
const BTDeviceRef& device)
override {
434 const bool match = parent.matches(device);
435 fprintf_td(stderr,
"****** Server GATT::disconnected(match %d): %s\n", match, device->toString().c_str());
441 void mtuChanged(
const BTDeviceRef& device,
const uint16_t mtu)
override {
442 const bool match = parent.matches(device);
443 const uint16_t usedMTU_old = usedMTU;
445 const std::lock_guard<std::mutex> lock(parent.mtx_sync);
448 fprintf_td(stderr,
"****** Server GATT::mtuChanged(match %d, served %zu, left %zu): %d -> %d, %s\n",
449 match, parent.servedProtocolSessionsTotal.
load(), parent.servingProtocolSessionsLeft.
load(),
450 match ? (
int)usedMTU_old : 0, (
int)mtu, device->toString().c_str());
451 if( parent.do_disconnect_randomly ) {
453 std::thread disconnectThread(&MyGATTServerListener::disconnectDeviceRandomly,
this);
454 disconnectThread.detach();
459 const bool match = parent.matches(device);
461 fprintf_td(stderr,
"****** Server GATT::readCharValue(match %d): to %s, from\n %s\n %s\n",
462 match, device->toString().c_str(), s->toString().c_str(), c->toString().c_str());
468 const bool match = parent.matches(device);
470 fprintf_td(stderr,
"****** Server GATT::readDescValue(match %d): to %s, from\n %s\n %s\n %s\n",
471 match, device->toString().c_str(), s->toString().c_str(), c->toString().c_str(), d->toString().c_str());
477 const bool match = parent.matches(device);
479 fprintf_td(stderr,
"****** Server GATT::writeCharValue(match %d): %s '%s' @ %u from %s, to\n %s\n %s\n",
482 device->toString().c_str(), s->toString().c_str(), c->toString().c_str());
488 const bool match = parent.matches(device);
490 bool isFinalHandshake =
false;
491 bool isFinalHandshakeSuccess =
false;
495 ( 0 != handleResponseDataNotify || 0 != handleResponseDataIndicate ) )
499 isFinalHandshake = isFinalHandshakeSuccess ||
503 if( isFinalHandshake ) {
504 if( isFinalHandshakeSuccess ) {
505 parent.servedProtocolSessionsSuccess++;
507 parent.servedProtocolSessionsTotal++;
508 if( parent.servingProtocolSessionsLeft > 0 ) {
509 parent.servingProtocolSessionsLeft--;
514 std::thread senderThread(&MyGATTServerListener::sendResponse,
this, value2);
515 senderThread.detach();
517 if( GATT_VERBOSE || isFinalHandshake ) {
518 fprintf_td(stderr,
"****** Server GATT::writeCharValueDone(match %d, finalCmd %d, sessions [%d ok / %d total], left %d): From %s, to\n %s\n %s\n Char-Value: %s\n",
519 match, isFinalHandshake, parent.servedProtocolSessionsSuccess.
load(), parent.servedProtocolSessionsTotal.
load(), parent.servingProtocolSessionsLeft.
load(),
520 device->toString().c_str(), s->toString().c_str(), c->toString().c_str(), value.
toString().c_str());
525 const bool match = parent.matches(device);
527 fprintf_td(stderr,
"****** Server GATT::writeDescValue(match %d): %s '%s' @ %u from %s\n %s\n %s\n %s\n",
530 device->toString().c_str(), s->toString().c_str(), c->toString().c_str(), d->toString().c_str());
536 const bool match = parent.matches(device);
538 fprintf_td(stderr,
"****** Server GATT::writeDescValueDone(match %d): From %s\n %s\n %s\n %s\n Desc-Value: %s\n",
539 match, device->toString().c_str(), s->toString().c_str(), c->toString().c_str(), d->toString().c_str(), value.
toString().c_str());
544 const bool match = parent.matches(device);
547 fprintf_td(stderr,
"****** GATT::clientCharConfigChanged(match %d): notify %d, indicate %d from %s\n %s\n %s\n %s\n Desc-Value: %s\n",
548 match, notificationEnabled, indicationEnabled,
549 device->toString().c_str(), s->toString().c_str(), c->toString().c_str(), d->toString().c_str(), value.
toString().c_str());
553 const std::lock_guard<std::mutex> lock(parent.mtx_sync);
554 handlePulseDataNotify = notificationEnabled ? c->getValueHandle() : 0;
555 handlePulseDataIndicate = indicationEnabled ? c->getValueHandle() : 0;
557 const std::lock_guard<std::mutex> lock(parent.mtx_sync);
558 handleResponseDataNotify = notificationEnabled ? c->getValueHandle() : 0;
559 handleResponseDataIndicate = indicationEnabled ? c->getValueHandle() : 0;
565 std::shared_ptr<MyGATTServerListener> gattServerListener = std::make_shared<MyGATTServerListener>(*
this);
566 std::shared_ptr<AdapterStatusListener> myAdapterStatusListener = std::make_shared<MyAdapterStatusListener>(*
this);
573 const bool use_SC_,
const BTSecurityLevel adapterSecurityLevel_,
const bool do_disconnect_randomly_=
false)
575 this->adapterName = adapterName_;
576 this->useAdapter = useAdapter_;
577 this->btMode = btMode_;
578 this->use_SC = use_SC_;
579 this->adapterSecurityLevel = adapterSecurityLevel_;
580 this->do_disconnect_randomly = do_disconnect_randomly_;
586 fprintf_td(stderr,
"****** Server dtor: running_threads %zu\n", running_threads.
value());
590 std::string
getName()
override {
return adapterName; }
595 this->serverAdapter = serverAdapter_;
601 static const uint16_t adv_interval_min=160;
602 static const uint16_t adv_interval_max=480;
603 static const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND;
604 static const uint8_t adv_chan_map=0x07;
605 static const uint8_t filter_policy=0x00;
609 void close(
const std::string& msg)
override {
610 fprintf_td(stderr,
"****** Server Close.0: %s\n", msg.c_str());
611 REQUIRE(
true == serverAdapter->removeStatusListener( myAdapterStatusListener ) );
613 stopAdvertising(msg);
615 if(
nullptr != connectedDevice_ ) {
617 connectedDevice_->disconnect();
620 gattServerListener->close();
621 fprintf_td(stderr,
"****** Server close: running_threads %zu\n", running_threads.
value());
625 stopAdvertising(msg);
626 fprintf_td(stderr,
"****** Server Close.X: %s\n", msg.c_str());
630 servingProtocolSessionsLeft = v;
633 return servingProtocolSessionsLeft;
636 return servedProtocolSessionsTotal;
639 return servedProtocolSessionsSuccess;
642 return disconnectCount;
648 fprintf_td(stderr,
"****** Server Stop advertising (%s) result: %s: %s\n", msg.c_str(),
to_string(status).c_str(), serverAdapter->toString().c_str());
656 EIRDataType adv_mask = EIRDataType::FLAGS | EIRDataType::SERVICE_UUID;
657 EIRDataType scanrsp_mask = EIRDataType::NAME | EIRDataType::CONN_IVAL;
659 eir.
addFlags(GAPFlags::LE_Gen_Disc);
660 eir.
addFlags(GAPFlags::BREDR_UNSUP);
665 eir.setName(serverAdapter->getName());
670 if(
nullptr != gattDevNameChar ) {
671 std::string aname = serverAdapter->getName();
672 gattDevNameChar->setValue(
reinterpret_cast<uint8_t*
>(aname.data()), aname.size(), 0);
675 fprintf_td(stderr,
"****** Start advertising (%s): EIR %s\n", msg.c_str(), eir.
toString().c_str());
676 fprintf_td(stderr,
"****** Start advertising (%s): adv %s, scanrsp %s\n", msg.c_str(),
to_string(adv_mask).c_str(),
to_string(scanrsp_mask).c_str());
679 adv_interval_min, adv_interval_max,
680 adv_type, adv_chan_map, filter_policy);
681 fprintf_td(stderr,
"****** Server Start advertising (%s) result: %s: %s\n", msg.c_str(),
to_string(status).c_str(), serverAdapter->toString().c_str());
689 void processDisconnectedDevice(
BTDeviceRef device) {
690 fprintf_td(stderr,
"****** Server Disconnected Device (count %zu, served %zu, left %zu): Start %s\n",
691 1+disconnectCount.
load(), servedProtocolSessionsTotal.
load(), servingProtocolSessionsLeft.
load(), device->toString().c_str());
694 stopAdvertising(
"device-disconnected");
701 if( servingProtocolSessionsLeft > 0 ) {
705 fprintf_td(stderr,
"****** Server Disonnected Device: End %s\n", device->toString().c_str());
712 if( useAdapter != EUI48::ALL_DEVICE && useAdapter != adapter->getAddressAndType().address ) {
713 fprintf_td(stderr,
"initServerAdapter: Adapter not selected: %s\n", adapter->toString().c_str());
716 adapterName = adapterName +
"-" + adapter->getAddressAndType().address.toString();
718 auto it =
std::remove( adapterName.begin(), adapterName.end(),
':');
719 adapterName.erase(it, adapterName.end());
722 if( !adapter->isInitialized() ) {
724 const HCIStatusCode status = adapter->initialize( btMode,
false );
725 if( HCIStatusCode::SUCCESS != status ) {
726 fprintf_td(stderr,
"initServerAdapter: initialize failed: %s: %s\n",
727 to_string(status).c_str(), adapter->toString().c_str());
730 }
else if( !adapter->setPowered(
false ) ) {
731 fprintf_td(stderr,
"initServerAdapter: setPower.1 off failed: %s\n", adapter->toString().c_str());
735 fprintf_td(stderr,
"initServerAdapter.1: %s\n", adapter->toString().c_str());
738 HCIStatusCode status = adapter->setName(adapterName, adapterShortName);
739 if( HCIStatusCode::SUCCESS == status ) {
740 fprintf_td(stderr,
"initServerAdapter: setLocalName OK: %s\n", adapter->toString().c_str());
742 fprintf_td(stderr,
"initServerAdapter: setLocalName failed: %s\n", adapter->toString().c_str());
746 status = adapter->setSecureConnections( use_SC );
747 if( HCIStatusCode::SUCCESS == status ) {
748 fprintf_td(stderr,
"initServerAdapter: setSecureConnections OK: %s\n", adapter->toString().c_str());
750 fprintf_td(stderr,
"initServerAdapter: setSecureConnections failed: %s\n", adapter->toString().c_str());
754 const uint16_t conn_min_interval = 8;
755 const uint16_t conn_max_interval = 40;
756 const uint16_t conn_latency = 0;
757 const uint16_t supervision_timeout = 50;
758 status = adapter->setDefaultConnParam(conn_min_interval, conn_max_interval, conn_latency, supervision_timeout);
759 if( HCIStatusCode::SUCCESS == status ) {
760 fprintf_td(stderr,
"initServerAdapter: setDefaultConnParam OK: %s\n", adapter->toString().c_str());
761 }
else if( HCIStatusCode::UNKNOWN_COMMAND == status ) {
762 fprintf_td(stderr,
"initServerAdapter: setDefaultConnParam UNKNOWN_COMMAND (ignored): %s\n", adapter->toString().c_str());
764 fprintf_td(stderr,
"initServerAdapter: setDefaultConnParam failed: %s, %s\n",
to_string(status).c_str(), adapter->toString().c_str());
768 if( !adapter->setPowered(
true ) ) {
769 fprintf_td(stderr,
"initServerAdapter: setPower.2 on failed: %s\n", adapter->toString().c_str());
774 fprintf_td(stderr,
"initServerAdapter.2: %s\n", adapter->toString().c_str());
777 const LE_Features le_feats = adapter->getLEFeatures();
780 if( adapter->getBTMajorVersion() > 4 ) {
781 LE_PHYs Tx { LE_PHYs::LE_2M }, Rx { LE_PHYs::LE_2M };
783 fprintf_td(stderr,
"initServerAdapter: Set Default LE PHY: status %s: Tx %s, Rx %s\n",
788 REQUIRE(
true == adapter->addStatusListener( myAdapterStatusListener ) );
790 adapter->setServerConnSecurity(adapterSecurityLevel, SMPIOCapability::UNSET);
static constexpr const char SERVER_KEY_PATH[]
static const jau::uuid128_t ResponseUUID
static const jau::uuid128_t StaticDataUUID
static const jau::uuid128_t CommandUUID
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.
static const jau::uuid128_t DataServiceUUID
static const jau::uuid128_t PulseDataUUID
This peripheral BTRole::Slave test participant works with DBTClient00.
void setAdapter(BTAdapterRef serverAdapter_) override
Set the server adapter for this endpoint.
int getProtocolSessionsDoneTotal() override
int getProtocolSessionsLeft() override
BTSecurityLevel getSecurityLevel() override
void setProtocolSessionsLeft(const int v) override
BTAdapterRef getAdapter() override
Return the adapter for this endpoint.
int getDisconnectCount() override
void close(const std::string &msg) override
DBTServer01(const std::string &adapterName_, const jau::EUI48 &useAdapter_, const BTMode btMode_, const bool use_SC_, const BTSecurityLevel adapterSecurityLevel_, const bool do_disconnect_randomly_=false)
int getProtocolSessionsDoneSuccess() override
bool initAdapter(BTAdapterRef adapter) override
Initialize the given adapter for this endpoint.
HCIStatusCode startAdvertising(const std::string &msg) override
std::string getName() override
Return name of this endpoint, which becomes the adapter's name.
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
Listener to remote master device's operations on the local GATT-Server.
Collection of 'Extended Advertising Data' (EAD), 'Advertising Data' (AD) or 'Extended Inquiry Respons...
std::string toString(const bool includeServices=true) const noexcept
void setServicesComplete(const bool v) noexcept
void addFlags(GAPFlags f) noexcept
bool addService(const std::shared_ptr< const jau::uuid_t > &uuid) noexcept
void setConnInterval(const uint16_t min, const uint16_t max) noexcept
Set slave connection interval range.
Persistent endian aware octet data, i.e.
std::string toString() const
void put_string_nc(const nsize_t i, const std::string &v, const nsize_t max_len, const bool includeEOS) noexcept
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
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.
Service runner, a reusable dedicated thread performing custom user services.
bool stop() noexcept
Stops this service, if running.
bool shall_stop() const noexcept
Returns true if service shall stop.
void start() noexcept
Starts this service, if not running already.
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")))))))
std::shared_ptr< DBTServer01 > DBTServer01Ref
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
constexpr const jau::fraction_i64 THREAD_SHUTDOWN_TIMEOUT_MS
Maximum time in fractions of seconds to wait for a thread shutdown.
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.
void clear() noexcept
Clears internal list.
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.
AD_PDU_Type
LE Advertising (AD) Protocol Data Unit (PDU) Types.
PairingMode
Bluetooth secure pairing mode.
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< DBGattDesc > DBGattDescRef
jau::POctets make_gvalue(const char *name)
Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values.
std::shared_ptr< DBGattService > DBGattServiceRef
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.
jau::function< R(A...)> bind_member(C1 *base, R(C0::*mfunc)(A...)) noexcept
Bind given class instance and non-void member function to an anonymous function using func_member_tar...
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.
std::string to_decstring(const value_type &v, const char separator=',', const nsize_t width=0) noexcept
Produce a decimal string representation of an integral integer value.
__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.
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 int getPairingPasskey() const noexcept
constexpr bool getPairingNumericComparison() const noexcept
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...
static const EUI48 ALL_DEVICE
EUI48 MAC address matching all device, i.e.
CXX_ALWAYS_INLINE _Tp load() 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
@ FIRMWARE_REVISION_STRING
@ HARDWARE_REVISION_STRING