0
Instead of me having to manually place the port in the txt field, how to make it be auto-detect and fill the field ?
private void btnSend_Click(object sender, EventArgs e)
{
try
{
SerialPort sp = new SerialPort();
sp.PortName = txtPort.Text;
sp.Open();
sp.WriteLine("AT" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CMGF=1" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CSCS=\"GSM\"" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine("AT+CMGS=\"" + txtPhoneNumber.Text + "\"" + Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(txtMessage.Text + Environment.NewLine);
Thread.Sleep(100);
sp.Write(new byte[] { 26 }, 0, 1);
Thread.Sleep(100);
var response = sp.ReadExisting();
if (response.Contains("ERRO"))
MessageBox.Show("Envio falhou , tente novamente daqui 5 segundos !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("SMS Enviado !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
sp.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
beauty, vlw by help, actually C Sharp to starting now, to accompany some video-lesson , and I will test some commands here on the console
– Mandrake Venom