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") raise ValueError(f"{self.central_freq} is not a valid Wi-Fi channel")
@property @property
def num_pilots(self) -> int: def num_guards(self) -> int:
if self.channel_width == 20: if self.channel_width == 20:
return 8 return 7
if self.channel_width == 40: return 11
return 14
return 24
@property @property
def subcarriers(self) -> int: 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 @property
def _delta_f_no_skipping(self) -> int: 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 This is done by averaging the subcarriers before and after the pilot
subcarriers. Pilots are detected by checking that the value is exactly 0. 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( return np.where(
np.expand_dims(csi[:, 0, 0] == 0, axis=(1, 2)), np.expand_dims(with_middle[:, 0, 0] == 0, axis=(1, 2)),
correlate(csi, [[[1 / 2]], [[0]], [[1 / 2]]], mode="same"), correlate(with_middle, [[[1 / 2]], [[0]], [[1 / 2]]], mode="same"),
csi, with_middle,
) )
def bandpass(self, csi: CSIMatrix) -> CSIMatrix: def bandpass(self, csi: CSIMatrix) -> CSIMatrix:
@ -206,7 +222,7 @@ class Preprocessor:
case "bandpass": case "bandpass":
h_hat = self.bandpass(h_hat) 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 self._last_sample = h_hat