First of all, you'll need Android Pro, because this will require usage of UDP sockets. Basically, the plugin just tunnels the Bluetooth over UDP sockets.

So there are two cases: when Android device initiates a Bluetooth connection, and when Arduino initiates a Bluetooth connection.



When Arduino device initiates a Bluetooth connection:

1) Select any random port number.

2) Create a UDP socket and bind it to that port.

3) Call BluetoothMultiplayerAndroid.Init().

4) Call BluetoothMultiplayerAndroid.InitializeServer(port).

5) Wait for connection to happen.

6) When Arduino sends the data via Bluetooth, it will be received on the UDP socket you've created.

7) To send data to Arduino, you have to send data via UDP to the same port from which you've received the data from Arduino.



When Android device initiates a Bluetooth connection:

1) Select any random port number.

2) Create a UDP socket.

3) Call BluetoothMultiplayerAndroid.Init().

4) Call BluetoothMultiplayerAndroid.Connect(arduinoAddress, port).

5) Wait for connection to happen.

7) To send data to Arduino, send data via UDP to the port you've chosen.

8) Data from Arduino will be received on your UDP port.



This is probably not easy to grasp, and it's not really a user-friendly way to communicate with Arduino via Bluetooth (as the plugin wasn't initially designed for that), but it is not that hard to implement if you really need it.

I haven't tested this personally, as I don't have an Arduino Bluetooth Shield, so I really can't help you with setting up the Arduino part, but I know some people did used SetRawPackets() in that manner and it worked for them.

Click to expand...