Cannot get IMEI
Closed this issue · 0 comments
erm3nda commented
Well.
I've hardcoded ttyUSB0 as modem device, tries to get IMEI but doesn't work.
Is trying code "AT+CGSN\r\n" but returns ERROR.
I tried to send manually the AT command "ATI\r\n" and returns IMEI along other info.
Manufacturer: huawei
Model: E1612
Revision: 11.806.02.03.18
IMEI: 352201030850216
+GCAP: +CGSM,+DS,+ES
OK
So, once i've edited that it told me that dongle was previously unlocked. I used networkmanager to create new dialup with just name and APN and worked :D
Actual obtainImei() looks like
def obtainImei(port):
print "\nTrying to obtain IMEI."
print "The modem will be given 5 seconds to respond."
ser = serial.Serial(port = port,
timeout = 0)
ser.flushInput()
#ser.write('AT+CGSN\r\n')
ser.write('ATI\r\n')
time.sleep(5)
response = ser.read(4096)
ser.close()
imei = re.findall('\d{15}', response)[0]
if imei:
print "Found probable IMEI: " + imei
return imei
else:
print "IMEI not found"
return ''