Command line interface to BLE (UART)

I've been able to use an Arduino Nano 33 BLE and create a UART connection to the unit with an iPhone (using Bluefruit Connect). I can send and receive messages; this is great. Relatively simple setup.

Now, the trick is to do so with a Linux box (Ubuntu 20.04).

From what I gather, using 'sudo hcitool -i hci0 lescan' can do an LE Scan, and I can see the various devices around. For example:

FB:0D:FF:43:44:3F (unknown)
5B:5D:F1:A3:D5:60 (unknown)
5B:5D:F1:A3:D5:60 Echo
1B:A8:4E:B8:03:7D (unknown)
7B:FF:94:C5:60:74 (unknown)

The device I have has been able to connect to via the phone. The question is, how does one connect to this device (which has a UART capability) from the Linux command line? Again, a simple 'Echo' program (which is in the Arduino HardwareSerialBLE examples) works fine with the phone.

I've tried the gatttool command in interactive mode:

gatttool --device=5B:5D:F1:A3:D5:60 -I

which returns:

[5B:5D:F1:A3:D5:60][LE]>

This is a good sign. Then, connecting:

[5B:5D:F1:A3:D5:60][LE]> connect
Attempting to connect to 5B:5D:F1:A3:D5:60
Connection successful
[5B:5D:F1:A3:D5:60][LE]> 

Now, looking at the primary and characteristics:

[5B:5D:F1:A3:D5:60][LE]> primary
attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0006, end grp handle: 0x0009 uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000a, end grp handle: 0x000f uuid: 6e400001-b5a3-f393-e0a9-e50e24dcca9e
[5B:5D:F1:A3:D5:60][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0007, char properties: 0x20, char value handle: 0x0008, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000b, char properties: 0x04, char value handle: 0x000c, uuid: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
handle: 0x000d, char properties: 0x10, char value handle: 0x000e, uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e
[5B:5D:F1:A3:D5:60][LE]> 

(The primary and characteristic commands show values that show that the serial communication stuff is there; a search on the uuid of 6e400002-b5a3-f393-e0a9-e50e24dcca9e and 6e400003-b5a3-f393-e0a9-e50e24dcca9e show that these are the UART things.

But what is the next step in connecting, so strings can can be sent back and forth?

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like