8.14.12 BLE Peripheral Mode Example for BlueZ 5.29 and Later

Starting with BlueZ 5.29 and later, the time profile is no longer supported using bluetoothd. An alternative approach is to use the btgatt-server example that is automatically built while building the BlueZ package. However, it is important to note that buildroot does not install this example to the target by default; we have to manually copy the example (install on) to the host using the scp or rz commands.

To install it automatically, the .mk file for BlueZ in the buildroot system will need to be modified as follows:
  1. Edit file buildroot/package/bluez5_utils/bluez5_utils.mk.
  2. Add the following lines at the end of the file before $(eval $(autotools-package))
    define BLUEZ5_UTILS_INSTALL_GATTEXAMPLE
            $(INSTALL) -D -m 0755 $(@D)/tools/btgatt-server $(TARGET_DIR)/usr/bin/btgatt-server
    endef
    BLUEZ5_UTILS_POST_INSTALL_TARGET_HOOKS += BLUEZ5_UTILS_INSTALL_GATTEXAMPLE
    
To run the example, use the following commands:
# modprobe wilc-sdio
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Registering wifi device
(unnamed net_device) (uninitialized): INFO [WILC_WFI_CfgAlloc]Allocating wireless device
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Successful Registering
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Registering wifi device
(unnamed net_device) (uninitialized): INFO [WILC_WFI_CfgAlloc]Allocating wireless device
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Successful Registering
wilc_sdio mmc0:0001:1: WILC got 60 for gpio_reset
wilc_sdio mmc0:0001:1: WILC got 94 for gpio_chip_en
wilc_sdio mmc0:0001:1: WILC got 91 for gpio_irq
wifi_pm : 0
wifi_pm : 1
wilc_sdio mmc0:0001:1: Driver Initializing success
# wilc_sdio mmc0:0001:1 wlan0: INFO [wilc_netdev_cleanup]Unregistering netdev d4782000
wilc_sdio mmc0:0001:1 wlan0 (unregistered): INFO [wilc_netdev_cleanup]Freeing Wiphy...
wilc_sdio mmc0:0001:1 wlan0 (unregistered): INFO [wilc_free_wiphy]Unregistering wiphy
wilc_sdio mmc0:0001:1 wlan0 (unregistered): INFO [wilc_free_wiphy]Freeing wiphy
wilc_sdio mmc0:0001:1 wlan0 (unregistered): INFO [wilc_netdev_cleanup]Freeing netdev...
wilc_sdio mmc0:0001:1 p2p0: INFO [wilc_netdev_cleanup]Unregistering netdev d477b000
wilc_sdio mmc0:0001:1 p2p0 (unregistered): INFO [wilc_netdev_cleanup]Freeing Wiphy...
wilc_sdio mmc0:0001:1 p2p0 (unregistered): INFO [wilc_free_wiphy]Unregistering wiphy
wilc_sdio mmc0:0001:1 p2p0 (unregistered): INFO [wilc_free_wiphy]Freeing wiphy
wilc_sdio mmc0:0001:1 p2p0 (unregistered): INFO [wilc_netdev_cleanup]Freeing netdev...
Module_exit Done.
at_pwr_dev: deinit
at_pwr_dev: unregistered
mmc0: card 0001 removed
mmc0: new high speed SDIO card at address 0001
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Registering wifi device
(unnamed net_device) (uninitialized): INFO [WILC_WFI_CfgAlloc]Allocating wireless device
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Successful Registering
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Registering wifi device
(unnamed net_device) (uninitialized): INFO [WILC_WFI_CfgAlloc]Allocating wireless device
(unnamed net_device) (uninitialized): INFO [wilc_create_wiphy]Successful Registering
wilc_sdio mmc0:0001:1: WILC got 60 for gpio_reset
wilc_sdio mmc0:0001:1: WILC got 94 for gpio_chip_en
wilc_sdio mmc0:0001:1: WILC got 91 for gpio_irq
wilc_sdio mmc0:0001:1: Driver Initializing success

# echo BT_POWER_UP > /dev/wilc_bt
at_pwr_dev: open()
AT PWR: bt_power_up
wilc_sdio mmc0:0001:1: SDIO speed: 50000000
wilc_sdio mmc0:0001:1: chipid 003000d0
WILC POWER UP
at_pwr_dev: close()
#
# echo BT_FW_CHIPaWt_pUwr_dev: open()
 > /at_pwwrc_dtev: close()
#
# echo BT_DOWNLOAD_FW > /dev/wilc_bt
at_pwr_dev: open()
AT PWR: bt_download_fw
Bluetooth firmware: mchp/wilc3000_ble_firmware.bin
Downloading BT firmware size = 58276 ...
Starting BT firmware
BT Start Succeeded
at_pwr_dev: close()
#
# echo BT_FW_CHIP_ALLOW_SLEEP   > /dev/wilc_bt
at_pwr_dev: open()
at_pwr_dev: close()
#
# hciattach ttyS1 any 115200 noflow
atmel_usart fc010000.serial: using dma0chan10 for rx DMA transfers
atmel_usart fc010000.serial: using dma0chan11 for tx DMA transfers
Device setup complete
#
# hciconfig hci0 up
#
# hciconfig hci0 leadv
#
# btgatt-server -i hci0 -s low -t public -r -v
Started listening on ATT channel. Waiting for connections
Connect from 49:0D:EA:C2:98:66
NET: Registered protocol family 38
Running GATT server
[GATT server]# att: > 0a 10 00                                         ...
[GATT server]# att: ATT PDU received: 0x0a
[GATT server]# server: Read Req - handle: 0x0010
[GATT server]# att: ATT op 0x0b
[GATT server]# att: < 0b 01                                            ..
[GATT server]#