diff options
| author | Daniel Bevenius <[email protected]> | 2022-09-09 11:57:02 +0200 |
|---|---|---|
| committer | Daniel Bevenius <[email protected]> | 2022-09-09 14:31:00 +0200 |
| commit | fe5229670f40757f63e56c68388be241b5470bf6 (patch) | |
| tree | 5ce3e58d9485ad72ce3c9189204fffd229f9ceff /src | |
| parent | 6b90ab86644b48fd4b687c1173d1f9284f568a3b (diff) | |
Add constants for ioctl commands
This commit adds contants for the IOCTL commands that are currently
used in cyw43::Control.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs index 21b8b2d80..3f801fe9d 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -126,6 +126,12 @@ const IRQ_F1_INTR: u16 = 0x2000; | |||
| 126 | const IRQ_F2_INTR: u16 = 0x4000; | 126 | const IRQ_F2_INTR: u16 = 0x4000; |
| 127 | const IRQ_F3_INTR: u16 = 0x8000; | 127 | const IRQ_F3_INTR: u16 = 0x8000; |
| 128 | 128 | ||
| 129 | const IOCTL_CMD_UP: u32 = 2; | ||
| 130 | const IOCTL_CMD_SET_SSID: u32 = 26; | ||
| 131 | const IOCTL_CMD_SET_VAR: u32 = 263; | ||
| 132 | const IOCTL_CMD_GET_VAR: u32 = 262; | ||
| 133 | const IOCTL_CMD_SET_PASSPHRASE: u32 = 268; | ||
| 134 | |||
| 129 | #[derive(Clone, Copy, PartialEq, Eq)] | 135 | #[derive(Clone, Copy, PartialEq, Eq)] |
| 130 | enum Core { | 136 | enum Core { |
| 131 | WLAN = 0, | 137 | WLAN = 0, |
| @@ -263,7 +269,8 @@ impl<'a> Control<'a> { | |||
| 263 | buf[0..8].copy_from_slice(b"clmload\x00"); | 269 | buf[0..8].copy_from_slice(b"clmload\x00"); |
| 264 | buf[8..20].copy_from_slice(&header.to_bytes()); | 270 | buf[8..20].copy_from_slice(&header.to_bytes()); |
| 265 | buf[20..][..chunk.len()].copy_from_slice(&chunk); | 271 | buf[20..][..chunk.len()].copy_from_slice(&chunk); |
| 266 | self.ioctl(2, 263, 0, &mut buf[..8 + 12 + chunk.len()]).await; | 272 | self.ioctl(2, IOCTL_CMD_SET_VAR, 0, &mut buf[..8 + 12 + chunk.len()]) |
| 273 | .await; | ||
| 267 | } | 274 | } |
| 268 | 275 | ||
| 269 | // check clmload ok | 276 | // check clmload ok |
| @@ -323,7 +330,7 @@ impl<'a> Control<'a> { | |||
| 323 | Timer::after(Duration::from_millis(100)).await; | 330 | Timer::after(Duration::from_millis(100)).await; |
| 324 | 331 | ||
| 325 | // set wifi up | 332 | // set wifi up |
| 326 | self.ioctl(2, 2, 0, &mut []).await; | 333 | self.ioctl(2, IOCTL_CMD_UP, 0, &mut []).await; |
| 327 | 334 | ||
| 328 | Timer::after(Duration::from_millis(100)).await; | 335 | Timer::after(Duration::from_millis(100)).await; |
| 329 | 336 | ||
| @@ -360,7 +367,7 @@ impl<'a> Control<'a> { | |||
| 360 | ssid: [0; 32], | 367 | ssid: [0; 32], |
| 361 | }; | 368 | }; |
| 362 | i.ssid[..ssid.len()].copy_from_slice(ssid.as_bytes()); | 369 | i.ssid[..ssid.len()].copy_from_slice(ssid.as_bytes()); |
| 363 | self.ioctl(2, 26, 0, &mut i.to_bytes()).await; // set_ssid | 370 | self.ioctl(2, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()).await; // set_ssid |
| 364 | 371 | ||
| 365 | info!("JOINED"); | 372 | info!("JOINED"); |
| 366 | } | 373 | } |
| @@ -381,7 +388,7 @@ impl<'a> Control<'a> { | |||
| 381 | passphrase: [0; 64], | 388 | passphrase: [0; 64], |
| 382 | }; | 389 | }; |
| 383 | pfi.passphrase[..passphrase.len()].copy_from_slice(passphrase.as_bytes()); | 390 | pfi.passphrase[..passphrase.len()].copy_from_slice(passphrase.as_bytes()); |
| 384 | self.ioctl(2, 268, 0, &mut pfi.to_bytes()).await; // WLC_SET_WSEC_PMK | 391 | self.ioctl(2, IOCTL_CMD_SET_PASSPHRASE, 0, &mut pfi.to_bytes()).await; // WLC_SET_WSEC_PMK |
| 385 | 392 | ||
| 386 | self.ioctl_set_u32(20, 0, 1).await; // set_infra = 1 | 393 | self.ioctl_set_u32(20, 0, 1).await; // set_infra = 1 |
| 387 | self.ioctl_set_u32(22, 0, 0).await; // set_auth = 0 (open) | 394 | self.ioctl_set_u32(22, 0, 0).await; // set_auth = 0 (open) |
| @@ -430,7 +437,7 @@ impl<'a> Control<'a> { | |||
| 430 | buf[name.len() + 1..][..val.len()].copy_from_slice(val); | 437 | buf[name.len() + 1..][..val.len()].copy_from_slice(val); |
| 431 | 438 | ||
| 432 | let total_len = name.len() + 1 + val.len(); | 439 | let total_len = name.len() + 1 + val.len(); |
| 433 | self.ioctl(2, 263, 0, &mut buf[..total_len]).await; | 440 | self.ioctl(2, IOCTL_CMD_SET_VAR, 0, &mut buf[..total_len]).await; |
| 434 | } | 441 | } |
| 435 | 442 | ||
| 436 | // TODO this is not really working, it always returns all zeros. | 443 | // TODO this is not really working, it always returns all zeros. |
| @@ -442,7 +449,7 @@ impl<'a> Control<'a> { | |||
| 442 | buf[name.len()] = 0; | 449 | buf[name.len()] = 0; |
| 443 | 450 | ||
| 444 | let total_len = max(name.len() + 1, res.len()); | 451 | let total_len = max(name.len() + 1, res.len()); |
| 445 | let res_len = self.ioctl(0, 262, 0, &mut buf[..total_len]).await; | 452 | let res_len = self.ioctl(0, IOCTL_CMD_GET_VAR, 0, &mut buf[..total_len]).await; |
| 446 | 453 | ||
| 447 | let out_len = min(res.len(), res_len); | 454 | let out_len = min(res.len(), res_len); |
| 448 | res[..out_len].copy_from_slice(&buf[..out_len]); | 455 | res[..out_len].copy_from_slice(&buf[..out_len]); |
