java smslib rxtx_短信猫java二次开发包源代码smslib-3.5.4.jar
// ReadMessages.java - Sample application.
// 短信读取程序
// This application shows you the basic procedure needed for reading
// SMS messages from your GSM modem, in synchronous mode.
//
// Operation description:
// The application setup the necessary objects and connects to the phone.
// As a first step, it reads all messages found in the phone.
// Then, it goes to sleep, allowing the asynchronous callback handlers to
// be called. Furthermore, for callback demonstration purposes, it responds
// to each received message with a "Got It!" reply.
//
// Tasks:
// 1) Setup Service object.
// 2) Setup one or more Gateway objects.
// 3) Attach Gateway objects to Service object.
// 4) Setup callback notifications.
// 5) Run
package examples.modem;
import java.util.ArrayList;
import java.util.List;
import javax.crypto.spec.SecretKeySpec;
import org.smslib.AGateway;
import org.smslib.AGateway.GatewayStatuses;
import org.smslib.AGateway.Protocols;
import org.smslib.ICallNotification;
import org.smslib.IGatewayStatusNotification;
import org.smslib.IInboundMessageNotification;
import org.smslib.IOrphanedMessageNotification;
import org.smslib.InboundMessage;
import org.smslib.InboundMessage.MessageClasses;
import org.smslib.Library;
import org.smslib.Message.MessageTypes;
import org.smslib.Service;
import org.smslib.crypto.AESKey;
import org.smslib.modem.SerialModemGateway;
public class ReadMessages
{
public void doIt() throws Exception
{
// Define a list which will hold the read messages.
List msgList;
// Create the notification callback method for inbound & status report
// messages.
InboundNotification inboundNotification = new InboundNotification();
// Create the notification callback method for inbound voice calls.
CallNotification callNotification = new CallNotification();
//Create the notification callback method for gateway statuses.
GatewayStatusNotification statusNotification = new GatewayStatusNotification();
OrphanedMessageNotification orphanedMessageNotification = new OrphanedMessageNotification();
try
{
System.out.println("Example: Read messages from a serial gsm modem.");
System.out.println(Library.getLibraryDescription());
System.out.println("Version: " + Library.getLibraryVersion());
// Create the Gateway representing the serial GSM modem.
SerialModemGateway gateway = new SerialModemGateway("modem.com4", "COM4", 115200, "Huawei", "E160");
// Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
gateway.setProtocol(Protocols.PDU);
// Do we want the Gateway to be used for Inbound messages?
gateway.setInbound(true);
// Do we want the Gateway to be used for Outbound messages?
gateway.setOutbound(true);
// Let SMSLib know which is the SIM PIN.
gateway.setSimPin("0000");
// Set up the notification methods.
Service.getInstance().setInboundMessageNotification(inboundNotification);
Service.getInstance().setCallNotification(callNotification);
Service.getInstance().setGatewayStatusNotification(statusNotification);
Service.getInstance().setOrphanedMessageNotification(orphanedMessageNotification);
// Add the Gateway to the Service object.
Service.getInstance().addGateway(gateway);
// Similarly, you may define as many Gateway objects, representing
// various GSM modems, add them in the Service object and control all of them.
// Start! (i.e. connect to all defined Gateways)
Service.getInstance().startService();
// Printout some general information about the modem.
System.out.println();
System.out.println("Modem Information:");
System.out.println(" Manufacturer: " + gateway.getManufacturer());
System.out.println(" Model: " + gateway.getModel());
System.out.println(" Serial No: " + gateway.getSerialNo());
System.out.println(" SIM IMSI: " + gateway.getImsi());
System.out.println(" Signal Level: " + gateway.getSignalLevel() + " dBm");
System.out.println(" Battery Level: " + gateway.getBatteryLevel() + "%");
System.out.println();
// In case you work with encrypted messages, its a good time to declare your keys.
// Create a new AES Key with a known key value.
// Register it in KeyManager in order to keep it active. SMSLib will then automatically
// encrypt / decrypt all messages send to / received from this number.
Service.getInstance().getKeyManager().registerKey("+306948494037",
new AESKey(new SecretKeySpec("0011223344556677".getBytes(), "AES")));
// Read Messages. The reading is done via the Service object and
// affects all Gateway objects defined. This can also be more directed to a specific
// Gateway - look the JavaDocs for information on the Service method calls.
msgList = new ArrayList();
Service.getInstance().readMessages(msgList, MessageClasses.ALL);
for (InboundMessage msg : msgList)
System.out.println(msg);
// Sleep now. Emulate real world situation and give a chance to the notifications
// methods to be called in the event of message or voice call reception.
System.out.println("Now Sleeping - Hit to stop service.");
System.in.read();
System.in.read();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
Service.getInstance().stopService();
}
}
public class InboundNotification implements IInboundMessageNotification
{
public void process(AGateway gateway, MessageTypes msgType, InboundMessage msg)
{
if (msgType == MessageTypes.INBOUND) System.out.println(">>> New Inbound message detected from Gateway: "
+ gateway.getGatewayId());
else if (msgType == MessageTypes.STATUSREPORT) System.out.println(">>> New Inbound Status " +
"Report message detected from Gateway: " + gateway.getGatewayId());
System.out.println(msg);
}
}
public class CallNotification implements ICallNotification
{
public void process(AGateway gateway, String callerId)
{
System.out.println(">>> New call detected from Gateway: " + gateway.getGatewayId() + " : " + callerId);
}
}
public class GatewayStatusNotification implements IGatewayStatusNotification
{
public void process(AGateway gateway, GatewayStatuses oldStatus, GatewayStatuses newStatus)
{
System.out.println(">>> Gateway Status change for " + gateway.getGatewayId() + ", OLD: " + oldStatus + " -> NEW: " + newStatus);
}
}
public class OrphanedMessageNotification implements IOrphanedMessageNotification
{
public boolean process(AGateway gateway, InboundMessage msg)
{
System.out.println(">>> Orphaned message part detected from " + gateway.getGatewayId());
System.out.println(msg);
// Since we are just testing, return FALSE and keep the orphaned message part.
return false;
}
}
public static void main(String args[])
{
ReadMessages app = new ReadMessages();
try
{
app.doIt();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
java smslib rxtx_短信猫java二次开发包源代码smslib-3.5.4.jar相关推荐
- wavecom java_使用java操作wavecom短信猫来发短信的方法|实例源码介绍
使用java操作wavecom短信猫来发短信的方法|实例源码介绍.由于业务的需要,用java实现了用wavecom短信猫发短信的功能,本来这个应该用随猫购买的二次开发接口实现的,但由于这几台猫买的时候 ...
- SMSLIB+RXTX 短信猫开发模块
几天的工作成果,winxp上早早就测好了,在linux 上花了不少时间. 一开始使用redhat4 64位系统,一直调不出来.后来换了centos_6_x86_64后,顺利好多. 另外由于java c ...
- wavecom java_使用java操作wavecom短信猫来发短信的方法
由于业务的需要,今天用java实现了用wavecom短信猫发短信的功能,本来这个应该用随猫购买的二次开发接口实现的,但由于这几台猫买的时候,经销商没有提供二次开发接口,所以我不得不在网上找了资料,自己 ...
- wavecom短信猫推荐RS232串口短信猫适于二次开发应用
wavecom短信猫是指采用wavecom模块生产的短信猫设备,RS232是基于标准串口连接,与电脑串口直连,免驱动性能稳定,适于短信猫二次开发应用.兼容性好,支持的短信猫软件产品丰富. 基于RS ...
- 短信猫 java 开发包,程序员福音!BAT企业联合出品《Java开发手册》强势来袭
随着金三银四的到来,我相信很多朋友都在刷各种各样的面试题,练习各种项目,写简历投简历,不断地提升自己的技术能力!期望能够在这个黄金时间找到一份自己满意的工作,能够冲击一下像 阿里P7.腾讯T3-2 等 ...
- 短信猫二次开发(java版)
短信猫二次开发(java版) 短信猫 短信猫用于批量收/发短信或其它SIM卡服务. 短信猫与PC通过GSM无线网络交互. 交互过程可以分为三个层次: 1.物理层,即无线网络通信. 2.指令层,短信猫支 ...
- Java调用SMSLib用单口短信猫发送短信详解
技术园地 当前位置:短信猫网站主页 > 技术园地 > [转载]Java调用SMSLib用单口短信猫发送短信详解 发布时间:2017/02/09 点击量:620 SMSLib是Apache的 ...
- wavecom工业级短信猫支持标准AT指令集
AT指令是提供给工业级短信猫做二次开发应用的,可以通过AT指令控制短信猫进行收发短信.语音呼叫等各种数据业务功能,可应用于单片机.工控机.服务器.PC电脑终端等设备,广泛用于公司.工业领域实现多样化不 ...
- Java调用SMSLib发送短信具体解释
项目中须要用到发送短信功能.之前没做过这方面.找人咨询了一下.也网上查了查.发现并非非常复杂. 眼下项目已经完毕了.做个记录以备后用.程序中发送短信主要有4种方法: 1.向当地的 ...
最新文章
- Mybatis缓存机制理解及配置
- 自己写的小程序 deb打包
- 【C 语言】二级指针案例 ( 字符串切割 | 返回 自定义二级指针 作为结果 | 每个 一级指针 指向不同大小内存 | 精准分配每个 一级指针 指向的内存大小 )
- eclips mysql jndi_Eclipse +Tomcat配置JNDI数据源
- [翻译]应用程序池和应用程序域的区别
- 【转】MVVM大比拼小结
- python视频人脸检测_Python基于OpenCV实现视频的人脸检测
- Android SQLite用法
- android自定义多按钮点击事件监听事件吗,安卓(Android)动态创建多个按钮并添加监听事件...
- maven不同环境引用不同版本的jar包依赖
- Autonomous Driving in Adverse Weather Conditions: A Survey - 恶劣天气条件下的自动驾驶:一项调查 (arXiv 2021)
- yum 安装没有公钥_CentOS7.7中使用yum安装进,提示尚未安装任何 GPG 公钥的解决办法...
- vue判断身份证是否合法
- 福斯数据服务平台产品白皮书
- bitcode 是什么_dictate什么意思
- 中科院吕本富:“互联网+”已产生泡沫
- 亚马逊运营思考:关于亚马逊CPC广告类型及权重问题值得一看!
- 【简易】微信小程序日期Date的加减
- 下载Visio2013镜像路径以及安装Visio2013软件
- SRPG游戏开发(二十七)第七章 寻路与地图对象 - 五 搜索移动范围与路径(Search Move Range and Path)
热门文章
- 听歌识曲java_homework_3
- 在WCF中启用事务的6个步骤
- (一)通过深度学习进行COVID-19诊断
- 使用Protobuf推动微服务和REST API的开发
- 突发!美国国会发函要求 Facebook 立即停止 Libra 项目
- C#坏习惯:通过不好的例子学习如何制作好的代码——第4部分
- 如何使用Visual Studio无需成本即可实现连续集成
- 比反射更快:委托 第2部分
- python try catch打印到日志_django 捕获异常和日志系统过程详解
- keil 在多字节的目标代码页中 没有此unicode_Go语言之父带你重新认识字符串、字节、rune和字符