Skip to content

Commit 9edb93a

Browse files
committed
bluetooth: analyze WifiConnectStatus response
1 parent 11dab88 commit 9edb93a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bluetooth.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const WLAN_IP_ADDR: &str = "10.0.0.1";
4040
const WLAN_SSID: &str = "AAWirelessDongle";
4141
const WLAN_WPA_KEY: &str = "ConnectAAWirelessDongle";
4242

43-
#[derive(Debug, Clone)]
43+
#[derive(Debug, Clone, PartialEq)]
4444
#[repr(u16)]
4545
#[allow(unused)]
4646
enum MessageId {
@@ -262,7 +262,18 @@ async fn read_message(stream: &mut Stream, id: MessageId) -> Result<usize> {
262262
// read and discard the remaining bytes
263263
if len > 0 {
264264
let mut buf = vec![0; len];
265-
stream.read_exact(&mut buf).await?;
265+
let n = stream.read_exact(&mut buf).await?;
266+
267+
// analyzing WifiConnectStatus
268+
// this is a frame where phone cannot connect to WiFi:
269+
// [08, FD, FF, FF, FF, FF, FF, FF, FF, FF, 01] -> which is -i64::MAX
270+
// and this is where all is fine:
271+
// [08, 00]
272+
if id == MessageId::WifiConnectStatus && n >= 2 {
273+
if buf[1] != 0 {
274+
return Err("phone cannot connect to our WiFi AP...".into());
275+
}
276+
}
266277
}
267278

268279
Ok(HEADER_LEN + len)

0 commit comments

Comments
 (0)