Skip to content

Commit 6d24ab1

Browse files
tekka007henrikekblad
authored andcommitted
Improve transport function & debug messages (#1191)
1 parent ea7f7be commit 6d24ab1

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

core/MyGatewayTransport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ inline void gatewayTransportProcess(void)
5252
inclusionModeSet(atoi(_msg.data) == 1);
5353
#endif
5454
} else {
55-
_processInternalMessages();
55+
(void)_processInternalCoreMessage();
5656
}
5757
} else {
5858
// Call incoming message callback if available

core/MySensorsCore.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,14 @@ bool requestTime(const bool ack)
400400
}
401401

402402
// Message delivered through _msg
403-
bool _processInternalMessages(void)
403+
bool _processInternalCoreMessage(void)
404404
{
405405
const uint8_t type = _msg.type;
406-
407406
if (_msg.sender == GATEWAY_ADDRESS) {
408407
if (type == I_REBOOT) {
409408
#if !defined(MY_DISABLE_REMOTE_RESET)
410-
// Requires MySensors or other bootloader with watchdogs enabled
411409
setIndication(INDICATION_REBOOT);
410+
// WDT fuse should be enabled
412411
hwReboot();
413412
#endif
414413
} else if (type == I_REGISTRATION_RESPONSE) {
@@ -468,7 +467,7 @@ bool _processInternalMessages(void)
468467
}
469468
#endif
470469
} else {
471-
return false;
470+
return false; // further processing required
472471
}
473472
} else {
474473
// sender is a node
@@ -496,10 +495,10 @@ bool _processInternalMessages(void)
496495
#endif
497496
#endif
498497
} else {
499-
return false;
498+
return false; // further processing required
500499
}
501500
}
502-
return true;
501+
return true; // if not GW or no further processing required
503502
}
504503

505504

core/MySensorsCore.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* - MCO:<b>BGN</b> from @ref _begin()
3333
* - MCO:<b>REG</b> from @ref _registerNode()
3434
* - MCO:<b>SND</b> from @ref send()
35-
* - MCO:<b>PIM</b> from @ref _processInternalMessages()
35+
* - MCO:<b>PIM</b> from @ref _processInternalCoreMessage()
3636
* - MCO:<b>NLK</b> from @ref _nodeLock()
3737
*
3838
* MySensorsCore debug log messages:
@@ -385,10 +385,10 @@ void _begin(void);
385385
*/
386386
void _process(void);
387387
/**
388-
* @brief Processes internal messages
389-
* @return True if received message requires further processing
388+
* @brief Processes internal core message
389+
* @return True if no further processing required
390390
*/
391-
bool _processInternalMessages(void);
391+
bool _processInternalCoreMessage(void);
392392
/**
393393
* @brief Puts node to a infinite loop if unrecoverable situation detected
394394
*/

core/MyTransport.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ void transportProcessMessage(void)
775775
} else {
776776
TRANSPORT_DEBUG(PSTR("!TSF:MSG:FPAR INACTIVE\n")); // find parent response received, but inactive
777777
}
778-
return;
778+
return; // no further processing required
779779
#endif
780780
}
781781
#endif // !defined(MY_GATEWAY_FEATURE)
@@ -802,16 +802,13 @@ void transportProcessMessage(void)
802802
}
803803
return; // no further processing required
804804
}
805-
if (_processInternalMessages()) {
806-
return; // no further processing required
807-
}
808805
if (type == I_SIGNAL_REPORT_REVERSE) {
809806
return; // no further processing required
810807
}
811808
if (type == I_SIGNAL_REPORT_REQUEST) {
812-
const char command = _msg.data[0];
813809
int16_t value = INVALID_RSSI;
814810
#if defined(MY_SIGNAL_REPORT_ENABLED)
811+
const char command = _msg.data[0];
815812
if (_msg.data[1] != '!') {
816813
value = transportSignalReport(command);
817814
} else {
@@ -822,13 +819,15 @@ void transportProcessMessage(void)
822819
value = transportSignalReport(command + 32); // reverse
823820
};
824821
}
825-
#else
826-
(void)command;
827822
#endif
828823
(void)transportRouteMessage(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL,
829824
I_SIGNAL_REPORT_RESPONSE).set(value));
830-
return;
825+
return; // no further processing required
826+
}
827+
if (_processInternalCoreMessage()) {
828+
return; // no further processing required
831829
}
830+
return; // other C_INTERNAL messages do not require further processing
832831
} else if (command == C_STREAM) {
833832
#if defined(MY_OTA_FIRMWARE_FEATURE)
834833
if(firmwareOTAUpdateProcess()) {
@@ -918,6 +917,7 @@ void transportProcessMessage(void)
918917
(void)gatewayTransportSend(_msg);
919918
#endif
920919
if (receive) {
920+
TRANSPORT_DEBUG(PSTR("TSF:MSG:RCV CB\n")); // hand over message to receive callback function
921921
receive(_msg);
922922
}
923923
}
@@ -926,18 +926,18 @@ void transportProcessMessage(void)
926926
// msg not to us and not BC, relay msg
927927
#if defined(MY_REPEATER_FEATURE)
928928
if (isTransportReady()) {
929-
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL MSG\n")); // relay msg
930929
if (command == C_INTERNAL) {
931930
if (type == I_PING || type == I_PONG) {
932931
uint8_t hopsCnt = _msg.getByte();
932+
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%" PRIu8 "\n"), hopsCnt);
933933
if (hopsCnt != MAX_HOPS) {
934-
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%" PRIu8 "\n"), hopsCnt);
935934
hopsCnt++;
936935
_msg.set(hopsCnt);
937936
}
938937
}
939938
}
940939
// Relay this message to another node
940+
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL MSG\n")); // relay msg
941941
(void)transportRouteMessage(_msg);
942942
}
943943
#else

core/MyTransport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
* | | TSF | MSG | BC | Broadcast message received
104104
* | | TSF | MSG | GWL OK | Link to GW ok
105105
* | | TSF | MSG | FWD BC MSG | Controlled broadcast message forwarding
106+
* | | TSF | MSG | RCV CB | Hand over message to @ref receive() callback function
106107
* | | TSF | MSG | REL MSG | Relay message
107108
* | | TSF | MSG | REL PxNG,HP=%%d | Relay PING/PONG message, increment hop counter (HP)
108109
* |!| TSF | MSG | LEN=%%d,EXP=%%d | Invalid message length (LEN), exptected length (EXP)

0 commit comments

Comments
 (0)