Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Classes | Functions | Variables
dbt_scanner10.cpp File Reference
#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 <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 (std::shared_ptr< BTDevice > device)
 
static void processReadyDevice (std::shared_ptr< BTDevice > device)
 
static void removeDevice (std::shared_ptr< BTDevice > device)
 
static void resetAdapter (BTAdapter *a, int mode)
 
static bool startDiscovery (BTAdapter *a, std::string msg)
 
static bool initAdapter (std::shared_ptr< BTAdapter > &adapter)
 
static bool myChangedAdapterSetFunc (const bool added, std::shared_ptr< BTAdapter > &adapter)
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

static const std::string KEY_PATH = "keys"
 
static uint64_t timestamp_t0
 
static int RESET_ADAPTER_EACH_CONN = 0
 
static std::atomic< int > deviceReadyCount = 0
 
static std::atomic< int > MULTI_MEASUREMENTS = 8
 
static bool KEEP_CONNECTED = true
 
static bool GATT_PING_ENABLED = false
 
static bool REMOVE_DEVICE = true
 
static bool USE_WHITELIST = false
 
static jau::darray< BDAddressAndTypeWHITELIST
 
static std::string charIdentifier = ""
 
static int charValue = 0
 
static bool SHOW_UPDATE_EVENTS = false
 
static bool QUIET = false
 
static const uuid16_t _TEMPERATURE_MEASUREMENT (GattCharacteristicType::TEMPERATURE_MEASUREMENT)
 
static bool le_scan_active = true
 
static const uint16_t le_scan_interval = 24
 
static const uint16_t le_scan_window = 24
 
static const uint8_t filter_policy = 0
 

Detailed Description

This dbt_scanner10 C++ scanner example uses the Direct-BT fully event driven workflow and adds multithreading, i.e. one thread processes each found device found as notified via the event listener.

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 ( std::shared_ptr< BTDevice device)
static
Examples
dbt_scanner10.cpp.

Definition at line 354 of file dbt_scanner10.cpp.

Here is the call graph for this function:

◆ initAdapter()

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

Definition at line 643 of file dbt_scanner10.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Definition at line 730 of file dbt_scanner10.cpp.

Here is the call graph for this function:

◆ myChangedAdapterSetFunc()

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

Definition at line 668 of file dbt_scanner10.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processReadyDevice()

static void processReadyDevice ( std::shared_ptr< BTDevice device)
static
Examples
dbt_scanner10.cpp.

Definition at line 425 of file dbt_scanner10.cpp.

Here is the call graph for this function:

◆ removeDevice()

static void removeDevice ( std::shared_ptr< BTDevice device)
static
Examples
dbt_scanner10.cpp.

Definition at line 613 of file dbt_scanner10.cpp.

Here is the call graph for this function:

◆ resetAdapter()

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

Definition at line 626 of file dbt_scanner10.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startDiscovery()

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

Definition at line 637 of file dbt_scanner10.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test()

void test ( )
Examples
dbt_scanner10.cpp.

Definition at line 682 of file dbt_scanner10.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _TEMPERATURE_MEASUREMENT

const uuid16_t _TEMPERATURE_MEASUREMENT(GattCharacteristicType::TEMPERATURE_MEASUREMENT)
static

◆ charIdentifier

std::string charIdentifier = ""
static
Examples
dbt_scanner10.cpp.

Definition at line 120 of file dbt_scanner10.cpp.

◆ charValue

int charValue = 0
static
Examples
dbt_scanner00.cpp, dbt_scanner01.cpp, and dbt_scanner10.cpp.

Definition at line 121 of file dbt_scanner10.cpp.

◆ deviceReadyCount

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

Definition at line 109 of file dbt_scanner10.cpp.

◆ filter_policy

const uint8_t filter_policy = 0
static
Examples
dbt_scanner10.cpp.

Definition at line 635 of file dbt_scanner10.cpp.

◆ GATT_PING_ENABLED

bool GATT_PING_ENABLED = false
static
Examples
dbt_scanner10.cpp.

Definition at line 114 of file dbt_scanner10.cpp.

◆ KEEP_CONNECTED

bool KEEP_CONNECTED = true
static
Examples
dbt_scanner10.cpp.

Definition at line 113 of file dbt_scanner10.cpp.

◆ KEY_PATH

const std::string KEY_PATH = "keys"
static
Examples
dbt_scanner10.cpp.

Definition at line 104 of file dbt_scanner10.cpp.

◆ le_scan_active

bool le_scan_active = true
static
Examples
dbt_scanner10.cpp.

Definition at line 632 of file dbt_scanner10.cpp.

◆ le_scan_interval

const uint16_t le_scan_interval = 24
static
Examples
dbt_scanner10.cpp.

Definition at line 633 of file dbt_scanner10.cpp.

◆ le_scan_window

const uint16_t le_scan_window = 24
static
Examples
dbt_scanner10.cpp.

Definition at line 634 of file dbt_scanner10.cpp.

◆ MULTI_MEASUREMENTS

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

Definition at line 111 of file dbt_scanner10.cpp.

◆ QUIET

bool QUIET = false
static
Examples
dbt_scanner10.cpp.

Definition at line 124 of file dbt_scanner10.cpp.

◆ REMOVE_DEVICE

bool REMOVE_DEVICE = true
static
Examples
dbt_scanner10.cpp.

Definition at line 115 of file dbt_scanner10.cpp.

◆ RESET_ADAPTER_EACH_CONN

int RESET_ADAPTER_EACH_CONN = 0
static
Examples
dbt_scanner10.cpp.

Definition at line 108 of file dbt_scanner10.cpp.

◆ SHOW_UPDATE_EVENTS

bool SHOW_UPDATE_EVENTS = false
static
Examples
dbt_scanner10.cpp.

Definition at line 123 of file dbt_scanner10.cpp.

◆ timestamp_t0

uint64_t timestamp_t0
static
Examples
dbt_scanner10.cpp.

Definition at line 106 of file dbt_scanner10.cpp.

◆ USE_WHITELIST

bool USE_WHITELIST = false
static
Examples
dbt_scanner10.cpp.

Definition at line 117 of file dbt_scanner10.cpp.

◆ WHITELIST

jau::darray<BDAddressAndType> WHITELIST
static
Examples
dbt_scanner10.cpp.

Definition at line 118 of file dbt_scanner10.cpp.