I've tried to send a SMS via AT commands with a script in Python, first I'm am testing the AT commands individually, but in the third command I received CME ERROR: 11
,this is the list of commands:
ATZ
OK
AT+CMGF=1
OK
AT+CMGS="phone number"
CME ERROR: 11
I'm using Windows 10, 64 bits, Huawei E303 is plugged at COM6.
I found out that error 11 is SIM PIN REQUIRED, but I don't know how to provide that SIM PIN during the execution of my AT commands list:
Part of Python script is this:
class TextMessage:
def __init__(self, numero, mensaje,puerto):
self.numero = numero
self.mensaje= mensaje
self.puerto = puerto
def setRecipient(self, numero):
self.numero = numero
def setContent(self, mensaje):
self.mensaje = mensaje
def conectar(self):
self.ser = serial.Serial(self.puerto, 460800, timeout=5)
time.sleep(1)
def enviarMensaje(self):
self.ser.write("ATZ\\r".encode())
time.sleep(1)
self.ser.write("AT+CMGF=1\\r".encode())
time.sleep(1)
self.ser.write("AT+CMGS=".encode())
self.ser.write(self.numero.encode())
self.ser.write("\\r".encode())
time.sleep(1)
self.ser.write(self.mensaje.encode())
self.ser.write("\\r".encode())
time.sleep(1)
self.ser.write(chr(26).encode())
time.sleep(1)
def desconectar(self):
self.ser.close()
def EnviarSMS():
sms = TextMessage("00525528960002", "Mensaje de prueba",puertoAsignado(puerto.get()))
sms.conectar()
sms.enviarMensaje()
sms.desconectar()
mensajeEmergente = 'Los SMS fueron enviados'
mensajeVar = tk.Message(ventana, width=140, text=mensajeEmergente)
mensajeVar.config(bg='lightgreen')
mensajeVar.grid(row=3, column=0)
You can provide the PIN authentication to your device by issuing the following command:
Usually the default PIN CODE is written in the card in which the SIM was inserted when you bought it.
Warning! Make sure that the PIN is correct, otherwise after 3 wrong attempts the PIN will be blocked! In that case only providing the **PUK code* with the same
+CPIN
command will unblock it.(after 10 failed attempts to provide the PUK code, the SIM will be lost).
At any moment, you can query the PIN status of the SIM by using the read command of
+CPIN
:Its most common responses, among the others are