Giter VIP home page Giter VIP logo

gattclient's Introduction

gattclient

A gatt client, based on bluez stack -- just using socket


How to use Gatt Client to see client features

context

Bluez is one of the bluetooth stack for linux. I was looking for a gatt client to make some testing for ble. Until know I was not successfull to get C code "easy" to understand with a simple architecture. I found that with the btgatt-client in bluez (based on version 5.32)

compile context

The main file is in <bluez source rep>/tools/btgatt-client.c But now, what are the files needed to compile it? I figured that out, here is the list

  • att.c & att.h
  • att-types.h
  • bluetooth.c & bluetooth.h
  • btgatt-client.c (main)
  • config.h
  • crypto.c & crypto.h
  • gatt-client.c & gatt-client.h
  • gatt-db.c & gatt-db.h
  • gatt-helpers.c & gatt-helpers.h
  • hci_lib.h
  • hci.c & hci.h
  • io.h
  • io-mainloop.c (don't take io-glib.c)
  • l2cap.h
  • mainloop.c & mainloop.h
  • queue.c & queue.h
  • timeout.h
  • timeout-glib.c
  • util.c & util.h
  • uuid.c & uuid.h

most of the files are in <bluez>/src/shared

project is under eclipse

you can clone with git and there is an eclipse project

Code Documentation

A doxygen documentation is provided: This is a work in progress with the intent of documenting all important functions and data structures

How to use Gatt Client

Usage

$./gattclient help
Options:
	-i, --index <id>				Specify adapter index, e.g. hci0
	-d, --dest <addr>				Specify the destination address
	-t, --type [random|public] 		Specify the LE address type
	-m, --mtu <mtu> 					The ATT MTU to use
	-s, --security-level <sec> 	Set security level (low|medium|high)
	-v, --verbose						Enable extra logging
	-h, --help							Display help (this message)
Example:
gattclient -v -d C4:BE:84:70:29:04

$gattclient -v -d C4:BE:84:70:29:04
.......................................................
[GATT client]#help
Commands:
	help           		Display help message
	services       		Show discovered services
	read-value     		Read a characteristic or descriptor value
	read-long-value		Read a long characteristic or desctriptor value
	read-multiple  		Read Multiple
	write-value    		Write a characteristic or descriptor value
	write-long-value	Write long characteristic or descriptor value
	write-prepare  		Write prepare characteristic or descriptor value
	write-execute  		Execute already prepared write
	register-notify		Subscribe to not/ind from a characteristic
	unregister-notify	Unregister a not/ind session
	set-security   		Set security level on le connection
	get-security   		Get security level on le connection
	set-sign-key   		Set signing key for signed write command
	quit           		Quit
[GATT client]# read-value
Usage: read-value <value_handle>
[GATT client]# read-long-value
Usage: read-long-value <value_handle> <offset>
[GATT client]# read-multiple
Usage: read-multiple <handle_1> <handle_2> ...
[GATT client]# write-value
Usage: write-value [options] <value_handle> <value>
Options:
	-w, --without-response	Write without response
	-s, --signed-write	Signed write command
e.g.:
	write-value 0x0001 00 01 00
[GATT client]# write-long-value
Usage: write-long-value [options] <value_handle> <offset> <value>
Options:
	-r, --reliable-write	Reliable write
e.g.:
	write-long-value 0x0001 0 00 01 00
[GATT client]# write-prepare
Usage: write-prepare [options] <value_handle> <offset> <value>
Options:
	-s, --session-id	Session id
e.g.:
	write-prepare -s 1 0x0001 00 01 00
[GATT client]# write-prepare
Usage: write-prepare [options] <value_handle> <offset> <value>
Options:
	-s, --session-id	Session id
e.g.:
	write-prepare -s 1 0x0001 00 01 00
[GATT client]# write-execute
Usage: write-execute <session_id> <execute>
e.g.:
	write-execute 1 0
[GATT client]# register-notify
Usage: register-notify <chrc value handle>
[GATT client]# unregister-notify	
Usage: unregister-notify <notify id>
[GATT client]# set-security
Usage: set_security <level>
level: 1-3
e.g.:
	set-sec-level 2
[GATT client]# get-security
Security level: 1
[GATT client]# set-sign-key
Usage: set-sign-key [options]
Options:
	 -c, --sign-key <csrk>	CSRK
e.g.:
	set-sign-key -c D8515948451FEA320DC05A2E88308188

gattclient's People

Contributors

gbrault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gattclient's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.