Merge development

This commit is contained in:
Olivier
2016-11-14 12:34:31 +01:00
17 changed files with 695 additions and 595 deletions
+21 -15
View File
@@ -54,11 +54,7 @@ void _callbackTransportOk()
}
void _process(void) {
hwWatchdogReset();
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
ledsProcess();
#endif
doYield();
#if defined(MY_INCLUSION_MODE_FEATURE)
inclusionProcess();
@@ -80,10 +76,7 @@ void _process(void) {
void _infiniteLoop(void) {
while(1) {
yield();
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
ledsProcess();
#endif
doYield();
#if defined(__linux__)
exit(1);
#endif
@@ -139,9 +132,8 @@ void _begin(void) {
#if !defined(MY_TRANSPORT_RELAX)
// check if transport ready
while (!isTransportReady()) {
hwWatchdogReset();
transportProcess();
yield();
doYield();
}
#else
CORE_DEBUG(PSTR("MCO:BGN:MTR\n"));
@@ -465,7 +457,6 @@ void wait(const uint32_t waitingMS) {
const uint32_t enteringMS = hwMillis();
while (hwMillis() - enteringMS < waitingMS) {
_process();
yield();
}
}
@@ -476,12 +467,21 @@ bool wait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t msgtype) {
bool expectedResponse = false;
while ( (hwMillis() - enteringMS < waitingMS) && !expectedResponse ) {
_process();
yield();
expectedResponse = (mGetCommand(_msg) == cmd && _msg.type == msgtype);
}
return expectedResponse;
}
void doYield(void) {
hwWatchdogReset();
yield();
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
ledsProcess();
#endif
}
int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2) {
CORE_DEBUG(PSTR("MCO:SLP:MS=%lu,SMS=%d,I1=%d,M1=%d,I2=%d,M2=%d\n"), sleepingMS, smartSleep, interrupt1, mode1, interrupt2, mode2);
// OTA FW feature: do not sleep if FW update ongoing
@@ -513,7 +513,6 @@ int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t in
uint32_t sleepDeltaMS = 0;
while (!isTransportReady() && (sleepDeltaMS < sleepingTimeMS) && (sleepDeltaMS < MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS)) {
_process();
yield();
sleepDeltaMS = hwMillis() - sleepEnterMS;
}
// sleep remainder
@@ -539,6 +538,13 @@ int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t in
transportPowerDown();
#endif
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
// Wait until leds finish their blinking pattern
while (ledsBlinking()) {
doYield();
}
#endif
setIndication(INDICATION_SLEEP);
int8_t result = MY_SLEEP_NOT_POSSIBLE; // default
@@ -601,7 +607,7 @@ void _nodeLock(const char* str)
while (1) {
setIndication(INDICATION_ERR_LOCKED);
CORE_DEBUG(PSTR("MCO:NLK:NODE LOCKED. TO UNLOCK, GND PIN %d AND RESET\n"), MY_NODE_UNLOCK_PIN);
yield();
doYield();
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID,C_INTERNAL, I_LOCKED).set(str));
#if defined(MY_SENSOR_NETWORK)
transportPowerDown();