I got a GATT server example for BlueZ 5.31 (the last of this post):
My environment:
Vagrant
Virtual box
Ubuntu Trusty Tahr as a guest OS (version 14.04 32-bit OS)
Updated to linux kernel 3.19
Installed packages:
* libglib2.0-dev
* libdbus-1-dev
* libudev-dev
* libical-dev
* libreadline-dev
Downloaded BlueZ 5.31 from here: https://www.kernel.org/pub/linux/bluetooth/bluez-5.31.tar.xz
Installing the updated kernel (version 3.19):
sudo apt-get update
sudo apt-get install --install-recommends linux-generic-lts-vivid
Reboot required. I am using Vagrant and have lost access to shared folders. If this happens to you, wait until the tramp reports an error and still enters the virtual machine (roaming ssh). In the virtual machine, run this command to fix the shared folder problem:
Configuring sudo / etc / init.d / vboxadd
I rebooted again (maybe not needed) to check if the shared folder is active.
Returning to the virtual machine, continue with the installation of BlueZ 5.31:
cd ~
sudo apt-get install libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev
wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.31.tar.xz
tar xvf bluez-5.31.tar.xz
cd bluez-5.31
. / configure --prefix = / usr --mandir = / usr / share / man --sysconfdir = / etc --localstatedir = / var --disable-systemd --enable-experimental --enable-maintainer-mode
to do
sudo make install
sudo cp attrib / gatttool / usr / bin
Installation completed. Check it out as follows:
hciconfig
You should get an answer (or something similar):
hci0: Type: BR / EDR Bus: USB
BD Address: 00: 1A: 7D: DA: 71: 0C ACL MTU: 310: 10 SCO MTU: 64: 8
Down
RX bytes: 15528 acl: 126 sco: 0 events: 683 errors: 0
TX bytes: 6459 acl: 146 sco: 0 instructions: 234 errors: 0
Set up a Bluetooth adapter, start advertising, run an example of a GATT server (heart rate service) with a detailed one (my adapter is hci0):
cd BlueZ catalog 5.31
sudo tools / btmgmt -i hci0 power off
sudo tools / btmgmt -i hci0 le
sudo tools / btmgmt -i hci0 to connect to
sudo tools / btmgmt -i hci0 name " friendly name "
sudo tools / btmgmt -i hci0 ads on
sudo tools / btmgmt -i hci0 power on
tools / btgatt-server -i hci0 -s low -t public -r -v
Switch to another device (I used an iPod, Android - Samsung Galaxy 5S and a Nexus tablet - and another computer with BlueZ) and connected to the service. Here's how I did it on another PC running BlueZ:
gatttool -b GATT server MAC -I
to plug
primary
specifications
You can issue other commands to read and write to the GATT server.
I also created my own GATT server (your original request) by copying and editing this file: tools / btgatt-server.c. You can edit the Makefile.tools file to include your own server in the assembly. You will need to run automake, make and sudo make install to run it.