diff --git a/src/actuator/loudspeaker.py b/src/actuator/loudspeaker.py index 28ad36f..d46ecdf 100644 --- a/src/actuator/loudspeaker.py +++ b/src/actuator/loudspeaker.py @@ -1,9 +1,6 @@ #!/usr/bin/env python3 -import random -import os -import os.path from .abcactuator import AbcActuator -from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformPlaybackDriver, BirbnetesIoTPlatformStatusDriver +from utils import BirbnetesIoTPlatformPlaybackDriver, BirbnetesIoTPlatformStatusDriver """ Abstract base class for Sender diff --git a/src/app.py b/src/app.py index 2d30f83..9f03f0d 100644 --- a/src/app.py +++ b/src/app.py @@ -6,7 +6,7 @@ import sentry_sdk from sentry_sdk.integrations.logging import LoggingIntegration from utils import LoopingTimer from signal_processor import SoundSignalProcessor -from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver +from utils import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver from actuator import Loudspeaker import paho.mqtt.client import json diff --git a/src/preprocessor/soundpreprocessor.py b/src/preprocessor/soundpreprocessor.py index 2239f31..428052d 100644 --- a/src/preprocessor/soundpreprocessor.py +++ b/src/preprocessor/soundpreprocessor.py @@ -15,7 +15,7 @@ if not config.DISABLE_AI: from pyAudioAnalysis import MidTermFeatures import numpy -from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver +from utils import BirbnetesIoTPlatformStatusDriver """ Abstract base class for Sender @@ -150,7 +150,7 @@ class SoundPreProcessorLegit(AbcPreProcessor): class SoundPreProcessorDummy(AbcPreProcessor): def __init__(self): - print("AI is disabled! Initializing dummy sound pre-processor...") + logging.info("AI is disabled! Initializing dummy sound pre-processor...") def preprocesssignal(self, file_path) -> bool: return True diff --git a/src/sensor/soundsensor.py b/src/sensor/soundsensor.py index ed6e1f0..6d283f4 100644 --- a/src/sensor/soundsensor.py +++ b/src/sensor/soundsensor.py @@ -1,8 +1,7 @@ #!/usr/bin/env python3 from typing import Optional from .abcsensor import AbcSensor -from utils import config -from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformRecordDriver +from utils import config, BirbnetesIoTPlatformRecordDriver """ Sound sensor high level API diff --git a/src/signal_processor/soundsignalprocessor.py b/src/signal_processor/soundsignalprocessor.py index 0cf1fe2..55fdca4 100644 --- a/src/signal_processor/soundsignalprocessor.py +++ b/src/signal_processor/soundsignalprocessor.py @@ -7,7 +7,7 @@ from preprocessor import SoundPreProcessor from .abcsignalprocessor import AbcSignalProcessor import os -from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver +from utils import BirbnetesIoTPlatformStatusDriver """ Abstract base class for signalprocessor diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 57bbb05..aff1722 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,2 +1,4 @@ #!/usr/bin/env python3 from .loopingtimer import LoopingTimer +from .platform import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \ + BirbnetesIoTPlatformPlaybackDriver diff --git a/src/utils/config.py b/src/utils/config.py index ef49b11..6070a35 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -34,3 +34,5 @@ REPORT_URL = os.environ.get("REPORT_URL", None) REPORT_INTERVAL = float(os.environ.get("REPORT_INTERVAL", 15)) DISABLE_AI = os.environ.get("DISABLE_AI").lower() in ['yes', '1', 'true'] + +PLATFORM = os.environ.get("PLATFORM", "raspberry") diff --git a/src/utils/platform.py b/src/utils/platform.py new file mode 100644 index 0000000..6009998 --- /dev/null +++ b/src/utils/platform.py @@ -0,0 +1,18 @@ +import config + +if config.PLATFORM == 'raspberry': + from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \ + BirbnetesIoTPlatformPlaybackDriver + +elif config.PLATFORM == 'emulator': + from birbnetes_iot_platform_emulator import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \ + BirbnetesIoTPlatformPlaybackDriver + +else: + raise ModuleNotFoundError(f"Could not load platform driver for {config.PLATFORM}") + +__all__ = [ + 'BirbnetesIoTPlatformStatusDriver', + 'BirbnetesIoTPlatformRecordDriver', + 'BirbnetesIoTPlatformPlaybackDriver' +]