ublox-config: Add poweroff feature
systemctl start ModemManager will start ublox-config first systemctl stop ublox-config will stop ModemManager first BugzID: 57325
This commit is contained in:
parent
5fd5028063
commit
40aca5599e
|
|
@ -122,17 +122,36 @@ def apn_setup(ser):
|
||||||
print("Full functionality mode")
|
print("Full functionality mode")
|
||||||
execute_and_check(ser, b'AT+CFUN=1\r')
|
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():
|
def main():
|
||||||
line = gpiod.find_line('GSM_SUP_EN')
|
line = gpiod.find_line('GSM_SUP_EN')
|
||||||
line.request(consumer='ublox-config', type=gpiod.LINE_REQ_DIR_OUT)
|
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)
|
line.set_value(1)
|
||||||
|
|
||||||
rst = False
|
|
||||||
# Wait on device
|
# Wait on device
|
||||||
while not os.path.exists(SERIAL_DEV):
|
while not os.path.exists(SERIAL_DEV):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
|
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
|
||||||
|
|
||||||
|
rst = False
|
||||||
if not os.path.exists(WWAN_DEV):
|
if not os.path.exists(WWAN_DEV):
|
||||||
print("Setting up bridge mode")
|
print("Setting up bridge mode")
|
||||||
execute_and_check(ser, b'AT+UBMCONF=2')
|
execute_and_check(ser, b'AT+UBMCONF=2')
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ Before=ModemManager.service
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/ublox-config
|
ExecStart=/usr/bin/ublox-config
|
||||||
|
ExecStop=/usr/bin/ublox-config stop
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=ModemManager.service
|
RequiredBy=ModemManager.service
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue