I have the following flutter code:
void sendData() async{
print("Sending Data to hc 05 bluetooth");
int i=0;
int contact1, contact2;
Uint8List mobileData = Uint8List(4);
if(bluetoothCheck) {
if(currentUser.quickAccessList!=null) {
for (var j in currentUser.quickAccessList!) {
contact1 = (double.parse(j.mobile.toString())).toInt();
contact2 = (double.parse(j.mobile.toString()) % 100000).toInt();
print(contact1.toString());
ByteData.view(mobileData.buffer).setInt32(0, int.parse(contact1.toString()), Endian.little);
connection!.output.add(mobileData);
await connection!.output.allSent.then((_) {
print("Sent Data");
}).catchError((error) {
print('Error: $error');
});
}
}
}
}
The output of flutter code is:
Sending Data to hc 05 bluetooth
I/flutter (31463): 639999999
Sent Data
My arduino code:
SoftwareSerial mySerial(8, 9);
void setup(){
mySerial.begin(38400);
}
void loop(){
Serial.print(mySerial.available());
if (mySerial.available()>0) {
// Read the incoming byte from Bluetooth module
char receivedChar = mySerial.read();
receivedChar += 30;
// Print the received byte to the Serial Monitor
Serial.println("Received: ");
Serial.println(receivedChar);
}
}
Output in arduino is just 0 in mySerial.available(). Other than that no output is shown.
I ensure that my bluetooth is connected to flutter.