- Ensure that BlueZ and related dependency softwares (listed in setup document earlier) are installed on the host
- BlueZ is example Bluetooth stack used, as it is generally available in Linux. Any other Bluetooth stack can also be used.
- In following test, Android device was used as a BT/BLE test device. For BLE testing, nRF connect for mobile APP was used.
- Ensure that
hci0
interface is visible. To check that, runhciconfig
.
hci0: Type: Primary Bus: SDIO
BD Address: 3C:71:BF:9A:C2:46 ACL MTU: 1021:9 SCO MTU: 255:4
UP RUNNING PSCAN
RX bytes:8801 acl:1000 sco:0 events:406 errors:0
TX bytes:5097 acl:147 sco:0 commands:52 errors:0
- This interface supports all standard HCI commands. Use standard hci tools to control and configure this interface.
- Please note that
hciconfig
might be deprecated in latest stable BlueZ versions. You can use alternatives given by BlueZ.
- ESP-Hosted related BR/EDR 4.2 and BLE 4.2 functionalities are tested with
bluez
5.50+. Whereas BLE 5.0 functionalities are tested withbluez
5.45+. - We suggest latest stable
bluez
version to be used. Any other bluetooth stack instead ofbluez
also could be used. - To upgrade
bluez
for particular version, follow this link. Replace bluezolder version
toexpected version
while following mentioned link.
Steps:
- Run
sudo bluetoothctl
. - Run
list
to get MAC address of ESP. - To set device name, run
menu advertise
. Thenname <enter_any_name>
. - To come back to main menu, run
back
. - To start advertising, run
advertise on
. Perform below steps on Mobile Phone: - Turn on mobile phone's bluetooth. Open nRF connect application, ESP's MAC address will be displayed under
SCANNER
tab as a result of scan. - Click on connect. Client tab will be open. Click on
Generic Attribute
option. - Perform read/write on listed characteristics fields in
Generic Attribute
service. To disconnet: - Run
disconnect <MAC_ADDRESS_of_gatt_client>
on linux host'sbluetoothctrl
OR click onDISCONNECT
in nRF connect application'sGATT client
screen.
- Run
sudo bluetoothctl
. - To Turn on power, run
power on
. - Make device discoverable, run
discoverable on
. - Make device pairable, run
pairable on
. - Set current agent to default, run
default-agent
. - Turn on bluetooth support, run
agent on
. - Turn on mobile phone's bluetooth so that linux host can detect it.
- Start scanning, run
scan on
. - Once mobile phone's MAC address is listed in scan list, stop scanning, run
scan off
. - Start btmon to collect log in separate terminal window, run
sudo btmon &
. - To trust, run
trust <MAC address of mobile phone>
. - To pair, run
pair <MAC address of mobile phone>
. - To connect, run
connect <MAC address of mobile phone>
. - Once connected, please run
discoverable off
. - Go to gatt menu, run
menu gatt
. - list available attributes, run
list-attributes
. - select characteristic of service, run
select-attribute <characteristic_of_service>
. - perform read/write operation on selected characteristic.
- To disconnect, run
disconnect <MAC_ADDRESS_of_gatt_server>
.
- Please refrain for using
hcitool
, as they are deprecated in latest stable releases ofBlueZ
.
Alternative tool likesudo buetoothctl
with commandscan on
could be used for BT scan.
- Please refrain for using
hcitool
, as they are deprecated in latest stable releases ofBlueZ
.
Alternative tool likesudo buetoothctl
with commandscan on
could be used for BT scan.