我在此主题中需要您的帮助:
我想从与USB连接的手机发送短信到笔记本电脑,并发送文本应从Java表单中写入。我尝试使用JSSC库进行一些代码,但是由于没有发送SMS,它不起作用。连接很好,沟通也很好,但是短信未发送。你们俩都可以帮助我吗?
public static void main(String[] args) {
SerialPort port = new SerialPort("COM3");
char enter = 13;
char control_z=26;
char comilla = 34;
try {
System.out.println("Port open: " + port.openPort());
System.out.println("Params setted: " + port.setParams(9600, 8, 1, 0));
System.out.println("Set to SMS: " + port.writeBytes(("AT+CMGF=1"+enter).getBytes()));
System.out.println("Set the destinatar: " + port.writeBytes(("AT+CMGS"+comilla+"+phone_number"+comilla+enter).getBytes()));
System.out.println("Set the text: " + port.writeBytes(("text"+control_z).getBytes()));
System.out.println("Port closed: " + port.closePort());
}
catch (SerialPortException ex){
System.out.println(ex);
}
}
您正在流产要发出的命令。您应该是阅读和解析您从调制解调器中获得的响应。请参阅此答案的第一部分,以及此答案。