bluetooth command fails to open ubuntu laptop connection

2 次查看(过去 30 天)
I'm trying to perform file transfers using bluetooth between a laptop running Ubuntu and my Windows laptop.
If I directly use the Windows and Ubuntu GUI functions, then files are transferred. I want to use the Matlab functions so that the data transfer is part of the data processing scripts.
I've enabled the SSP on the linux laptop (the command 'sudo sdptool add SP' returns 'Serial Port service registered'.
With the device showing disconnected in the Windows Settings -> Bluetooth & devices -> Devices page, I run the bluetoothlist command in Matlab and the device is listed as 'ready to connect' with a channel of 1
If I then run the bluetooth command using the device name or mac address and the channel number, the connection fails with an exception and the object isn't returned, but the linux machine shows it's now connected.
>> bluetoothlist
Name Address Channel Status
_______ ______________ _______ __________________
"xxxxxx" "nnnnnnnnnnnn" 1 "Ready to connect"
>> bt = bluetooth("nnnnnnnnnnnn", 1);
Unable to connect to device. Run bluetoothlist to check device status and channel number.
Running bluetoothlist again shows the channel and status as unknown.
I've stepped through the process and find the exception is raised in channel.m line 308
% Gain exclusive access of the device.
obj.ChannelImpl.open(options);
I can't step into this function to isolate the problem further.
I'm running Matlab 2024B (with latest updates) on Windows 11.
Any suggestions are gratefully appreciated.

回答(1 个)

Gayathri
Gayathri 2025-5-14
编辑:Gayathri 2025-5-14
Hi @Nigel,
To resolve the issue, please look into the following points:
  • Please confirm that the two PC's are paired the machines with each other over bluetooth.
  • I see that you have already enabled SSP on the linux laptop. On the "SPP server" computer, open MATLAB and open a connection to the incoming COM port using serialport. After this, the computer will be ready to listen to incoming Bluetooth connection requests. Please refer to the below command as an example to the function usage, and you can find more information on: https://www.mathworks.com/help/matlab/ref/serialport.html
s=serialport('COM4',9600)
  • On the "SPP client" computer, open MATLAB and open a connection to the other computer using MATLAB bluetooth
bluetoothlist
b = bluetooth(<name>,<channel>)
At this point you should be able to use "writeline/readline", "write/read" to exchange data between the two PC's.
Hope this helps!
  3 个评论
Gayathri
Gayathri 2025-5-15
编辑:Gayathri 2025-5-15
@Nigel, I was able to perform successful file transfers with a Windows 11 machine. I am hopeful that the "serialport command" would help resolve the issue.
Nigel
Nigel 2025-5-15
Thanks Gayathri for confirming. I hope to review later today and comeback with a successful result!

请先登录,再进行评论。

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by