简体   繁体   中英

Enable SIM Lock using AT Command VB.net

I want lock my simcard using code, after click the button i restart modem and nothig happen . i want the sim locked status required pin to use it.

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    SerialPort1.PortName = "COM8"
    SerialPort1.BaudRate = 9600
    SerialPort1.Parity = Parity.None
    SerialPort1.StopBits = StopBits.One
    SerialPort1.DataBits = 8
    SerialPort1.Handshake = Handshake.RequestToSend
    SerialPort1.DtrEnable = True
    SerialPort1.RtsEnable = True
    SerialPort1.NewLine = vbCrLf
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SerialPort1.Open()
    If SerialPort1.IsOpen() Then
        SerialPort1.Write("AT" & vbCrLf)

        SerialPort1.Write("AT+CPIN=1234" & vbCrLf)
        SerialPort1.Write("AT+CLCK='SC',1,'1234'" & vbCrLf)
        MsgBox("LOcked")
    Else
        MsgBox("Port not available")
    End If
End Sub




No error Return, SIM CArd Still Unlocked.

Thanks 

Here are several things done wrong, and you must make significant changes before you can start expecting things to work.

The most severe is the complete lack of any parsing of the response codes sent back from the modem. Nothing will ever work until you fix that . Everything in this answer applies. Do read all of chapter 5 in V.250.

In addition (but do not bother addressing the following before you have implemented reading and parsing of the responses from the modem), the command line should be terminated by a single \\r carriage return character, and not vbCrLf. And the string arguments should be encapsulated with " double quotes (eg AT+CPIN="1234" and AT+CLCK="SC",1,"1234" ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM