Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Functions | Variables
dbt_scanner10.cpp File Reference

This dbt_scanner10 C++ scanner ::BTRole::Master GATT client example uses an event driven workflow and multithreading, i.e. More...

#include <cstring>
#include <string>
#include <memory>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <cinttypes>
#include <pthread.h>
#include <csignal>
#include <jau/cpp_lang_util.hpp>
#include <jau/dfa_utf8_decode.hpp>
#include <jau/basic_algos.hpp>
#include <jau/darray.hpp>
#include <direct_bt/DirectBT.hpp>
#include <unistd.h>
#include "dbt_constants.hpp"
#include <cstdio>
Include dependency graph for dbt_scanner10.cpp:

Go to the source code of this file.

Classes

class  MyAdapterStatusListener
 
class  MyGATTEventListener
 

Functions

static void connectDiscoveredDevice (BTDeviceRef device)
 
static bool initAdapter (std::shared_ptr< BTAdapter > &adapter)
 
int main (int argc, char *argv[])
 
static void myChangedAdapterSetFunc (const bool added, std::shared_ptr< BTAdapter > &adapter)
 
static void processReadyDevice (const BTDeviceRef &device)
 
static void removeDevice (BTDeviceRef device)
 
static void resetAdapter (BTAdapter *a, int mode)
 
static bool startDiscovery (BTAdapter *a, const std::string &msg)
 
void test ()
 

Variables

static const uuid16_t _TEMPERATURE_MEASUREMENT (GattCharacteristicType::TEMPERATURE_MEASUREMENT)
 
static BTMode btMode = BTMode::DUAL
 
static std::shared_ptr< BTAdapterchosenAdapter = nullptr
 
static uint8_t cmd_arg = 0x44
 
static std::unique_ptr< uuid_tcmd_rsp_uuid = jau::uuid_t::create(std::string("d0ca6bf3-3d53-4760-98e5-fc5883e93712"))
 
static std::unique_ptr< uuid_tcmd_uuid = jau::uuid_t::create(std::string("d0ca6bf3-3d52-4760-98e5-fc5883e93712"))
 
static std::atomic< int > deviceReadyCount = 0
 
static DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY
 
static const bool filter_dup = true
 
static const uint8_t filter_policy = 0
 
static bool GATT_PING_ENABLED = false
 
static bool KEEP_CONNECTED = true
 
static bool le_scan_active = true
 
static const uint16_t le_scan_interval = 24
 
static const uint16_t le_scan_window = 24
 
static std::atomic< int > MULTI_MEASUREMENTS = 8
 
static bool QUIET = false
 
static bool REMOVE_DEVICE = true
 
static int RESET_ADAPTER_EACH_CONN = 0
 
static bool SHOW_UPDATE_EVENTS = false
 
static uint64_t timestamp_t0
 
static bool use_privacy = false
 
static EUI48 useAdapter = EUI48::ALL_DEVICE
 

Detailed Description

This dbt_scanner10 C++ scanner ::BTRole::Master GATT client example uses an event driven workflow and multithreading, i.e.

one thread processes each found device when notified.

dbt_scanner10 represents the recommended utilization of Direct-BT.

dbt_scanner10 Invocation Examples:

Using scripts/run-dbt_scanner10.sh from dist directory:

Special Actions

Definition in file dbt_scanner10.cpp.

Function Documentation

◆ connectDiscoveredDevice()

static void connectDiscoveredDevice ( BTDeviceRef  device)
static
Examples
dbt_scanner10.cpp.

Definition at line 358 of file dbt_scanner10.cpp.

◆ processReadyDevice()

static void processReadyDevice ( const BTDeviceRef device)
static
Examples
dbt_scanner10.cpp.

Definition at line 403 of file dbt_scanner10.cpp.

◆ removeDevice()

static void removeDevice ( BTDeviceRef  device)
static
Examples
dbt_scanner10.cpp.

Definition at line 606 of file dbt_scanner10.cpp.

◆ resetAdapter()

static void resetAdapter ( BTAdapter a,
int  mode 
)
static
Examples
dbt_scanner10.cpp.

Definition at line 612 of file dbt_scanner10.cpp.

Here is the caller graph for this function:

◆ startDiscovery()

static bool startDiscovery ( BTAdapter a,
const std::string &  msg 
)
static
Examples
dbt_scanner10.cpp.

Definition at line 618 of file dbt_scanner10.cpp.

Here is the caller graph for this function:

◆ initAdapter()

static bool initAdapter ( std::shared_ptr< BTAdapter > &  adapter)
static
Examples
dbt_scanner10.cpp.

Definition at line 628 of file dbt_scanner10.cpp.

Here is the caller graph for this function:

◆ myChangedAdapterSetFunc()

static void myChangedAdapterSetFunc ( const bool  added,
std::shared_ptr< BTAdapter > &  adapter 
)
static
Examples
dbt_scanner10.cpp.

Definition at line 669 of file dbt_scanner10.cpp.

Here is the caller graph for this function:

◆ test()

void test ( )
Examples
dbt_scanner10.cpp.

Definition at line 691 of file dbt_scanner10.cpp.

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)
Examples
dbt_scanner10.cpp.

Definition at line 738 of file dbt_scanner10.cpp.

Variable Documentation

◆ timestamp_t0

uint64_t timestamp_t0
static
Examples
dbt_scanner10.cpp.

Definition at line 112 of file dbt_scanner10.cpp.

◆ useAdapter

EUI48 useAdapter = EUI48::ALL_DEVICE
static
Examples
dbt_scanner10.cpp.

Definition at line 114 of file dbt_scanner10.cpp.

◆ btMode

BTMode btMode = BTMode::DUAL
static
Examples
dbt_scanner10.cpp.

Definition at line 115 of file dbt_scanner10.cpp.

◆ use_privacy

bool use_privacy = false
static
Examples
dbt_scanner10.cpp.

Definition at line 116 of file dbt_scanner10.cpp.

◆ discoveryPolicy

DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY
static
Examples
dbt_scanner10.cpp.

Definition at line 118 of file dbt_scanner10.cpp.

◆ le_scan_active

bool le_scan_active = true
static
Examples
dbt_scanner10.cpp.

Definition at line 119 of file dbt_scanner10.cpp.

◆ le_scan_interval

const uint16_t le_scan_interval = 24
static
Examples
dbt_scanner10.cpp.

Definition at line 120 of file dbt_scanner10.cpp.

◆ le_scan_window

const uint16_t le_scan_window = 24
static
Examples
dbt_scanner10.cpp.

Definition at line 121 of file dbt_scanner10.cpp.

◆ filter_policy

const uint8_t filter_policy = 0
static
Examples
dbt_scanner10.cpp.

Definition at line 122 of file dbt_scanner10.cpp.

◆ filter_dup

const bool filter_dup = true
static
Examples
dbt_scanner10.cpp.

Definition at line 123 of file dbt_scanner10.cpp.

◆ chosenAdapter

std::shared_ptr<BTAdapter> chosenAdapter = nullptr
static
Examples
dbt_scanner10.cpp.

Definition at line 125 of file dbt_scanner10.cpp.

◆ RESET_ADAPTER_EACH_CONN

int RESET_ADAPTER_EACH_CONN = 0
static
Examples
dbt_scanner10.cpp.

Definition at line 127 of file dbt_scanner10.cpp.

◆ deviceReadyCount

std::atomic<int> deviceReadyCount = 0
static
Examples
dbt_scanner10.cpp.

Definition at line 128 of file dbt_scanner10.cpp.

◆ MULTI_MEASUREMENTS

std::atomic<int> MULTI_MEASUREMENTS = 8
static
Examples
dbt_scanner10.cpp.

Definition at line 130 of file dbt_scanner10.cpp.

◆ KEEP_CONNECTED

bool KEEP_CONNECTED = true
static
Examples
dbt_scanner10.cpp.

Definition at line 132 of file dbt_scanner10.cpp.

◆ GATT_PING_ENABLED

bool GATT_PING_ENABLED = false
static
Examples
dbt_scanner10.cpp.

Definition at line 133 of file dbt_scanner10.cpp.

◆ REMOVE_DEVICE

bool REMOVE_DEVICE = true
static
Examples
dbt_scanner10.cpp.

Definition at line 134 of file dbt_scanner10.cpp.

◆ cmd_uuid

std::unique_ptr<uuid_t> cmd_uuid = jau::uuid_t::create(std::string("d0ca6bf3-3d52-4760-98e5-fc5883e93712"))
static
Examples
dbt_scanner10.cpp.

Definition at line 137 of file dbt_scanner10.cpp.

◆ cmd_rsp_uuid

std::unique_ptr<uuid_t> cmd_rsp_uuid = jau::uuid_t::create(std::string("d0ca6bf3-3d53-4760-98e5-fc5883e93712"))
static
Examples
dbt_scanner10.cpp.

Definition at line 138 of file dbt_scanner10.cpp.

◆ cmd_arg

uint8_t cmd_arg = 0x44
static
Examples
dbt_scanner10.cpp.

Definition at line 139 of file dbt_scanner10.cpp.

◆ SHOW_UPDATE_EVENTS

bool SHOW_UPDATE_EVENTS = false
static
Examples
dbt_scanner10.cpp.

Definition at line 141 of file dbt_scanner10.cpp.

◆ QUIET

bool QUIET = false
static
Examples
dbt_scanner10.cpp.

Definition at line 142 of file dbt_scanner10.cpp.

◆ _TEMPERATURE_MEASUREMENT