I am working on an Android app that needs to send data from an accelerometer to an arduino. The problem is that the string is sent only half-way moment at which the next transmission starts. Anything I tried like SystemClock.sleep(); did not help, meaning that any next line would interrupt the transmission of the string.
public void onSensorChanged(SensorEvent event) {
acceler[0]=event.values[0];
acceler[1]=event.values[1];
acceler[2]=event.values[2];
transmit();
}
private void transmit() {
String str =":" + acceler[0] + " " + acceler[1] + " " + acceler[2] + "\n\r";
final byte[] tx = str.getBytes();
if(mConnected) {
TXcharact.setValue(tx);
mBluetoothLeService.writeCharacteristic(TXcharact);
}
}