Enable SIM Lock using AT Command VB.net

瘦欲@ 提交于 2019-12-12 04:57:16

问题


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 

回答1:


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 (e.g. AT+CPIN="1234" and AT+CLCK="SC",1,"1234").



来源:https://stackoverflow.com/questions/44097689/enable-sim-lock-using-at-command-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!