Skip to content

Commit 5420ce0

Browse files
authored
WPA2 ENTERPRISE (#2004)
* WPA2 ENTERPRISE * Defmt, Clippy, Changelog * Defmt, again * Clippy, again * Mention corresponding JIRA ticket * Rename * fmt * Use Mutex in scheduler * Adapt wifi_delete_queue * Adapt log level
1 parent 9465244 commit 5420ce0

File tree

23 files changed

+987
-899
lines changed

23 files changed

+987
-899
lines changed

esp-ieee802154/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ byte = "0.2.7"
2020
critical-section = "1.1.3"
2121
document-features = "0.2.10"
2222
esp-hal = { version = "0.20.0", path = "../esp-hal" }
23-
esp-wifi-sys = "0.4.0"
23+
esp-wifi-sys = "0.5.0"
2424
heapless = "0.8.0"
2525
ieee802154 = "0.6.1"
2626
log = "0.4.22"

esp-ieee802154/src/compat/mod.rs

Lines changed: 7 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
#[cfg(feature = "binary-logs")]
2-
mod str_buf;
3-
41
#[cfg(feature = "binary-logs")]
52
mod binary_logs {
6-
use core::{ffi::VaListImpl, fmt::Write};
7-
83
use log::info;
94

10-
use super::str_buf::StrBuf;
5+
extern "C" {
6+
fn vsnprintf(dst: *mut u8, _n: u32, format: *const u8, ...) -> i32;
7+
}
118

129
#[no_mangle]
1310
pub unsafe extern "C" fn phy_printf(_format: *const u8, _args: ...) {
@@ -29,109 +26,10 @@ mod binary_logs {
2926
pub unsafe extern "C" fn syslog(format: *const u8, args: VaListImpl) {
3027
let mut buf = [0u8; 512];
3128
vsnprintf(&mut buf as *mut u8, 511, format, args);
32-
let res_str = StrBuf::from(&buf as *const u8);
33-
info!("{}", res_str.as_str_ref());
34-
}
35-
36-
pub(crate) unsafe fn vsnprintf(
37-
dst: *mut u8,
38-
_n: u32,
39-
format: *const u8,
40-
mut args: VaListImpl,
41-
) -> i32 {
42-
let fmt_str_ptr = format;
43-
44-
let mut res_str = StrBuf::new();
45-
46-
let strbuf = StrBuf::from(fmt_str_ptr);
47-
let s = strbuf.as_str_ref();
48-
49-
let mut format_char = ' ';
50-
let mut is_long = false;
51-
let mut found = false;
52-
for c in s.chars() {
53-
if !found {
54-
if c == '%' {
55-
found = true;
56-
}
57-
58-
if !found {
59-
res_str.append_char(c);
60-
}
61-
} else if c.is_numeric() || c == '-' || c == 'l' {
62-
if c == 'l' {
63-
is_long = true;
64-
}
65-
// ignore
66-
} else {
67-
// a format char
68-
format_char = c;
69-
}
70-
71-
if found && format_char != ' ' {
72-
// have to format an arg
73-
match format_char {
74-
'd' => {
75-
if is_long {
76-
let v = args.arg::<i64>();
77-
write!(res_str, "{}", v).ok();
78-
} else {
79-
let v = args.arg::<i32>();
80-
write!(res_str, "{}", v).ok();
81-
}
82-
}
83-
84-
'u' => {
85-
let v = args.arg::<u32>();
86-
write!(res_str, "{}", v).ok();
87-
}
88-
89-
'p' => {
90-
let v = args.arg::<u32>();
91-
write!(res_str, "0x{:x}", v).ok();
92-
}
93-
94-
'X' => {
95-
let v = args.arg::<u32>();
96-
write!(res_str, "{:02x}", (v & 0xff000000) >> 24).ok();
97-
}
98-
99-
'x' => {
100-
let v = args.arg::<u32>();
101-
write!(res_str, "{:02x}", v).ok();
102-
}
103-
104-
's' => {
105-
let v = args.arg::<u32>() as *const u8;
106-
let vbuf = StrBuf::from(v);
107-
write!(res_str, "{}", vbuf.as_str_ref()).ok();
108-
}
109-
110-
'c' => {
111-
let v = args.arg::<u8>();
112-
if v != 0 {
113-
write!(res_str, "{}", v as char).ok();
114-
}
115-
}
116-
117-
_ => {
118-
write!(res_str, "<UNKNOWN{}>", format_char).ok();
119-
}
120-
}
121-
122-
format_char = ' ';
123-
found = false;
124-
is_long = false;
125-
}
126-
}
127-
let mut idx = 0;
128-
res_str.as_str_ref().chars().for_each(|c| {
129-
*(dst.offset(idx)) = c as u8;
130-
idx += 1;
131-
});
132-
*(dst.offset(idx)) = 0;
133-
134-
idx as i32
29+
let res_str = core::ffi::CStr::from_ptr(core::ptr::addr_of!(buf).cast())
30+
.to_str()
31+
.unwrap();
32+
info!("{}", res_str);
13533
}
13634
}
13735

esp-ieee802154/src/compat/str_buf.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

esp-wifi/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Added support for WPA2-ENTERPRISE (#2004)
13+
1214
### Changed
1315

1416
### Fixed

esp-wifi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ heapless = { version = "0.8.0", default-features = false, features = [
3535
num-derive = { version = "0.4.2" }
3636
num-traits = { version = "0.2.19", default-features = false }
3737
no-std-net = { version = "0.6.0", optional = true }
38-
esp-wifi-sys = { version = "0.4.0" }
38+
esp-wifi-sys = { version = "0.5.0" }
3939
embassy-sync = { version = "0.6.0", optional = true }
4040
embassy-futures = { version = "0.1.1", optional = true }
4141
embassy-net-driver = { version = "0.2.0", optional = true }

esp-wifi/src/ble/btdm.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
HciOutCollector,
1111
HCI_OUT_COLLECTOR,
1212
},
13-
compat::{common::str_from_c, queue::SimpleQueue, task_runner::spawn_task},
13+
compat::{common::str_from_c, queue::SimpleQueue},
1414
hal::macros::ram,
1515
memory_fence::memory_fence,
1616
timer::yield_task,
@@ -305,21 +305,15 @@ unsafe extern "C" fn task_create(
305305
core_id
306306
);
307307

308-
*(handle as *mut usize) = 0; // we will run it in task 0
308+
let task_func = core::mem::transmute::<
309+
*mut crate::binary::c_types::c_void,
310+
extern "C" fn(*mut esp_wifi_sys::c_types::c_void),
311+
>(func);
309312

310-
if spawn_task(
311-
func,
312-
name as *const i8,
313-
stack_depth,
314-
param,
315-
prio,
316-
handle,
317-
core_id,
318-
) {
319-
1
320-
} else {
321-
0
322-
}
313+
let task = crate::preempt::arch_specific::task_create(task_func, param, stack_depth as usize);
314+
*(handle as *mut usize) = task as usize;
315+
316+
1
323317
}
324318

325319
unsafe extern "C" fn task_delete(_task: *const ()) {

esp-wifi/src/ble/npl.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
include::*,
1313
},
1414
compat,
15-
compat::{common::str_from_c, queue::SimpleQueue, task_runner::spawn_task},
15+
compat::{common::str_from_c, queue::SimpleQueue},
1616
timer::yield_task,
1717
};
1818

@@ -294,10 +294,10 @@ pub struct ext_funcs_t {
294294
hal_uart_init: Option<unsafe extern "C" fn(i32, *const c_void) -> i32>,
295295
task_create: Option<
296296
unsafe extern "C" fn(
297-
*const c_void,
297+
*mut c_void,
298298
*const c_char,
299299
u32,
300-
*const c_void,
300+
*mut c_void,
301301
u32,
302302
*const c_void,
303303
u32,
@@ -352,10 +352,10 @@ unsafe extern "C" fn os_random() -> u32 {
352352
}
353353

354354
unsafe extern "C" fn task_create(
355-
task_func: *const c_void,
355+
task_func: *mut c_void,
356356
name: *const c_char,
357357
stack_depth: u32,
358-
param: *const c_void,
358+
param: *mut c_void,
359359
prio: u32,
360360
task_handle: *const c_void,
361361
core_id: u32,
@@ -374,19 +374,15 @@ unsafe extern "C" fn task_create(
374374

375375
*(task_handle as *mut usize) = 0; // we will run it in task 0
376376

377-
if spawn_task(
378-
task_func as *mut c_void,
379-
name as *const c_char,
380-
stack_depth,
381-
param as *mut c_void,
382-
prio,
383-
task_handle as *mut c_void,
384-
core_id,
385-
) {
386-
1
387-
} else {
388-
0
389-
}
377+
let task_func = core::mem::transmute::<
378+
*mut crate::binary::c_types::c_void,
379+
extern "C" fn(*mut esp_wifi_sys::c_types::c_void),
380+
>(task_func);
381+
382+
let task = crate::preempt::arch_specific::task_create(task_func, param, stack_depth as usize);
383+
*(task_handle as *mut usize) = task as usize;
384+
385+
1
390386
}
391387

392388
unsafe extern "C" fn task_delete(_: *const c_void) {

0 commit comments

Comments
 (0)