Skip to content

Commit 13628f7

Browse files
committed
WIP: Log all publish failures
1 parent ad1e7e1 commit 13628f7

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

src/Wippersnapper.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ bool Wippersnapper::publish(const char *topic, uint8_t *payload, uint16_t bLen,
26662666
// method when caused with WS object in another file.
26672667
#ifdef ARDUINO_ARCH_ESP32
26682668
// print stack and heap usage
2669-
WS_DEBUG_PRINT("Free Heap: ");
2669+
WS_DEBUG_PRINT("\nFree Heap: ");
26702670
WS_DEBUG_PRINTLN(ESP.getFreeHeap());
26712671
WS_DEBUG_PRINT("Min Free Heap: ");
26722672
WS_DEBUG_PRINTLN(ESP.getMinFreeHeap());
@@ -2894,9 +2894,15 @@ void Wippersnapper::publishPinConfigComplete() {
28942894

28952895
// Publish message
28962896
WS_DEBUG_PRINTLN("Publishing to pin config complete...");
2897-
WS.publish(WS._topic_device_pin_config_complete, _message_buffer,
2898-
_message_len, 1);
2899-
WS_DEBUG_PRINTLN("Published! (pin config complete)");
2897+
if (WS.publish(WS._topic_device_pin_config_complete, _message_buffer,
2898+
_message_len, 1))
2899+
{
2900+
WS_DEBUG_PRINTLN("Published! (pin config complete)");
2901+
}
2902+
else
2903+
{
2904+
WS_DEBUG_PRINTLN("Failed to publish! (pin config complete)");
2905+
}
29002906
}
29012907

29022908
/**************************************************************************/

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
305305
wippersnapper_signal_v1_CreateSignalRequest_fields,
306306
&outgoingSignalMsg);
307307
WS_DEBUG_PRINT("Publishing pinEvent...");
308-
WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1);
308+
if(!WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1)) {
309+
WS_DEBUG_PRINTLN("ERROR: Unable to publish analogIO pin event message");
310+
return false;
311+
}
309312
WS_DEBUG_PRINTLN("Published!");
310313

311314
return true;

src/components/digitalIO/Wippersnapper_DigitalGPIO.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
276276
&_outgoingSignalMsg);
277277

278278
WS_DEBUG_PRINT("Publishing pinEvent...");
279-
WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1);
280-
WS_DEBUG_PRINTLN("Published!");
279+
if (!WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1)){
280+
WS_DEBUG_PRINTLN("ERROR: Unable to publish DigitalIO pinEvent");
281+
} else {
282+
WS_DEBUG_PRINTLN("Published! (DigitalIO PinEvent)");
283+
}
281284

282285
// reset the digital pin
283286
_digital_input_pins[i].prvPeriod = curTime;
@@ -315,8 +318,14 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
315318
&msgSz, wippersnapper_signal_v1_CreateSignalRequest_fields,
316319
&_outgoingSignalMsg);
317320
WS_DEBUG_PRINT("Publishing pinEvent...");
318-
WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1);
319-
WS_DEBUG_PRINTLN("Published!");
321+
if (!WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1))
322+
{
323+
WS_DEBUG_PRINTLN("ERROR: Unable to publish DigitalIO pinEvent");
324+
}
325+
else
326+
{
327+
WS_DEBUG_PRINTLN("Published! (DigitalIO PinEvent)");
328+
}
320329

321330
// set the pin value in the digital pin object for comparison on next
322331
// run

src/components/register/Wippersnapper_Register.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ bool Wippersnapper::encodePubRegistrationReq() {
5656
return _status;
5757

5858
// pubish message
59-
WS.publish(WS._topic_description, _message_buffer, _message_len, 1);
60-
WS_DEBUG_PRINTLN("Published!");
59+
if (!WS.publish(WS._topic_description, _message_buffer, _message_len, 1)){
60+
WS_DEBUG_PRINTLN("ERROR: Unable to publish registration message");
61+
} else {
62+
WS_DEBUG_PRINTLN("Published! (Registration)");
63+
}
6164
WS._boardStatus = WS_BOARD_DEF_SENT;
6265

6366
return _status;
@@ -153,10 +156,15 @@ void Wippersnapper::decodeRegistrationResp(char *data, uint16_t len) {
153156
}
154157

155158
// Publish message
156-
WS.publish(_topic_description_status_complete, _message_buffer,
157-
_message_len, 1);
158-
WS_DEBUG_PRINTLN("Completed registration process, configuration next!");
159-
159+
if (WS.publish(_topic_description_status_complete, _message_buffer,
160+
_message_len, 1))
161+
{
162+
WS_DEBUG_PRINTLN("Completed registration process, configuration next!");
163+
}
164+
else
165+
{
166+
WS_DEBUG_PRINTLN("ERROR: Unable to publish registration complete message");
167+
}
160168
} else {
161169
WS._boardStatus = WS_BOARD_DEF_INVALID;
162170
}

0 commit comments

Comments
 (0)