Exemple #1
0
    def __init__(self, config: SystemConfig):
        super().__init__()

        self.event = dict()
        self.daemon = True
        self.client = None
        self.logger = config.logger()

        # Queues
        self.q_int = config.get('q_int')
        self.q_ext = config.get('q_ext')

        # Device
        self.skip_until = 0
        self.pub = config.get('pub')
        self.sub = config.get('sub')

        # MQTT broker
        self.broker_ip = config.get('broker_ip')
        self.broker_port = config.get('broker_port', 1883)
        self.username = config.get('username')
        self.password = config.get('password')
        self.client_id = f"{config.get('topic')}_{config.get('uid')}"

        if not self.broker_ip:
            self.logger.error(
                '[!] cannot configure client, broker ip missing. exiting...')
            return
Exemple #2
0
 def __init__(self, app_config: SystemConfig, device_config: DeviceConfig):
     if not isinstance(app_config, SystemConfig):
         raise Exception(
             f'app_config is not a SystemConfig, but {type(app_config)} instead'
         )
     if not isinstance(device_config, self.config_class):
         raise Exception(
             f'device_config is not a {self.config_class}, but {type(device_config)} instead'
         )
     # assign system config
     self.system = app_config
     self.q_int = app_config.get('q_int')
     self.uid = app_config.get('uid')
     self.logger = app_config.logger()
     # assign device ingame config
     self.config = device_config
     self.config.load()  # load and update current running conf
Exemple #3
0
from skabenclient.config import SystemConfig
from skabenclient.helpers import get_mac
from skabenclient.main import start_app

from dotenv import load_dotenv

from device import BoilerplateDevice
from config import BoilerplateConfig

root = os.path.abspath(os.path.dirname(__file__))

sys_config_path = os.path.join(root, 'conf', 'system.yml')
dev_config_path = os.path.join(root, 'conf', 'device.yml')

log_path = os.path.join(root, 'local.log')

if __name__ == "__main__":
    #
    # DO NOT FORGET TO RUN ./pre-run.sh install BEFORE FIRST START
    #

    # setting system configuration and logger
    app_config = SystemConfig(sys_config_path, root=root)
    app_config.logger(file_path=log_path)
    # inject arguments into system configuration
    dev_config = BoilerplateConfig(dev_config_path)
    # instantiating device
    device = BoilerplateDevice(app_config, dev_config)
    # start application
    start_app(app_config=app_config, device=device)