Convert to module
This commit is contained in:
parent
51cd1ea70e
commit
0ce3545e1e
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
@ -1,8 +1,27 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
PREPROCESSING_SHORT_TERM_WINDOW_SIZE = 5
|
PREPROCESSING_SHORT_TERM_WINDOW_SIZE = 5
|
||||||
PREPROCESSING_LONG_TERM_ALPHA = 0.1
|
PREPROCESSING_LONG_TERM_ALPHA = 0.01
|
||||||
AOA_SLIDING_WINDOW_SIZE = 20
|
AOA_SLIDING_WINDOW_SIZE = 20
|
||||||
|
|
||||||
FEITCSI_IP_ADDRESS = os.getenv("IP_ADDRESS", "10.0.12.62")
|
RECEIVE_IP_ADDRESS = os.getenv("IP_ADDRESS", "10.0.12.64")
|
||||||
|
INJECT_IP_ADDRESS = os.getenv("INJECT_IP_ADDRESS", "10.0.12.63")
|
||||||
FEITCSI_PORT = 8008
|
FEITCSI_PORT = 8008
|
||||||
|
|
||||||
|
SAMPLE_RATE = 100 # Hz
|
||||||
|
|
||||||
|
EIGVAL_THRESHOLD = 1e4
|
||||||
|
|
||||||
|
|
||||||
|
DELTA_F = 312_500 # Spacing between subcarriers in Hz
|
||||||
|
CENTRAL_FREQUENCY_MHZ = 6195
|
||||||
|
CENTRAL_FREQUENCY_HZ = CENTRAL_FREQUENCY_MHZ * 1_000_000
|
||||||
|
|
||||||
|
ANTENNA_SPACING = 0.0285
|
||||||
|
# ANTENNA_SPACING = 0.0285 * 3
|
||||||
|
|
||||||
|
CHANNEL_WIDTH = 20
|
||||||
|
FRAME_FORMAT = "HT"
|
||||||
|
|
||||||
|
|
||||||
|
C = 299_792_458
|
||||||
|
|||||||
38
src/main.py
38
src/main.py
@ -1,13 +1,14 @@
|
|||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from csi import CSI
|
|
||||||
from aoa import AoA
|
|
||||||
from preprocess import Preprocessor
|
|
||||||
import visualise
|
|
||||||
import threading
|
import threading
|
||||||
import struct
|
import struct
|
||||||
import config
|
|
||||||
|
from .csi import CSI
|
||||||
|
from .aoa import AoA
|
||||||
|
from .preprocess import Preprocessor
|
||||||
|
from . import config
|
||||||
|
from . import visualise
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@ -18,23 +19,31 @@ logging.basicConfig(
|
|||||||
class FeitServer:
|
class FeitServer:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
ip: str,
|
|
||||||
frequency: int = 5260,
|
|
||||||
channel_width: int = 80,
|
|
||||||
frame_format: str = "VHT",
|
|
||||||
):
|
):
|
||||||
self.ip = ip
|
|
||||||
self.port = config.FEITCSI_PORT
|
self.port = config.FEITCSI_PORT
|
||||||
self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
self.server.connect((self.ip, self.port))
|
self.server.connect((config.RECEIVE_IP_ADDRESS, self.port))
|
||||||
self.start_string = (
|
self.start_string = (
|
||||||
f"feitcsi --frequency {frequency} "
|
f"feitcsi --frequency {config.CENTRAL_FREQUENCY_MHZ} "
|
||||||
f"--channel-width {channel_width} --format {frame_format} "
|
f"--channel-width {config.CHANNEL_WIDTH} "
|
||||||
|
f"--format {config.FRAME_FORMAT} "
|
||||||
f"--mode measure"
|
f"--mode measure"
|
||||||
)
|
)
|
||||||
self.server.send(b"stop\n")
|
self.server.send(b"stop\n")
|
||||||
self.server.send(self.start_string.encode())
|
self.server.send(self.start_string.encode())
|
||||||
|
|
||||||
|
self.inject_server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
self.inject_server.connect((config.INJECT_IP_ADDRESS, self.port))
|
||||||
|
inject_start_string = (
|
||||||
|
f"feitcsi --frequency {config.CENTRAL_FREQUENCY_MHZ} "
|
||||||
|
f"--channel-width {config.CHANNEL_WIDTH} "
|
||||||
|
f"--format {config.FRAME_FORMAT} "
|
||||||
|
f"--mode inject -s 1 --verbose "
|
||||||
|
f"--inject-delay {1_000_000 // config.SAMPLE_RATE}"
|
||||||
|
)
|
||||||
|
self.inject_server.send(b"stop\n")
|
||||||
|
self.inject_server.send(inject_start_string.encode())
|
||||||
|
|
||||||
def listen(self, callback: Callable[[CSI], None]):
|
def listen(self, callback: Callable[[CSI], None]):
|
||||||
while True:
|
while True:
|
||||||
# This is the max size of a UDP packet. The size of the actual CSI
|
# This is the max size of a UDP packet. The size of the actual CSI
|
||||||
@ -56,11 +65,12 @@ def process_data(data: CSI):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
server = FeitServer(config.FEITCSI_IP_ADDRESS)
|
server = FeitServer()
|
||||||
preprocess = Preprocessor()
|
preprocess = Preprocessor()
|
||||||
aoa = AoA()
|
aoa = AoA()
|
||||||
|
|
||||||
# Start webapp in background thread
|
# Start webapp in background thread
|
||||||
|
visualise.aoa = aoa
|
||||||
webapp = threading.Thread(target=visualise.start)
|
webapp = threading.Thread(target=visualise.start)
|
||||||
webapp.start()
|
webapp.start()
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from csi import CSI
|
from .csi import CSI
|
||||||
import logging
|
import logging
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
import config
|
from . import config
|
||||||
import numpy.typing as npt
|
import numpy.typing as npt
|
||||||
|
from scipy.signal import correlate
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
np.seterr(invalid="ignore")
|
||||||
|
|
||||||
|
|
||||||
class Preprocessor:
|
class Preprocessor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user