Android to Arduino via BLE 112 : Serial(read) always reading 255

I am building a system that requires sending an integer/decimal value from android app via BLE based Blugeiga module BLE112, to arduino for further controlling process. But on using simple Serial.read(), I am getting some random number, most of the time, its 255. Where do I need to make modifications to get the correct value?

Where do I need to make modifications to get the correct value?

Are you making sure that there is actually something available before reading it ? As you have not posted your code it is difficult to give advice. Would this query not be better in the Programming section of the forum ?

My arduino code involves just reading the UART data. The code is as following-

#include <SoftwareSerial.h>

int datalength=10;

char str[10];

int data;
char senddata;

void setup()

{
Serial.begin(9600);

}

void loop()
{
int i=0;
//itoa(senddata, str1, 10); //Turn value into a character array

if (Serial.available()>0)

{

while(Serial.available())
{
//i++;
//data= Serial.read();
Serial.write(Serial.read());
}

// if (i>0)
//Serial.println(str);

}

}

#################################

My android BLE write characteristic code is as below-

BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); // getting service indicated by BLE device
showMessage(“mBluetoothGatt null” + mBluetoothGatt);
if (RxService == null) {
showMessage(“Rx service not found!”); // if no service found
broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
return;
}
BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID);
if (RxChar == null) {
showMessage(“Rx charateristic not found!”);
broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); // if no characteristics found
return;
}
RxChar.setValue(value); //sets the value and the Rx stores the value to be sent over BLE
boolean status = mBluetoothGatt.writeCharacteristic(RxChar); //status is set on setting the “value”

Log.d(TAG, “data written over BLE” + RxChar + value);
System.out.println(“DATA SENT:”);
System.out.println(RxChar);
System.out.println(value);
}

Please suggest what am I missing to get the data in the correct format?

Not fully read all the code…
but…

#include<SoftwareSeria.h>

will need a line such as:

SoftwareSerial mySerial(6,7);//Rx on pin 6, Tx on pin 7

mySerial.begin(9600); // Initilise the software serial with 9600 baud.

Serial.begin(9600); //Start the arduino Serial line for PC comms via USB

void loop(){

if (mySerial.available){               //If there is some byte available from the software serial...
Serial.println(mySerial.read());    // Print it out via the Arduino Serial connection to the PC.
}