记录历史最大充电电压并上报

TempBranch
Matthew 9 months ago
parent 160b599c6e
commit 33030ca2b7

@ -272,12 +272,16 @@ public class AppMaster {
// }
try {
String battery = getBatteryVoltage() + "V/" + getChargingBatteryVoltage() + "V";
String battery = mService.getBatteryVoltage() + "V/" + mService.getChargingBatteryVoltage() + "V";
postParams.add(new Pair<String, String>("battery", battery));
} catch (Exception ex) {
ex.printStackTrace();
}
if (mService.isSeparateNetwork()) {
postParams.add(new Pair<String, String>("maxBCV", mService.getAndResetMaxBCV()));
}
for (int idx = 0; idx < 3; idx++) {
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
@ -481,29 +485,7 @@ public class AppMaster {
return ((cnts[0] == 0) && (cnts[1] == 0)) ? null : Integer.toString(cnts[0]) + " " + Integer.toString(cnts[1]);
}
private String getBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(115);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
private String getChargingBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
private String getImei(int number) {
return (number == 1) ? SysApi.getImei(mService) : SysApi.getImei2(mService);

@ -128,6 +128,9 @@ public class MpMasterService extends Service {
private long mPreviousMpHbTime = 0;
private int mMaxBCV = 0;
private long mMaxBCVTime = 0;
private String mIccid1 = null;
private String mIccid2 = null;
@ -199,6 +202,8 @@ public class MpMasterService extends Service {
mPreviousMpHbTime = System.currentTimeMillis();
buildChargingBatteryVoltage(System.currentTimeMillis());
logger.info("MpMaster started version=" + mMpMasterVersion);
mHander = new Handler();
@ -541,6 +546,8 @@ public class MpMasterService extends Service {
mService.mPreviousHeartbeatTime = 0;
mService.registerHeartbeatTimer();
mService.buildChargingBatteryVoltage(System.currentTimeMillis());
if (!keepAlive) {
mService.startMaster(false);
}
@ -557,6 +564,7 @@ public class MpMasterService extends Service {
mService.registerHeartbeatTimer();
mService.buildChargingBatteryVoltage(System.currentTimeMillis());
if (!mService.mSeparateNetwork && (!mService.mMntnMode)) {
mService.startMaster(true);
}
@ -620,7 +628,6 @@ public class MpMasterService extends Service {
SysApi.installOTA(context, context.getPackageName(), path);
}
});
}
private void registerHeartbeatTimer() {
@ -930,6 +937,57 @@ public class MpMasterService extends Service {
return signalLevel;
}
public static String getBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(115);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
private void buildChargingBatteryVoltage(long ts) {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
break;
}
}
if (val > 0) {
if (val > mMaxBCV) {
mMaxBCV = val;
mMaxBCVTime = ts;
}
}
}
public String getAndResetMaxBCV() {
String val = Integer.toString(mMaxBCV / 1000) + "." + Integer.toString((mMaxBCV % 1000) / 100)
+ "/" + Long.toString(mMaxBCVTime / 1000);
mMaxBCV = 0;
mMaxBCVTime = 0;
return val;
}
public static String getChargingBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
public void downloadAndInstall(final String url) {
final Context context = getApplicationContext();

Loading…
Cancel
Save