Bluetooth communication through Matlab error

Hello all,
I've started looking at communicating with devices using bluetooth, and have run into a few problems. I've already had a read through Configuring Bluetooth Communications, Transmitting Data Over the Bluetooth Interface and a couple of community questions and not found a solution.
>> instrhwinfo('Bluetooth')
ans =
RemoteNames: {'itsmedoug'}
RemoteIDs: {'btspp://D4206DADA6AA'}
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.2'
So far, so good, but if I try to access the device 'itsmedoug' directly, I get an empty structure:
>> instrhwinfo('Bluetooth', 'itsmedoug')
ans =
RemoteName: []
RemoteID: []
ObjectConstructorName: []
Channels: []
Any idea why this should be the case?
If I assume that the channels are indexed from 1, I can open a connection:
>> bt = Bluetooth('itsmedoug', 1)
Bluetooth Object : Bluetooth-itsmedoug:1
Communication Settings
RemoteName: itsmedoug
RemoteID: btspp://D4206DADA6AA
Channel: 1
Terminator: 'LF'
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
>> fopen(bt)
Which doesn't return an error (unlike when I use channel 0, 2, 3, etc...) But then when I try to write to the device:
>> fwrite(bt, uint8([2,0,1,155]))
Error using icinterface/fwrite (line 191)
An error occurred during writing
I'm assume this is a manifestation of the same issue, though I'm not sure.
The device is paired in Windows Explorer, and I'm using R2012b.
Any help would be much appreciated.

4 个评论

On an off chance.. could you try
info = instrhwinfo('Bluetooth');
disp(info.RemoteName{1})
disp(info.RemoteName{1} + 0)
I just want to check that the name does not have any invisible characters in it.
This returns
>>disp(info.RemoteNames{1}+0)
105 116 115 109 101 100 111 117 103
, presumably as expected. And
>>info = intrhwinfo('Bluetooth');
>>info2 = instrhwinfo('Bluetooth', info.RemoteNames{1})
gives the same empty stucture as before.
Yes, that does look as expected for a name.
Worked for me, there was one extra zero in the name... Thanks a lot !

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by