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

This dbt_repeater00 C++ repeater example implementing a GATT repeater, 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_repeater00.cpp:

Go to the source code of this file.

Classes

class  AdapterToClientStatusListener
 
class  AdapterToServerStatusListener
 
class  NativeGattToServerCharListener
 

Functions

static void connectToDiscoveredServer (BTDeviceRef device)
 
static bool initAdapterToClient (std::shared_ptr< BTAdapter > &adapter)
 
static bool initAdapterToServer (std::shared_ptr< BTAdapter > &adapter)
 
int main (int argc, char *argv[])
 
static void myChangedAdapterSetFunc (const bool added, std::shared_ptr< BTAdapter > &adapter)
 
static void processDisconnectedDeviceToClient (BTDeviceRef device)
 
static void processReadyToServer (const BTDeviceRef &device)
 
static void removeDeviceToServer (BTDeviceRef device)
 
static void resetConnectionToServer (BTDeviceRef device)
 
static bool startAdvertisingToClient (const BTAdapterRef &a, const std::string &msg)
 
static bool startDiscoveryToServer (BTAdapter *a, std::string msg)
 
static bool stopAdvertisingToClient (const BTAdapterRef &a, const std::string &msg)
 
void test ()
 

Variables

static BTAdapterRef adapterToClient = nullptr
 
static EUI48 adapterToClientAddr = EUI48::ALL_DEVICE
 
static std::string adapterToClientName = "repeater0"
 
static BTSecurityLevel adapterToClientSecLevel = BTSecurityLevel::UNSET
 
static std::string adapterToClientShortName = "repeater0"
 
static bool adapterToClientUseSC = true
 
static BTAdapterRef adapterToServer = nullptr
 
static EUI48 adapterToServerAddr = EUI48::ALL_DEVICE
 
static const uint8_t adv_chan_map =0x07
 
static const uint16_t adv_interval_max =640
 
static const uint16_t adv_interval_min =640
 
static const AD_PDU_Type adv_type =AD_PDU_Type::ADV_IND
 
static BTMode btMode = BTMode::DUAL
 
static BTDeviceRef connectedDeviceToClient = nullptr
 
static BTDeviceRef connectedDeviceToServer = nullptr
 
static DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED
 
static const uint8_t filter_policy = 0
 
static const bool le_scan_active = true
 
static const uint16_t le_scan_interval = 24
 
static const uint16_t le_scan_window = 24
 
static uint16_t max_att_mtu_to_client = 512+1
 
static jau::nsize_t MAX_SERVED_CONNECTIONS = 0
 
static bool QUIET = false
 
static jau::relaxed_atomic_nsize_t servedClientConnections = 0
 
static std::atomic< int > serverDeviceReadyCount = 0
 
static jau::sc_atomic_bool sync_data
 
static uint64_t timestamp_t0
 

Detailed Description

This dbt_repeater00 C++ repeater example implementing a GATT repeater, i.e.

forwarding client requests to a GATT server and passing the results back.

The repeater can be used in between an existing Bluetooth LE client and server, acting as a forwarder and to analyze the GATT client/server protocol.

dbt_repeater00 Invocation Examples:

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

Definition in file dbt_repeater00.cpp.

Function Documentation

◆ connectToDiscoveredServer()

static void connectToDiscoveredServer ( BTDeviceRef  device)
static
Examples
dbt_repeater00.cpp.

Definition at line 401 of file dbt_repeater00.cpp.

◆ processReadyToServer()

static void processReadyToServer ( const BTDeviceRef device)
static
Examples
dbt_repeater00.cpp.

Definition at line 446 of file dbt_repeater00.cpp.

◆ removeDeviceToServer()

static void removeDeviceToServer ( BTDeviceRef  device)
static
Examples
dbt_repeater00.cpp.

Definition at line 495 of file dbt_repeater00.cpp.

◆ startDiscoveryToServer()

static bool startDiscoveryToServer ( BTAdapter a,
std::string  msg 
)
static
Examples
dbt_repeater00.cpp.

Definition at line 522 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ startAdvertisingToClient()

static bool startAdvertisingToClient ( const BTAdapterRef a,
const std::string &  msg 
)
static
Examples
dbt_repeater00.cpp.

Definition at line 722 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ stopAdvertisingToClient()

static bool stopAdvertisingToClient ( const BTAdapterRef a,
const std::string &  msg 
)
static
Examples
dbt_repeater00.cpp.

Definition at line 758 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ processDisconnectedDeviceToClient()

static void processDisconnectedDeviceToClient ( BTDeviceRef  device)
static
Examples
dbt_repeater00.cpp.

Definition at line 698 of file dbt_repeater00.cpp.

◆ resetConnectionToServer()

static void resetConnectionToServer ( BTDeviceRef  device)
static
Examples
dbt_repeater00.cpp.

Definition at line 508 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ initAdapterToServer()

static bool initAdapterToServer ( std::shared_ptr< BTAdapter > &  adapter)
static
Examples
dbt_repeater00.cpp.

Definition at line 532 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ initAdapterToClient()

static bool initAdapterToClient ( std::shared_ptr< BTAdapter > &  adapter)
static
Examples
dbt_repeater00.cpp.

Definition at line 764 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ myChangedAdapterSetFunc()

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

Definition at line 846 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ test()

void test ( )
Examples
dbt_repeater00.cpp.

Definition at line 878 of file dbt_repeater00.cpp.

Here is the caller graph for this function:

◆ main()

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

Definition at line 913 of file dbt_repeater00.cpp.

Variable Documentation

◆ timestamp_t0

uint64_t timestamp_t0
static
Examples
dbt_repeater00.cpp.

Definition at line 69 of file dbt_repeater00.cpp.

◆ sync_data

jau::sc_atomic_bool sync_data
static
Examples
dbt_repeater00.cpp.

Definition at line 71 of file dbt_repeater00.cpp.

◆ btMode

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

Definition at line 72 of file dbt_repeater00.cpp.

◆ adapterToServerAddr

EUI48 adapterToServerAddr = EUI48::ALL_DEVICE
static
Examples
dbt_repeater00.cpp.

Definition at line 77 of file dbt_repeater00.cpp.

◆ adapterToServer

BTAdapterRef adapterToServer = nullptr
static
Examples
dbt_repeater00.cpp.

Definition at line 78 of file dbt_repeater00.cpp.

◆ connectedDeviceToServer

BTDeviceRef connectedDeviceToServer = nullptr
static
Examples
dbt_repeater00.cpp.

Definition at line 79 of file dbt_repeater00.cpp.

◆ serverDeviceReadyCount

std::atomic<int> serverDeviceReadyCount = 0
static
Examples
dbt_repeater00.cpp.

Definition at line 80 of file dbt_repeater00.cpp.

◆ discoveryPolicy

DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED
static
Examples
dbt_repeater00.cpp.

Definition at line 87 of file dbt_repeater00.cpp.

◆ le_scan_active

const bool le_scan_active = true
static
Examples
dbt_repeater00.cpp.

Definition at line 88 of file dbt_repeater00.cpp.

◆ le_scan_interval

const uint16_t le_scan_interval = 24
static
Examples
dbt_repeater00.cpp.

Definition at line 89 of file dbt_repeater00.cpp.

◆ le_scan_window

const uint16_t le_scan_window = 24
static
Examples
dbt_repeater00.cpp.

Definition at line 90 of file dbt_repeater00.cpp.

◆ filter_policy

const uint8_t filter_policy = 0
static
Examples
dbt_repeater00.cpp.

Definition at line 91 of file dbt_repeater00.cpp.

◆ adv_interval_min

const uint16_t adv_interval_min =640
static
Examples
dbt_repeater00.cpp.

Definition at line 92 of file dbt_repeater00.cpp.

◆ adv_interval_max

const uint16_t adv_interval_max =640
static
Examples
dbt_repeater00.cpp.

Definition at line 93 of file dbt_repeater00.cpp.

◆ adv_type

const AD_PDU_Type adv_type =AD_PDU_Type::ADV_IND
static
Examples
dbt_repeater00.cpp.

Definition at line 94 of file dbt_repeater00.cpp.

◆ adv_chan_map

const uint8_t adv_chan_map =0x07
static
Examples
dbt_repeater00.cpp.

Definition at line 95 of file dbt_repeater00.cpp.

◆ adapterToClientAddr

EUI48 adapterToClientAddr = EUI48::ALL_DEVICE
static
Examples
dbt_repeater00.cpp.

Definition at line 100 of file dbt_repeater00.cpp.

◆ adapterToClientUseSC

bool adapterToClientUseSC = true
static
Examples
dbt_repeater00.cpp.

Definition at line 101 of file dbt_repeater00.cpp.

◆ adapterToClientName

std::string adapterToClientName = "repeater0"
static
Examples
dbt_repeater00.cpp.

Definition at line 102 of file dbt_repeater00.cpp.

◆ adapterToClientShortName

std::string adapterToClientShortName = "repeater0"
static
Examples
dbt_repeater00.cpp.

Definition at line 103 of file dbt_repeater00.cpp.

◆ max_att_mtu_to_client

uint16_t max_att_mtu_to_client = 512+1
static
Examples
dbt_repeater00.cpp.

Definition at line 104 of file dbt_repeater00.cpp.

◆ adapterToClientSecLevel

BTSecurityLevel adapterToClientSecLevel = BTSecurityLevel::UNSET
static
Examples
dbt_repeater00.cpp.

Definition at line 105 of file dbt_repeater00.cpp.

◆ adapterToClient

BTAdapterRef adapterToClient = nullptr
static
Examples
dbt_repeater00.cpp.

Definition at line 106 of file dbt_repeater00.cpp.

◆ servedClientConnections

jau::relaxed_atomic_nsize_t servedClientConnections = 0
static
Examples
dbt_repeater00.cpp.

Definition at line 107 of file dbt_repeater00.cpp.

◆ MAX_SERVED_CONNECTIONS

jau::nsize_t MAX_SERVED_CONNECTIONS = 0
static
Examples
dbt_repeater00.cpp.

Definition at line 108 of file dbt_repeater00.cpp.

◆ connectedDeviceToClient

BTDeviceRef connectedDeviceToClient = nullptr
static
Examples
dbt_repeater00.cpp.

Definition at line 109 of file dbt_repeater00.cpp.

◆ QUIET

bool QUIET = false
static
Examples
dbt_repeater00.cpp.

Definition at line 115 of file dbt_repeater00.cpp.