mirror of
https://github.com/vshymanskyy/TinyGSM.git
synced 2026-05-15 04:06:10 +00:00
Made battery return types signed
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -24,17 +24,16 @@ class TinyGsmBattery {
|
||||
/*
|
||||
* Battery functions
|
||||
*/
|
||||
uint16_t getBattVoltage() {
|
||||
int16_t getBattVoltage() {
|
||||
return thisModem().getBattVoltageImpl();
|
||||
}
|
||||
int8_t getBattPercent() {
|
||||
return thisModem().getBattPercentImpl();
|
||||
}
|
||||
uint8_t getBattChargeState() {
|
||||
int8_t getBattChargeState() {
|
||||
return thisModem().getBattChargeStateImpl();
|
||||
}
|
||||
bool getBattStats(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) {
|
||||
return thisModem().getBattStatsImpl(chargeState, percent, milliVolts);
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ class TinyGsmBattery {
|
||||
*/
|
||||
protected:
|
||||
// Use: float vBatt = modem.getBattVoltage() / 1000.0;
|
||||
uint16_t getBattVoltageImpl() {
|
||||
int16_t getBattVoltageImpl() {
|
||||
thisModem().sendAT(GF("+CBC"));
|
||||
if (thisModem().waitResponse(GF("+CBC:")) != 1) { return 0; }
|
||||
thisModem().streamSkipUntil(','); // Skip battery charge status
|
||||
@@ -84,7 +83,7 @@ class TinyGsmBattery {
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t getBattChargeStateImpl() {
|
||||
int8_t getBattChargeStateImpl() {
|
||||
thisModem().sendAT(GF("+CBC"));
|
||||
if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; }
|
||||
// Read battery charge status
|
||||
@@ -94,8 +93,8 @@ class TinyGsmBattery {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
thisModem().sendAT(GF("+CBC"));
|
||||
if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; }
|
||||
chargeState = thisModem().streamGetIntBefore(',');
|
||||
|
||||
@@ -435,7 +435,7 @@ class TinyGsmA6 : public TinyGsmModem<TinyGsmA6>,
|
||||
* Battery functions
|
||||
*/
|
||||
protected:
|
||||
uint16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
// Needs a '?' after CBC, unlike most
|
||||
int8_t getBattPercentImpl() {
|
||||
@@ -450,8 +450,8 @@ class TinyGsmA6 : public TinyGsmModem<TinyGsmA6>,
|
||||
}
|
||||
|
||||
// Needs a '?' after CBC, unlike most
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
sendAT(GF("+CBC?"));
|
||||
if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return false; }
|
||||
chargeState = streamGetIntBefore(',');
|
||||
|
||||
@@ -563,7 +563,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
|
||||
*/
|
||||
protected:
|
||||
// SRGD Note: Returns voltage in VOLTS instead of millivolts
|
||||
uint16_t getBattVoltageImpl() {
|
||||
int16_t getBattVoltageImpl() {
|
||||
sendAT(GF("+CBC"));
|
||||
if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return 0; }
|
||||
streamSkipUntil(','); // Skip battery charge status
|
||||
@@ -578,8 +578,8 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
|
||||
}
|
||||
|
||||
// SRGD Note: Returns voltage in VOLTS instead of millivolts
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
sendAT(GF("+CBC"));
|
||||
if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return false; }
|
||||
chargeState = streamGetIntBefore(',');
|
||||
|
||||
@@ -590,7 +590,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
||||
*/
|
||||
protected:
|
||||
// returns volts, multiply by 1000 to get mV
|
||||
uint16_t getBattVoltageImpl() {
|
||||
int16_t getBattVoltageImpl() {
|
||||
sendAT(GF("+CBC"));
|
||||
if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return 0; }
|
||||
|
||||
@@ -605,10 +605,10 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
||||
|
||||
int8_t getBattPercentImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
chargeState = 0;
|
||||
percent = 0;
|
||||
milliVolts = getBattVoltage();
|
||||
|
||||
@@ -628,7 +628,7 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
|
||||
* Battery functions
|
||||
*/
|
||||
protected:
|
||||
uint16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
int8_t getBattPercentImpl() {
|
||||
sendAT(GF("+CIND?"));
|
||||
@@ -641,10 +641,10 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
|
||||
return percent;
|
||||
}
|
||||
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
chargeState = 0;
|
||||
percent = getBattPercent();
|
||||
milliVolts = 0;
|
||||
|
||||
@@ -621,7 +621,7 @@ class TinyGsmSaraR5 : public TinyGsmModem<TinyGsmSaraR5>,
|
||||
* Battery functions
|
||||
*/
|
||||
protected:
|
||||
uint16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
int8_t getBattPercentImpl() {
|
||||
sendAT(GF("+CIND?"));
|
||||
@@ -634,10 +634,10 @@ class TinyGsmSaraR5 : public TinyGsmModem<TinyGsmSaraR5>,
|
||||
return percent;
|
||||
}
|
||||
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
chargeState = 0;
|
||||
percent = getBattPercent();
|
||||
milliVolts = 0;
|
||||
|
||||
@@ -609,7 +609,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
|
||||
* Battery functions
|
||||
*/
|
||||
protected:
|
||||
uint16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
int8_t getBattPercentImpl() {
|
||||
sendAT(GF("+CIND?"));
|
||||
@@ -622,10 +622,10 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
|
||||
return percent;
|
||||
}
|
||||
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
chargeState = 0;
|
||||
percent = getBattPercent();
|
||||
milliVolts = 0;
|
||||
|
||||
@@ -1088,7 +1088,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
||||
*/
|
||||
protected:
|
||||
// Use: float vBatt = modem.getBattVoltage() / 1000.0;
|
||||
uint16_t getBattVoltageImpl() {
|
||||
int16_t getBattVoltageImpl() {
|
||||
int16_t intRes = 0;
|
||||
XBEE_COMMAND_START_DECORATOR(5, false)
|
||||
if (beeType == XBEE_UNKNOWN) getSeries();
|
||||
@@ -1100,11 +1100,11 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
||||
return intRes;
|
||||
}
|
||||
|
||||
int8_t getBattPercentImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattPercentImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) {
|
||||
bool getBattStatsImpl(int8_t& chargeState, int8_t& percent,
|
||||
int16_t& milliVolts) {
|
||||
chargeState = 0;
|
||||
percent = 0;
|
||||
milliVolts = getBattVoltage();
|
||||
|
||||
Reference in New Issue
Block a user