Bluetooth serial out using arduino for printing images faces an issue of data loss when wifi not connected.
Posted: Thu Jan 28, 2021 9:35 am
byte receivedBytes;
while(SerialBT.available()>0)
{
receivedBytes = SerialBT.read();
recBuff[Recv_count] = receivedBytes;
Recv_count++;
bluetooth_rx_complt = 1;
if(Recv_count == 8192)
{
recBuff[Recv_count] ='\0';
Serial.write((const uint8_t*)recBuff,/Recv_count);
Serial.flush();
Recv_count = 0;
memset(recBuff,0,sizeof(recBuff));
state = FREE;
}
}
if(bluetooth_rx_complt)
{
recBuff[Recv_count] ='\0';
data_Sout_count = Recv_count;
Recv_count = 0;
bluetooth_rx_complt = 0;
Serial.write((const uint8_t*)recBuff,data_Sout_count);
return 1;
}
return 0;
while(SerialBT.available()>0)
{
receivedBytes = SerialBT.read();
recBuff[Recv_count] = receivedBytes;
Recv_count++;
bluetooth_rx_complt = 1;
if(Recv_count == 8192)
{
recBuff[Recv_count] ='\0';
Serial.write((const uint8_t*)recBuff,/Recv_count);
Serial.flush();
Recv_count = 0;
memset(recBuff,0,sizeof(recBuff));
state = FREE;
}
}
if(bluetooth_rx_complt)
{
recBuff[Recv_count] ='\0';
data_Sout_count = Recv_count;
Recv_count = 0;
bluetooth_rx_complt = 0;
Serial.write((const uint8_t*)recBuff,data_Sout_count);
return 1;
}
return 0;