@@ -27,11 +27,11 @@ | |||||
#define SLEEP_DEFAULT_TIME_SECONDS 1800 | #define SLEEP_DEFAULT_TIME_SECONDS 1800 | ||||
#define SLEEP_DEFAULT_INCREASE_THRESHOLD 3 | #define SLEEP_DEFAULT_INCREASE_THRESHOLD 3 | ||||
#define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000 | |||||
#define GPS_DEFAULT_TOTAL_TIMEOUT_MS 80000 | |||||
#define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000L | |||||
#define GPS_DEFAULT_TOTAL_TIMEOUT_MS 80000L | |||||
#define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 6000 | |||||
#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 80000 | |||||
#define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 1000L | |||||
#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 80000L | |||||
#define NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD 8 | #define NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD 8 | ||||
#define NETWORK_DEFAULT_NO_NETWORK_TRIES 5 | #define NETWORK_DEFAULT_NO_NETWORK_TRIES 5 | ||||
@@ -34,9 +34,9 @@ namespace hardware { | |||||
void powerOffIfUnused() { | void powerOffIfUnused() { | ||||
bool gpsPowered = false; | bool gpsPowered = false; | ||||
bool gprsPowered = false; | |||||
if ((!device.getGpsPowerState(&gpsPowered) || !gpsPowered) && | if ((!device.getGpsPowerState(&gpsPowered) || !gpsPowered) && | ||||
(!device.getGprsPowerState(&gprsPowered) || !gprsPowered)) { | |||||
(device.getPhoneFunctionality() != SIM808_PHONE_FUNCTIONALITY::FULL)) { | |||||
powerOff(); | powerOff(); | ||||
} | } | ||||
} | } | ||||
@@ -10,8 +10,8 @@ | |||||
namespace network { | namespace network { | ||||
SIM808RegistrationStatus waitForRegistered(int32_t timeout) { | |||||
NOTICE_FORMAT("waitForRegistered", "Timeout : %d", timeout); | |||||
__attribute__((__optimize__("O2"))) | |||||
SIM808RegistrationStatus waitForRegistered(uint32_t timeout) { | |||||
SIM808RegistrationStatus currentStatus; | SIM808RegistrationStatus currentStatus; | ||||
SIM808SignalQualityReport report; | SIM808SignalQualityReport report; | ||||
@@ -33,6 +33,7 @@ namespace network { | |||||
mainunit::deepSleep(NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); | mainunit::deepSleep(NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); | ||||
timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS; | timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS; | ||||
} while (timeout > 1); | } while (timeout > 1); | ||||
report = hardware::sim808::device.getSignalQuality(); | report = hardware::sim808::device.getSignalQuality(); | ||||
@@ -7,7 +7,7 @@ namespace network { | |||||
inline void powerOn() { hardware::sim808::networkPowerOn(); } | inline void powerOn() { hardware::sim808::networkPowerOn(); } | ||||
inline void powerOff() { hardware::sim808::networkPowerOff(); } | inline void powerOff() { hardware::sim808::networkPowerOff(); } | ||||
SIM808RegistrationStatus waitForRegistered(int32_t timeout); | |||||
SIM808RegistrationStatus waitForRegistered(uint32_t timeout); | |||||
bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); | bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); | ||||
bool enableGprs(); | bool enableGprs(); | ||||
} | } |
@@ -46,17 +46,16 @@ namespace positions { | |||||
return responseCode; | return responseCode; | ||||
} | } | ||||
__attribute__((__optimize__("O2"))) | |||||
//__attribute__((__optimize__("O2"))) | |||||
void NetworkPositionsBackup::appendPositions() { | void NetworkPositionsBackup::appendPositions() { | ||||
uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | ||||
int32_t networkTimeout = 0; | |||||
uint32_t networkTimeout = 0; | |||||
PositionEntry currentEntry; | PositionEntry currentEntry; | ||||
SIM808RegistrationStatus networkStatus; | SIM808RegistrationStatus networkStatus; | ||||
network::powerOn(); | network::powerOn(); | ||||
networkTimeout = _prepareTime > 0 ? | |||||
NETWORK_DEFAULT_TOTAL_TIMEOUT_MS - (rtc::getTime() - _prepareTime) * 1000 : | |||||
NETWORK_DEFAULT_TOTAL_TIMEOUT_MS; | |||||
networkTimeout = NETWORK_DEFAULT_TOTAL_TIMEOUT_MS; | |||||
if (_prepareTime > 0) networkTimeout -= (rtc::getTime() - _prepareTime) * 1000; | |||||
networkStatus = network::waitForRegistered(networkTimeout); | networkStatus = network::waitForRegistered(networkTimeout); | ||||