20140106

Accessing IR-Blue-DM from linux

Note: do the initial tests with the bluetooth dongle straight on the machine (Udoo in my case) instead of plugged in a hub. Scanning works on a hub but for some reason rfcomm doesn't connect very often if the dongle is on a hub.

Quick hack #1:

Check if we can see the device:
root@imx6-qsdl:/home/ubuntu# hcitool scanScanning ...
    EC:FE:xx:xx:xx:xx    IR-Blue-DM


Same using LE:
root@imx6-qsdl:/home/ubuntu# hcitool lescan
LE Scan ...
EC:FE:xx:xx:xx:xx






Check if we need a pin:
root@imx6-qsdl:/home/ubuntu# bluez-simple-agent hci0 EC:FE:xx:xx:xx:xx
Release
New device (/org/bluez/5683/hci0/dev_EC_FE_xx_xx_xx_xx)

Seems we don't need one, connect using rfcomm.
root@imx6-qsdl:/home/ubuntu# rfcomm connect hci0 EC:FE:xx:xx:xx:xx        
Connected /dev/rfcomm0 to EC:FE:xx:xx:xx:xx on channel 1
Press CTRL-C for hangup
^CDisconnected






See if there is any data:
root@imx6-qsdl:/home/ubuntu# cat /dev/rfcomm0

And after you do 'echo >/dev/rfcomm0 "R001\r\n"' in another terminal there is data!:
E211208208208215214212212218220218213222223221218223223221216224225223220227226225222226227225223228228227225229229228225229228229228229230230228230230229230230230231230230230229229227229227227188188188188205205196196205205205196205205205205213205205205205213205205213213213205213213213205213213222213222222222213222222222222222222222222222222222222222222222222222222222222213222222222  0 17 17 10 41 62 62 52 79 86 96 90103121124107131152159138159162169148169183183155179186186162179193193159176190190165176186183148172172176131151158158120124138145 96103107110 65 69 75 68 23255255255255255255255255255255  0  0  0  0  0  0  0  0  0216221205  0  0  0  8150 26 17 93105 36230 79 40 34  0128  0  0255 33  0188 26190 59 25245 27150 26255 30116 91166 32136 44 10 33  1 26EX

R144006836145-00045I   -54   -54   -52   -54   -53   -54   -51   -50   -52   -50   -52   -49   -50   -50   -49   -47   -51   -51   -51   -49   -52   -50   -50   -48   -48   -50   -45   -47   -45   -43   -42   -44   -41   -42   -43   -45   -27   -41   -43   -44   -40   -41   -41   -43   -42   -42   -42   -42   -44   -43   -43   -42   -42   -43   -42   -42   -42   -41   -42   -40   -42   -42   -42   -41X



Quick hack #2:

Use a small python routine to read data:
import serial
import time

ser=serial.Serial("/dev/rfcomm0", baudrate=57600,timeout=0.1)

ser.open()
ser.write("R001"+chr(13)+chr(10))

while (1==1):

 d=ser.readline()
 print len(d),d


Success! Now to write something that gets temperature values and shows the result graphically...

I found the R001 command in the android code on http://github.com/RHWorkshop , the H command can be used to increase the speed at which the data is sent.