(cherry picked from commit 275bc46688
)
tags/v1.4.0^2
@@ -61,7 +61,7 @@ namespace core { | |||||
} | } | ||||
uint8_t notifyFailures(PositionEntryMetadata &metadata) { | uint8_t notifyFailures(PositionEntryMetadata &metadata) { | ||||
SIM808RegistrationStatus networkStatus; | |||||
SIM808_NETWORK_REGISTRATION_STATE networkStatus; | |||||
char buffer[SMS_BUFFER_SIZE]; | char buffer[SMS_BUFFER_SIZE]; | ||||
const __FlashStringHelper * backupFailureString = F(" Backup battery failure ?"); | const __FlashStringHelper * backupFailureString = F(" Backup battery failure ?"); | ||||
bool notified = false; | bool notified = false; | ||||
@@ -74,7 +74,7 @@ namespace core { | |||||
network::powerOn(); | network::powerOn(); | ||||
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); | 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); | strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); | ||||
if (bitRead(triggered, ALERT_BATTERY_LEVEL_1) || bitRead(triggered, ALERT_BATTERY_LEVEL_2)) { | if (bitRead(triggered, ALERT_BATTERY_LEVEL_1) || bitRead(triggered, ALERT_BATTERY_LEVEL_2)) { | ||||
details::appendToSmsBuffer(buffer, PSTR("\n- Battery at %d%%."), metadata.batteryLevel); | details::appendToSmsBuffer(buffer, PSTR("\n- Battery at %d%%."), metadata.batteryLevel); | ||||
@@ -35,7 +35,7 @@ namespace gps { | |||||
SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF; | SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF; | ||||
do { | 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 | if (currentStatus > SIM808_GPS_STATUS::FIX) break; //if we have an accurate fix, break right now | ||||
NOTICE_FORMAT("acquireCurrentPosition", "%d", currentStatus); | NOTICE_FORMAT("acquireCurrentPosition", "%d", currentStatus); | ||||
@@ -90,7 +90,7 @@ namespace gps { | |||||
} | } | ||||
uint8_t getVelocity() { | uint8_t getVelocity() { | ||||
uint8_t velocity; | |||||
int16_t velocity; | |||||
if (!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::SPEED, &velocity)) velocity = 0; | if (!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::SPEED, &velocity)) velocity = 0; | ||||
VERBOSE_FORMAT("getVelocity", "%d", velocity); | VERBOSE_FORMAT("getVelocity", "%d", velocity); | ||||
@@ -1,7 +1,7 @@ | |||||
#pragma once | #pragma once | ||||
#include <Arduino.h> | #include <Arduino.h> | ||||
#include <SIM808_Types.h> | |||||
#include <SIM808.Types.h> | |||||
#include "Hardware.h" | #include "Hardware.h" | ||||
#include "Time2.h" | #include "Time2.h" | ||||
@@ -59,7 +59,7 @@ namespace hardware { | |||||
//SIM808 turns phone on by default but we don't need it for gps only | //SIM808 turns phone on by default but we don't need it for gps only | ||||
device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM); | device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM); | ||||
} | } | ||||
device.enableGps(); | |||||
device.powerOnOffGps(true); | |||||
} | } | ||||
void gpsPowerOff() { | void gpsPowerOff() { | ||||
@@ -74,7 +74,7 @@ namespace hardware { | |||||
} | } | ||||
VERBOSE("gpsPowerOff"); | VERBOSE("gpsPowerOff"); | ||||
device.disableGps(); | |||||
device.powerOnOffGps(false); | |||||
powerOffIfUnused(); | powerOffIfUnused(); | ||||
} | } | ||||
@@ -22,9 +22,9 @@ namespace network { | |||||
} | } | ||||
__attribute__((__optimize__("O2"))) | __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; | SIM808SignalQualityReport report; | ||||
uint8_t noReliableNetwork = 0; | uint8_t noReliableNetwork = 0; | ||||
@@ -34,9 +34,9 @@ namespace network { | |||||
report = hardware::sim808::device.getSignalQuality(); | report = hardware::sim808::device.getSignalQuality(); | ||||
do { | 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++; | if (report.rssi < NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++; | ||||
else noReliableNetwork = 0; | else noReliableNetwork = 0; | ||||
@@ -52,7 +52,7 @@ namespace network { | |||||
report = hardware::sim808::device.getSignalQuality(); | report = hardware::sim808::device.getSignalQuality(); | ||||
} while (timeout > 1); | } 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; | return currentStatus; | ||||
} | } | ||||
@@ -8,7 +8,7 @@ namespace network { | |||||
void powerOn(); | void powerOn(); | ||||
void powerOff(); | 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); | bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
bool enableGprs(); | bool enableGprs(); | ||||
@@ -57,7 +57,7 @@ namespace positions { | |||||
void NetworkPositionsBackup::appendPositions() { | void NetworkPositionsBackup::appendPositions() { | ||||
uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | ||||
PositionEntry currentEntry; | PositionEntry currentEntry; | ||||
SIM808RegistrationStatus networkStatus; | |||||
SIM808_NETWORK_REGISTRATION_STATE networkStatus; | |||||
//avoid edge case where if 0, whole set of positions will be sent again | //avoid edge case where if 0, whole set of positions will be sent again | ||||
if (!positions::count(config::main::value.network.lastSavedEntry)) return; | if (!positions::count(config::main::value.network.lastSavedEntry)) return; | ||||
@@ -65,7 +65,7 @@ namespace positions { | |||||
network::powerOn(); | network::powerOn(); | ||||
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); | 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 | networkUnavailableInARow = min(networkUnavailableInARow + 1, POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD + 1); //avoid increment overflow | ||||
NOTICE_MSG("appendPositions", "network or gprs unavailable"); | NOTICE_MSG("appendPositions", "network or gprs unavailable"); | ||||
@@ -1,7 +1,7 @@ | |||||
#pragma once | #pragma once | ||||
#include <Arduino.h> | #include <Arduino.h> | ||||
#include <SIM808_Types.h> | |||||
#include <SIM808.Types.h> | |||||
#define POSITION_SIZE 115 | #define POSITION_SIZE 115 | ||||
@@ -20,7 +20,7 @@ | |||||
\def VERSION | \def VERSION | ||||
Version string, only used for indicative purpose | Version string, only used for indicative purpose | ||||
*/ | */ | ||||
#define VERSION "1.30" | |||||
#define VERSION "1.40" | |||||
/** | /** | ||||