|
|
@ -484,7 +484,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED() |
|
|
|
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; |
|
|
|
|
|
|
|
/* |
|
|
|
* Battery functions |
|
|
|
* Battery & temperature functions |
|
|
|
*/ |
|
|
|
|
|
|
|
// Use: float vBatt = modem.getBattVoltage() / 1000.0; |
|
|
@ -493,10 +493,11 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED() |
|
|
|
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
streamSkipUntil(','); // Skip |
|
|
|
streamSkipUntil(','); // Skip |
|
|
|
|
|
|
|
streamSkipUntil(','); // Skip battery charge status |
|
|
|
streamSkipUntil(','); // Skip battery charge level |
|
|
|
// return voltage in mV |
|
|
|
uint16_t res = stream.readStringUntil(',').toInt(); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return res; |
|
|
|
} |
|
|
@ -506,12 +507,53 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED() |
|
|
|
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
stream.readStringUntil(','); |
|
|
|
streamSkipUntil(','); // Skip battery charge status |
|
|
|
// Read battery charge level |
|
|
|
int res = stream.readStringUntil(',').toInt(); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t getBattChargeState() |
|
|
|
sendAT(GF("+CBC?")); |
|
|
|
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
// Read battery charge status |
|
|
|
int res = stream.readStringUntil(',').toInt(); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) { |
|
|
|
sendAT(GF("+CBC?")); |
|
|
|
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
chargeState = stream.readStringUntil(',').toInt(); |
|
|
|
percent = stream.readStringUntil(',').toInt(); |
|
|
|
milliVolts = stream.readStringUntil('\n').toInt(); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
float getTemperature(uint16_t &milliVolts = 0) { |
|
|
|
sendAT(GF("+QTEMP")); |
|
|
|
if (waitResponse(GF(GSM_NL "+QTEMP:")) != 1) { |
|
|
|
return (float)-9999; |
|
|
|
} |
|
|
|
streamSkipUntil(','); // Skip mode |
|
|
|
// Read charge of thermistor |
|
|
|
milliVolts = stream.readStringUntil(',').toInt(); |
|
|
|
float temp = stream.readStringUntil('\n').toFloat(); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return temp; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Client related functions |
|
|
|
*/ |
|
|
|