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
512e2234de
commit
83ca2f3e10
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue