def main(): """Main function for the project. """ # Call CreateConfig class cc = CreateConfig() # Read config.ini file config = cc.read() cd_port = config["Card_Reader"]["Port"] cd_id = config["Card_Reader"]["ID"] io_port = config["Controller"]["Port"] io_id = config["Controller"]["ID"] # Create card reader one card_reader = ACT230(cd_port, cd_id) # Call class Tokens and get_tokens method tokens = Tokens() # Create controller controller = IOController(io_port, io_id) # Call AccessControl class ac = AccessControl(card_reader, tokens, controller) #call update method in a while cycle to check for token input non-stop while (1): ac.update()
def __init__(self, ip='192.168.43.186', port=2026): self.ip = ip self.port = port self._run = True self.io_controller = IOController() self.start()
def main(): gc.enable() # Get the config from json config file with open("config.json") as fd: config = ujson.loads(fd.read()) # Disable wifi access point wifi.access_point(disable=True) # Connect to WIFI and wait for IP wifi.connect(config["wifi"]["ssid"], config["wifi"]["password"], True, True) gc.collect() # Use the NTP to prime the local offset ntp = SimpleNTP() ntp.request_time() print("Time synced from NTP, local: %d, offset: %d" % (ntp.get_local_time(), ntp.get_offset())) # Make a MQTT connection mqtt = MQTTClient(config["mqtt"].get("name"), config["mqtt"]["prefix"], config["mqtt"]["server"], config["mqtt"].get("port", 0)) # Start an IO controller module (if enabled in config) io_conf = config.get("io") if io_conf: io_controller = IOController(mqtt, io_conf) # Start publishing MQTT-messages coordinator = PublisherCoordinator(mqtt, config["publisher"]) # Update the time from NTP every 6th iteration coordinator.add_callback(ntp.request_time, divider=30) # Check for incoming mqtt messages for the IOContoroller every iteration if io_conf: coordinator.add_callback(io_controller.iterate, divider=1) # The run-call blocks untill an exception is thrown (e.g. ctrl+C) print("Free / Available: %d / %d" % (gc.mem_free(), gc.mem_free() + gc.mem_alloc())) coordinator.run()
def main(): """Main function for the project. """ # Create card reader one card_reader = ACT230("COM3") # Call class Tokens and get_database method tokens = Tokens() tbase = tokens.get_database() # Create controller controller = IOController() # Call AccessControl class ac = AccessControl(card_reader, tbase, controller) #call update method in a while cycle to check for token input non-stop while (1): ac.update()