phone = list[1].strip('\"') print "Phone number = " + phone print print "Deleting old messages ..." gsm.query("AT+CMGD=70,4") print SwitchGPSon() print "Boot successful, waiting for messages ..." while True: # Check messages message = gsm.next_message() if message: print "loop 1" print message text = message.text if text[0:5] == 'Start': print "Start sending Position ..." SendGPSPosition() lastmessage = 'Start' time.sleep(300) elif text[0:4] == 'Stop': print "Text was Stop. Stop sending" lastmessage = 'Stop' else: if lastmessage == 'Start':
time.sleep(1) message = gsm.next_message(fetch=True) try: socket.inet_aton(message.text) # legal except socket.error: # Not legal gsm.send_sms(msisdn,"Disconnecting your IP is invalid please try again in 30s") print("Adding routing for you %s" % message.text) Actions = do_something() print "Waiting for network..." s = gsm.wait_for_network() # start query the memory try: while True: message = gsm.next_message(fetch=True) if message is None: time.sleep(1) else: pprint.pprint("Received message: %s " % message) if any(message.sender in s for s in options.msisdn): print "Your command master is: %s" % message.text try: func = getattr(Actions,message.text) func(message.sender) except Exception, e: exp = '*** I made a booboo : %s: %s' % (e.__class__, e) print exp except Exception, e:
len(msg.text)) def serve_forever(self): while True: # print "Checking for message..." msg = self.modem.next_message() if msg is not None: print "Got Message: %r" % (msg) self.incoming(msg) time.sleep(2) # all arguments to GsmModem.__init__ are optional, and passed straight # along to pySerial. for many devices, this will be enough: gsm = GsmModem( port="/dev/ttyUSB2", logger=GsmModem.debug_logger).boot() print "Waiting for network..." s = gsm.wait_for_network() #gsm.send_sms("0711661919", "Hey, wake up!") while True: print "DEBUG:***********Message = {}".format(gsm.next_message()) time.sleep(2) # start the demo app #app = CountLettersApp(gsm) #app.serve_forever()