GithubHelp home page GithubHelp logo

tiger12506 / bleuart Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 20 KB

UART bridge for BLE devices such as HM-10. Similar to rfcomm.

License: GNU General Public License v3.0

Makefile 3.57% C 96.43%
bluetooth low energy rfcomm uart spp hm-10

bleuart's Introduction

bleuart

A utility that functions similar to rfcomm, but for cheap china bluetooth low energy uart bridges, such as the HM-10

Dependencies: gattlib

How to use this code:

git clone https://github.com/labapart/gattlib.git
cd gattlib
mkdir build
cd build
cmake ../
make
cpack -G DEB
sudo dpkg -i gattlib_0.2-dev_x86_64.deb 

cd ../..
git clone [email protected]:tiger12506/bleuart.git
cd bleuart
make
bluetoothctl
./bleuart -d 00:15:83:10:EA:BE -c 0000ffe1-0000-1000-8000-00805f9b34fb

In order to find bluetooth address and characteristic uuid, use bluetoothctl

jacob@js:~/bleuart$ bluetoothctl
[NEW] Device 00:15:83:10:EA:BE CC41-A

... much output withheld for brevity ...

[bluetooth]# connect 00:15:83:10:EA:BE 
Attempting to connect to 00:15:83:10:EA:BE
[CHG] Device 00:15:83:10:EA:BE Connected: yes
Connection successful
[CHG] Device 00:15:83:10:EA:BE ServicesResolved: yes

[CC41-A]# list-attributes 00:15:83:10:EA:BE 
Primary Service
	/org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023
	0000ffe0-0000-1000-8000-00805f9b34fb
	Unknown
Characteristic
	/org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024
	0000ffe1-0000-1000-8000-00805f9b34fb
	Unknown
Descriptor
	/org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Descriptor
	/org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0026
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration

... other attributes withheld for brevity ...

[CC41-A]# select-attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 
[CC41-A:/service0023/char0024/desc0027]# read
Attempting to read /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x20
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x54
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x58
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x20
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x26
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x20
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x52
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x58
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024/desc0027 Value: 0x20
  20 54 58 20 26 20 52 58 20                        TX & RX        

... Looks like char0024 is the serial characteristic, because it's "User Description" descriptor has this value ...

[CC41-A:/service0023/char0024/desc0027]# select-attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024

[CC41-A:/service0023/char0024]# read
Attempting to read /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024
[CHG] Attribute /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024 Value: 0x0a
  0a                                               .               

... I'm not sure this is meant to work, notify will work, however ...

[CC41-A:/service0023/char0024]# write 0x30
Attempting to write /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024


... Write a '0' character through the bluetooth uart characteristic. Should appear on the TX pin of the HM-10 ...

[CC41-A:/service0023/char0024]# attribute-info /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023/char0024
Characteristic - Unknown
	UUID: 0000ffe1-0000-1000-8000-00805f9b34fb
	Service: /org/bluez/hci0/dev_00_15_83_10_EA_BE/service0023
	Value: 0x0a
	Notifying: no
	Flags: read
	Flags: write-without-response
	Flags: write
	Flags: notify
[CC41-A:/service0023/char0024]# 


... There's the UUID we want, that belongs to the serial characteristic we found ...

bleuart's People

Contributors

tiger12506 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

haogitcc

bleuart's Issues

RFCOMM equivalence

Need to update this to make it act more like rfcomm.

  1. Need to pipe through a "device" file like rfcomm does with /dev/rfcomm0
  2. Need to add command-line option(s) for specifying the UUID for the serial characteristic
  3. Need to update readme to reflect these changes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.