像调制解调器一样接收短信
我有一个只能将 SMS 发送到串行 AT 调制解调器的应用程序,但我想通过 Web 服务发送此 SMS。
我的想法是将虚拟软件调制解调器连接到应用程序的(虚拟)串行端口并在软件中接收短信,然后我会将此短信传递给 Web API。
我的问题是,我既找不到一个可以像调制解调器一样接收短信的软件,也找不到一个提供像调制解调器一样功能的库。
有什么想法吗?
I have an application which can only send SMS to a serial AT modem, but I want to send this SMS via an web service.
My idea is to connect a virtual software modem to the (virtual) serial port of the application and receive the SMS in software, then I would pass this SMS to the web API.
My problem is, that i nether find a software which can recieve SMS like a modem nor find a library which offers ability to act like a modem.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您现有的应用程序需要连接到串行端口。这意味着您需要某种虚拟串行端口。谷歌将为您提供该术语的完美可用的搜索结果。这些库中的任何一个都应该为您提供字符流。
解析这个流应该相当简单。您可以放弃所有调制解调器初始化,而只关注 SMS 命令。理论上,有一个“写入”和一个“发送”命令,但您可以放心地假设 PC 应用程序将发送它编写的任何 SMS。它不像PC 那样会出现拼写错误。因此,您只需要解析
AT+CMGW
命令即可;所有其他命令都可以获得标准的 OK 响应。从
AT+CMGW
命令中获取电话号码和消息,并将其传递给 Web 服务。完毕!Your existing application expects to connect to a serial port. That means you need some kind of virtual serial port. Google will give you perfectly usable hits for that term. Any of those libs should give you a character stream.
Parsing this stream should be fairly straightforward. You can toss out all modem initialization, and just focus on the SMS command. In theory, there's a "write" and a "send" command, but you can safely assume that a PC application will send any SMS that it writes. It's not like PC's make typo's. Hence, you just need to parse the
AT+CMGW
command; all other commands can get a standard OK response.Grab the phone number and message from the
AT+CMGW
command, and pass it to the webservice. Done!