Setting up Bluetooth automatic pairing on Linux [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to use any mobile phone to connect to a IoT device via Bluetooth Classic with the serial port protocol (SPP). The IoT device has no screen and no keyboard, and it's supposed to accept connections automatically as long as the connecting phone knows a secret PIN (ie, I don't want to be forced to ssh into the IoT device to set up pairing every time a new mobile phone tries to connect).
These are the commands that I've run so far on the IoT device:
# Make the device discoverable:
hciconfig hci0 piscan
# Register SPP:
sdptool add --channel=22 SP
# Start rfcomm:
rfcomm -r watch /dev/rfcomm0 22
Unfortunately, I couldn't find any way to set up a PIN, and pairing fails when I try to connect with a mobile phone. In addition, the device is only discoverable for a short interval.
How do I configure the IoT device's Bluetooth stack (running a recent Bluez) to auto pair with any phone that knows a given PIN, and how do I make the discovery period eternal?

If anyone happens upon this question, to use (much of) the BlueZ "BT Management Sockets" C API directly from bash, try:
btmgmt --help
btmgmt add-device, btmgmt find, btmgmt discov, etc.

You can run an application which implements BlueZ DBus API. I recommands BlueZ >= 5.42.
Use the agent interface and implements your own PIN code.
After registring your agent, bluez will automaticaly call and use you own agent when a pairing is asked.
Moreover, you can set the DiscoverableTimeout to 0 through DBus with org.bluez.Adapter1 interface.
"A value of zero
means that the timeout is disabled and it will stay in
discoverable/limited mode forever."
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt (dbus adapter object doc)
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/agent-api.txt (dbus agent object doc)
https://kernel.googlesource.com/pub/scm/bluetooth/bluez/+/5.44/test/simple-agent (sample)
http://www.bluez.org/bluez-5-api-introduction-and-porting-guide/ (read at the bottom)

Related

HFP/HSP profile in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have Ubuntu 16.04 and already installed BlueZ 5.37, PulseAudio 10.0, and ofono 1.20 (clone from github).
And I need to use phone like modem for transmitting my phone calls to computer. I paired my telephone with PC, made device trust and connect (all actions are successfully). I think problem with ofono, because I can play music (which use the A2DP) but if i want use hends free or headset profile - I have no sound on PC.
In pacmd (PulseAudio console tool) list-cards I see my bluetooth device, but Headset Audio Gateway HFP/HSP is not avalible. Also I tested it on different devices and computers.
Thank you in advice.
I've solved in this way:
Install ofono
In /etc/pulse/default.pa find the line load-module module-bluetooth-discover and change it to load-module module-bluetooth-discover headset=ofono.
If the user pulse is not a member of group bluetooth, then add it: sudo useradd -g bluetooth pulse
VERY IMPORTANT: add this to /etc/dbus-1/system.d/ofono.conf before </busconfig>:
<policy user="pulse">
<allow send_destination="org.ofono"/>
</policy>
See: https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/
The good news: Now in pavucontrol I can see that the profile changes automatically from A2DP to HSP / HFP if I make a phone call, and then it magically returns to A2DP!
The bad news: it works only one time per booting (and checking if ofonod is running), then I have to reboot my Debian system.
My Solution:
I just found my solution in Fedora 26, using Plantronics Legend and Pluggable Bluetooth USB, after a lot of searching.
I am going back through my history, and updating threads with my solution where I can. This worked for me, direct from Plugable (which is the USB module I am using).
See this post: plugable-usb-bluetooth-adapter-solving-hfphsp-profile-issues-on-linux
Command Summary per Above Link:
wget https://s3.amazonaws.com/plugable/bin/fw-0a5c_21e8.hcd
sudo mkdir /lib/firmware/brcm
sudo mv fw-0a5c_21e8.hcd /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd
sudo cp /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd /lib/firmware/brcm/BCM20702A1-0a5c-21e8.hcd
Then reboot.
HSP/HFP Profile not available for Bluetooth headset in Fedora 20, was available in Fedora 19 change the device and test it again
SOLVING HFP/HSP AND A2DP PROFILE ISSUES ON LINUX

How to force Wi-Fi adapter to use specific channel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am trying to force the Wi-Fi adapter to use a specific channel while connecting to the access point which supports both 2.4 GHz and 5 GHz (WPA authentication).
I am using the following configuration:
OS: Raspbian
Model: Raspberry Pi 2 Model B
Wi-Fi Adapter: Edimax EW-7811UTC
Driver: 8812au
I also tried with a different Wi-Fi adapter: Asus USB-N53 using driver rt2800.
Tried with iwconfig which is giving SET failed on device wlan0 ; Operation not supported.
Also tried wpa_supplicant.
What extra arguments need to be given to the wpa_cli or wpa_supplicant utility so that the Wi-Fi adapter will connect only to the specific band?
look for your interface
sudo iwconfig
look at your channels
sudo iwlist {interface} channel
turn off wifi
sudo iwconfig {interface} power off
set your desired channel
sudo iwconfig {interface} channel {channel, ex. "23"}
set your desired frequency
sudo iwconfig {interface} freq {frequency, ex. "5.00G"}
turn on wifi
sudo iwconfig {interface} power on
You can't do that. The channel is selected automatically in the 2.4 or 5GHz band because the channel depends on your router: The router selects a channel and your client simply uses it. There is no way for the client to tell the router "please switch to band 13".
The 2.4 and 5GHz bands are usually selected by the network name; your router should offer two WLAN names.

Arduino Uno Bluetooth Communication with Mac [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm trying to create an Arduino bluetooth remote that can connect with my Mac (and potentially other devices) and basically transmit a few distinct signals back and forth at the push of a button (or Arduino pushbutton). I want to create a remote to control a web app I've built, basically a controller for a game.
I have an Arduino Uno Rev3 starter kit, an RN-42 bluetooth module & a 1sheeld from Google Play, and a Macbook Pro.
Could anyone suggest good guides or online tutorials that can help me set up the communication from Arduino to my computer? Or does anyone have experience with this and would be able to give me some tips?
It's relatively straightforward.
bind the arduino bluetooth to your mac bluetooth.
use Serial.* print commands. Normally these go to your computer via USB, but if you have the Bluetooth connected it will go over the Bluetooth connection.
the default baud rate of most bluetooth devices is 9600 baud.
So, develop your code the same way as if you were connected via Serial over USB, and it will work without change when you attach the Bluetooth.
Note: Typically USB and Bluetooth will use the same pins, so you can only use one or the other, not both at the same time.

how to determine which codecs a bluetooth device supports over A2DP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
The community reviewed whether to reopen this question 2 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have a bluetooth device (headphones) that supports playing audio over A2DP.
I've been pairing them with both an iPhone and an Android, and I get only extremely poor audio quality with both sources.
My suspicion is that the device only supports the SBC codec, but not Mp3. Or if it does MP3, only an abysmally low bitrate.
The manufacturer only states A2DP is supported, but not which codecs.
How can I determine which codecs are supported? Is there a kind of protocol sniffer I could use on my phone or my computer and interrogate the device to get a definitive answer on what it supports?
You can actually see used A2DP codec in iOS device's console.
Step-by-step guide:
Connect your iOS device to your Mac, answer Trust on the iOS device if you haven't done this before.
Open Console.app.
Select your iOS device on the left sidebar.
Type bluetooth in the top-right search bar, press Enter and select Subsystem instead of All:
Now, start playing to your bluetooth headphones on the iOS device (codec activates only when you output sound).
Press Cmd+F and search for Starting a2dp send thread in your console messages:
You'll see used codec in codec: field. Values are the same as specified in Bluetooth specs (example). Basically 0 = SBC, 2 = AAC.
Was very surprised, though, that a pair of headphones I just bought from very adored and award-winning manufacturer (not Sennheiser) does not have AAC codec in them, despite having that in specifications (will not name them here, contacting their tech support for clarification).

PPP demand dial with modem bank in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a linux box with a bank of modems and need to create demand-dial (outbound) PPP connections to a very large set of remote machines. Since I have far more remotes than local modems, I'd like to launch one or more instances of pppd in demand mode, but not allocate a particular modem until a connection is requested. When the connection becomes idle, I'd like pppd to release the modem so it can be used for a connection to a different remote.
I've been through the pppd man pages and understand the concepts of the call and connect options, as well as the options.DEVICE files and the /etc/ppp/peers directory. Lock files will tell me which modems are in use or available. And I'm able to connect to multiple remote peers as long as I hard-code the modem assignments. But I haven't found a way to assign them dynamically, say by calling a get_available_modem script when pppd needs to dial. Google doesn't seem to know, either.
A work-around might be to detect the need to demand-dial with an external mechanism, and then launch pppd to service it, but it seems cleaner to leverage the facility within pppd itself.
Any pointers or ideas are appreciated. Thanks for your thoughts!
This is the solution I'm going with:
Enumerate the modems as /dev/modem0, /dev/modem1, ...
Start an instance of pppd in demand-dial mode for each peer, but instead of a "real" modem, attach it to /dev/modem.peer, which the "ppp-on-dialer" script soft-links to the first available modem dynamically.
When the connection times out and the modem goes offline, soft link /dev/modem.peer to /dev/null so the modem can be re-used for a connection to a different peer.
Thanks for your comments!
Does it have to be directly driven by the Linux box, or could you use something like the old Lucent Portmaster boxen?

Resources