1
0
Fork 0

Send over BLE only if we have data

This commit is contained in:
Daniele Tricoli 2023-03-06 02:13:14 +01:00
parent 054235b031
commit 5cc97d328d

View file

@ -207,13 +207,14 @@ async fn write_ble(device: Peripheral, text_channel: Receiver<String>) {
loop {
let mut words = String::new();
if let Ok(text) = text_channel.try_recv() {
words = text;
words = text.trim().to_string();
}
if !words.is_empty() {
device
.write(&tx_char, words.as_bytes(), WriteType::WithoutResponse)
.await
.unwrap();
}
device
.write(&tx_char, words.as_bytes(), WriteType::WithoutResponse)
.await
.unwrap();
time::sleep(Duration::from_millis(100)).await;
}
}