Bluetooth communication through Matlab error
Show older comments
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 Comments
Walter Roberson
on 10 Feb 2013
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.
Doug Kelly
on 10 Feb 2013
Walter Roberson
on 10 Feb 2013
Yes, that does look as expected for a name.
kalokagatija
on 8 Jul 2016
Worked for me, there was one extra zero in the name... Thanks a lot !
Answers (0)
Categories
Find more on Bluetooth Communication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!