diff --git a/recipes-connectivity/ublox-configuration/files/ublox-config.py b/recipes-connectivity/ublox-configuration/files/ublox-config.py index be5e157..673d586 100755 --- a/recipes-connectivity/ublox-configuration/files/ublox-config.py +++ b/recipes-connectivity/ublox-configuration/files/ublox-config.py @@ -122,17 +122,36 @@ def apn_setup(ser): print("Full functionality mode") execute_and_check(ser, b'AT+CFUN=1\r') +def poweroff(gpio): + print('poweroff') + if not os.path.exists(SERIAL_DEV): + print('serial interface is not available') + gpio.set_value(0) + return -1 + ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5) + ser.write(b'AT+CPWROFF\r') + ser.close() + + time.sleep(2) + + gpio.set_value(0) + def main(): line = gpiod.find_line('GSM_SUP_EN') line.request(consumer='ublox-config', type=gpiod.LINE_REQ_DIR_OUT) + + if len(sys.argv) == 2 and sys.argv[1] == 'stop': + return poweroff(line) + + # Power on line.set_value(1) - rst = False # Wait on device while not os.path.exists(SERIAL_DEV): time.sleep(1) ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5) + rst = False if not os.path.exists(WWAN_DEV): print("Setting up bridge mode") execute_and_check(ser, b'AT+UBMCONF=2') diff --git a/recipes-connectivity/ublox-configuration/files/ublox-config.service b/recipes-connectivity/ublox-configuration/files/ublox-config.service index 33d1223..ad05f59 100644 --- a/recipes-connectivity/ublox-configuration/files/ublox-config.service +++ b/recipes-connectivity/ublox-configuration/files/ublox-config.service @@ -4,8 +4,10 @@ Before=ModemManager.service [Service] Type=oneshot ExecStart=/usr/bin/ublox-config +ExecStop=/usr/bin/ublox-config stop +RemainAfterExit=yes [Install] -WantedBy=ModemManager.service +RequiredBy=ModemManager.service