# Trouble with bluetooth BLE connection between Pi3 and Blueduino

**URL:** https://discourse.processing.org/t/trouble-with-bluetooth-ble-connection-between-pi3-and-blueduino/3578
**Category:** Electronics (Arduino, etc.)
**Created:** [September 16, 2018, 4:52pm UTC](https://discourse.processing.org/t/trouble-with-bluetooth-ble-connection-between-pi3-and-blueduino/3578 "2018-09-16T16:52:03Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [September 23, 2018, 7:37am UTC](https://discourse.processing.org/t/trouble-with-bluetooth-ble-connection-between-pi3-and-blueduino/3578/7 "2018-09-23T07:37:12Z")

</div>

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:

```auto
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](https://stackoverflow.com/questions/51086932/ble-gatttool-interactive-shell-script) so I looked for a java implementation of it and found [expectJ](http://expectj.sourceforge.net/).

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

```auto
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");

```

```auto
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

---

_[View the full topic](https://discourse.processing.org/t/trouble-with-bluetooth-ble-connection-between-pi3-and-blueduino/3578)._
