Connecting two raspberry pi through bluetooth with bluez - bluetooth

I'm trying to use this API: https://www.linumiz.com/bluetooth-connectdevice-without-scanning/ to make a connection between two Raspberry PI. I'm using this program like a server such as:
pi#raspberrypi:~/bluetoothC $ sudo ./bin/bluez_adapter_connect
Adapter is Powered "on"
and then, in the client side:
pi#raspberrypi:~/bluetoothC $ sudo ./bin/bluez_adapter_connect
B8:27:EB:9F:91:A7
Adapter is Powered "on" Unable to get result:
GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Method
"ConnectDevice" with signature "a{sv}" on interface
"org.bluez.Adapter1" doesn't exist
But I don't understand this error. I'm doing this correctly? If not, what I have to do?

As mentioned in the article, ConnectDevice is the new adapter API introduced in BlueZ 5.49. Refer release notes here for more details.
This API is still marked as experimental, so you need to run bluetoothd daemon in experimental mode, i.e by passing "-E" as extra argument when starting bluetoothd.
So you need,
BlueZ 5.49 or later
Run bluetoothd daemon with "-E" option

Related

hcitool cc and hcitool auth returns Input/output error

I have successfully set up and enabled Bluetooth on my server running Debian Buster. That in itself is quite an achievement. Anyhow, I am trying to use a Node package called node-bluetooth-serial-port to connect to a tiny Bluetooth speaker with a display. I manage to list/scan devices, but it cannot send anything to the device. I'm thinking this is because my server hasn't been paired with the device yet.
$ hcitool scan
Scanning ...
11:22:33:44:55:66 TimeBox-mini-audio
$ sudo hcitool cc 11:22:33:44:55:66; sudo hcitool auth 11:22:33:44:55:66
HCI authentication request failed: Input/output error
So hcitool can find the device, but it cannot connect to it, for some reason. dmesg doesn't show me any errors what so ever.
I have tried to pair with other devices (like my phone), but that doesn't work either.
The device does not require a 4-digit pin to auth.
What can I do here?

Serial port unavaliable arduino

Trying to upload a code to arduino, but whether in the Arduino IDE or Arduino Create, both return this erro while uploading. Running on Linux Tara(mint 19 cinnamon).
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega2560 -build-cache /tmp -build-path /tmp/716441957/build -verbose -libraries /tmp/716441957/custom -libraries /tmp/716441957/pinned /tmp/716441957/sketch_oct8a
Sketch uses 8280 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 443 bytes (5%) of dynamic memory, leaving 7749 bytes for local variables. Maximum is 8192 bytes.
Programming with: Serial
Flashing with command:/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude -C/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino-create-agent734074237/sketch_oct8a.hex:i
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
1#
First, check the port in your IDE. In Arduino tools->port
If the port is hidden or you can not move the cursor over this then run this commands in your terminal.If everything ok then skips this and follow the second part.
sudo apt-get install librxtx-java -y
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
2#
After this again check the first method. If it is not working then run this commands
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>
You probably have another program running which is already using this port.
You should close most other programs like putty or another serial monitor app.
Otherwise, try to reconnect the Arduino to the PC.
I know that these ideas below come from using a Teensy, but they may help you.
Sometimes there are the ACM* ports listed in the Arduino IDE. Try looking at the ser ports. I know when I am running my Teensy, sometimes I have them switched and need to select the correct one.
Also, from my experience with the Teensy, you might need to add a udev rule to allow permissions to access the port from non-root user. Here is the link that shows the udev file.
There is no direct way to solve this issue. In addition to it, you are not using an IDE. I will list the things you need to check, I am sure this will solve your problem.
I am not good at Linux environment so I will refer to applications names as window, you go the corresponding application in Linux.
Go to linux device manager and see for your arduino board. It should have proper naming like "arduino uno at port 3", then use the correct port in your command. If this name does not come properly then it means Driver is not available in your machine. So, go to step2.
Find the driver online and install it in your system, I am not sure about the support of linux with arduino, once it is done please repeat step1.
So, I conclude in short that you do not have the proper driver (which is strongly believe) or pointing the wrong port. I am not an expert with the udev rules, but it is definitely an issue you can experience with these kinds of micro-controllers.

Cygwin Error : tcp_peer_send_blocking: send() to socket

My Cygwin installed on Windows 7 was working properly till I try to install a new package. The package installation failed. Then I keep getting this error every time I want to run my Open MPI program. I can successfully compile the program but cannot run it. I even remove and make a new installation without success.
Thanks for any hints. Below is the sample error message.
[Reloaded-PC:03900] [[3921,1],0] tcp_peer_send_blocking: send() to socket 13 failed: Transport endpoint is not connected (128)
[Reloaded-PC:03900] [[3921,1],0] tcp_peer_send_blocking: send() to socket 13 failed: Transport endpoint is not connected (128)
[Reloaded-PC:04676] [[3921,1],2] tcp_peer_send_blocking: send() to socket 13 failed: Transport endpoint is not connected (128)
[Reloaded-PC:04676] [[3921,1],2] tcp_peer_send_blocking: send() to socket 13 failed: Transport endpoint is not connected (128)
The problem is solved by disabling the unused network adapter in "Control Panel->Network and Internet->Network Connections".
It turned out the unused network adapter tried to get configured by DHCP and an IP address started with "169.254.X.X" was assigned to this adapter when DHCP fails. Somehow openmpi on Cygwin use that invalid IP address for establishing communication between processes.
I figured it out by looking at /tmp/openmpi-sessions-{username}/{PID of orterun}/contact.txt.
I had this same problem on Cygwin with OpenMPI 1.10.4.
Try adding "-report-uri -" to your mpirun command to see what IP address it's trying to use for connection:
mpirun -report-uri - -np 2 a.exe
It should print out a line that looks something like this:
568328192.0;tcp://192.168.10.103,169.254.247.11,0.0.0.0,0.0.0.0,0.0.0.0:55600
If the first IP address after the "tcp://" is not a current valid address for your machine, that's the problem and things are likely to break (even if the correct IP appears later in the list). Apparently ORTE is not smart enough to order the interfaces based on what is actually enabled and online.
If the wrong IP corresponds to an old/disabled interface, uninstall it (if possible) using the windows network connections control panel.
In my case, the first address was a DHCP address for an old hardware adapter I'd removed and thrown away long ago (but apparently not uninstalled in software). Windows normally hides such removed-but-not-uninstalled interfaces in the control panel, but the settings remain in the registry under:
HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\
Search in that registry subkey for the bogus IP address and you are likely to find the problematic interface. I fixed mine by changing the IP address in that registry key to match my current static IP, but uninstalling the interface entirely would probably also work.
I had the same problem with openmpi v 1.8.8 (which is the default version of the package installed by cygwin). Manually going back to version 1.8.6 fixed the issue for me.
I just encountered this problem and in my case I had to disable the "VirtualBox Host-Only Network" adapter (I recently installed virtualbox and have not used openmpi in cygwin after that until today).
1. Open the Cygwin terminal.
mpicc --version
mpirun --version
If not execute, follow the document below and reinstall everything. Document
2. Try turning off Bluetooth and test your program again.
3. Try closing the Wifi and test your program again (you can connect to the wired internete)
4. Open C:\Windows\System32\drivers\etc\hosts
add line
127.0.0.1 localhost cygdrive wpad
and test your program again.
5. If you have a virtual network like VirtualBox or similar, turn off the control panel and test your program again.
6. If possible, uninstall VirtualBox completely. Restart your computer and test your program again.
7. Try turning off the Windows Firewall and test your program again.
The above steps solved both the "tcp_peer_send_blocking: send () to socket 12 failed: transport endpoint is not connected" error and the slowness problem in MPI for Windows 10 - Cygwin.

gatttool and hcitool on Linux

I'm trying to connect to a device using gatttool on Linux. I run hcitool lescan to get the device MAC address, and then gatttool -i hci1 -b <macaddr> -t random -I. Then I type connect. I see [CON] as expected, but the problem is that it disappears automatically after about 1s, with no error messages. I have been searching for hours, but I don't see why that is so?
Note: I have run hcitool lecc before running gatttool one time just to try it, but it seems to me that since then, gatttool connection is not working properly anymore (unexpected disconnection as explained above). Is it because I have used hcitool lecc? If yes, is there a way to "undo" it?
Not sure if this helps you because I'm seeing this behavior on my Raspberry Pi (an up-to-date wheezy version) and bluez 5.18 (released April 2014.)
I can connect to my BLE peripheral from the command line after doing an lecc without any problems. I don't think you need to reset after an lecc. Regardless, if you do want to reset your BT dongle because it is in some funky state, look at this excellent step-by-step guide to reset the BT dongle. I have followed these steps with consistent results.
I can connect and query say primary but more often than not, the connection drops before I can manually type in primary. See the results below. If I use the up/down arrows after connecting to quickly scroll to primary, I am able to see primary services offered by this peripheral without any problems.
~ $ sudo gatttool -I -i hci0 -m 48 -b 20:CD:39:A8:11:AF
[20:CD:39:A8:11:AF][LE]> connect
Attempting to connect to 20:CD:39:A8:11:AF
Connection successful
[20:CD:39:A8:11:AF][LE]> primary
Command Failed: Disconnected

Can't connect to OBD-II device from node-bluetooth-obd

I'm attempting to connect via node.js to an ELM327 Bluetooth OBD-II adapter using Eric Smekens node-bluetooth-obd package, but I'm getting an error I'm not sure how to debug. I am doing this on a Beagle Bone Black running Ubuntu. I'm able to pair with the device using bluez-simple-agent:
sudo bluez-simple-agent hci0 00:0D:18:A0:4E:35
And I've updated the MAC address in the second line of the Readme.md example to match the MAC address of the device:
var btOBDReader = new OBDReader('00:0D:18:A0:4E:35', 14);
However, when I run the script, I get this error:
Error with OBD-II device: Error: Cannot connect
I'm still pretty new with bluetooth comms, so I don't really know where to start debugging this. Any suggestions?

Resources