Esempio n. 1
0
def _diagnose(arg):
    modem.monitor["cellular_connection"] = False
    modem.incident_flag = True
    diag_type = 0

    if queue.sub == 6:
        queue.set_step(sub=0,
                       base=6,
                       success=7,
                       fail=7,
                       interval=0.1,
                       is_ok=False,
                       retry=5)
        diag_type = 0
    elif queue.sub == 13:
        queue.set_step(sub=0,
                       base=13,
                       success=7,
                       fail=7,
                       interval=0.1,
                       is_ok=False,
                       retry=5)
        diag_type = 1
    try:
        modem.diagnose(diag_type)
    except Exception as e:
        logger.error("diagnose() ->" + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 2
0
def _identify_setup(arg):
    global modem
    queue.set_step(sub=0,
                   base=1,
                   success=2,
                   fail=13,
                   interval=0.1,
                   is_ok=False,
                   retry=50)

    try:
        new_id = identify_setup()
    except Exception as e:
        logger.error("identify_setup -> " + str(e))
        queue.is_ok = False
    else:
        if new_id != 0:
            modem.update(vendor=new_id.get("modem_vendor", ""),
                         model=new_id.get("modem_name", ""),
                         imei=new_id.get("imei", ""),
                         iccid=new_id.get("iccid", ""),
                         sw_version=new_id.get("sw_version", ""),
                         vendor_id=new_id.get("modem_vendor_id", ""),
                         product_id=new_id.get("modem_product_id", ""))
        queue.is_ok = True
Esempio n. 3
0
def _reset_modem_hardly(arg):
    queue.set_step(sub=0,
                   base=12,
                   success=1,
                   fail=1,
                   interval=1,
                   is_ok=False,
                   retry=1)

    try:
        modem.reset_modem_hardly()
    except Exception as e:
        logger.error("reset_modem_hardly() -> " + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 4
0
def _reset_usb_interface(arg):
    queue.set_step(sub=0,
                   base=9,
                   success=10,
                   fail=11,
                   interval=1,
                   is_ok=False,
                   retry=2)

    try:
        modem.reset_usb_interface()
    except Exception as e:
        logger.error("reset_usb_interface() -> " + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 5
0
def _initiate_ecm(arg):
    queue.set_step(sub=0,
                   base=4,
                   success=5,
                   fail=13,
                   interval=0.1,
                   is_ok=False,
                   retry=5)

    try:
        modem.initiate_ecm()
    except Exception as e:
        logger.error("initiate_ecm() -> " + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 6
0
def _check_network(arg):
    queue.set_step(sub=0,
                   base=3,
                   success=4,
                   fail=13,
                   interval=5,
                   is_ok=False,
                   retry=120)

    try:
        modem.check_network()
    except Exception as e:
        logger.error("check_network() -> " + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 7
0
def _configure_modem(arg):
    queue.set_step(sub=0,
                   base=2,
                   success=3,
                   fail=13,
                   interval=1,
                   is_ok=False,
                   retry=5)

    try:
        modem.configure_modem()
    except ModemNotSupported:
        queue.is_ok = False
    except ModemNotFound:
        queue.is_ok = False
    except Exception as e:
        logger.error("configure_modem() -> " + str(e))
        queue.is_ok = False
    else:
        queue.is_ok = True
Esempio n. 8
0
def _check_internet(arg):

    if queue.sub == 5:
        queue.set_step(sub=0,
                       base=5,
                       success=5,
                       fail=6,
                       interval=INTERVAL_CHECK_INTERNET,
                       is_ok=False,
                       retry=0)
    elif queue.sub == 8:
        queue.set_step(sub=0,
                       base=8,
                       success=5,
                       fail=9,
                       interval=10,
                       is_ok=False,
                       retry=0)
    elif queue.sub == 10:
        queue.set_step(sub=0,
                       base=10,
                       success=5,
                       fail=11,
                       interval=10,
                       is_ok=False,
                       retry=0)

    try:
        modem.check_internet()
    except Exception as e:
        print("")  # debug purpose
        logger.error("check_internet() -> " + str(e))
        queue.is_ok = False
    else:
        modem.monitor["cellular_connection"] = True

        if modem.incident_flag == True:
            modem.monitor["fixed_incident"] += 1
            modem.incident_flag = False

        print(".", end="", flush=True)  # debug purpose
        queue.is_ok = True
Esempio n. 9
0
#!/usr/bin/python3

import time
import os.path

from helpers.commander import send_at_com
from helpers.yamlio import *
from helpers.exceptions import *
from helpers.config_parser import *
from helpers.queue import queue

from modules.identify import identify_setup
from modules.modem import Modem

system_info = {}
queue.set_step(0, 0, 0, 0, 0, 0, 0)

logger.info("Core Manager started.")

while True:
    if os.path.isfile(SYSTEM_PATH):
        break
    else:
        try:
            logger.warning(
                "system.yaml doesn't exist! Identifying the system...")
            identify_setup()
        except Exception as e:
            logger.critical("identify_setup() -> " + str(e))
            logger.critical(
                "First identification failed. Retrying to identify required parameters!"