fix channel bonding (ish)

This commit is contained in:
Christos Falas 2025-05-15 03:03:03 +01:00
parent 6ce62cbfe2
commit 57fadd245a
No known key found for this signature in database
2 changed files with 26 additions and 10 deletions

View File

@ -105,16 +105,16 @@ class Config(BaseModel):
raise ValueError(f"{self.central_freq} is not a valid Wi-Fi channel")
@property
def num_pilots(self) -> int:
def num_guards(self) -> int:
if self.channel_width == 20:
return 8
if self.channel_width == 40:
return 14
return 24
return 7
return 11
@property
def subcarriers(self) -> int:
return int((self.channel_width * 1e6) // self.delta_f) - self.num_pilots
return (
int((self.channel_width * 1e6) // self.delta_f) - self.num_guards
) // self.preprocessing.subcarrier_step
@property
def _delta_f_no_skipping(self) -> int:

View File

@ -147,11 +147,27 @@ class Preprocessor:
This is done by averaging the subcarriers before and after the pilot
subcarriers. Pilots are detected by checking that the value is exactly 0.
Also, it adds placeholders for the middle null subcarriers.
"""
num_middle = 1 if config.channel_width == 20 else 3
assert csi.shape[0] + num_middle == config.subcarriers
with_middle = np.zeros(
(csi.shape[0] + num_middle, csi.shape[1], csi.shape[2]), dtype=np.complex64
)
with_middle[: csi.shape[0] // 2, :, :] = csi[: csi.shape[0] // 2, :, :]
with_middle[csi.shape[0] // 2 + num_middle :, :, :] = csi[
csi.shape[0] // 2 :, :, :
]
if num_middle == 3:
with_middle[csi.shape[0] // 2 + 1, :, :] = (
csi[csi.shape[0] // 2 - 1, :, :] + csi[csi.shape[0] // 2, :, :]
) / 2
return np.where(
np.expand_dims(csi[:, 0, 0] == 0, axis=(1, 2)),
correlate(csi, [[[1 / 2]], [[0]], [[1 / 2]]], mode="same"),
csi,
np.expand_dims(with_middle[:, 0, 0] == 0, axis=(1, 2)),
correlate(with_middle, [[[1 / 2]], [[0]], [[1 / 2]]], mode="same"),
with_middle,
)
def bandpass(self, csi: CSIMatrix) -> CSIMatrix:
@ -206,7 +222,7 @@ class Preprocessor:
case "bandpass":
h_hat = self.bandpass(h_hat)
logger.debug(f"CSI shape: {h_hat.shape}")
logger.info(f"CSI shape: {h_hat.shape}")
self._last_sample = h_hat