-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgsm_controller.py
More file actions
43 lines (32 loc) · 909 Bytes
/
gsm_controller.py
File metadata and controls
43 lines (32 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import logging
import ifcfg
class GsmController:
def enable(self):
self.on()
self.on_ppp()
def disable(self):
self.off()
self.off_ppp()
def on_ppp(self):
self.call('sudo pon u-GSM')
def off_ppp(self):
self.call('sudo poff u-GSM')
def on(self):
self.call('sudo sh /home/pi/u-GSM-ppp/poweronGSM')
def off(self):
self.call('sudo sh /home/pi/u-GSM-ppp/poweroffGSM')
def call(self, command):
logging.info('System command call: %s' % command)
os.system(command)
logging.info('System command call done: %s' % command)
def is_ppp_interface_present(self):
exists = False
for name, interface in ifcfg.interfaces().items():
if interface['device'] == 'ppp0':
exists = True
if exists:
logging.info('ppp0 interface is present.')
else:
logging.info('ppp0 interface is not present.')
return exists