I'm trying to send a simple binary file to a paired bluetooth device, but having a lot of difficulty. I'm using 2012a, so the bluetooth support is available.
Following is a sample of my setup to ensure that I am paired with the device.
>> instrhwinfo('bluetooth')
ans =
RemoteNames: {6x1 cell}
RemoteIDs: {6x1 cell}
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.0.0'
>> ans.RemoteNames
ans =
'FRANK'
'WENDY-VAIO'
'FRANK-PC'
'DESALLAR-WS'
'HOMEPC'
'CHRIS-PC'
>> bt = Bluetooth('FRANK')
Bluetooth Object : Bluetooth-FRANK:0
Communication Settings
RemoteName: FRANK
RemoteID: 002243F270C7
Channel: 0
Terminator: 'LF'
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
At this point I need to change the Communication state to open so I can use the fwrite command. This is where I have a problem.
I use the fopen command to establish the connection, but get the following error.
fopen(bt)
Error using icinterface/fopen (line 83)
Unsuccessful open: Cannot connect to the
device. Possible reasons are another
application is connected
or the device is not available.
Where do I go from here?
I've read that others have set up a COMM port, but I am of the understanding that this is not needed with 2012a. Is that right?
I know next to nothing about bluetooth connectivity and/or communication. So any information is greatly appreciated.
Thanks

 Réponse acceptée

Ankit Desai
Ankit Desai le 5 Avr 2012
Hi Chris,
You might want to consider a couple of things:
  1. Make sure that the device is paired prior to accessing it in MATLAB
  2. The line where you create bt is incorrect
You need to pass the channel ID as the second parameter to Bluetooth.
To find out the correct channel ID, use the following function:
btInfo = instrhwinfo('Bluetooth','FRANK')
That should give you the object constructor, including the channel ID required.
Hope that helps.
-Ankit

9 commentaires

Chris Morman
Chris Morman le 16 Avr 2012
Sorry for the late reply and thanks for the advice. I am able to write data now, but the phone does not respond.
When you send a file through the bluetooth manager on Windows, the phone reacts, similar to receiving a text message. When I use the fwrite command in Matlab this does not occur. I check the device and it claims to have been sent values. here's my work
bt
Bluetooth Object : Bluetooth-Chris Phone:1
Communication Settings
RemoteName: Chris Phone
RemoteID: 64995DECE368
Channel: 1
Terminator: 'LF'
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
fwrite(bt,105)
>> bt
Bluetooth Object : Bluetooth-Chris Phone:1
Communication Settings
RemoteName: Chris Phone
RemoteID: 64995DECE368
Channel: 1
Terminator: 'LF'
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 1
So it is clear that the value has been sent, is there a different command to use so that I can read the file from my phone?
Thanks
MUSTAFA
MUSTAFA le 25 Mai 2012
i am doing same things and sending data but i cant see it my phone. Can i send file instead of a string? can u help me plz?
hi could you help me? >> a = instrhwinfo('Bluetooth')
a =
RemoteNames: {'Hphone'}
RemoteIDs: {'btspp://087A4C001CFC'}
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.2'
>> instrhwinfo('Bluetooth','Hphone')
ans =
RemoteName: []
RemoteID: []
ObjectConstructorName: []
Channels: []
instrhwfind does not work for me, Matlab says"btInfo = instrhwinfo('Bluetooth','Adafruit EZ-Link 2e96')
btInfo =
HardwareInfo with properties:
RemoteName: []
RemoteID: []
ObjectConstructorName: []
Channels: []
Access to your hardware may be provided by a support package. Go to the Support Package Installer to learn more."
yong hu
yong hu le 7 Nov 2015
I'm having the same issue. And I installed the package, the problem remains. Have you figured it out?
Vinod
Vinod le 20 Nov 2015
Modifié(e) : Vinod le 22 Nov 2015
This may have to do with the device going into a power save mode and not being discoverable. Try power cycling your device and then executing
>>instrhwinfo bluetooth myDevice.
Edit: My theory is confirmed by this post:
http://forums.adafruit.com/viewtopic.php?f=10&t=56275
Please see page (2) where the adafruit engineers confirm an issue with a discoverability timeout.
You may be able to work around the issue by restarting the module and immediately searching for the device from MATLAB. You may be able to stay connected to the device despite the discoverability timeout.
hello,The bluetooth device is transmitting data, and matble can't find it. instrhwinfo('Bluetooth')
ans =
HardwareInfo (具有属性):
RemoteNames: []
RemoteIDs: []
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.9'
Vinod
Vinod le 14 Déc 2017
What Operating System are you using? What is the version of MATLAB you are using?
Diogo Simões
Diogo Simões le 29 Avr 2020
My fopen keeps telling me it can't connect in spite of doing it like Ankit Desai wrote in the first comment

Connectez-vous pour commenter.

Plus de réponses (1)

siddesh pawar
siddesh pawar le 9 Sep 2016
Communication State
Status: closed
RecordStatus: off
HOW TO SET IT ON.., I.E how to transmit the data 1

Community Treasure Hunt

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

Start Hunting!

Translated by