Skip to content

Commit

Permalink
Improve transport function & debug messages (#1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
tekka007 authored and henrikekblad committed Aug 29, 2018
1 parent ea7f7be commit 6d24ab1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/MyGatewayTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void gatewayTransportProcess(void)
inclusionModeSet(atoi(_msg.data) == 1);
#endif
} else {
_processInternalMessages();
(void)_processInternalCoreMessage();
}
} else {
// Call incoming message callback if available
Expand Down
11 changes: 5 additions & 6 deletions core/MySensorsCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,14 @@ bool requestTime(const bool ack)
}

// Message delivered through _msg
bool _processInternalMessages(void)
bool _processInternalCoreMessage(void)
{
const uint8_t type = _msg.type;

if (_msg.sender == GATEWAY_ADDRESS) {
if (type == I_REBOOT) {
#if !defined(MY_DISABLE_REMOTE_RESET)
// Requires MySensors or other bootloader with watchdogs enabled
setIndication(INDICATION_REBOOT);
// WDT fuse should be enabled
hwReboot();
#endif
} else if (type == I_REGISTRATION_RESPONSE) {
Expand Down Expand Up @@ -468,7 +467,7 @@ bool _processInternalMessages(void)
}
#endif
} else {
return false;
return false; // further processing required
}
} else {
// sender is a node
Expand Down Expand Up @@ -496,10 +495,10 @@ bool _processInternalMessages(void)
#endif
#endif
} else {
return false;
return false; // further processing required
}
}
return true;
return true; // if not GW or no further processing required
}


Expand Down
8 changes: 4 additions & 4 deletions core/MySensorsCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* - MCO:<b>BGN</b> from @ref _begin()
* - MCO:<b>REG</b> from @ref _registerNode()
* - MCO:<b>SND</b> from @ref send()
* - MCO:<b>PIM</b> from @ref _processInternalMessages()
* - MCO:<b>PIM</b> from @ref _processInternalCoreMessage()
* - MCO:<b>NLK</b> from @ref _nodeLock()
*
* MySensorsCore debug log messages:
Expand Down Expand Up @@ -385,10 +385,10 @@ void _begin(void);
*/
void _process(void);
/**
* @brief Processes internal messages
* @return True if received message requires further processing
* @brief Processes internal core message
* @return True if no further processing required
*/
bool _processInternalMessages(void);
bool _processInternalCoreMessage(void);
/**
* @brief Puts node to a infinite loop if unrecoverable situation detected
*/
Expand Down
20 changes: 10 additions & 10 deletions core/MyTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void transportProcessMessage(void)
} else {
TRANSPORT_DEBUG(PSTR("!TSF:MSG:FPAR INACTIVE\n")); // find parent response received, but inactive
}
return;
return; // no further processing required
#endif
}
#endif // !defined(MY_GATEWAY_FEATURE)
Expand All @@ -802,16 +802,13 @@ void transportProcessMessage(void)
}
return; // no further processing required
}
if (_processInternalMessages()) {
return; // no further processing required
}
if (type == I_SIGNAL_REPORT_REVERSE) {
return; // no further processing required
}
if (type == I_SIGNAL_REPORT_REQUEST) {
const char command = _msg.data[0];
int16_t value = INVALID_RSSI;
#if defined(MY_SIGNAL_REPORT_ENABLED)
const char command = _msg.data[0];
if (_msg.data[1] != '!') {
value = transportSignalReport(command);
} else {
Expand All @@ -822,13 +819,15 @@ void transportProcessMessage(void)
value = transportSignalReport(command + 32); // reverse
};
}
#else
(void)command;
#endif
(void)transportRouteMessage(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL,
I_SIGNAL_REPORT_RESPONSE).set(value));
return;
return; // no further processing required
}
if (_processInternalCoreMessage()) {
return; // no further processing required
}
return; // other C_INTERNAL messages do not require further processing
} else if (command == C_STREAM) {
#if defined(MY_OTA_FIRMWARE_FEATURE)
if(firmwareOTAUpdateProcess()) {
Expand Down Expand Up @@ -918,6 +917,7 @@ void transportProcessMessage(void)
(void)gatewayTransportSend(_msg);
#endif
if (receive) {
TRANSPORT_DEBUG(PSTR("TSF:MSG:RCV CB\n")); // hand over message to receive callback function
receive(_msg);
}
}
Expand All @@ -926,18 +926,18 @@ void transportProcessMessage(void)
// msg not to us and not BC, relay msg
#if defined(MY_REPEATER_FEATURE)
if (isTransportReady()) {
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL MSG\n")); // relay msg
if (command == C_INTERNAL) {
if (type == I_PING || type == I_PONG) {
uint8_t hopsCnt = _msg.getByte();
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%" PRIu8 "\n"), hopsCnt);
if (hopsCnt != MAX_HOPS) {
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%" PRIu8 "\n"), hopsCnt);
hopsCnt++;
_msg.set(hopsCnt);
}
}
}
// Relay this message to another node
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL MSG\n")); // relay msg
(void)transportRouteMessage(_msg);
}
#else
Expand Down
1 change: 1 addition & 0 deletions core/MyTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
* | | TSF | MSG | BC | Broadcast message received
* | | TSF | MSG | GWL OK | Link to GW ok
* | | TSF | MSG | FWD BC MSG | Controlled broadcast message forwarding
* | | TSF | MSG | RCV CB | Hand over message to @ref receive() callback function
* | | TSF | MSG | REL MSG | Relay message
* | | TSF | MSG | REL PxNG,HP=%%d | Relay PING/PONG message, increment hop counter (HP)
* |!| TSF | MSG | LEN=%%d,EXP=%%d | Invalid message length (LEN), exptected length (EXP)
Expand Down

0 comments on commit 6d24ab1

Please sign in to comment.