return genFZDCMD(cmd, locationData);
}
+ /**
+ * B 终端发送:[XT*YYYYYYYYYYYYYYY*LEN*WT2,位置数据(见附录一)]
+ * 实例: [XT*334588000000156*009F*WT2,260916,020049,V,22.683546,
+ * N,113.9907380,E,0.00,0.0,0.0,0,100,77,0,0,00000000,
+ * 5,0,460,0,9346,4711,167,9346,4712,126,9360,4151,125,9346,4713,122,9360,408 1,119]
+ * 平台回复: [XT*334588000000156*009F*WT2,<地址>,<天气>,<实时温度>,<风>,<时间>]
+ * [XT*334588000000156*009F*WT2,深圳市,多云,-27 度,西风,1 级,2016-11-14,10:00:00] 以上数据部分使用
+ * Unicode 编码,上面示例传到终端将是: [XT*334588000000156*0094*WT2,
+ * 6DF157335E02002C591A4E91002C002D003200375EA6002C897F98CE002C0
+ * 0317EA7002C0032003000310036002D00310031002D00310034002C00310030003A00300030003A00300030]
+ *
+ * @return
+ */
+ public static StringMessage WT2(Runtime runtime) {
+ //指令
+ String cmd = cmdMap.get(CMD_TYPE.WT2);
+ //位置数据
+ String locationData = getLocationData(runtime);
+ return genFZDCMD(cmd, locationData);
+ }
+
/*登录*/
public static StringMessage LK() {
/*IC*YYYYYYYYYYYYYYY*LEN*LK*/
ICLogger.i("服务器收到登录包LK");
mConnection.DeliverCMDMessageToSystem("login", cmd);//通知下面线程状态变化
//测试一下获取天气消息
- //TODO:
- mConnection.send(WT(mRuntime));
+ //mConnection.send(WT2(mRuntime));
break;
case KA:
ICLogger.i("服务器收到心跳包KA");
break;
case WT:
ICLogger.d("收到请求的天气消息.. WT");
- ICLogger.d("WT--> DATA--> " + data);
+ //ICLogger.d("WT--> DATA--> " + data);
//处理消息
handleWT(data);
- mConnection.DeliverCMDMessageToSystem("WT", cmd);//通知下面线程状态变化
+ mConnection.DeliverCMDMessageToSystem("WT", cmd);
break;
+ case WT2:
+ ICLogger.d("收到请求的天气信息... WT2");
+ handleWT2(data);
+ mConnection.DeliverCMDMessageToSystem("WT2", cmd);
+ break;
+
}
return ret;
}
+ /**
+ * 处理天气结果,WT2,与WT格式不一样
+ * [XT*334588000000156*009F*WT2,深圳市,多云,-27 度,西风,1 级,2016-11-14,10:00:00]
+ * <p>
+ * 深圳市,多云,23度,南风,≤3级,21-04-07,11:27:59
+ * <p>
+ * 以上是请求回来的数据,如果UI需要详细信息,可以两个接口结合使用
+ *
+ * @param data
+ */
+ private void handleWT2(String data) {
+ //转码
+ String result = Util.decodeUnicode2Utf8(data);
+ ICLogger.d("data ==> " + result);
+ String[] split = result.split(CMDSPLIT);
+ if (split.length == 7) {
+ String city = split[0];
+ String wtDesc = split[1];
+ String temperature = split[2];
+ String windDirection = split[3];
+ String windLev = split[4];
+ String date = split[5];
+ String time = split[6];
+ ICLogger.d("city == > " + city);
+ ICLogger.d("wtDesc == > " + wtDesc);
+ ICLogger.d("temperature == > " + temperature);
+ ICLogger.d("windDirection == > " + windDirection);
+ ICLogger.d("windLev == > " + windLev);
+ ICLogger.d("date == > " + date);
+ ICLogger.d("time == > " + time);
+ } else {
+ ICLogger.d("data -WT2- > split size " + split.length);
+ ICLogger.d("parse data error..." + data);
+ }
+ }
+
/**
* 处理天气结果,后面得通知到远程
* //TODO:
ICLogger.d("highTemp == > " + highTemp);
ICLogger.d("cityName == > " + cityName);
} else {
- ICLogger.d("data -- > split size " + split.length);
+ ICLogger.d("data -WT- > split size " + split.length);
ICLogger.d("parse data error..." + data);
}
}