Trouble with bluetooth BLE connection between Pi3 and Blueduino

Hi @gohai,

I think the processing shell() function can’t work because after the first command line: gatttool -b 50:65:83:A0:BE:81 -I, this line appears: [50:65:83:A0:BE:81][LE]> and this is the line who expect connect.

In fact the only way I managed to send data was by using non interactive mode:

Runtime.getRuntime().exec("gatttool -b 50:65:83:A0:BE:81 --char-write-req -a 0x0029 -n 01

The problem with that method is that It always reconnect to the device so instead of just reading my value I also read OK+CONN and bonded.

To avoid that, I need to use interactive mode to be able to connect to the device once and for all.

Now I read that pexpect would work here so I looked for a java implementation of it and found expectJ.

I tried the 2 following piece of code but nothing works:

ExpectJ exp = new ExpectJ(5);
Spawn shell = exp.spawn("/bin/bash");
shell.send("gatttool -b 50:65:83:A0:BE:81 -I");
shell.send("connect");
ExpectJ exp = new ExpectJ(5);
Spawn gatt = exp.spawn("gatttool -b 50:65:83:A0:BE:81 -I");
gatt.send("connect");

I got no error, it just does not connect…

Any idea on what I coud do or try?

Thanks