Send over BLE only if we have data
This commit is contained in:
parent
054235b031
commit
5cc97d328d
13
src/ble.rs
13
src/ble.rs
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue