最近做了一个使用MOTO mc3190 二维码机器的客户,对这个机器简单说一下。
1,名牌就是名牌,对得起价格,做工精细,细节完美。美中不足,我拿到机器,居然是 英文OS,呵呵,订货的时候我也没说明。直接就订了。
不过,发过来一个中文OS,自己update一下就好了。这个没什么难度,只是需要仔细看清说明,运行对应方式的快捷方式。
2,关于EMDK 开发文档和SDK以及demo示范,是我目前见过,最完整,最有条理的,没有一点拖泥带水的感觉,美中不足全是“鸟语”,看得不太习惯。
3,发现一个问题,同屏软件mymobiler 居然连接不上MC3190S 呵呵,懒得去研究,也懒得去建模拟器,直接机器上调试,工程进度要紧。
4,我将我的工程删减后,形成一个读码演示程序,公开整个工程和源代码,里头还有注解。需要的可以下载:
http://download.csdn.net/detail/zyai001/6329979
5,几点用法总结一下
1. 冷启动:关机状态下: 1 + 9 + power 警告:会格式化数据,恢复到出厂值,重新校正触控笔。
热启动:部分资料介绍为:7 + 9 +power,但是我手里这个机器不是,直接长按电源就关机了,在按一下就热启动了。
另外,我手里的机器,有个机器自带的 warmboot 的程序,呵呵,一点就热启动重启了。
2. 机器充电:显示剩余10%左右电量充电,不要完全耗完电池的电。一般机子显示充满电之后,
大概再充一个小时的电,电池就可以达到完全饱和。
3. 关于MC3190 冷启动自动恢复
在 Application 目录下建立 *.cpy 和 *.reg 两个后缀名文件
*.cpy: 机器冷启动后,会自动按照这个文件指定格式内容,复制文件。
请严格按照如下格式建立:
\Application\备份\ xxxx.cab > \xxxxxx\xxxx.cab
*.reg: 机器在执行完文件复制任务后,会自动导入这个注册表,然后运行其中指定的程序用的最多的就是SQLCE等恢复。
请参照如下格式和注解:
;--------------------------------
; FILENAME: Setup.Reg
; Company: ZhengZhou ZhiMa Computer S&T CO.,LTD
; Web: www.0371pos.net QQ:1157292096
;--------------------------------
; For
[HKEY_CURRENT_USER\Software\Symbol\Startup\Programs\Prog10]
"Name"="\windows\wceload.exe"
"Command"="/noaskdest \windows\sqlce.wce5.armv4i.CAB"
"Continue"=dword:0
"ColdBootOnly"=dword:1
; For
[HKEY_CURRENT_USER\Software\Symbol\Startup\Programs\Prog11]
"Name"="\windows\wceload.exe"
"Command"="/noaskdest \windows\QsMent6.cab"
"Continue"=dword:0
"ColdBootOnly"=dword:1
;注解
;注册表键值
;运行程序名称
;程序运行参数 /noaskdest 不询问,自动静默安装。
;
;
;备注,经我亲自测试 /delete 0 这个参数不可靠,如果安装成功 *.cab 不会删除,安装失败,依旧会删除。
;所以,最好的办法就是,自动复制一份,然后运行。
;另,自动建立桌面图标,我用cpy方法在MC3190s怎么实验都不成功,其他品牌都成功过。
;最后只要将我的程序制作一个 CAB 安装包。
最近在做这个玩意、其中碰到的最大的问题是联络的问题,还有一个就是资料匮乏的问题。遇到问题了问移动的经理,他说他不清楚、问卓望的人他说他不是搞开发他不知道!
好了、公司申请了短信订购业务过后,我们就会得到发送订购报文的地址跟业务代码,企业代码这些报文信息,具体报文如下:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<TransactionID xmlns="http://www.monternet.com/dsmp/schemas/">00240301659556</TransactionID> ------该消息编号
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<SyncOrderRelationReq xmlns="http://www.monternet.com/dsmp/schemas/"><Version>1.5.0</Version>
<MsgType>SyncOrderRelationReq</MsgType>
<Send_Address>
<DeviceType>0</DeviceType>
<DeviceID>0028</DeviceID>
</Send_Address>
<Dest_Address>
<DeviceType>400</DeviceType>
<DeviceID>0</DeviceID>
</Dest_Address>
<FeeUser_ID>
<UserIDType>1</UserIDType>
<MSISDN>13885078893</MSISDN> ----------------------手机号码
<PseudoCode></PseudoCode>
</FeeUser_ID>
<DestUser_ID>
<UserIDType>1</UserIDType>
<MSISDN>13885078893</MSISDN> ----------------------手机号码
<PseudoCode></PseudoCode>
</DestUser_ID>
<LinkID>SP</LinkID>
<ActionID>1</ActionID>
<ActionReasonID>1</ActionReasonID>
<SPID>924703</SPID> ----------------------企业代码
<SPServiceID>-PG</SPServiceID> ----------------------业务代码
<AccessMode>3</AccessMode>
<FeatureStr>UXI=</FeatureStr>
</SyncOrderRelationReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
上面的是订购的xml内容,我们需要将上面的手机号码,企业代码,业务代码,消息编号(如果你不考虑接收取消订购的消息的话可以不管它)替换掉,下面是我写的一个订购测试类:
package com.bx.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
/**
* 移动订购业务包
* @author admin_Hzw
*
*/
public class CMMISC {
/**
* 反向订购请求包
* @return
*/
public static String getRequest(String phone,String msgId){
StringBuffer sendStr = new StringBuffer();
sendStr.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+
"<SOAP-ENV:Envelope "+
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "+
"xmlns:SOAP-ENC=\"http://schemas .xmlsoap.org/soap/encoding/\" "+
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "+
"SOAP-ENV:encodinghttp://schemas.xmlsoap.org/soap/encoding/\" "+
"xmlns=\"http://www.monternet.com/dsmp/schemas/\">");
sendStr.append("<SOAP-ENV:Header> "+
"<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\" "+
"xsi:type=\"xsd:string\">"+msgId+"</TransactionID> "+
" </SOAP-ENV:Header>");
sendStr.append("<SOAP-ENV:Body>");
sendStr.append("<SubscribeServiceReq xmlns=\"http://www.monternet.com/dsmp/schemas/\">");
sendStr.append("<Version>1.5.0</Version>");
sendStr.append("<MsgType>SubscribeServiceReq</MsgType>");
sendStr.append("<Send_Address>");
sendStr.append("<DeviceType>400</DeviceType>");
sendStr.append("<DeviceID>924403</DeviceID>");
sendStr.append("</Send_Address>");
sendStr.append("<Dest_Address>");
sendStr.append("<DeviceType>0</DeviceType>");
sendStr.append("<DeviceID>0028</DeviceID>");
sendStr.append("</Dest_Address>");
sendStr.append("<FeeUser_ID>");
sendStr.append("<UserIDType>1</UserIDType>");
sendStr.append("<MSISDN>"+phone+"</MSISDN>");
sendStr.append("<PseudoCode />");
sendStr.append("</FeeUser_ID>");
sendStr.append("<DestUser_ID>");
sendStr.append("<UserIDType>1</UserIDType>");
sendStr.append("<MSISDN>"+phone+"</MSISDN>");
sendStr.append("<PseudoCode />");
sendStr.append("</DestUser_ID>");
sendStr.append("<Service_ID>");
sendStr.append("<ServiceIDType>1</ServiceIDType>");
sendStr.append("<SPID>企业代码</SPID>");
sendStr.append("<SPServiceID>业务代码</SPServiceID>");
sendStr.append("<AccessNo />");
sendStr.append("<FeatureStr />");
sendStr.append("</Service_ID>");
sendStr.append("<FeatureStr />");
sendStr.append("</SubscribeServiceReq>");
sendStr.append("</SOAP-ENV:Body>");
sendStr.append("</SOAP-ENV:Envelope>");
return sendStr.toString();
}
/**
* 模拟返回包
* @return
*/
public static String getResult(){
StringBuffer r = new StringBuffer();
r.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append(
"<SOAP-ENV:Envelope").append(
" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"").append(
" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"").append(
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"").append(
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">").append(
"<SOAP-ENV:Header>").append(
"<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\">9990100019175</TransactionID>").append(
"</SOAP-ENV:Header>").append(
"<SOAP-ENV:Body>").append(
"<SyncOrderRelationResp>").append(
"<MsgType>SyncOrderRelationResp</MsgType>").append(
"<Version>1.5.0</Version>").append(
"<hRet>0</hRet>").append(
"</SyncOrderRelationResp>").append(
"</SOAP-ENV:Body>").append(
"</SOAP-ENV:Envelope>");
return r.toString();
}
/**
* 取消包
* @param tel
* @return
*/
public static String getCanCel(String tel){
StringBuffer b = new StringBuffer();
b.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>")
.append("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" SOAP-ENV:encodinghttp://schemas.xmlsoap.org/soap/encoding/\" xmlns=\"http://www.monternet.com/dsmp/schemas/\">")
.append("<SOAP-ENV:Header>")
.append("<TransactionID xmlns=\"http://www.monternet.com/dsmp/schemas/\" xsi:type=\"xsd:string\">00240301801050</TransactionID>")
.append("</SOAP-ENV:Header>")
.append("<SOAP-ENV:Body>")
.append("<UnSubscribeServiceReq xmlns=\"http://www.monternet.com/dsmp/schemas/\">")
.append("<Version>1.5.0</Version> ")
.append("<MsgType>UnSubscribeServiceReq</MsgType>")
.append("<Send_Address>")
.append("<DeviceType>400</DeviceType>")
.append("<DeviceID>924403</DeviceID>")
.append("</Send_Address>")
.append("<Dest_Address>")
.append("<DeviceType>0</DeviceType>")
.append("<DeviceID>0028</DeviceID>")
.append("</Dest_Address>")
.append("<FeeUser_ID>")
.append("<UserIDType>1</UserIDType>")
.append("<MSISDN>"+tel+"</MSISDN>")
.append("<PseudoCode />")
.append("</FeeUser_ID>")
.append("<DestUser_ID>")
.append("<UserIDType>1</UserIDType>")
.append("<MSISDN>"+tel+"</MSISDN>")
.append("<PseudoCode />")
.append("</DestUser_ID>")
.append("<Service_ID>")
.append("<ServiceIDType>1</ServiceIDType>")
.append("<SPID>企业代码</SPID>")
.append("<SPServiceID>业务代码</SPServiceID>")
.append("<AccessNo />")
.append("<FeatureStr />")
.append("</Service_ID>")
.append("</UnSubscribeServiceReq>")
.append("</SOAP-ENV:Body>")
.append("</SOAP-ENV:Envelope>");
return b.toString();
}
/**
* 发送报文
* @param tel 电话号码
* @param msgId 消息编号
* @return
* @throws Exception
*/
public static boolean sendMessage(String tel,String msgId) throws Exception {
boolean bool = false;
System.out.println("调用servlet开始=================");
String sendStr = CMMISC.getRequest(tel,msgId);
BufferedReader reader = null;
try {
String strMessage = "";
StringBuffer buffer = new StringBuffer();
URL uploadServlet = new URL("http://..ip../dsmp/dsmp.wsdl"); // 接报文的地址
HttpURLConnection servletConnection = (HttpURLConnection) uploadServlet.openConnection(); // 设置连接参数
servletConnection.setRequestMethod("POST");
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
servletConnection.setAllowUserInteraction(true); // 开启流,写入XML数据
OutputStream output = servletConnection.getOutputStream();
System.out.println("发送的报文:");
System.out.println(sendStr);
output.write(sendStr.getBytes());
output.flush();
output.close();
// 获取返回的数据
InputStream inputStream = servletConnection.getInputStream();
reader = new BufferedReader(new
InputStreamReader(inputStream));
while ((strMessage = reader.readLine()) != null) {
buffer.append(strMessage);
}
System.out.println("接收返回值:" + buffer);
System.out.println("--------------");
//hRet等于0为成功
if(Integer.valueOf(getXmlResult(buffer.toString()).get("hRet"))==0){
bool = true;
}
System.out.println();
}catch (java.net.ConnectException e) {
throw new Exception();
} finally {
if (reader != null) {
reader.close();
}
}
return bool;
}
/**
* 解析返回的XML信息
* @param xml
* @return 0为成功、其它为失败
*/
public static Map<String,String> getXmlResult(String result) {
File f = null;
Map<String, String> map = new HashMap<String, String>();
try{
f = new File("C://temp//temp"+System.currentTimeMillis()+".xml");
if(f.exists()){
f.delete();
}
f.createNewFile();
RandomAccessFile ra = new RandomAccessFile(f,"rw");
ra.writeBytes(result);
ra.close();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(f);
Element foo = doc.getRootElement();
List allChildren = foo.getChildren(); //获取所有节点集合
for (int i = 0; i < allChildren.size(); i++) {
Element e = ((Element) allChildren.get(i));
String nName = e.getName();
//System.out.println(nName);
if(nName.equals("Header")){
List hList = e.getChildren(); //获取Header节点集合
for (int j = 0; j < hList.size(); j++) {
Element eH = ((Element) hList.get(j));
//System.out.println(eH.getName()+"---"+eH.getText());
map.put(eH.getName(), eH.getText());
}
}else{
List bList = e.getChildren(); //获取Body节点集合
for (int j = 0; j < bList.size(); j++) {
Element eB = ((Element) bList.get(j));
//System.out.println(eB.getName()+"---"+eB.getContent().size());
map.put(eB.getName(), eB.getContent().size()+"");
List bEList = eB.getChildren();
for (int k = 0; k < bEList.size(); k++) {
Element eBE = ((Element) bEList.get(k));
//System.out.println(eBE.getName()+"---"+eBE.getText());
map.put(eBE.getName(), eBE.getText());
}
}
}
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(f!=null){
f.delete();
}
}
return map;
}
//取消
public static void getCanCel() throws Exception {
String xml = CMMISC.getCanCel("13985046628");
BufferedReader reader = null;
try {
String strMessage = "";
StringBuffer buffer = new StringBuffer(); // 接报文的地址
URL uploadServlet = new URL("http://..ip../dsmp/dsmp.wsdl");
HttpURLConnection servletConnection = (HttpURLConnection) uploadServlet.openConnection();
// 设置连接参数
servletConnection.setRequestMethod("POST");
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
servletConnection.setAllowUserInteraction(true); // 开启流,写入XML数据
OutputStream output = servletConnection.getOutputStream();
System.out.println("发送的报文:");
System.out.println(xml);
output.write(xml.getBytes());
output.flush();
output.close();
// 获取返回的数据
InputStream inputStream = servletConnection.getInputStream();
reader = new BufferedReader(new
InputStreamReader(inputStream));
while ((strMessage = reader.readLine()) != null) {
buffer.append(strMessage);
}
System.out.println("接收返回值:" + buffer);
Map<String,String> map = getXmlResult(buffer.toString());
System.out.println(map.get("hRet")); //0为成功
}catch (java.net.ConnectException e) {
throw new Exception();
} finally {
if (reader != null) {
reader.close();
}
}
}
}
这是反向订购、已经测试成功了。不过反向订购太“王八”了点,报文发送过去你的手机就会收到扣费信息了......立即生效的那种。
还有记得一点就是必须要在你申请的那个ip地址对应的机器上进行报文的发送,否则就会返回“9017”的错误代码:ip非法。
一个前台的service是被用户强烈关注的从而不会在内存低时被系统杀死.前台service必须在状态栏上提供一个通知,这个通知被放在"正在进行"区域中,这表示这个通知不能被解除,除非服务停止了或者从前台移除了.
例如,一个从service播放音乐的音乐播放器,应被设置为前台运行,因为用户会明确地注意它的运行.在状态栏中的通知可能会显示当前的歌曲并且允许用户启动一个activity来与音乐播放器交互.
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text),
System.currentTimeMillis());
Intent notificationIntent = new Intent(this, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, getText(R.string.notification_title),
getText(R.string.notification_message), pendingIntent);
startForeground(ONGOING_NOTIFICATION, notification);
要请求你的service运行于前台,调用startForeground().此方法有两个参数:一个整数唯一的标识一个通知,和这个用于状态栏的通知,例如:
要从前台移除service,调用stopForeground().这个方法有boolean型参数,表明是否也从状态栏删除对应的通知.这个方法不会停掉service.然而,如果你停止了正在前台运行的service,这个通知也会被删除.
注意:方法startForeground()和方法stopForeground()是从Android2.0 (API Level 5)引入的.为了在早期版本是于前台运行你的service,你必须使用以前的那个setForeground()方法—见startForeground()的API文档查看如何提供与旧版本的兼容性.