Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPA2 ENTERPRISE #2004

Merged
merged 10 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esp-ieee802154/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ byte = "0.2.7"
critical-section = "1.1.3"
document-features = "0.2.10"
esp-hal = { version = "0.20.0", path = "../esp-hal" }
esp-wifi-sys = "0.4.0"
esp-wifi-sys = "0.5.0"
heapless = "0.8.0"
ieee802154 = "0.6.1"
log = "0.4.22"
Expand Down
116 changes: 7 additions & 109 deletions esp-ieee802154/src/compat/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#[cfg(feature = "binary-logs")]
mod str_buf;

#[cfg(feature = "binary-logs")]
mod binary_logs {
use core::{ffi::VaListImpl, fmt::Write};

use log::info;

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

#[no_mangle]
pub unsafe extern "C" fn phy_printf(_format: *const u8, _args: ...) {
Expand All @@ -29,109 +26,10 @@ mod binary_logs {
pub unsafe extern "C" fn syslog(format: *const u8, args: VaListImpl) {
let mut buf = [0u8; 512];
vsnprintf(&mut buf as *mut u8, 511, format, args);
let res_str = StrBuf::from(&buf as *const u8);
info!("{}", res_str.as_str_ref());
}

pub(crate) unsafe fn vsnprintf(
dst: *mut u8,
_n: u32,
format: *const u8,
mut args: VaListImpl,
) -> i32 {
let fmt_str_ptr = format;

let mut res_str = StrBuf::new();

let strbuf = StrBuf::from(fmt_str_ptr);
let s = strbuf.as_str_ref();

let mut format_char = ' ';
let mut is_long = false;
let mut found = false;
for c in s.chars() {
if !found {
if c == '%' {
found = true;
}

if !found {
res_str.append_char(c);
}
} else if c.is_numeric() || c == '-' || c == 'l' {
if c == 'l' {
is_long = true;
}
// ignore
} else {
// a format char
format_char = c;
}

if found && format_char != ' ' {
// have to format an arg
match format_char {
'd' => {
if is_long {
let v = args.arg::<i64>();
write!(res_str, "{}", v).ok();
} else {
let v = args.arg::<i32>();
write!(res_str, "{}", v).ok();
}
}

'u' => {
let v = args.arg::<u32>();
write!(res_str, "{}", v).ok();
}

'p' => {
let v = args.arg::<u32>();
write!(res_str, "0x{:x}", v).ok();
}

'X' => {
let v = args.arg::<u32>();
write!(res_str, "{:02x}", (v & 0xff000000) >> 24).ok();
}

'x' => {
let v = args.arg::<u32>();
write!(res_str, "{:02x}", v).ok();
}

's' => {
let v = args.arg::<u32>() as *const u8;
let vbuf = StrBuf::from(v);
write!(res_str, "{}", vbuf.as_str_ref()).ok();
}

'c' => {
let v = args.arg::<u8>();
if v != 0 {
write!(res_str, "{}", v as char).ok();
}
}

_ => {
write!(res_str, "<UNKNOWN{}>", format_char).ok();
}
}

format_char = ' ';
found = false;
is_long = false;
}
}
let mut idx = 0;
res_str.as_str_ref().chars().for_each(|c| {
*(dst.offset(idx)) = c as u8;
idx += 1;
});
*(dst.offset(idx)) = 0;

idx as i32
let res_str = core::ffi::CStr::from_ptr(core::ptr::addr_of!(buf).cast())
.to_str()
.unwrap();
info!("{}", res_str);
}
}

Expand Down
58 changes: 0 additions & 58 deletions esp-ieee802154/src/compat/str_buf.rs

This file was deleted.

2 changes: 2 additions & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added support for WPA2-ENTERPRISE (#2004)

### Changed

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ heapless = { version = "0.8.0", default-features = false, features = [
num-derive = { version = "0.4.2" }
num-traits = { version = "0.2.19", default-features = false }
no-std-net = { version = "0.6.0", optional = true }
esp-wifi-sys = { version = "0.4.0" }
esp-wifi-sys = { version = "0.5.0" }
embassy-sync = { version = "0.6.0", optional = true }
embassy-futures = { version = "0.1.1", optional = true }
embassy-net-driver = { version = "0.2.0", optional = true }
Expand Down
24 changes: 9 additions & 15 deletions esp-wifi/src/ble/btdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
HciOutCollector,
HCI_OUT_COLLECTOR,
},
compat::{common::str_from_c, queue::SimpleQueue, task_runner::spawn_task},
compat::{common::str_from_c, queue::SimpleQueue},
hal::macros::ram,
memory_fence::memory_fence,
timer::yield_task,
Expand Down Expand Up @@ -305,21 +305,15 @@ unsafe extern "C" fn task_create(
core_id
);

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

if spawn_task(
func,
name as *const i8,
stack_depth,
param,
prio,
handle,
core_id,
) {
1
} else {
0
}
let task = crate::preempt::arch_specific::task_create(task_func, param, stack_depth as usize);
*(handle as *mut usize) = task as usize;

1
}

unsafe extern "C" fn task_delete(_task: *const ()) {
Expand Down
32 changes: 14 additions & 18 deletions esp-wifi/src/ble/npl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
include::*,
},
compat,
compat::{common::str_from_c, queue::SimpleQueue, task_runner::spawn_task},
compat::{common::str_from_c, queue::SimpleQueue},
timer::yield_task,
};

Expand Down Expand Up @@ -294,10 +294,10 @@ pub struct ext_funcs_t {
hal_uart_init: Option<unsafe extern "C" fn(i32, *const c_void) -> i32>,
task_create: Option<
unsafe extern "C" fn(
*const c_void,
*mut c_void,
*const c_char,
u32,
*const c_void,
*mut c_void,
u32,
*const c_void,
u32,
Expand Down Expand Up @@ -352,10 +352,10 @@ unsafe extern "C" fn os_random() -> u32 {
}

unsafe extern "C" fn task_create(
task_func: *const c_void,
task_func: *mut c_void,
name: *const c_char,
stack_depth: u32,
param: *const c_void,
param: *mut c_void,
prio: u32,
task_handle: *const c_void,
core_id: u32,
Expand All @@ -374,19 +374,15 @@ unsafe extern "C" fn task_create(

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

if spawn_task(
task_func as *mut c_void,
name as *const c_char,
stack_depth,
param as *mut c_void,
prio,
task_handle as *mut c_void,
core_id,
) {
1
} else {
0
}
let task_func = core::mem::transmute::<
*mut crate::binary::c_types::c_void,
extern "C" fn(*mut esp_wifi_sys::c_types::c_void),
>(task_func);

let task = crate::preempt::arch_specific::task_create(task_func, param, stack_depth as usize);
*(task_handle as *mut usize) = task as usize;

1
}

unsafe extern "C" fn task_delete(_: *const c_void) {
Expand Down
Loading
Loading