print "Modem details:" reply = gsm.hardware() print "Manufacturer = " + reply['manufacturer'] print "Model = " + reply['model'] # Try and get phone number reply = gsm.command('AT+CNUM') if len(reply) > 1: list = reply[0].split(",") 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
usbPortsIdentified = {} iccid = '' # Default values are blank for those that come from GSM modem imei = '' for usbPort in allUSBDevicePorts: try: with time_limit(4): print("Trying to connect as GSM to " + str(usbPort)) gsm = GsmModem(port=usbPort, logger=GsmModem.debug_logger).boot() print("GSM modem detected at " + str(usbPort)) allUSBDevicePorts.remove( usbPort) # We just found it engaged, don't use it again iccid = gsm.query("AT^ICCID?", "^ICCID:").strip('"') imei = gsm.query("ATI", "IMEI:") usbPortsIdentified[str(usbPort)] = "gsm" print(usbPort, usbPortsIdentified[usbPort]) break # We got a port, so break out of loop except TimeoutException: # Maybe this is not the right port for the GSM modem, so skip to the next number print("Timed out!") except IOError: print("IOError - so " + usbPort + " is also not a GSM device") # Open a SQLlite3 connection dbconnection = sqlite3.connect( '/opt/driver-signature-raspberry-pi/database/obd2data.db') dbcursor = dbconnection.cursor()
print("Modem details:") reply = gsm.hardware() print("Manufacturer = " + reply['manufacturer']) print("Model = " + reply['model']) # Try and get phone number reply = gsm.command('AT+CNUM') if len(reply) > 1: list = reply[0].split(",") phone = list[1].strip('\"') print("Phone number = " + phone) print print("Deleting old messages ...") gsm.query("AT+CMGD=1,4") print SwitchGPSon() time.sleep(90) # waiting to receive satellites SwitchGPSon() # Trick to start again to reive position # ricava posizione iniziale SendGPSPosition() PreviousAltitude = float(Altitude) PreviousLatitude = float(Latitude) PreviousLongitude = float(Longitude) # ricevi la posizione iniziale sul cellulare