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

The example demonstrates a client connecting to Avalun's LabPad device. 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_labpadclient01.cpp:

Go to the source code of this file.

Classes

class  MyAdapterStatusListener
 
class  MyGATTEventListener
 

Functions

static void connectDiscoveredDevice (BTDeviceRef device)
 
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 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 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 const POctets cmd_data2 ({ 0x01, 0xB8 }, lb_endian::little)
 
static std::unique_ptr< uuid_tcmd_req_uuid = jau::uuid_t::create(std::string("2c1b2472-4a5f-11e5-9595-0002a5d5c51b"))
 
static std::unique_ptr< uuid_tcmd_rsp_uuid = jau::uuid_t::create(std::string("2c1b2473-4a5f-11e5-9595-0002a5d5c51b"))
 
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 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 bool SHOW_UPDATE_EVENTS = false
 
static uint64_t timestamp_t0
 
static bool use_privacy = false
 
static EUI48 useAdapter = EUI48::ALL_DEVICE
 

Detailed Description

The example demonstrates a client connecting to Avalun's LabPad device.

It differs from dbt_scanner10 as follows:

Other than that, please refer to dbt_scanner10 as a general example.

Definition in file dbt_labpadclient01.cpp.

Function Documentation

◆ connectDiscoveredDevice()

static void connectDiscoveredDevice ( BTDeviceRef  device)
static

Definition at line 376 of file dbt_labpadclient01.cpp.

◆ processReadyDevice()

static void processReadyDevice ( const BTDeviceRef device)
static

Definition at line 421 of file dbt_labpadclient01.cpp.

◆ removeDevice()

static void removeDevice ( BTDeviceRef  device)
static

Definition at line 645 of file dbt_labpadclient01.cpp.

◆ resetAdapter()

static void resetAdapter ( BTAdapter a,
int  mode 
)
static

Definition at line 651 of file dbt_labpadclient01.cpp.

Here is the caller graph for this function:

◆ startDiscovery()

static bool startDiscovery ( BTAdapter a,
const std::string &  msg 
)
static

Definition at line 657 of file dbt_labpadclient01.cpp.

Here is the caller graph for this function:

◆ dbGattServer()

DBGattServerRef dbGattServer ( new   DBGattServerjau::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"))))))
Examples
dbt_repeater00.cpp.
Here is the caller graph for this function:

◆ initAdapter()

static bool initAdapter ( std::shared_ptr< BTAdapter > &  adapter)
static

Definition at line 678 of file dbt_labpadclient01.cpp.

Here is the caller graph for this function:

◆ myChangedAdapterSetFunc()

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

Definition at line 719 of file dbt_labpadclient01.cpp.

Here is the caller graph for this function:

◆ test()

void test ( )

Definition at line 741 of file dbt_labpadclient01.cpp.

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 788 of file dbt_labpadclient01.cpp.

Variable Documentation

◆ timestamp_t0

uint64_t timestamp_t0
static

Definition at line 71 of file dbt_labpadclient01.cpp.

◆ useAdapter

EUI48 useAdapter = EUI48::ALL_DEVICE
static

Definition at line 73 of file dbt_labpadclient01.cpp.

◆ btMode

BTMode btMode = BTMode::DUAL
static

Definition at line 74 of file dbt_labpadclient01.cpp.

◆ use_privacy

bool use_privacy = false
static

Definition at line 75 of file dbt_labpadclient01.cpp.

◆ discoveryPolicy

DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY
static

Definition at line 77 of file dbt_labpadclient01.cpp.

◆ le_scan_active

bool le_scan_active = true
static

Definition at line 78 of file dbt_labpadclient01.cpp.

◆ le_scan_interval

const uint16_t le_scan_interval = 24
static

Definition at line 79 of file dbt_labpadclient01.cpp.

◆ le_scan_window

const uint16_t le_scan_window = 24
static

Definition at line 80 of file dbt_labpadclient01.cpp.

◆ filter_policy

const uint8_t filter_policy = 0
static

Definition at line 81 of file dbt_labpadclient01.cpp.

◆ filter_dup

const bool filter_dup = true
static

Definition at line 82 of file dbt_labpadclient01.cpp.

◆ chosenAdapter

std::shared_ptr<BTAdapter> chosenAdapter = nullptr
static

Definition at line 84 of file dbt_labpadclient01.cpp.

◆ RESET_ADAPTER_EACH_CONN

int RESET_ADAPTER_EACH_CONN = 0
static

Definition at line 86 of file dbt_labpadclient01.cpp.

◆ deviceReadyCount

std::atomic<int> deviceReadyCount = 0
static

Definition at line 87 of file dbt_labpadclient01.cpp.

◆ MULTI_MEASUREMENTS

std::atomic<int> MULTI_MEASUREMENTS = 8
static

Definition at line 89 of file dbt_labpadclient01.cpp.

◆ KEEP_CONNECTED

bool KEEP_CONNECTED = true
static

Definition at line 91 of file dbt_labpadclient01.cpp.

◆ GATT_PING_ENABLED

bool GATT_PING_ENABLED = false
static

Definition at line 92 of file dbt_labpadclient01.cpp.

◆ REMOVE_DEVICE

bool REMOVE_DEVICE = true
static

Definition at line 93 of file dbt_labpadclient01.cpp.

◆ cmd_req_uuid

std::unique_ptr<uuid_t> cmd_req_uuid = jau::uuid_t::create(std::string("2c1b2472-4a5f-11e5-9595-0002a5d5c51b"))
static

Definition at line 96 of file dbt_labpadclient01.cpp.

◆ cmd_rsp_uuid

std::unique_ptr<uuid_t> cmd_rsp_uuid = jau::uuid_t::create(std::string("2c1b2473-4a5f-11e5-9595-0002a5d5c51b"))
static

Definition at line 97 of file dbt_labpadclient01.cpp.

◆ cmd_data1

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) ( { 0x00, 0x14, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x5E, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x9B, 0x23, 0x84 }  ,
lb_endian::little   
)
static

◆ cmd_data2

const POctets cmd_data2({ 0x01, 0xB8 }, lb_endian::little) ( { 0x01, 0xB8 }  ,
lb_endian::little   
)
static

◆ resp_exp

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) ( { 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

◆ SHOW_UPDATE_EVENTS

bool SHOW_UPDATE_EVENTS = false
static

Definition at line 113 of file dbt_labpadclient01.cpp.

◆ QUIET

bool QUIET = false
static

Definition at line 114 of file dbt_labpadclient01.cpp.

◆ _TEMPERATURE_MEASUREMENT