diff --git a/src/Core.cpp b/src/Core.cpp index f67898f..a5fed38 100644 --- a/src/Core.cpp +++ b/src/Core.cpp @@ -61,7 +61,7 @@ namespace core { } uint8_t notifyFailures(PositionEntryMetadata &metadata) { - SIM808RegistrationStatus networkStatus; + SIM808_NETWORK_REGISTRATION_STATE networkStatus; char buffer[SMS_BUFFER_SIZE]; const __FlashStringHelper * backupFailureString = F(" Backup battery failure ?"); bool notified = false; @@ -74,7 +74,7 @@ namespace core { network::powerOn(); networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); - if (network::isAvailable(networkStatus.stat)) { + if (network::isAvailable(networkStatus)) { strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); if (bitRead(triggered, ALERT_BATTERY_LEVEL_1) || bitRead(triggered, ALERT_BATTERY_LEVEL_2)) { details::appendToSmsBuffer(buffer, PSTR("\n- Battery at %d%%."), metadata.batteryLevel); diff --git a/src/Gps.cpp b/src/Gps.cpp index 3529cf1..013fe33 100644 --- a/src/Gps.cpp +++ b/src/Gps.cpp @@ -35,7 +35,7 @@ namespace gps { SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF; do { - currentStatus = hardware::sim808::device.getGpsStatus(lastPosition); + currentStatus = hardware::sim808::device.getGpsStatus(lastPosition, GPS_POSITION_SIZE); if (currentStatus > SIM808_GPS_STATUS::FIX) break; //if we have an accurate fix, break right now NOTICE_FORMAT("acquireCurrentPosition", "%d", currentStatus); @@ -90,7 +90,7 @@ namespace gps { } uint8_t getVelocity() { - uint8_t velocity; + int16_t velocity; if (!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::SPEED, &velocity)) velocity = 0; VERBOSE_FORMAT("getVelocity", "%d", velocity); diff --git a/src/Gps.h b/src/Gps.h index aac10d2..7fbd585 100644 --- a/src/Gps.h +++ b/src/Gps.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include "Hardware.h" #include "Time2.h" diff --git a/src/Hardware.cpp b/src/Hardware.cpp index 246cff2..99d360b 100644 --- a/src/Hardware.cpp +++ b/src/Hardware.cpp @@ -59,7 +59,7 @@ namespace hardware { //SIM808 turns phone on by default but we don't need it for gps only device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM); } - device.enableGps(); + device.powerOnOffGps(true); } void gpsPowerOff() { @@ -74,7 +74,7 @@ namespace hardware { } VERBOSE("gpsPowerOff"); - device.disableGps(); + device.powerOnOffGps(false); powerOffIfUnused(); } diff --git a/src/Network.cpp b/src/Network.cpp index 0cab1c0..463d380 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -22,9 +22,9 @@ namespace network { } __attribute__((__optimize__("O2"))) - SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true) { + SIM808_NETWORK_REGISTRATION_STATE waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true) { - SIM808RegistrationStatus currentStatus; + SIM808_NETWORK_REGISTRATION_STATE currentStatus; SIM808SignalQualityReport report; uint8_t noReliableNetwork = 0; @@ -34,9 +34,9 @@ namespace network { report = hardware::sim808::device.getSignalQuality(); do { - if (isAvailable(currentStatus.stat)) break; + if (isAvailable(currentStatus)) break; - NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.rssi, report.attenuation); + NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus, report.rssi, report.attenuation); if (report.rssi < NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++; else noReliableNetwork = 0; @@ -52,7 +52,7 @@ namespace network { report = hardware::sim808::device.getSignalQuality(); } while (timeout > 1); - NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.rssi, report.attenuation); + NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus, report.rssi, report.attenuation); return currentStatus; } diff --git a/src/Network.h b/src/Network.h index 555e20e..061c3c4 100644 --- a/src/Network.h +++ b/src/Network.h @@ -8,7 +8,7 @@ namespace network { void powerOn(); void powerOff(); - SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true); + SIM808_NETWORK_REGISTRATION_STATE waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true); bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); #if BACKUP_ENABLE_NETWORK bool enableGprs(); diff --git a/src/NetworkPositionsBackup.cpp b/src/NetworkPositionsBackup.cpp index 4b90370..183c9e2 100644 --- a/src/NetworkPositionsBackup.cpp +++ b/src/NetworkPositionsBackup.cpp @@ -57,7 +57,7 @@ namespace positions { void NetworkPositionsBackup::appendPositions() { uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; PositionEntry currentEntry; - SIM808RegistrationStatus networkStatus; + SIM808_NETWORK_REGISTRATION_STATE networkStatus; //avoid edge case where if 0, whole set of positions will be sent again if (!positions::count(config::main::value.network.lastSavedEntry)) return; @@ -65,7 +65,7 @@ namespace positions { network::powerOn(); networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); - if (!network::isAvailable(networkStatus.stat) || !network::enableGprs()) { + if (!network::isAvailable(networkStatus) || !network::enableGprs()) { networkUnavailableInARow = min(networkUnavailableInARow + 1, POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD + 1); //avoid increment overflow NOTICE_MSG("appendPositions", "network or gprs unavailable"); diff --git a/src/Positions.h b/src/Positions.h index bc552f5..268a9b5 100644 --- a/src/Positions.h +++ b/src/Positions.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #define POSITION_SIZE 115 diff --git a/src/config/System.h b/src/config/System.h index 331672c..c82e618 100644 --- a/src/config/System.h +++ b/src/config/System.h @@ -20,7 +20,7 @@ \def VERSION Version string, only used for indicative purpose */ -#define VERSION "1.30" +#define VERSION "1.40" /**