|| (lbs_ok && (gps_ok || startSOSLocation == true) && wifi_ok)
|| (lbs_ok && gps_nosignal && wifi_ok)
) {
+
+ String locationtype = "LBS";
+ if (gps_ok) {
+ locationtype = "GPS";
+ } else if (wifi_ok) {
+ locationtype = "WiFi";
+ }
+
+ runtime.getLocationInstance().setLocationType(locationtype);
+ runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
+
if (startSOSLocation == true) {
StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
DeliverMessage(AP10_CMD);
stopCheckLocationResult();
- String locationtype = "LBS";
- if (gps_ok) {
- locationtype = "GPS";
- } else if (wifi_ok) {
- locationtype = "WiFi";
- }
- runtime.getLocationInstance().setLocationType(locationtype);
- runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
String msg = "Location Fixed Type " + runtime.getLocationInstance().getLocationType() + " at " + runtime.getLocationInstance().getLocationTime() + " timeout " + timeout;
ICLogger.i(msg);
if ((lbs_ok && timeout == true) || (lbs_ok && wifi_ok)) {
+ String locationtype = "LBS";
+ if (wifi_ok) {
+ locationtype = "WiFi";
+ }
+ runtime.getLocationInstance().setLocationType(locationtype);
+ runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
+
if (startSOSLocation == true) {
StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
DeliverMessage(AP10_CMD);
stopCheckLocationResult();
- String locationtype = "LBS";
- if (wifi_ok) {
- locationtype = "WiFi";
- }
- runtime.getLocationInstance().setLocationType(locationtype);
- runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
String msg = "Location Fixed Type " + runtime.getLocationInstance().getLocationType() + " at " + runtime.getLocationInstance().getLocationTime() + " timeout " + timeout;
ICLogger.i(msg);
private StringBuilder handleScanResults() {\r
List aplist = this.wifiManager.getScanResults();\r
ICLogger.i("get Wifi Result " + aplist.size());\r
+ //========清除全局变量runtime中的wifi数据\r
+ runtime.getLocationInstance().clearWiFidata();\r
+\r
if (aplist.size() < 1) {\r
return null;\r
} else {\r
+\r
this.sortByLevel(aplist);\r
StringBuilder sb = new StringBuilder("");\r
StringBuilder sblog = new StringBuilder("");\r
sb.append(result.BSSID);\r
sb.append("|");\r
sb.append(result.level);\r
+\r
+ //添加扫描到的wifi地址到全局变量runtime中\r
+ runtime.getLocationInstance().append_wifiap(result.BSSID,result.level);\r
}\r
sblog.append("[").append(count).append(",SSID:").append(result.SSID).append(",BSSID:").append(result.BSSID).append(",Level:").append(result.level).append("];");\r
}\r
}\r
\r
public void clearLBSdata(){\r
- currentLBS.wifi_aps.clear();\r
currentLBS.gsm_stations.clear();\r
}\r
+ public void clearWiFidata(){\r
+ currentLBS.wifi_aps.clear();\r
+ }\r
\r
public void append_gsmstation(String station,int rssi){\r
currentLBS.gsm_stations.put(station,rssi);\r
import com.enqualcomm.support.utils.DnsUtil;
import com.enqualcomm.support.utils.ICLogger;
import com.enqualcomm.support.utils.LanguageUtils;
+import com.enqualcomm.support.utils.TimeUtil;
import com.ic.fzd.weather.IFZDWeatherCallback;
import java.io.File;
return sb.toString();
}
- public String getWifiData() {
+ public String getGatorWifiData() {
StringBuilder sb = new StringBuilder();
int i = 0;
- for (String mac : gpsp.getLBSdata().wifi_aps.keySet()) {
- sb.append("AP").append(i).append("|").append(mac).append("|").append(gpsp.getLBSdata().wifi_aps.get(mac)).append(",");
- i++;
- }
- if (i > 0) {
- int index = sb.lastIndexOf(",");
- sb.replace(index, index + 1, "");
+ if (gpsp.getLBSdata().wifi_aps.size()>0) {
+ sb.append(gpsp.getLBSdata().wifi_aps.size());
+ for (String mac : gpsp.getLBSdata().wifi_aps.keySet()) {
+ String APName = "AP" + i;
+ sb.append(",").append(APName.length()).append(",");
+ sb.append(APName).append(",");
+ sb.append(mac).append(",");
+ sb.append(gpsp.getLBSdata().wifi_aps.get(mac));
+ i++;
+ }
}
return sb.toString();
}
public String getGatorLBSMultiStationData(){
return mGatorLBSMultiStationData;
}
+
+ public String getGatorGPSLocationData(){
+ /**150728A2934.0133N10627.2544E000.0141830309.62
+ * 消息字段 字段值 类型 长度(字节) 说明
+ * 日期 YYMMDD N_STRING 6 年月日各占 2 个字节
+ * GPS 定位有效 CHAR 1 “A”或“V”。A 表示 GPS 数据有效,V表示 GPS 数据定位精度不高
+ * 纬度 N_STRING 9 前 2 字节单位为度,取值为 0~90;后 7字节单位为分。
+ * 纬度标志 “N”或“S” CHAR 1 N 表示北纬,S 表示南纬
+ * 经度 N_STRING 10 前 3 字节单位为度,取值为 0~180;后 7字节单位为分
+ * 经度标志 “E”或“W” CHAR 1 E 表示东经,W 表示西经
+ * 速度 N_STRING 5 单位为 km/h
+ * 时间 HHmmSS N_STRING 6 时分秒各占 2 个字节
+ * 方向 N_STRING 6
+ */
+ StringBuilder sb=new StringBuilder();
+ sb.append(TimeUtil.getSystemDateYYMMDD());
+ // 2232.9806N11404.9355E000.1: 北纬22度32.9806分,东经114度04.9355分,速度为000.1 km/h,如经纬度无效,可默认全为0,如0000.0000N00000.0000E
+// 纬度格式为: ddmm.mmmm ,长度不足长度前补0
+// 经度格式为:dddmm.mmmm,长度不足前补0
+
+ String latname = gpsp.getLocation().lat_name;
+ String lonname = gpsp.getLocation().lon_name;
+ if (isGPSFixed()) {
+ String gpsStr = String.format("%s%s%s%s%05f", gpsp.getLocation().latGPSStr,latname, gpsp.getLocation().lonGPSStr,lonname, gpsp.getLocation().speed);
+ sb.append("A").append(gpsStr);
+ } else {
+ String gpsStr = String.format("%04d.%04dN%05d.%04dE%03d.%01d", 0, 0, 0, 0, 0, 0);
+ sb.append("V").append(gpsStr);
+ }
+
+ sb.append(TimeUtil.getSystemTimeHHmmss());
+ sb.append(String.format("%06f",gpsp.getLocation().heading));
+
+ return sb.toString();
+
+ }
public boolean sleepDataReported = false;
import com.enqualcomm.support.provider.FZDDatabaseHelper;
import com.enqualcomm.support.provider.FZDMessageProvider;
import com.enqualcomm.support.service.base.AbstractConnectionService;
+import com.enqualcomm.support.utils.AESCipher;
import com.enqualcomm.support.utils.Connection;
import com.enqualcomm.support.utils.FileCache;
import com.enqualcomm.support.utils.ICLogger;
sb.append("index ").append(msg.getIndex())
.append("\nDate ").append(msg.getDate()).append(msg.getTime())
.append("\nflag ").append(msg.haveSent())
- .append("\ntopic ").append(msg.cmd())
- .append("\ncmd ").append(msg.isFromCache()).append("\n");
+ .append("\ntopic ").append(msg.cmd());
+ if(Config.protocol_no == Config.PROTOCOL_GATOR){
+ if(msg.isFromCache().length()>8) {
+ sb.append("\norigin ").append(AESCipher.aesDecryptStringFixedKey(msg.isFromCache().substring(8)));
+ }
+ }
+ sb.append("\ncmd ").append(msg.isFromCache()).append("\n");
+
}
ICLogger.i(sb.toString());
}
if (mccmnc != null && mccmnc.length() > 3) {
+ //==========清除Runtime中lbs数据,暂时没有使用此lbs数据
+ runtime.getLocationInstance().clearLBSdata();
+ runtime.setLBSMultiStationData("");
+ runtime.setFZDLBSMultiStationData("");
+ runtime.setGatorLBSMultiStationData("");
+
+ //如果没插卡,后面数据会获取不到,以上数据也就为空了
CellLocation celllocation = telephonyManager.getCellLocation();
if (celllocation == null) {
ICLogger.i("LBS cellLocation = null");
ICLogger.i("LBS GsmCellLocation "+ gsmSb.toString());
if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSb.toString());
+ //===添加gsm station到Runtime全局变量
+ runtime.getLocationInstance().append_gsmstation(gsmCell.getLac()+","+gsmCell.getCid(),150-Math.abs(getSignal(telephonyManager,runtime)));
+
List neighboringCell_list = telephonyManager.getNeighboringCellInfo();
//AP02 Multi GSM Station
StringBuilder gsmSbMulti = new StringBuilder(); //头
// Gator MCC(%03d)+MNC(%03d)+LACID(%04X)+CELLID(%07X)+RX LEVEL(%02X)
- gsmSbMultiGator_data.append(String.format("%1$03d",mcc))
- .append(String.format("%1$03d",mnc))
- .append(String.format("%1$04X",mNeighboringCellInfo.getLac()))
- .append(String.format("%1$07X",mNeighboringCellInfo.getCid()))
- .append(String.format("%1$02X",150-Math.abs(mNeighboringCellInfo.getRssi())));
+ gsmSbMultiGator_data.append(",");
+ gsmSbMultiGator_data.append(String.format("%1$03d",mcc));
+ gsmSbMultiGator_data.append(String.format("%1$03d",mnc));
+ gsmSbMultiGator_data.append(String.format("%1$04X",mNeighboringCellInfo.getLac()));
+ gsmSbMultiGator_data.append(String.format("%1$07X",mNeighboringCellInfo.getCid()));
+ gsmSbMultiGator_data.append(String.format("%1$02X",150-Math.abs(mNeighboringCellInfo.getRssi())));
+ //添加gsm station到Runtime全局变量
+ runtime.getLocationInstance().append_gsmstation(mNeighboringCellInfo.getLac()+","+mNeighboringCellInfo.getCid(),150-Math.abs(mNeighboringCellInfo.getRssi()));
maxstationCount ++;
if (maxstationCount == 5) {
gsmSbMultiFZD.append(150-Math.abs(getSignal(telephonyManager,runtime)));
gsmSbMultiFZD.append(gsmSbMultiFZD_data.toString());
+ gsmSbMultiGator.append(size);
+ gsmSbMultiGator.append(",");
gsmSbMultiGator.append(String.format("%1$03d",mcc))
.append(String.format("%1$03d",mnc))
.append(String.format("%1$04X",gsmCell.getLac()))
.append(String.format("%1$07X",gsmCell.getCid()))
.append(String.format("%1$02X",150-Math.abs(getSignal(telephonyManager,runtime))));
+ gsmSbMultiGator.append(",");
+ gsmSbMultiGator.append(gsmSbMultiGator_data.toString());
ICLogger.i("LBS GsmCellLocation MultiStation "+ gsmSbMulti.toString());
ICLogger.i("FZD LBS GsmCellLocation MultiStation "+ gsmSbMultiFZD.toString());
runtime.setLBSMultiStationData(gsmSbMulti.toString());
runtime.setFZDLBSMultiStationData(gsmSbMultiFZD.toString());
runtime.setGatorLBSMultiStationData(gsmSbMultiGator.toString());
+
return gsmSb.toString();
} else if (celllocation instanceof CdmaCellLocation) {
CdmaCellLocation cdmaCelllocation = (CdmaCellLocation)celllocation;
String timezone_name = "";
if(timezoneStr.startsWith("e")||timezoneStr.startsWith("E")){
- timezone_name = String.format("GMT+%1$s:%2$s",timezoneStr.substring(1,2),timezoneStr.substring(3,4));
+ timezone_name = String.format("GMT+%1$s:%2$s",timezoneStr.substring(1,3),timezoneStr.substring(3,5));
}else{
- timezone_name = String.format("GMT-%1$s:%2$s", timezoneStr.substring(1,2),timezoneStr.substring(3,4));
+ timezone_name = String.format("GMT-%1$s:%2$s", timezoneStr.substring(1,3),timezoneStr.substring(3,5));
}
ICLogger.i("====set timezone " + timezone_name);
TimeZone tz = TimeZone.getTimeZone(timezone_name);
int timezonehours=0;
int timezoneminutes=0;
try {
- timezonehours = Integer.parseInt(timezoneStr.substring(1, 2));
- timezoneminutes = Integer.parseInt(timezoneStr.substring(3, 4));
+ timezonehours = Integer.parseInt(timezoneStr.substring(1, 3));
+ timezoneminutes = Integer.parseInt(timezoneStr.substring(3, 5));
}catch (Exception e){
ICLogger.e(e.getMessage(),e);
}
public static void setTimeZone(Context context, String timeZonedate) {
String timezone_name = "";
if(timeZonedate.startsWith("e")||timeZonedate.startsWith("E")){
- timezone_name = String.format("GMT+%1$s:%2$s",timeZonedate.substring(1,2),timeZonedate.substring(3,4));
+ timezone_name = String.format("GMT+%1$s:%2$s",timeZonedate.substring(1,3),timeZonedate.substring(3,5));
}else{
- timezone_name = String.format("GMT-%1$s:%2$s", timeZonedate.substring(1,2),timeZonedate.substring(3,4));
+ timezone_name = String.format("GMT-%1$s:%2$s", timeZonedate.substring(1,3),timeZonedate.substring(3,5));
}
ICLogger.i("====set timezone " + timezone_name);
//TimeZone tz = TimeZone.getTimeZone(timezone_name);
ret = protocol_s123.AP01(runtime);
break;
case Config.PROTOCOL_GATOR:
- ret = null;
+ ret = protocol_gator.BP30(runtime);
break;
}
return ret;
ret = protocol_s123.AP02(runtime);
break;
case Config.PROTOCOL_GATOR:
- ret = null;
+ ret = protocol_gator.BP30(runtime);
break;
}
return ret;
* @param ds
* @return
*/
- public StringMessage BP30(Runtime ds){
+ public static StringMessage BP30(Runtime ds){
StringBuilder sb=new StringBuilder(cmdMap.get(CMD_TYPE.BP30)).append(CMDSPLIT);
int batstat=0;
//类型 "LBS" "GPS" "WiFi"
String LocationType = ds.getLocationInstance().getLocationType();
if(LocationType.equals("LBS")) {
- if(ds.getWifiData().isEmpty() )
- {
- if(ds.getGatorLBSMultiStationData().isEmpty()){
- //no available data
- ICLogger.e("没有有效定位信息");
- return null;
- }else{
- /* 基站定位:
+
+ if(ds.getGatorLBSMultiStationData().isEmpty()){
+ //no available data
+ ICLogger.e("没有有效定位信息");
+ return null;
+ }else{
+ /* 基站定位:
(008E0106357593060153353BP30,L,2,000000FF,5,1,4,46000024820000DE127,46000024820000DDF1A,46000024820000DEB0D,46000024820000F160B,150728,152900)
SOS报警上行基站位置消息,步数为255步,电量等级5,服务器需要下发经纬度信息给手表,定位数据采集时间为 2015 年 07 月 28 日,当地时间15:29:00.采集到的基站数为4个,第一个是主基站,其余3个为辅助基站
基站数据格式为: MCC(%03d)+MNC(%03d)+LACID(%04X)+CELLID(%07X)+RX LEVEL(%02X), (终端最多可以搜集7个基站数据,当前接入基站和信号优的前5个周边基站将上报)
*/
- /*
- 报警类型:0x0 无报警;0x02 SOS报警;0x08 电池低电量报警;0x20 设备脱离
- */
- sb.append("L").append(CMDSPLIT);
- sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
- //步数
- sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
-
- //电池电量5级
- sb.append(batstat).append(CMDSPLIT);
- /*服务器需要下发经纬度信息给手表*/
- sb.append(1).append(CMDSPLIT);
- sb.append(ds.getGatorLBSMultiStationData());
- sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
- sb.append(TimeUtil.getSystemTimeHHmmss());
- }
- }else{
- if(ds.getLBSMultiStationData().isEmpty()){
+ /*
+ 报警类型:0x0 无报警;0x02 SOS报警;0x08 电池低电量报警;0x20 设备脱离
+ */
+ sb.append("L").append(CMDSPLIT);
+ sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
+ //步数
+ sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
+
+ //电池电量5级
+ sb.append(batstat).append(CMDSPLIT);
+ /*服务器需要下发经纬度信息给手表*/
+ sb.append(1).append(CMDSPLIT);
+ sb.append(ds.getGatorLBSMultiStationData()).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemTimeHHmmss());
+ }
+
+ }else if(LocationType.equals("WiFi")) {
+
+ if(ds.getLBSMultiStationData().isEmpty()){
/*WIFI定位:
(00A60106357593060153353BP30,W,2,000000FF,5,1,150728,152900,3,08,wifi2462,1C:78:57:08:A5:CA,-88,05,HDB-H,D8:15:0D:5C:4D:74,-87,0D,WWW.CXGPS.COM,D8:15:0D:A8:E8:DE,-86)
SOS报警上行WIFI数据,步数为255步,电量等级5,服务器需要下发经纬度信息给手表,数据采集时间2015年7月28日,当地时间15:29:00,共3条数据(最多6条),分别由SSID长度(%02X),SSID,MAC地址,RSSI组成
*/
- sb.append("W").append(CMDSPLIT);
- sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
- //步数
- sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
- //电池电量5级
- sb.append(batstat).append(CMDSPLIT);
- /*服务器需要下发经纬度信息给手表*/
- sb.append(1).append(CMDSPLIT);
- sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
- sb.append(TimeUtil.getSystemTimeHHmmss()).append(CMDSPLIT);
+ sb.append("W").append(CMDSPLIT);
+ sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
+ //步数
+ sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
+ //电池电量5级
+ sb.append(batstat).append(CMDSPLIT);
+ /*服务器需要下发经纬度信息给手表*/
+ sb.append(1).append(CMDSPLIT);
+ sb.append(ds.getGatorWifiData()).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemTimeHHmmss()).append(CMDSPLIT);
- }else{
+ }else{
/*WIFI、LBS混合定位:
(00F80106357593060153353BP30,M,2,000000FF,5,1,150728,152900,4,46000024820000DE127,46000024820000DDF1A,46000024820000DEB0D,46000024820000F160B,3,08,wifi2462,1C:78:57:08:A5:CA,-88,05,HDB-H,D8:15:0D:5C:4D:74,-87,0D,WWW.CXGPS.COM,D8:15:0D:A8:E8:DE,-86)
SOS报警上行WIFI、LBS混合定位数据,步数为255步,电量等级5,数据采集时间2015年7月28日,当地时间15:29:00,基站数为4个,第一个是主基站,其余3个为辅助基站,WIFI共3条数据(最多6条),分别由SSID长度(%02X),SSID,MAC地址,RSSI组成
*/
- sb.append("M").append(CMDSPLIT);
- sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
- //步数
- sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
- //电池电量5级
- sb.append(batstat).append(CMDSPLIT);
- /*服务器需要下发经纬度信息给手表*/
- sb.append(1).append(CMDSPLIT);
- sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
- sb.append(TimeUtil.getSystemTimeHHmmss()).append(CMDSPLIT);
- sb.append(ds.getGatorLBSMultiStationData()).append(CMDSPLIT);
+ sb.append("M").append(CMDSPLIT);
+ sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
+ //步数
+ sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
+ //电池电量5级
+ sb.append(batstat).append(CMDSPLIT);
+ /*服务器需要下发经纬度信息给手表*/
+ sb.append(1).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT);
+ sb.append(TimeUtil.getSystemTimeHHmmss()).append(CMDSPLIT);
+ sb.append(ds.getGatorLBSMultiStationData()).append(CMDSPLIT);
+ sb.append(ds.getGatorWifiData());
- }
}
+
}else if(LocationType.equals("GPS")){
/*GPS定位:
(006E0106357593060153353BP30,G,2,000000FF,5,46000024820000DE127,150728A2934.0133N10627.2544E000.0141830309.62)
SOS报警上行GPS位置数据,步数为255步,电量等级5,当前基站接入的为:46000024820000DE127
*/
- sb.append(ds.getGatorLBSData()).append(CMDSPLIT);
+ sb.append("G").append(CMDSPLIT);
+ sb.append(ds.getGatorAlarmType()).append(CMDSPLIT);
+ //步数
+ sb.append(String.format("%08X", ds.getTotalStepCount())).append(CMDSPLIT);
+ //电池电量5级
+ sb.append(batstat).append(CMDSPLIT);
+ sb.append(ds.getGatorLBSData()).append(CMDSPLIT);
+ sb.append(ds.getGatorGPSLocationData());
+ }else{
+ //生成数据错误,返回null
+ return null;
}
StringMessage ret = genStringMessage(cmdMap.get(CMD_TYPE.BP30), AddHeader(ds,sb.toString()));
if (cmdlist.length==2){
sb.append("server msg index "+cmdlist[1]+"\n");
String cmdlist1[]=cmdlist[0].split("#");
- if(cmdlist1.length%3==0) {
- for (int i = 0; i < cmdlist1.length; i += 3) {
+ if(cmdlist1.length%3==1) {
+ for (int i = 1; i < cmdlist1.length; i += 3) {
String number= cmdlist1[i];
String name=cmdlist1[i+1];
String type=cmdlist1[i+2];
- sb.append(name+" "+number + "" + type+"\n");
+ sb.append(name+" "+number + " " + type+"\n");
}
}else{
# Location of the SDK. This is only used by Gradle.\r
# For customization when using a Version Control System, please read the\r
# header note.\r
-#Tue Jun 29 20:13:18 CST 2021\r
+#Tue Jun 29 22:28:38 CST 2021\r
>>>>>>>=bac6231c4f7e5884c23cfac5feb384cddb497355\r
-sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk\r
-=\=\=\=\=\=\=\r
+sdk.dir=D\:\\Android\\Sdk\r
<<<<<<<=HEAD\r
+=\=\=\=\=\=\=\r