Bluetooth connection close itself right after start - linux

my problem is the connection with a Bluetooth device. I have a Netbook with an integrated bluetooth device. I want to connect my netbook with an OBD-II interface and write a software to read out the stats of my car. To test the connection, I started by adding the OBD device via the bluetooth menu. The manager connects to the interface and it wants me to wait while the configurations are taking place. This state lasts "forever". After 60-Minutes of waiting, I closed the window. However, the device is shown in the list of available devices. Because I'm not able to switch the button to initiate the connection, I thought about using minicom (the OBD-II interface uses SPP for communicating).
As far as I did understand, I need an initiated connection with a bluetooth device and with it a virtual serial port to connect to with minicom. After reading some postings, I found out that the hcitool should be able to create the bluetooth session. With this I was able to connect to the device and the "connected" button turned on. Unfortunately it switches back after 2 secs.
hcitool scan is able to find the device
hcitool cc 00:11:22:33:44:55 is able to connect for the already mentioned 2 secs
hcitool con list the connection if it's called within 2 sec after initiating
I also tried to connect via a Windows PC using putty. Windows connected with the device without a problem and after that, I was able to send requests and get the appropriate answers. So it seems like the interface is working correctly.
I'm using Fedora 17 with gnome3. If you need any output or more information, please let me know.
Thanks in advance

Related

How to allow only 1 connection to BlueZ GATT server at any given moment?

I'm working on Bluetooth on the embedded Linux. I'm using BlueZ and D-Bus. I have a server taken from the example https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-server.
I have the app such as nRF installed in 2 iPhones. I'm able to connect to my Linux Bluetooth server at the same time. I'm able to modify the characteristic from either of the iPhone app. But this is a problem because we don't want it. We'd like to have only 1 phone connected to the Linux device. That way, the same characteristic won't be modified by more than 1 phone app at the same time.
Is there a way to allow only 1 connection to the Linux Bluetooth GATT server at any given time?
Thanks.
Yes, the way to do this is to disable/stop advertisements on your Linux device as soon as a connection is established. This way, upon a connection, your Linux device will no longer be advertising and remote devices will no longer be able to connect to it.

beaglebone black wireless bluetooth AVRCP

I am working on a project with the beagle bone black wireless, where I need to be able to send music control commands to a phone. Note, I don't want to stream music to my beaglebone. I have spent about a week looking online, and found very little about this.
The OS for the beaglebone is Debian Jessie. I can get things like hci0tool, Bluetoothctl, hciconfig to work. I can detect and pair to a device. It seems though that my connection only lasts for the pairing process, and fails every time afterwards.
My current process is executing:
sudo su
bluetoothctl
power on
agent on
default-agent
scan on
I get the mac address
scan off
pair <MAC Address>
trust <MAC Address>
connect <MAC Address>
As of now pairing and trust succeed, though the connection ends after pairing finishes. And I have no idea of where to start for sending a command to a phone.
Connect call on Device1 interface will tries to connect all the profiles supported between the device and adapter. This happens by negotiating or exchanging the supported profiles.
Connection may not be possible when Adapter doesn't support the minimal requirement of profiles which is needed by the Device. In this case, you may need A2DP provider in adapter end to get connection successful. Yes, this is contradictory to this statement.
If you don't want to connect with all the profiles between Device and Adapter, then you can use ConnectProfile method in Device1 interface.
But bluetoothctl doesn't provide commands to achieve neither ConnectProfile nor you AVRCP commands.
You need to use D-Bus calls to get the communication with Bluetoothd. If your application is command line/shell based, you can use dbus-send/gdbus commands to address the D-Bus interface.
Although bluez-tools implements media control AVRCP commands, it doesn't provide any utility which uses it. Either you can compile bluez-tools as library and develop application using the media control API or use dbus-send/gdbus.
I have started with some samples using GDBUS, but not yet for AVRCP controls. See here : https://gist.github.com/parthitce
and Documentation here: https://www.linumiz.com/category/blog/

Issue with Bluetooth connection. Raspberry pi3 and nodejs 7.4.0

Ass everyone saying in their first posts "I'm new one" and trying to figure out one complexity.
I want to scan and create list of available wifi networks in Raspberry area and send the list to the phone via bluetooth.
Next - select one of the networks in the list on the phone, enter a password to selected network and send back via bluetooth to Raspberry
I'm using Raspberry pi3 with bluetooth on board, Raspbian OS and nodejs v7.4.0
I choose wifi-control to work with wifi network and it works greate. One thing - I should run npm run with sudo to get all networks, not just current one;
Then I'm trying to work with bluetooth via bluetooth-serial-port lib.
First of all I did all preparations that was written in documentation.
var btSerial = new (require('bluetooth-serial-port')).BluetoothSerialPort();
btSerial.inquire();
And it does nothing. At least I don't see any effect - my phone doesn't "see" Raspberry in available bluetooth devices list;
I thought that my Raspberry has porblems with bluetooth, but then I run
bluetoothctl -> power on -> discoverable on
And Raspberry appeared on phone.
What should I do to "turn on" Bluetooth control and add my Raspberry to list of available bluetooth devices?
Peace!
Got the exact same problem. My solution (which might or might not be fitting for your needs) was to pair the phone via bluetoothctl beforehand. (this already is you why this solution kinda sucks: you can't come and use a different phone/pi the next day, stuff got completely screwed when changing to a different pi :D)
Oh and the main script should run as root, else all of this wont work.
1) Pairing your device
$ bluetoothctl
[bluetoothctl] agent on
[bluetoothctl] discoverable on
[bluetoothctl] pairable on
[bluetoothctl] scan on
(now you turn on your bluetooth on your phone and search for devices, in bluetoothctl you should see your device and mac to be shown)
[bluetoothctl] pair XX:XX...(MAC of your phone)
(phone is going to show the "yo this device wants to pair"-dialog and bluetoothctl wants you to confirm the pairing too)
Now you can always connect to the pi via bluetooth, if it is discoverable or not. (I'm using Serial Bluetooth Terminal)
2) Actual talking between devices
NONE of the npm packages supposed to work with bluetooth worked for me. Not a single one. So in the end I used rfcomm and it's ability to start a program on connection. Together with serialport I let rfcomm run node myscript.js, which establishes the actual serial connection like so:
2.1) rfcomm waiting for connections
const rfcommProc = spawn(
'rfcomm',
['watch', 'hci0', '1', 'node', `${__dirname}/myscript.js`]
);
2.2) myscript.js opening the port
const port = new SerialPort('/dev/rfcomm0', spError => {
if (spError) {
process.send(spError);
}
})
Look up on the npmjs-page how to receive and send stuff now.(:
Hope this gives you some ideas and/or helped.
3) Note
The bluetooth service starts quite late. Making a service requiring it didn't do the job for me, but adding it to rc.local seems to be "late enough" to have it running and listening on startup.

Automatic bluetooth connection to a certain device

I am working on an application (windows phone 8.1), which is the following: if my phone is already connected to a bluetooth device then it should connect in parralel to another device which is already paired("cc2541"). I would appreciate a little help with the coding.
My problem is i don't know how to connect to a device automatically. I only found code samples that are only scans and lists devices and it only connects when I touch the screen ( approve the connectivity ).
You can get the RSSI value (signal strength) for each device, then you can implement a dispatcherTimer, where you start the scanning as the timer starts and then connect to the closest device on a timeout.
This is a basic example of automatic connection establishment.

communication between bluetooth module and remote Human interface device

I have been using bluetooth module BC 417 of company "NOVA".
I have kept all UART setting as suggested by datasheet.
i.e. buad rate=9600, parity=none, stop bit=1
My connection is getting established with nokia 5130 bluetooth, but as soon as m going to send something from UART connection is disabled.
Whenever i go to connect this module to android phone's bluetooth, connection does not take place.
For making connection i am using this command BC:CS=<address of bluetooth>
So i have following question:-
Is there any another setting is required in hyper terminal?
Is there any firmware is available for nova comm control interface module version 1.2?
Sorry, I only have enough reputation to answer and not just comment. You might want to try making sure that hardware flow control is switched on. It's a little difficult to know for sure as details of your set-up are so sketchy. Are you connecting this to an embedded micro and then trying to connect to a phone? What are you connecting hyper terminal to? Another phone or this Nova module?

Resources