问题描述
我通过 GSM 设备发送短信,试试这个:https://stackoverflow.com/a/31361225/6250402
它可以发送普通短信,我尝试发送 Unicode 文本,但它会自动转换为 ASCII:VD¥n ba:#n D_a:?n: TBM01
库:
<dependency>
<groupId>com.neuronrobotics</groupId>
<artifactId>nrjavaserial</artifactId>
<version>5.1.1</version>
</dependency>
我的代码:
CommPortIdentifier portId = "I get CommPort match name";
SerialPort serialPort = portId.open("name",2000);
serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
this.outputStream = serialPort.getOutputStream();
// each command function
private void send(String cmd) throws IOException {
outputStream.write(cmd.getBytes(StandardCharsets.UTF_8)); //
outputStream.flush();
}
// this sends message method
send("AT+CMGS=" + '"' + phone + '"' + "\r\n");
send(message + '\032');
我的配置有误吗?
任何通过 GSM for java 发送短信的代码都是一个很好的答案。
结果我错过了AT+CSMP=1,167,8
(https://stackoverflow.com/a/15312611/6250402,要了解更多信息,请看https://www.smssolutions.net/tutorials/gsm/sendsmsat/)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)