2015年7月27日 星期一

BLE in Linux Two : Set a Simple Peripheral


      Resuming from last article , I modify the bluez code to be a simple peripheral (GATT server).


Step 0.
  download the last bluez .

 and
    
Step 1.

use the parameters to configurate it.

gaiger@i5-3210m:~/sandbox/bluez-5.32/src$./configure --enable-experimental --enable-maintainer-mode --prefix=$PWD/built CFLAGS="$CFLAGS -Wno-sign-compare -Wno-unused-function"  

If you encounter some error like that :

configure: error: libical is required

or

checking for UDEV... no
configure: error: libudev >= 172 is required

 just install those libraries. I note here, in fedora, the libudev has been included in systemd package, you should use that command line:


gaiger@i5-3210m:~/sandbox/bluez-5.32/src$sudo yum install systemd-devel

To install libudev-dev.


After configuration has been done, the building should be passed without error.

Step2.

   Stop current bluetoothd program:

In fedora :


gaiger@i5-3210m:~/sandbox/bluez-5.32/src$sudo killall -p bluetoothd

In Ubuntu :


gaiger@i5-3210m:~/sandbox/bluez-5.32/src$sudo service bluetooth  status
bluetooth start/running, process 2619


gaiger@i5-3210m:~/sandbox/bluez-5.32/src$ sudo service bluetooth stop
bluetooth stop/waiting


Then, goto the src folder under your bluez package, and execute that:


[gaiger@localhost src]$ sudo ./bluetoothd -p xx -n

If the output log be :


bluetoothd[12465]: Bluetooth daemon 5.30
bluetoothd[12465]: Starting SDP server
bluetoothd[12465]: Bluetooth management interface 1.7 initialized
bluetoothd[12465]: Failed to obtain handles for "Service Changed" characteristic
bluetoothd[12465]: Failed to register org.bluez.LEAdvertisingManager1
bluetoothd[12465]: Failed to register LEAdvertisingManager1 interface for adapter
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: gatt-example-adapter-driver: Input/output error (5)
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Error adding Link Loss service
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Current Time Service could not be registered
bluetoothd[12465]: gatt-time-server: Input/output error (5)
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Not enough free handles to register service
bluetoothd[12465]: Sap driver initialization failed.
bluetoothd[12465]: sap-server: Operation not permitted (1)
bluetoothd[12465]: Endpoint registered: sender=:1.122 path=/MediaEndpoint/A2DPSource
bluetoothd[12465]: Endpoint registered: sender=:1.122 path=/MediaEndpoint/A2DPSink


    That is,  the gatt-server fails in start. The only solution I know currently, is to use the Bluez version which is not later than 5.28. please back to Step 0, use version 5.28 and do all again.


    if your result be :


[gaiger@localhost src]$ sudo ./bluetoothd -p xx -n
bluetoothd[31541]: Bluetooth daemon 5.28
bluetoothd[31541]: Starting SDP server
bluetoothd[31541]: Ignoring (cli) hostname
bluetoothd[31541]: Ignoring (cli) wiimote
bluetoothd[31541]: Ignoring (cli) autopair
bluetoothd[31541]: Ignoring (cli) policy
bluetoothd[31541]: Ignoring (cli) gatt_example
bluetoothd[31541]: Ignoring (cli) neard
bluetoothd[31541]: Ignoring (cli) sap
bluetoothd[31541]: Ignoring (cli) a2dp
bluetoothd[31541]: Ignoring (cli) avrcp
bluetoothd[31541]: Ignoring (cli) network
bluetoothd[31541]: Ignoring (cli) input
bluetoothd[31541]: Ignoring (cli) hog
bluetoothd[31541]: Ignoring (cli) health
bluetoothd[31541]: Ignoring (cli) gap
bluetoothd[31541]: Ignoring (cli) scanparam
bluetoothd[31541]: Ignoring (cli) deviceinfo
bluetoothd[31541]: Ignoring (cli) alert
bluetoothd[31541]: Ignoring (cli) time
bluetoothd[31541]: Ignoring (cli) proximity
bluetoothd[31541]: Ignoring (cli) thermometer
bluetoothd[31541]: Ignoring (cli) heartrate
bluetoothd[31541]: Ignoring (cli) cyclingspeed
bluetoothd[31541]: Ignoring (cli) external_dummy
bluetoothd[31541]: Bluetooth management interface 1.7 initialized

  Congratulation, you could go below.

Step 3.
  Excute the command :


[gaiger@localhost src]$ sudo ./bluetoothd -p gatt_example -n

And run this script, bleAdvertise:



#!/bin/bash
# ref: http://www.theregister.co.uk/Print/2013/11/29/feature_diy_apple_ibeacons/
set -x
# inquiry local bluetooth device
#hcitool dev
export BLUETOOTH_DEVICE=hci0
#sudo hcitool -i hcix cmd <OGF> <OCF> <No. Significant Data Octets> <iBeacon Prefix> <UUID> <Major> <Minor> <Tx Power> <Placeholder Octets>

#OGF = Operation Group Field = Bluetooth Command Group = 0x08
#OCF = Operation Command Field = HCI_LE_Set_Advertising_Data = 0x0008
#No. Significant Data Octets (Max of 31) = 1E (Decimal 30)
#iBeacon Prefix (Always Fixed) = 02 01 1A 1A FF 4C 00 02 15

export OGF="0x08"
export OCF="0x0008"
#export IBEACONPROFIX="1E 02 01 1A 1A FF 4C 00 02 15"
export IBEACONPROFIX="1E 02 01 16 1A FF 4C 00 02 15"


#uuidgen  could gerenate uuid
export UUID="00 00 FF FF 00 00 10 00 80 00 00 80 5F 9B 34 FB"
#export UUID="B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D"
#export UUID="76 E8 B4 E0 7E B5 11 E4 B4 A9 08 00 20 0C 9A 66"

export MAJOR="00 01"
export MINOR="00 00"
export POWER="C5 00"

 initialize device
sudo hciconfig $BLUETOOTH_DEVICE up
# disable advertising 
sudo hciconfig $BLUETOOTH_DEVICE noleadv
# stop the dongle looking for other Bluetooth devices
sudo hciconfig $BLUETOOTH_DEVICE noscan

sudo hciconfig $BLUETOOTH_DEVICE pscan

#hciconfig $BLUETOOTH_DEVICE iscan
#sudo hciconfig $BLUETOOTH_DEVICE name "i5-3210M "$BLUETOOTH_DEVICE
sudo hciconfig $BLUETOOTH_DEVICE leadv

# advertise 
sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x0008 $IBEACONPROFIX $UUID $MAJOR $MINOR $POWER
#sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x0006 A0 00 A0 00 00 00 00 00 00 00 00 00 00 07 00
#sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x000a 01

#sudo hciconfig $BLUETOOTH_DEVICE leadv 
#sudo hciconfig $BLUETOOTH_DEVICE pscan
echo "complete" 

 You should be able to use your mobile application (BLE scanner for Android, LightBlue for iOS) 
to scan and connect to this Bluez peripheral.
 




 

That shows the bluez gatt-server works.

 Step 4.
 Backup the plugin/wiimote.c , and replace that as below code completely:
  
 

/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
 *
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <unistd.h>
 
 
#include <stdbool.h>

#include <bluetooth/bluetooth.h>
#include <glib.h>

#include "lib/uuid.h"
#include "src/plugin.h"
#include "src/adapter.h"
#include "src/shared/util.h"
#include "src/log.h"
#include "attrib/gattrib.h"
#include "attrib/gatt-service.h"
#include "attrib/att.h"
#include "attrib/gatt.h"
#include "attrib/att-database.h"
#include "src/attrib-server.h"


#define MAX_STR_LEN       (256)

#define SIMPLE_SVC_UUID      0xfff0
#define SIMPLE_READ1_CHAR_UUID    0xfff1
#define SIMPLE_READ2_CHAR_UUID    0xfff2
#define SIMPLE_WRITE_CHAR_UUID    0xfff3  
#define SIMPLE_NOTIFY_CHAR_UUID    0xfff4


static char read1Data[MAX_STR_LEN];
static char read2Data[MAX_STR_LEN];

static int notifyData;

static uint8_t SimpleCharacteristic1Read(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{
 struct btd_adapter *adapter;
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
 
 adapter = user_data;
 
 attrib_db_update(adapter, a->handle, NULL, 
  (uint8_t*)&read1Data[0], strlen(&read1Data[0]), NULL);
 
 return 0;
}/*Characteristic1Read*/      

     

static uint8_t SimpleCharacteristic2Read(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{
 struct btd_adapter *adapter;
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
  
 adapter = user_data;
 
 attrib_db_update(adapter, a->handle, NULL, 
  (uint8_t*)&read2Data[0], strlen(&read2Data[0]), NULL);
  
 return 0;
}/*Characteristic2Read*/ 


static uint8_t SimpleCharacteristicWrite(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{

 unsigned char data[MAX_STR_LEN];
 int i;
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
 memset(&data[0], 0, MAX_STR_LEN);
 
 memcpy(&data[0], a->data, a->len);
  
 printf("written data : %s \n", &data[0]); 

 for(i = 0; i< a->len;i++)
  printf("%#1x ", (unsigned char)(data[i]));
 printf("\n"); 
 
 return 0;
}/*CharacteristicWrite*/


static uint8_t SimpleCharacteristicNotify(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{
 struct btd_adapter *adapter;
 
 adapter = user_data;
 
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
 do
 { 
  attrib_db_update(adapter, a->handle, NULL, 
   (uint8_t*)&notifyData, sizeof(notifyData), NULL);  
   
  //usleep(1*1000*1000);
  notifyData++; 
 }while(0); 
 
 return 0;
}/*CharacteristicNotify*/


static void RegisterSimpleService(struct btd_adapter *adapter)
{
 bt_uuid_t uuid;
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
 bt_uuid16_create(&uuid, SIMPLE_SVC_UUID);
 
 gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
 
 /* characteristic register*/
 
   /*read 1*/
   GATT_OPT_CHR_UUID16, SIMPLE_READ1_CHAR_UUID,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_READ ,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
     SimpleCharacteristic1Read, adapter,
     
   /*read 2*/
   GATT_OPT_CHR_UUID16, SIMPLE_READ1_CHAR_UUID,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_READ ,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
     SimpleCharacteristic2Read, adapter,

   /*write*/
   GATT_OPT_CHR_UUID16, SIMPLE_WRITE_CHAR_UUID,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_WRITE_WITHOUT_RESP,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
     SimpleCharacteristicWrite, adapter,

   /*NOTIFY*/
   GATT_OPT_CHR_UUID16, SIMPLE_NOTIFY_CHAR_UUID,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_READ|GATT_CHR_PROP_NOTIFY,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
     SimpleCharacteristicNotify, adapter,     
   /*end*/    
 GATT_OPT_INVALID);
 
 return ;      
}/*RegisterSimpleService*/

#define DEVICEINFO_SVC_UUID     0x180a 

char versionStr[MAX_STR_LEN] = "0.0.1";
char manufacturerStr[MAX_STR_LEN] = "Gaiger";   


static uint8_t SoftwareRevisionStringRead(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{
 struct btd_adapter *adapter;
 
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
   
 adapter = user_data;
 
 attrib_db_update(adapter, a->handle, NULL, 
  (uint8_t*)&versionStr[0], strlen(&versionStr[0]), NULL);
  
 return 0;
}/*SoftwareRevisionStringRead*/ 


static uint8_t ManufacturerStringRead(struct attribute *a,
      struct btd_device *device, gpointer user_data)
{
 struct btd_adapter *adapter;
 
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
   
 adapter = user_data;
 
 attrib_db_update(adapter, a->handle, NULL, 
  (uint8_t*)&manufacturerStr[0], strlen(&manufacturerStr[0]), NULL);
  
 return 0;
}/*ManufacturerStringRead*/ 


static void RegisterDeviceInfo(struct btd_adapter *adapter)
{
 bt_uuid_t uuid;
 printf("__FILE__ = %s, __FUNCTION__ = %s, __LINE__ =%d\n", 
  __FILE__, __FUNCTION__, __LINE__);
 
 bt_uuid16_create(&uuid, DEVICEINFO_SVC_UUID);
 
 gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
 
 /* characteristic register*/
     
   /*GATT_CHARAC_SOFTWARE_REVISION_STRING*/
   GATT_OPT_CHR_UUID16, GATT_CHARAC_SOFTWARE_REVISION_STRING,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_READ ,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
     SoftwareRevisionStringRead, adapter,
   
   /*GATT_CHARAC_MANUFACTURER_NAME_STRING*/
   GATT_OPT_CHR_UUID16, GATT_CHARAC_MANUFACTURER_NAME_STRING,
   GATT_OPT_CHR_PROPS, GATT_CHR_PROP_READ ,
   GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
     ManufacturerStringRead, adapter, 
   /*end*/    
 GATT_OPT_INVALID);
 
 return ;      
}/*RegisterSimpleService*/

static void update_name(struct btd_adapter *adapter, gpointer user_data)
{
 adapter_set_name(adapter, (char*)user_data);
}/*update_name*/



static int wii_probe(struct btd_adapter *adapter)
{
  
 update_name(adapter, "SimplePeripherial");
 RegisterDeviceInfo(adapter);
 RegisterSimpleService(adapter);
 
 return 0;
}/*wii_probe*/


static void wii_remove(struct btd_adapter *adapter)
{

}/*wii_remove*/

/*function pointers*/
static struct btd_adapter_driver wii_driver = {
 .name = "wiimote",
 .probe = wii_probe,
 .remove = wii_remove,
};


static int wii_init(void)
{
 printf("__FUNCTION__ = %s\n", __FUNCTION__);
 
 
 memset(&read1Data[0], 0, MAX_STR_LEN);
 memset(&read2Data[0], 0, MAX_STR_LEN);
 notifyData = 0;
 
 snprintf(&read1Data[0], MAX_STR_LEN, "it is read 1");
 snprintf(&read2Data[0], MAX_STR_LEN, "it is read 2");
 
 return btd_register_adapter_driver(&wii_driver);
}

static void wii_exit(void)
{
 printf("__FUNCTION__ = %s\n", __FUNCTION__);
 btd_unregister_adapter_driver(&wii_driver);
}

BLUETOOTH_PLUGIN_DEFINE(wiimote, VERSION,
  BLUETOOTH_PLUGIN_PRIORITY_LOW, wii_init, wii_exit)


 

And re-compiler the bluez library (you could just delete plugins/bluetoothd-wiimote.o and 
type make again to boost the compilation time).

Step 5.
    Similar with Step 3
Execute the command line under src folder:

[gaiger@localhost src]$ sudo ./bluetoothd -p wiimote -n


And run the BleAdvertise script again : you may need to run it twice, to ensure that has been executed indeedly.

  Now you could use your BLE Scanner or LightBlue to confirm your Pheripheral has been run:














Known Insuffiecient :
   If a central device (moblie) access the Notify characteristic, the bluez peripheral would  be led to crash.
  After the disconneciton event occurs, the Bluez perihpheral would not start again, it is,you need to run the BleAdvertise script again.
 

13 則留言:

  1. Hi chen,Thanks for This blog again,
    What is the importance of udev and systemd what if I --disable (udev and systemd) ?
    Is this script correct seems like we need to comment line "initialize device"
    Thanks

    回覆刪除
  2. Hi Chen,
    My setup: Intel Edison+bluez 5.27
    Followed your steps as it is
    Errors:Edison side

    root@edison:~/bluez-5.27# src/bluetoothd -p gatt_example -n &
    [1] 10820
    root@edison:~/bluez-5.27# bluetoothd[10820]: Bluetooth daemon 5.27
    bluetoothd[10820]: Starting SDP server
    bluetoothd[10820]: Ignoring (cli) hostname
    bluetoothd[10820]: Ignoring (cli) wiimote
    bluetoothd[10820]: Ignoring (cli) autopair
    bluetoothd[10820]: Ignoring (cli) policy
    bluetoothd[10820]: Ignoring (cli) sap
    bluetoothd[10820]: Ignoring (cli) a2dp
    bluetoothd[10820]: Ignoring (cli) avrcp
    bluetoothd[10820]: Ignoring (cli) network
    bluetoothd[10820]: Ignoring (cli) input
    bluetoothd[10820]: Ignoring (cli) hog
    bluetoothd[10820]: Ignoring (cli) health
    bluetoothd[10820]: Ignoring (cli) gap
    bluetoothd[10820]: Ignoring (cli) scanparam
    bluetoothd[10820]: Ignoring (cli) deviceinfo
    bluetoothd[10820]: Ignoring (cli) alert
    bluetoothd[10820]: Ignoring (cli) time
    bluetoothd[10820]: Ignoring (cli) proximity
    bluetoothd[10820]: Ignoring (cli) thermometer
    bluetoothd[10820]: Ignoring (cli) heartrate
    bluetoothd[10820]: Ignoring (cli) cyclingspeed
    bluetoothd[10820]: Ignoring (cli) external_dummy
    bluetoothd[10820]: Bluetooth management interface 1.3 initialized
    bluetoothd[10820]: hci0 Load Connection Parameters failed: Unknown Command (0x01)
    ^C
    root@edison:~/bluez-5.27# sh script.sh
    + export BLUETOOTH_DEVICE=hci0
    + BLUETOOTH_DEVICE=hci0
    + export OGF=0x08
    + OGF=0x08
    + export OCF=0x0008
    + OCF=0x0008
    + export 'IBEACONPROFIX=1E 02 01 16 1A FF 4C 00 02 15'
    + IBEACONPROFIX='1E 02 01 16 1A FF 4C 00 02 15'
    + export 'UUID=00 00 FF FF 00 00 10 00 80 00 00 80 5F 9B 34 FB'
    + UUID='00 00 FF FF 00 00 10 00 80 00 00 80 5F 9B 34 FB'
    + export 'MAJOR=00 01'
    + MAJOR='00 01'
    + export 'MINOR=00 00'
    + MINOR='00 00'
    + export 'POWER=C5 00'
    + POWER='C5 00'
    + hciconfig hci0 up
    + hciconfig hci0 noleadv
    LE set advertise enable on hci0 returned status 12
    + hciconfig hci0 noscan
    + hciconfig hci0 pscan
    + hciconfig hci0 leadv
    + hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 16 1A FF 4C 00 02 15 00 00 FF FF 00 00 10 00 80 00 00 80 5F 9B 34 FB 00 01 00 00 C5 00
    < HCI Command: ogf 0x08, ocf 0x0008, plen 32
    1E 02 01 16 1A FF 4C 00 02 15 00 00 FF FF 00 00 10 00 80 00
    00 80 5F 9B 34 FB 00 01 00 00 C5 00
    > HCI Event: 0x0e plen 4
    01 08 20 00
    + echo complete
    complete

    Android App:

    and I cant see find Device 5.27 TYPE: BLE ONLY
    only UNKNOWN DEVICE IS SEEN on android app

    回覆刪除
    回覆
    1. please note this line "bluetoothd[10820]: hci0 Load Connection Parameters failed: Unknown Command (0x01)"
      ans also note I was unable to install systemd and udev on edison so i used --disable-udev --disable-systemd while ./configure
      does it make any difference.
      Hoping for quick reply,
      Thanks

      刪除
    2. Sorry for my feeble knowledge in embedded system: As my knowing, If you wish the script or bluetoothd being executed automatically when the generic bluetooth dongle be just plugged, the udev (or mdev) is very imperious. But how to implement the connection between udev and bluetoothd I do not know detailly. Sorry for my late replying.

      刪除
  3. Hi,
    Thanks a lot for this tutorial. It's really been helpful.
    So I've been able to run the gatt_example plugin and advertise from my Raspberry Pi. I'm using LightBlue to connect to it on iOS, but when I connect to it I can't see any of the services and I get this message from bluetoothd:
    bluetoothd[2823]: Refusing storage path for private addressed device /org/bluez/hci0/dev_4E_8C_5E_D8_69_A5
    bluetoothd[2823]: Can't store info for private addressed device /org/bluez/hci0/dev_4E_8C_5E_D8_69_A5
    bluetoothd[2823]: Can't store services for private addressed device /org/bluez/hci0/dev_4E_8C_5E_D8_69_A5
    bluetoothd[2823]: Unable to register GATT service with handle 0x0001 for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x0006 for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x000a for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x000f for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x0013 for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x0019 for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x001e for device 4E:8C:5E:D8:69:A5:
    bluetoothd[2823]: Unable to register GATT service with handle 0x0028 for device 4E:8C:5E:D8:69:A5:

    Am I missing something?

    I'm using Bluez 5.28 with the latest version of Raspian

    回覆刪除
  4. Unable to register GATT service with handle - same problem here! i've tried bluez-5.11 bluez-5.28 and bluez-5.32 !

    回覆刪除
  5. Hey, Great work. Love it.

    I wish implement a HiD over GATT to make BLE Keyboard.Please share some clues to do it.

    回覆刪除
  6. Hi Chen,

    I am a newbie with BLE and using Bluez 5.46, however when I compiled your example I got these messages:
    ./src/adapter.h:87:1: error: unknown type name ‘sdp_list_t’
    sdp_list_t *btd_adapter_get_services(struct btd_adapter *adapter);
    ^
    ./src/adapter.h:98:54: error: unknown type name ‘sdp_record_t’
    int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
    ^
    In file included from plugins/wiimote.c:21:0:
    ./attrib/gatt.h:120:34: error: unknown type name ‘sdp_record_t’
    gboolean gatt_parse_record(const sdp_record_t *rec,
    ^
    ./attrib/gatt.h:121:6: error: unknown type name ‘uuid_t’
    uuid_t *prim_uuid, uint16_t *psm,

    Could you please show me what I should do to show it?
    Thank you so much!

    回覆刪除
    回覆
    1. "That is, the gatt-server fails in start. The only solution I know currently, is to use the Bluez version which is not later than 5.28. please back to Step 0, use version 5.28 and do all again."

      I have mentioned it in this post.

      刪除
  7. I tried your instructions, and it worked. I need to use Bluez 5.16 to get it to work. Thanks.

    I have one question. After I first connected with my peripheral, I disconnected. Before I tried to connect again, I need to run your BleAdvertise script. Is this supposed to be the way? I wish we could just run the BleAdvertise script once and do multiple connect/disconnect. Please shed your insight.

    Thanks again. Great work.

    回覆刪除
    回覆
    1. The script is withing insufficiency, it needs the user to be optimized.

      刪除
  8. Hi,

    I'm unable to get the notifications with the above provided example "wiimote".
    Can you please help me with that.How can I get notify to GATT client with the change in the value.

    Thanks for your help.

    回覆刪除