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
Walter Roberson
2013년 2월 10일
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
2013년 2월 10일
Walter Roberson
2013년 2월 10일
Yes, that does look as expected for a name.
kalokagatija
2016년 7월 8일
Worked for me, there was one extra zero in the name... Thanks a lot !
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Bluetooth Communication에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!