private Thread smssendThread = null;
private void buttonX1_Click(object sender, EventArgs e)
{
if (smssendThread == null)
{
this.ConnectState.Visible = true;
this.ConnectState.Text = "设备连接成功!";
this.buttonX1.Enabled = false;
this.buttonX2.Enabled = true;
this.buttonX3.Enabled = true;
this.labelX1.Visible = false;
this.labelX2.Visible = false;
}
else
{
this.ConnectState.Visible = true;
this.buttonX1.Enabled = true;
this.buttonX2.Enabled = false;
this.buttonX3.Enabled = false;
this.labelX1.Visible = true;
this.labelX2.Visible = false;
}
}
如果我不打开设备也提示 设备连接成功,不知道怎么样判断连接失败
private void SendSMS(String phoneNumber, String message)
{
try
{
if (!serialPort1.IsOpen)
serialPort1.Open();
serialPort1.Write("AT+CMGF=1" + (Char)13);
serialPort1.Write(String.Format("AT+CMGS=\"{0}\"" + (Char)13, phoneNumber));
serialPort1.Write(String.Format("{0}" + (Char)26 + (Char)13, message));
MessageBox.Show("发送成功!");
}
catch (Exception e)
{
MessageBox.Show("异常:" + e.Message);
}
}
可以正常发送短信,可是却没有办法判断是否成功?请兄弟们支持我一下,另外怎么样读取短消息??????在线等答复!!!!!!!由于我没有积分所以不能给积分!!!有了积分给大家!
private void buttonX1_Click(object sender, EventArgs e)
{
if (smssendThread == null)
{
this.ConnectState.Visible = true;
this.ConnectState.Text = "设备连接成功!";
this.buttonX1.Enabled = false;
this.buttonX2.Enabled = true;
this.buttonX3.Enabled = true;
this.labelX1.Visible = false;
this.labelX2.Visible = false;
}
else
{
this.ConnectState.Visible = true;
this.buttonX1.Enabled = true;
this.buttonX2.Enabled = false;
this.buttonX3.Enabled = false;
this.labelX1.Visible = true;
this.labelX2.Visible = false;
}
}
如果我不打开设备也提示 设备连接成功,不知道怎么样判断连接失败
private void SendSMS(String phoneNumber, String message)
{
try
{
if (!serialPort1.IsOpen)
serialPort1.Open();
serialPort1.Write("AT+CMGF=1" + (Char)13);
serialPort1.Write(String.Format("AT+CMGS=\"{0}\"" + (Char)13, phoneNumber));
serialPort1.Write(String.Format("{0}" + (Char)26 + (Char)13, message));
MessageBox.Show("发送成功!");
}
catch (Exception e)
{
MessageBox.Show("异常:" + e.Message);
}
}
可以正常发送短信,可是却没有办法判断是否成功?请兄弟们支持我一下,另外怎么样读取短消息??????在线等答复!!!!!!!由于我没有积分所以不能给积分!!!有了积分给大家!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货