import android.text.TextUtils;
import com.enqualcomm.support.Config;
+import com.enqualcomm.support.Constants;
import com.enqualcomm.support.CoreService;
import com.enqualcomm.support.LocationClient;
import com.enqualcomm.support.bean.Alarm;
import com.enqualcomm.support.utils.TemperatureUtil;
import com.enqualcomm.support.utils.TimeUtil;
import com.enqualcomm.support.utils.Util;
-import com.ic.fzd.weather.FZDWeatherInfo;
import com.ic.iclooger.ICLogger;
+import com.ic.s123.GenericWeatherInfo;
import java.io.File;
import java.io.FileOutputStream;
import static com.enqualcomm.support.Constants.ACTION_ALARM_ALARM_CHANGE;
import static com.enqualcomm.support.Constants.FROM_SERVER;
import static com.enqualcomm.support.LocationClient.LOCATION_MODE;
-import static com.ic.protocols.protocol_beehome.CMD_TYPE.AP05;
-import static com.ic.protocols.protocol_beehome.CMD_TYPE.AP32;
import static java.lang.Math.abs;
public class protocol_beehome {
public void doAP05() {
ICLogger.d("doAP05...");
String ap05Msg = AP05(true);
- StringMessage stringMessage = genStringMessage(cmdStrMap.get(AP05), ap05Msg);
+ StringMessage stringMessage = genStringMessage(cmdStrMap.get(CMD_TYPE.AP05), ap05Msg);
mConnection.send(stringMessage);
}
cmdStrMap.put(CMD_TYPE.AP31, "AP31");
cmdStrMap.put(CMD_TYPE.BP31, "BP31");
cmdStrMap.put(CMD_TYPE.BP32, "BP32");
- cmdStrMap.put(AP32, "AP32");
+ cmdStrMap.put(CMD_TYPE.AP32, "AP32");
cmdStrMap.put(CMD_TYPE.AP33, "AP33");
cmdStrMap.put(CMD_TYPE.BP33, "BP33");
cmdStrMap.put(CMD_TYPE.AP34, "AP34");
// AP05命令L02服务器不适用
public static String AP05(boolean recFlat) {
- return new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP05))
+ return new StringBuffer(CMDHEADER).append(cmdStrMap.get(CMD_TYPE.AP05))
.append(CMDSPLIT).append(recFlat ? 1 : 0)
.append(CMDEND).toString();
}
* 1:当前设备收到的是第几个包
* 1:表示设备接受数据成功,0表示设备接受数据失败
*/
- String Name;
+ String name;
String appendIndex;
int packetCount;
int currentId;
if (msg.length >= 6) {
try {
- Name = msg[1];
+ name = msg[1];
+ if (TextUtils.isEmpty(name)) {
+ name = "group";
+ }
appendIndex = msg[2];
packetCount = Integer.parseInt(msg[3]);
currentId = Integer.parseInt(msg[4]);
packetData = Util.subArray(bytes, msg[0].length() + msg[1].length() + msg[2].length() + msg[3].length() + msg[4].length() + msg[5].length() + 6, bytes.length - 1);
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append("recv BP28 name = ").append(Name)
+ stringBuffer.append("recv BP28 name = ").append(name)
.append(",appendIndex = ").append(appendIndex)
.append(",packetCount = ").append(packetCount)
.append(",currentId = ").append(currentId)
.append(",packetDatalen = ").append(packetData.length);
log(stringBuffer.toString());
- connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
- voicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
+ connection.send(AP28(name, appendIndex, packetCount, currentId, 1));
+ voicePacket.getInstance().appendVoice(name, appendIndex, packetCount, currentId, packetLen, packetData);
log("================" + voicePacket.getInstance().toString());
if (voicePacket.getInstance().isFinished()) {
String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
*/
private void handleBPTQ(String cmd) {
//对指令进行切割
- String[] split = cmd.split(CMDSPLIT);
- if (split.length == 23) {
- //先拿到城市数据
- String cityName = split[split.length - 1];
- for (int j = 1; j < split.length; j += 7) {
- //日期
- String date = split[j];
- //时间
- String time = split[j + 1];
- ICLogger.d("天气日期:" + date + " 时间:" + time);
- String description = split[j + 2];
- String weatherCode = split[j + 3];
- String currentTemp = split[j + 4];
- String minTemp = split[j + 5];
- String maxTemp = split[j + 6];
- FZDWeatherInfo fzdWeatherInfo = new FZDWeatherInfo(
- Util.decodeUnicode2Utf8(description), weatherCode, currentTemp, minTemp,
- maxTemp, Util.decodeUnicode2Utf8(cityName),
- null, null, date + " " + time
- );
- ICLogger.d("fzdWeatherInfo ==> " + fzdWeatherInfo);
+ String[] cmdList = cmd.split(CMDSPLIT);
+ if (cmdList.length == 23) {
+
+ StringBuilder sb = new StringBuilder();
+ StringBuilder msg = new StringBuilder();
+ String cityName = Util.decodeUnicode2Utf8(cmdList[22]);
+ List<GenericWeatherInfo> weatherInfo = new ArrayList<>();
+ for (int i = 0; i < 3; i++) {
+ String DayTime = cmdList[1 + i * 7] + " " + cmdList[2 + i * 7];
+ String date = "20" + cmdList[1 + i * 7].trim();
+ String weather_name = Util.decodeUnicode2Utf8(cmdList[3 + i * 7].trim());
+ String weather_id = cmdList[4 + i * 7];
+ String temp_current = cmdList[5 + i * 7];
+ String temp_high = cmdList[6 + i * 7];
+ String temp_low = cmdList[7 + i * 7];
+
+ sb.append(" " + DayTime);
+ sb.append(",天气:" + weather_name);
+ sb.append(",ID " + weather_id);
+ sb.append(",当前温度 " + temp_current);
+ sb.append(",最高温度 " + temp_high);
+ sb.append(",最低温度 " + temp_low);
+ sb.append("\n");
+
+ msg.append(date);
+ msg.append("," + weather_name);
+ msg.append("," + weather_id);
+ msg.append("," + temp_current);
+ msg.append("," + temp_high);
+ msg.append("," + temp_low);
+ msg.append(";");
+
+ //返回数据给UI
+ GenericWeatherInfo itemFirst = new GenericWeatherInfo(DayTime,
+ weather_name, weather_id, temp_current, temp_low, temp_high, cityName);
+ //封装数据
+ weatherInfo.add(itemFirst);
+ }
+ ICLogger.i(cityName + " \n" + sb.toString());
+
+ msg.insert(0, cityName + ";");
+ String weatherStr = msg.toString();
+ if (weatherStr.endsWith(";")) {
+ weatherStr = weatherStr.substring(0, weatherStr.lastIndexOf(";"));
}
+ Intent intent = new Intent(Constants.ACTION_WEATHER_RECEIVED);
+ intent.putExtra(Constants.KEY_Weather, weatherStr);
+ ICLogger.i("send Broadcast " + Constants.ACTION_WEATHER_RECEIVED + "\n" + weatherStr + "\n");
+ CoreService.getInstance().sendBroadcast(intent);
+ mRuntime.updateS123Weather(weatherInfo);
} else {
- ICLogger.d("format BPTQ 错误...");
+ ICLogger.i(" BPTQ Format error!");
}
}
* @return
*/
private StringMessage AP32(String cmdIndex) {
- return genStringMessage(cmdStrMap.get(AP32),
- new StringBuilder(CMDHEADER).append(cmdMap.get(AP32))
+ return genStringMessage(cmdStrMap.get(CMD_TYPE.AP32),
+ new StringBuilder(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP32))
.append(CMDSPLIT).append(cmdIndex).append(CMDEND).toString());
}