- 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
hci0interface 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
hciconfigmight 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
bluez5.50+. Whereas BLE 5.0 functionalities are tested withbluez5.45+. - We suggest latest stable
bluezversion to be used. Any other bluetooth stack instead ofbluezalso could be used. - To upgrade
bluezfor particular version, follow this link. Replace bluezolder versiontoexpected versionwhile following mentioned link.
Steps:
- Run
sudo bluetoothctl. - Run
listto 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
SCANNERtab as a result of scan. - Click on connect. Client tab will be open. Click on
Generic Attributeoption. - Perform read/write on listed characteristics fields in
Generic Attributeservice. To disconnet: - Run
disconnect <MAC_ADDRESS_of_gatt_client>on linux host'sbluetoothctrlOR click onDISCONNECTin nRF connect application'sGATT clientscreen.
- 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 buetoothctlwith commandscan oncould be used for BT scan.
- Please refrain for using
hcitool, as they are deprecated in latest stable releases ofBlueZ.
Alternative tool likesudo buetoothctlwith commandscan oncould be used for BT scan.