ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
btgattclient.c File Reference

bluetooth main gatt client More...

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <limits.h>
#include <errno.h>
#include "bluetooth.h"
#include "hci.h"
#include "hci_lib.h"
#include "l2cap.h"
#include "uuid.h"
#include "mainloop.h"
#include "util.h"
#include "att.h"
#include "queue.h"
#include "gatt-db.h"
#include "gatt-client.h"

Go to the source code of this file.

Data Structures

struct  client
 

Macros

#define ATT_CID   4
 
#define PRLOG(...)   printf(__VA_ARGS__); print_prompt();
 
#define COLOR_OFF   "\x1B[0m"
 
#define COLOR_RED   "\x1B[0;91m"
 
#define COLOR_GREEN   "\x1B[0;92m"
 
#define COLOR_YELLOW   "\x1B[0;93m"
 
#define COLOR_BLUE   "\x1B[0;94m"
 
#define COLOR_MAGENTA   "\x1B[0;95m"
 
#define COLOR_BOLDGRAY   "\x1B[1;30m"
 
#define COLOR_BOLDWHITE   "\x1B[1;36m"
 

Typedefs

typedef void(* command_func_t )(struct client *cli, char *cmd_str)
 

Functions

static void print_prompt (void)
 
static const char * ecode_to_string (uint8_t ecode)
 
static void att_disconnect_cb (int err, void *user_data)
 
static void att_debug_cb (const char *str, void *user_data)
 
static void gatt_debug_cb (const char *str, void *user_data)
 
static void ready_cb (bool success, uint8_t att_ecode, void *user_data)
 
static void service_changed_cb (uint16_t start_handle, uint16_t end_handle, void *user_data)
 
static void log_service_event (struct gatt_db_attribute *attr, const char *str)
 
static void service_added_cb (struct gatt_db_attribute *attr, void *user_data)
 
static void service_removed_cb (struct gatt_db_attribute *attr, void *user_data)
 
static struct clientclient_create (int fd, uint16_t mtu)
 
static void client_destroy (struct client *cli)
 
static void print_uuid (const bt_uuid_t *uuid)
 
static void print_incl (struct gatt_db_attribute *attr, void *user_data)
 
static void print_desc (struct gatt_db_attribute *attr, void *user_data)
 
static void print_chrc (struct gatt_db_attribute *attr, void *user_data)
 
static void print_service (struct gatt_db_attribute *attr, void *user_data)
 
static void print_services (struct client *cli)
 
static void print_services_by_uuid (struct client *cli, const bt_uuid_t *uuid)
 
static void print_services_by_handle (struct client *cli, uint16_t handle)
 
static void services_usage (void)
 
static bool parse_args (char *str, int expected_argc, char **argv, int *argc)
 
static void cmd_services (struct client *cli, char *cmd_str)
 
static void read_multiple_usage (void)
 
static void read_multiple_cb (bool success, uint8_t att_ecode, const uint8_t *value, uint16_t length, void *user_data)
 
static void cmd_read_multiple (struct client *cli, char *cmd_str)
 
static void read_value_usage (void)
 
static void read_cb (bool success, uint8_t att_ecode, const uint8_t *value, uint16_t length, void *user_data)
 
static void cmd_read_value (struct client *cli, char *cmd_str)
 
static void read_long_value_usage (void)
 
static void cmd_read_long_value (struct client *cli, char *cmd_str)
 
static void write_value_usage (void)
 
static void write_cb (bool success, uint8_t att_ecode, void *user_data)
 
static void cmd_write_value (struct client *cli, char *cmd_str)
 
static void write_long_value_usage (void)
 
static void write_long_cb (bool success, bool reliable_error, uint8_t att_ecode, void *user_data)
 
static void cmd_write_long_value (struct client *cli, char *cmd_str)
 
static void write_prepare_usage (void)
 
static void cmd_write_prepare (struct client *cli, char *cmd_str)
 
static void write_execute_usage (void)
 
static void cmd_write_execute (struct client *cli, char *cmd_str)
 
static void register_notify_usage (void)
 
static void notify_cb (uint16_t value_handle, const uint8_t *value, uint16_t length, void *user_data)
 
static void register_notify_cb (uint16_t att_ecode, void *user_data)
 
static void cmd_register_notify (struct client *cli, char *cmd_str)
 
static void unregister_notify_usage (void)
 
static void cmd_unregister_notify (struct client *cli, char *cmd_str)
 
static void set_security_usage (void)
 
static void cmd_set_security (struct client *cli, char *cmd_str)
 
static void cmd_get_security (struct client *cli, char *cmd_str)
 
static bool convert_sign_key (char *optarg, uint8_t key[16])
 
static void set_sign_key_usage (void)
 
static bool local_counter (uint32_t *sign_cnt, void *user_data)
 
static void cmd_set_sign_key (struct client *cli, char *cmd_str)
 
static void cmd_help (struct client *cli, char *cmd_str)
 
static void cmd_quit (struct client *cli, char *cmd_str)
 
static void prompt_read_cb (int fd, uint32_t events, void *user_data)
 
static void signal_cb (int signum, void *user_data)
 
static int l2cap_le_att_connect (bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type, int sec)
 
static void usage (void)
 
int main (int argc, char *argv[])
 

Variables

static bool verbose = false
 
static struct option write_value_options []
 
static struct option write_long_value_options []
 
static struct option write_prepare_options []
 
struct {
   char *   cmd
 
   command_func_t   func
 
   char *   doc
 
command []
 
static struct option main_options []
 

Detailed Description

bluetooth main gatt client

the original file is in bluez/tools and the name is btgatt-client.c

Author
Gilbert Brault

Definition in file btgattclient.c.

Macro Definition Documentation

#define ATT_CID   4

Definition at line 62 of file btgattclient.c.

Referenced by l2cap_le_att_connect().

#define COLOR_BLUE   "\x1B[0;94m"

Definition at line 71 of file btgattclient.c.

Referenced by print_prompt().

#define COLOR_BOLDGRAY   "\x1B[1;30m"

Definition at line 73 of file btgattclient.c.

Referenced by att_debug_cb().

#define COLOR_BOLDWHITE   "\x1B[1;36m"

Definition at line 74 of file btgattclient.c.

Referenced by att_debug_cb().

#define COLOR_GREEN   "\x1B[0;92m"

Definition at line 69 of file btgattclient.c.

Referenced by gatt_debug_cb(), and print_incl().

#define COLOR_MAGENTA   "\x1B[0;95m"

Definition at line 72 of file btgattclient.c.

Referenced by print_desc().

#define COLOR_OFF   "\x1B[0m"
#define COLOR_RED   "\x1B[0;91m"

Definition at line 68 of file btgattclient.c.

Referenced by print_service().

#define COLOR_YELLOW   "\x1B[0;93m"

Definition at line 70 of file btgattclient.c.

Referenced by print_chrc().

Typedef Documentation

typedef void(* command_func_t)(struct client *cli, char *cmd_str)

Definition at line 1653 of file btgattclient.c.

Function Documentation

static void att_debug_cb ( const char *  str,
void *  user_data 
)
static

print a prefix (user_data) followed by a message (str) example att: ATT op 0x02 (att: is the prefix)

Parameters
strmessage to print
user_datapointer to prefix

Definition at line 177 of file btgattclient.c.

References COLOR_BOLDGRAY, COLOR_BOLDWHITE, COLOR_OFF, and PRLOG.

Referenced by client_create().

static void att_disconnect_cb ( int  err,
void *  user_data 
)
static

disconnect callback, quit mainloop

Parameters
errerror code associated with disconnect
user_datauser data pointer (not used)

Definition at line 163 of file btgattclient.c.

References mainloop_quit().

Referenced by client_create().

static void client_destroy ( struct client cli)
static

client structure cleanup

Parameters
cliclient pointer to destroy

Definition at line 326 of file btgattclient.c.

References client::att, bt_att_unref(), bt_gatt_client_unref(), and client::gatt.

Referenced by main().

static void cmd_get_security ( struct client cli,
char *  cmd_str 
)
static

get security command

Parameters
clipointer to the client stricture
cmd_strget security command string

Definition at line 1548 of file btgattclient.c.

References bt_gatt_client_get_security(), bt_gatt_client_is_ready(), and client::gatt.

static void cmd_help ( struct client cli,
char *  cmd_str 
)
static

help command

Parameters
clipointer to client structure
cmd_strhelp command string

Definition at line 1695 of file btgattclient.c.

References cmd, command, and doc.

Referenced by prompt_read_cb().

static void cmd_quit ( struct client cli,
char *  cmd_str 
)
static

Definition at line 1648 of file btgattclient.c.

References mainloop_quit().

static void cmd_read_long_value ( struct client cli,
char *  cmd_str 
)
static

read long value command

Parameters
clipointer to the client structure
cmd_strcommand string for read long value

Definition at line 799 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_read_long_value(), client::gatt, parse_args(), read_cb(), and read_long_value_usage().

static void cmd_read_multiple ( struct client cli,
char *  cmd_str 
)
static

read multiple command

Parameters
clipointer to the client structure
cmd_strcommand string for read multiple

Definition at line 668 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_read_multiple(), client::gatt, parse_args(), read_multiple_cb(), and read_multiple_usage().

static void cmd_read_value ( struct client cli,
char *  cmd_str 
)
static

read value command

Parameters
clipointer to the client structure
cmd_strcommand string for read value

Definition at line 757 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_read_value(), client::gatt, parse_args(), read_cb(), and read_value_usage().

static void cmd_register_notify ( struct client cli,
char *  cmd_str 
)
static

register notify command

Parameters
clipointer to the client structure
cmd_strregister notify command string

Definition at line 1409 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_register_notify(), client::gatt, notify_cb(), parse_args(), PRLOG, register_notify_cb(), and register_notify_usage().

static void cmd_services ( struct client cli,
char *  cmd_str 
)
static

command interpreter

Parameters
clipointer to the client structure
cmd_strone of the possible command (help to get a list) <command> –help to have a help on that command

Definition at line 575 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_string_to_uuid(), bt_uuid_to_uuid128(), client::gatt, parse_args(), print_services(), print_services_by_handle(), print_services_by_uuid(), and services_usage().

static void cmd_set_security ( struct client cli,
char *  cmd_str 
)
static

set security command

Parameters
clipointer to the client structure
cmd_strset security command string

Definition at line 1506 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_set_security(), client::gatt, parse_args(), and set_security_usage().

static void cmd_set_sign_key ( struct client cli,
char *  cmd_str 
)
static

set sign key command

Parameters
clipointer to client structure
cmd_strset sign key command string

Definition at line 1621 of file btgattclient.c.

References client::att, bt_att_set_local_key(), convert_sign_key(), local_counter(), parse_args(), and set_sign_key_usage().

static void cmd_unregister_notify ( struct client cli,
char *  cmd_str 
)
static

un-register notify command

Parameters
clipointer to the client structure
cmd_strun-register notify command string

Definition at line 1458 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_unregister_notify(), client::gatt, parse_args(), and unregister_notify_usage().

static void cmd_write_execute ( struct client cli,
char *  cmd_str 
)
static

write execute command

Parameters
clipointer to the client structure
cmd_strwrite execute command string

Definition at line 1296 of file btgattclient.c.

References bt_gatt_client_cancel(), bt_gatt_client_is_ready(), bt_gatt_client_write_execute(), client::gatt, parse_args(), client::reliable_session_id, write_cb(), write_execute_usage(), and write_value_usage().

static void cmd_write_long_value ( struct client cli,
char *  cmd_str 
)
static

write long value command

Parameters
clipointer to the client structure
cmd_strcommand string for write long value

Definition at line 1029 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_write_long_value(), client::gatt, parse_args(), write_long_cb(), write_long_value_options, write_long_value_usage(), and write_value_usage().

static void cmd_write_prepare ( struct client cli,
char *  cmd_str 
)
static

write prepare command

Parameters
clipointer to the client structure
cmd_strwrite prepare command string

Definition at line 1154 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_prepare_write(), client::gatt, parse_args(), client::reliable_session_id, write_long_cb(), write_prepare_options, write_prepare_usage(), and write_value_usage().

static void cmd_write_value ( struct client cli,
char *  cmd_str 
)
static

write value command

Parameters
clipointer to the client structure
cmd_strcommand string for write value

Definition at line 877 of file btgattclient.c.

References bt_gatt_client_is_ready(), bt_gatt_client_write_value(), bt_gatt_client_write_without_response(), client::gatt, parse_args(), write_cb(), write_value_options, and write_value_usage().

static bool convert_sign_key ( char *  optarg,
uint8_t  key[16] 
)
static

convert sign key ascii to vector

Parameters
optargascii key string
keyreturned parsed vector
Returns
true if success else false

Definition at line 1571 of file btgattclient.c.

Referenced by cmd_set_sign_key().

static void gatt_debug_cb ( const char *  str,
void *  user_data 
)
static

print a prefix (user_data) followed by a message (str) example gatt: MTU exchange complete, with MTU: 23 (gatt: is the prefix)

Parameters
strmessage to print
user_datapointer to prefix

Definition at line 190 of file btgattclient.c.

References COLOR_GREEN, COLOR_OFF, and PRLOG.

Referenced by client_create().

static int l2cap_le_att_connect ( bdaddr_t *  src,
bdaddr_t *  dst,
uint8_t  dst_type,
int  sec 
)
static

create a bluetooth le l2cap socket and connect src to dst

Parameters
src6 bytes BD Address source address
dst6 bytes BD Address destination address
dst_typedestination type BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM
secsecurity level BT_SECURITY_LOW or BT_SECURITY_MEDIUM or BT_SECURITY_HIGH
Returns
socket or -1 if error

Definition at line 1787 of file btgattclient.c.

References AF_BLUETOOTH, ATT_CID, ba2str(), bacpy(), BT_SECURITY, BTPROTO_L2CAP, htobs, sockaddr_l2::l2_bdaddr, sockaddr_l2::l2_bdaddr_type, sockaddr_l2::l2_cid, sockaddr_l2::l2_family, bt_security::level, PF_BLUETOOTH, SOL_BLUETOOTH, and verbose.

Referenced by main().

static bool local_counter ( uint32_t *  sign_cnt,
void *  user_data 
)
static

counter increment sign_cnt by one

Parameters
sign_cntvariable to increment
user_datanot used
Returns
true

Definition at line 1606 of file btgattclient.c.

Referenced by cmd_set_sign_key().

static void log_service_event ( struct gatt_db_attribute attr,
const char *  str 
)
static

log discovered service

Parameters
attrgatt_db_attribute structure (service data)
strcomment about the logged service ("Service added", "Service removed"...)

Definition at line 207 of file btgattclient.c.

References bt_uuid_to_string(), gatt_db_attribute_get_service_handles(), gatt_db_attribute_get_service_uuid(), MAX_LEN_UUID_STR, and PRLOG.

Referenced by service_added_cb(), and service_removed_cb().

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

gatt client which browse ble device services and characteristics

See also
usage function for args definition
Parameters
argcargs count
argvargs value
Returns
EXIT_FAILURE or EXIT_SUCCESS

Definition at line 1896 of file btgattclient.c.

References bacpy(), BDADDR_ANY, BDADDR_LE_PUBLIC, BDADDR_LE_RANDOM, BT_SECURITY_HIGH, BT_SECURITY_LOW, BT_SECURITY_MEDIUM, client_create(), client_destroy(), hci_devba(), hci_devid(), l2cap_le_att_connect(), main_options, mainloop_add_fd(), mainloop_init(), mainloop_run(), mainloop_set_signal(), print_prompt(), prompt_read_cb(), signal_cb(), str2ba(), usage(), and verbose.

static void notify_cb ( uint16_t  value_handle,
const uint8_t *  value,
uint16_t  length,
void *  user_data 
)
static

notify call back

Parameters
value_handlehandle of the notifying object
valuevector value of the object
lengthlength of vector value
user_datanot used

Definition at line 1366 of file btgattclient.c.

References PRLOG.

Referenced by cmd_register_notify().

static bool parse_args ( char *  str,
int  expected_argc,
char **  argv,
int *  argc 
)
static

parse command string

Parameters
strcommand to parse
expected_argcnumber of arguments expected
argvpointers to arguments separated by space or tab
argcargument counter (and actual count)
Returns
true = success false = error

Definition at line 550 of file btgattclient.c.

Referenced by cmd_read_long_value(), cmd_read_multiple(), cmd_read_value(), cmd_register_notify(), cmd_services(), cmd_set_security(), cmd_set_sign_key(), cmd_unregister_notify(), cmd_write_execute(), cmd_write_long_value(), cmd_write_prepare(), and cmd_write_value().

static void print_chrc ( struct gatt_db_attribute attr,
void *  user_data 
)
static
static void print_desc ( struct gatt_db_attribute attr,
void *  user_data 
)
static

print attribute uuid

Parameters
attr
user_data

Definition at line 383 of file btgattclient.c.

References COLOR_MAGENTA, COLOR_OFF, gatt_db_attribute_get_handle(), gatt_db_attribute_get_type(), and print_uuid().

Referenced by print_chrc().

static void print_incl ( struct gatt_db_attribute attr,
void *  user_data 
)
static

print included data

Parameters
attrgatt_db_attribute to print
user_dataclient structure pointer

Definition at line 355 of file btgattclient.c.

References COLOR_GREEN, COLOR_OFF, client::db, gatt_db_attribute_get_incl_data(), gatt_db_attribute_get_service_uuid(), gatt_db_get_attribute(), print_uuid(), gatt_db_attribute::service, and gatt_db_attribute::uuid.

Referenced by print_service().

static void print_prompt ( void  )
static

print prompt

Definition at line 97 of file btgattclient.c.

References COLOR_BLUE, and COLOR_OFF.

Referenced by main(), prompt_read_cb(), ready_cb(), and service_changed_cb().

static void print_service ( struct gatt_db_attribute attr,
void *  user_data 
)
static
static void print_services ( struct client cli)
static

print the list of services

Parameters
cliclient pointer

Definition at line 451 of file btgattclient.c.

References client::db, gatt_db_foreach_service(), and print_service().

Referenced by cmd_services(), and ready_cb().

static void print_services_by_handle ( struct client cli,
uint16_t  handle 
)
static

print services providing the handle

Parameters
cli
handle

Definition at line 477 of file btgattclient.c.

References client::db, gatt_db_foreach_service(), and print_service().

Referenced by cmd_services().

static void print_services_by_uuid ( struct client cli,
const bt_uuid_t uuid 
)
static

print services providing the uuid

Parameters
cli
uuid

Definition at line 464 of file btgattclient.c.

References client::db, gatt_db_foreach_service(), and print_service().

Referenced by cmd_services().

static void print_uuid ( const bt_uuid_t uuid)
static

printing bt_uuid_t structure (uuid)

Parameters
uuid

Definition at line 338 of file btgattclient.c.

References bt_uuid_to_string(), bt_uuid_to_uuid128(), and MAX_LEN_UUID_STR.

Referenced by print_chrc(), print_desc(), print_incl(), and print_service().

static void prompt_read_cb ( int  fd,
uint32_t  events,
void *  user_data 
)
static

prompt read call back

Parameters
fdstdin
eventsepoll event
user_datapointer to client structure

Definition at line 1711 of file btgattclient.c.

References cmd, cmd_help(), command, mainloop_quit(), and print_prompt().

Referenced by main().

static void read_cb ( bool  success,
uint8_t  att_ecode,
const uint8_t *  value,
uint16_t  length,
void *  user_data 
)
static

read value callback

Parameters
success==0 => print error, <>0 print value
att_ecodeatt error code
valuevector of values
lengthsize of vector
user_datanot used

Definition at line 725 of file btgattclient.c.

References ecode_to_string(), and PRLOG.

Referenced by cmd_read_long_value(), and cmd_read_value().

static void read_long_value_usage ( void  )
static

read long value usage

Definition at line 788 of file btgattclient.c.

Referenced by cmd_read_long_value().

static void read_multiple_cb ( bool  success,
uint8_t  att_ecode,
const uint8_t *  value,
uint16_t  length,
void *  user_data 
)
static

read multiple callback

Parameters
success==0 => print error, <>0 print values
att_ecodeatt error code
valuevector of values
lengthnumber of values
user_datanot used

Definition at line 643 of file btgattclient.c.

References PRLOG.

Referenced by cmd_read_multiple().

static void read_multiple_usage ( void  )
static

read multiple usage

Definition at line 629 of file btgattclient.c.

Referenced by cmd_read_multiple().

static void read_value_usage ( void  )
static

read value usage

Definition at line 711 of file btgattclient.c.

Referenced by cmd_read_value().

static void ready_cb ( bool  success,
uint8_t  att_ecode,
void *  user_data 
)
static

GATT discovery procedures call back

Parameters
successif not 0 an error occured
att_ecodeatt error code
user_datapointer to client structure

Definition at line 492 of file btgattclient.c.

References print_prompt(), print_services(), and PRLOG.

Referenced by client_create().

static void register_notify_cb ( uint16_t  att_ecode,
void *  user_data 
)
static

register notify call back

Parameters
att_ecodeatt error code
user_datanot used

Definition at line 1392 of file btgattclient.c.

References PRLOG.

Referenced by cmd_register_notify().

static void register_notify_usage ( void  )
static

register notify usage

Definition at line 1353 of file btgattclient.c.

Referenced by cmd_register_notify().

static void service_added_cb ( struct gatt_db_attribute attr,
void *  user_data 
)
static

service added callback

Parameters
attr
user_data

Definition at line 228 of file btgattclient.c.

References log_service_event().

Referenced by client_create().

static void service_changed_cb ( uint16_t  start_handle,
uint16_t  end_handle,
void *  user_data 
)
static

service changed call back

Parameters
start_handle
end_handle
user_dataclient pointer

Definition at line 515 of file btgattclient.c.

References client::db, gatt_db_foreach_service_in_range(), print_prompt(), and print_service().

Referenced by client_create().

static void service_removed_cb ( struct gatt_db_attribute attr,
void *  user_data 
)
static

service removed callback

Parameters
attr
user_data

Definition at line 239 of file btgattclient.c.

References log_service_event().

Referenced by client_create().

static void services_usage ( void  )
static

services usage (services –help to learn options)

Definition at line 531 of file btgattclient.c.

Referenced by cmd_services().

static void set_security_usage ( void  )
static

set security usage

Definition at line 1492 of file btgattclient.c.

Referenced by cmd_set_security().

static void set_sign_key_usage ( void  )
static

sign key usage

Definition at line 1591 of file btgattclient.c.

Referenced by cmd_set_sign_key().

static void signal_cb ( int  signum,
void *  user_data 
)
static

signal call back SIGINT and SIGTERM processing

Parameters
signumSIGXXX
user_dataunused

Definition at line 1766 of file btgattclient.c.

References mainloop_quit().

Referenced by main().

static void unregister_notify_usage ( void  )
static

un-register notify usage

Definition at line 1447 of file btgattclient.c.

Referenced by cmd_unregister_notify().

static void usage ( void  )
static

print usage

Definition at line 1858 of file btgattclient.c.

Referenced by main().

static void write_cb ( bool  success,
uint8_t  att_ecode,
void *  user_data 
)
static

write value call back

Parameters
success==0 => print error, <>0 print value
att_ecodeatt error code
user_datanot used

Definition at line 861 of file btgattclient.c.

References ecode_to_string(), and PRLOG.

Referenced by cmd_write_execute(), and cmd_write_value().

static void write_execute_usage ( void  )
static

write execute usage

Definition at line 1283 of file btgattclient.c.

Referenced by cmd_write_execute().

static void write_long_cb ( bool  success,
bool  reliable_error,
uint8_t  att_ecode,
void *  user_data 
)
static

write long call back

Parameters
success==0 => print error, <>0 print value
reliable_errorstatus of the write operation when failed
att_ecodeatt error code
user_datanot used

Definition at line 1010 of file btgattclient.c.

References ecode_to_string(), and PRLOG.

Referenced by cmd_write_long_value(), and cmd_write_prepare().

static void write_long_value_usage ( void  )
static

write long value usage

Definition at line 987 of file btgattclient.c.

Referenced by cmd_write_long_value().

static void write_prepare_usage ( void  )
static

write prepare usage

Definition at line 1133 of file btgattclient.c.

Referenced by cmd_write_prepare().

static void write_value_usage ( void  )
static

write value usage

Definition at line 838 of file btgattclient.c.

Referenced by cmd_write_execute(), cmd_write_long_value(), cmd_write_prepare(), and cmd_write_value().

Variable Documentation

char* cmd

Definition at line 1656 of file btgattclient.c.

Referenced by cmd_help(), and prompt_read_cb().

struct { ... } command[]
Initial value:
= {
{ "help", cmd_help, "\tDisplay help message" },
{ "services", cmd_services, "\tShow discovered services" },
{ "read-value", cmd_read_value,
"\tRead a characteristic or descriptor value" },
{ "read-long-value", cmd_read_long_value,
"\tRead a long characteristic or desctriptor value" },
{ "read-multiple", cmd_read_multiple, "\tRead Multiple" },
{ "write-value", cmd_write_value,
"\tWrite a characteristic or descriptor value" },
{ "write-long-value", cmd_write_long_value,
"Write long characteristic or descriptor value" },
{ "write-prepare", cmd_write_prepare,
"\tWrite prepare characteristic or descriptor value" },
{ "write-execute", cmd_write_execute,
"\tExecute already prepared write" },
{ "register-notify", cmd_register_notify,
"\tSubscribe to not/ind from a characteristic" },
{ "unregister-notify", cmd_unregister_notify,
"Unregister a not/ind session"},
{ "set-security", cmd_set_security,
"\tSet security level on le connection"},
{ "get-security", cmd_get_security,
"\tGet security level on le connection"},
{ "set-sign-key", cmd_set_sign_key,
"\tSet signing key for signed write command"},
{ "quit", cmd_quit ,"\tQuit"},
{ }
}
static void cmd_read_value(struct client *cli, char *cmd_str)
Definition: btgattclient.c:757
static void cmd_read_long_value(struct client *cli, char *cmd_str)
Definition: btgattclient.c:799
static void cmd_services(struct client *cli, char *cmd_str)
Definition: btgattclient.c:575
static void cmd_quit(struct client *cli, char *cmd_str)
static void cmd_set_sign_key(struct client *cli, char *cmd_str)
static void cmd_write_prepare(struct client *cli, char *cmd_str)
static void cmd_set_security(struct client *cli, char *cmd_str)
static void cmd_unregister_notify(struct client *cli, char *cmd_str)
static void cmd_write_long_value(struct client *cli, char *cmd_str)
static void cmd_write_execute(struct client *cli, char *cmd_str)
static void cmd_get_security(struct client *cli, char *cmd_str)
static void cmd_register_notify(struct client *cli, char *cmd_str)
static void cmd_write_value(struct client *cli, char *cmd_str)
Definition: btgattclient.c:877
static void cmd_help(struct client *cli, char *cmd_str)
static void cmd_read_multiple(struct client *cli, char *cmd_str)
Definition: btgattclient.c:668

Referenced by cmd_help(), and prompt_read_cb().

char* doc

Definition at line 1658 of file btgattclient.c.

Referenced by cmd_help().

struct option main_options[]
static
Initial value:
= {
{ "index", 1, 0, 'i' },
{ "dest", 1, 0, 'd' },
{ "type", 1, 0, 't' },
{ "mtu", 1, 0, 'm' },
{ "security-level", 1, 0, 's' },
{ "verbose", 0, 0, 'v' },
{ "help", 0, 0, 'h' },
{ }
}

Definition at line 1877 of file btgattclient.c.

Referenced by main().

bool verbose = false
static

Definition at line 76 of file btgattclient.c.

Referenced by client_create(), l2cap_le_att_connect(), and main().

struct option write_long_value_options[]
static
Initial value:
= {
{ "reliable-write", 0, 0, 'r' },
{ }
}

Definition at line 997 of file btgattclient.c.

Referenced by cmd_write_long_value().

struct option write_prepare_options[]
static
Initial value:
= {
{ "session-id", 1, 0, 's' },
{ }
}

Definition at line 1143 of file btgattclient.c.

Referenced by cmd_write_prepare().

struct option write_value_options[]
static
Initial value:
= {
{ "without-response", 0, 0, 'w' },
{ "signed-write", 0, 0, 's' },
{ }
}

Definition at line 848 of file btgattclient.c.

Referenced by cmd_write_value().