unified rayhunter-daemon binary for all devices

Replace per-device features with config "display" field with the value
set at install time.
This commit is contained in:
oopsbagel
2025-07-17 11:04:50 -07:00
committed by Will Greenberg
parent 5b59efa4c8
commit 22d927aa25
13 changed files with 85 additions and 118 deletions

View File

@@ -86,11 +86,11 @@ pub struct DiagDevice {
}
impl DiagDevice {
pub async fn new() -> DiagResult<Self> {
Self::new_with_retries(Duration::from_secs(30)).await
pub async fn new(tplink: bool) -> DiagResult<Self> {
Self::new_with_retries(Duration::from_secs(30), tplink).await
}
pub async fn new_with_retries(max_duration: Duration) -> DiagResult<Self> {
pub async fn new_with_retries(max_duration: Duration, tplink: bool) -> DiagResult<Self> {
// For some reason the diag device needs a very long time to become available again with in
// the same process, on TP-Link M7350 v3. While process restart would reset it faster.
@@ -101,7 +101,7 @@ impl DiagDevice {
let mut num_retries = 0;
loop {
match Self::try_new().await {
match Self::try_new(tplink).await {
Ok(device) => {
info!("Diag device initialization succeeded after {num_retries} retries");
return Ok(device);
@@ -125,7 +125,7 @@ impl DiagDevice {
}
}
async fn try_new() -> DiagResult<Self> {
async fn try_new(tplink: bool) -> DiagResult<Self> {
let diag_file = File::options()
.read(true)
.write(true)
@@ -134,7 +134,7 @@ impl DiagDevice {
.map_err(DiagDeviceError::OpenDiagDeviceError)?;
let fd = diag_file.as_raw_fd();
enable_frame_readwrite(fd, MEMORY_DEVICE_MODE)?;
enable_frame_readwrite(fd, MEMORY_DEVICE_MODE, tplink)?;
let use_mdm = determine_use_mdm(fd)?;
Ok(DiagDevice {
@@ -300,24 +300,30 @@ struct DiagLoggingModeParam {
}
// Triggers the diag device's debug logging mode
fn enable_frame_readwrite(fd: i32, mode: u32) -> DiagResult<()> {
fn enable_frame_readwrite(fd: i32, mode: u32, tplink: bool) -> DiagResult<()> {
unsafe {
if libc::ioctl(fd, DIAG_IOCTL_SWITCH_LOGGING, mode, 0, 0, 0) < 0 {
let try_params: &[DiagLoggingModeParam] = &[
// tplink M7350 HW revision 3-8 need this mode
#[cfg(feature = "tplink")]
DiagLoggingModeParam {
req_mode: mode,
peripheral_mask: 0,
mode_param: 1,
},
// tplink M7350 HW revision v9 requires the same parameters as orbic
DiagLoggingModeParam {
let try_params: &[DiagLoggingModeParam] = match tplink {
true => &[
// tplink M7350 HW revision 3-8 need this mode
DiagLoggingModeParam {
req_mode: mode,
peripheral_mask: 0,
mode_param: 1,
},
// tplink M7350 HW revision v9 requires the same parameters as orbic
DiagLoggingModeParam {
req_mode: mode,
peripheral_mask: u32::MAX,
mode_param: 0,
},
],
false => &[DiagLoggingModeParam {
req_mode: mode,
peripheral_mask: u32::MAX,
mode_param: 0,
},
];
}],
};
let mut ret = 0;