aqing1987 / bluez5-spp-example Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tonyespy/bluez5-spp-example
Bluez5 Serial Port Profile example client/server
This project forked from tonyespy/bluez5-spp-example
Bluez5 Serial Port Profile example client/server
This is an example Bluetooth Serial Port Profile client and server application which uses bluez 5.x to exercise the Bluetooth Serial Port Profile (1.2). To run as a server, just invoke from the command-line using 'sudo' and no arguements. To run as a client, adding any string after the command name will trigger this mode. First, the application registers itself to bluez using the ProfileManager1's RegisterProfile method. It will indicate to bluez what role it's playing (client or server). If run as server, this will cause the BT controller to list the Serial Port profile when the bluetoothctl 'show' command is run. Likewise, from a remote device, the bluetootctl 'info' command will also show the Serial Port profile listed for the device. When run a client, the Serial Port profile will not be listed on either side. When a connection is triggered on the client, bluez will call the NewConnection method and pass an active Bluetooth RFCOMM socket which then can be used to write data to the server. On the server side, if the client device is paired, but trusted, then the default agent needs to be configured (eg. agent on, default-agent), and if so, a prompt will be displayed asking an admin to confirm the incoming server request. If trusted, or an admin confirms the service request, then the server's NewConnection method will be called with a fd representing the other end of the BT socket. In the current implementation, the IO is done very simply with read/write calls. Also, the server explicitly sets the socket to blocking mode to simplify the code. When boths sides complete their IO, the application exits. To trigger the connection from client to server, the following dbus-send command can be used: $ sudo dbus-send --system --print-reply --dest=org.bluez \ /org/bluez/hciX/dev_XX_YY_ZZ_AA_BB_CC \ org.bluez.Device1.ConnectProfile \ string:"00001101-0000-1000-8000-00805f9b34fb" * hciX - replace X with controller index (eg. hci0) * dev_XX_YY_ZZ_AA_BB_CC - replace with server's BT control MAC address
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.