@@ -558,7 +558,7 @@ void publishI2CResponse(wippersnapper_signal_v1_I2CResponse *msgi2cResponse) {
558
558
pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_I2CResponse_fields,
559
559
msgi2cResponse);
560
560
WS_DEBUG_PRINT (" Publishing Message: I2CResponse..." );
561
- if (!WS._mqtt -> publish (WS._topic_signal_i2c_device , WS._buffer_outgoing ,
561
+ if (!WS.publish (WS._topic_signal_i2c_device , WS._buffer_outgoing ,
562
562
msgSz, 1 )) {
563
563
WS_DEBUG_PRINTLN (" ERROR: Failed to publish I2C Response!" );
564
564
} else {
@@ -995,9 +995,16 @@ bool cbDecodeServoMsg(pb_istream_t *stream, const pb_field_t *field,
995
995
pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_ServoResponse_fields,
996
996
&msgServoResp);
997
997
WS_DEBUG_PRINT (" -> Servo Attach Response..." );
998
- WS._mqtt ->publish (WS._topic_signal_servo_device , WS._buffer_outgoing , msgSz,
999
- 1 );
1000
- WS_DEBUG_PRINTLN (" Published!" );
998
+ if (!WS.publish (WS._topic_signal_servo_device , WS._buffer_outgoing , msgSz,
999
+ 1 ))
1000
+ {
1001
+ WS_DEBUG_PRINTLN (" ERROR: Failed to publish Servo Attach Response!" );
1002
+ return false ;
1003
+ }
1004
+ else
1005
+ {
1006
+ WS_DEBUG_PRINTLN (" Published!" );
1007
+ }
1001
1008
} else if (field->tag ==
1002
1009
wippersnapper_signal_v1_ServoRequest_servo_write_tag) {
1003
1010
WS_DEBUG_PRINTLN (" GOT: Servo Write" );
@@ -1161,12 +1168,12 @@ bool cbPWMDecodeMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
1161
1168
pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_PWMResponse_fields,
1162
1169
&msgPWMResponse);
1163
1170
WS_DEBUG_PRINT (" PUBLISHING: PWM Attach Response..." );
1164
- if (!WS._mqtt -> publish (WS._topic_signal_pwm_device , WS._buffer_outgoing ,
1171
+ if (!WS.publish (WS._topic_signal_pwm_device , WS._buffer_outgoing ,
1165
1172
msgSz, 1 )) {
1166
1173
WS_DEBUG_PRINTLN (" ERROR: Failed to publish PWM Attach Response!" );
1167
1174
return false ;
1168
1175
}
1169
- WS_DEBUG_PRINTLN (" Published!" );
1176
+ WS_DEBUG_PRINTLN (" Published! (PWM Attach Response) " );
1170
1177
1171
1178
#ifdef USE_DISPLAY
1172
1179
char buffer[100 ];
@@ -1571,12 +1578,12 @@ bool cbDecodeUARTMessage(pb_istream_t *stream, const pb_field_t *field,
1571
1578
pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_UARTResponse_fields,
1572
1579
&msgUARTResponse);
1573
1580
WS_DEBUG_PRINT (" PUBLISHING: UART Attach Response..." );
1574
- if (!WS._mqtt -> publish (WS._topic_signal_uart_device , WS._buffer_outgoing ,
1581
+ if (!WS.publish (WS._topic_signal_uart_device , WS._buffer_outgoing ,
1575
1582
msgSz, 1 )) {
1576
1583
WS_DEBUG_PRINTLN (" ERROR: Failed to publish UART Attach Response!" );
1577
1584
return false ;
1578
1585
}
1579
- WS_DEBUG_PRINTLN (" Published!" );
1586
+ WS_DEBUG_PRINTLN (" Published! (UART Device Attached) " );
1580
1587
1581
1588
} else if (field->tag ==
1582
1589
wippersnapper_signal_v1_UARTRequest_req_uart_device_detach_tag) {
@@ -2653,14 +2660,27 @@ void Wippersnapper::processPackets() {
2653
2660
The Quality of Service to publish with.
2654
2661
*/
2655
2662
/* ******************************************************/
2656
- void Wippersnapper::publish (const char *topic, uint8_t *payload, uint16_t bLen,
2663
+ bool Wippersnapper::publish (const char *topic, uint8_t *payload, uint16_t bLen,
2657
2664
uint8_t qos) {
2658
2665
// runNetFSM(); // NOTE: Removed for now, causes error with virtual _connect
2659
2666
// method when caused with WS object in another file.
2660
2667
WS.feedWDT ();
2661
- if (!WS._mqtt ->publish (topic, payload, bLen, qos)) {
2662
- WS_DEBUG_PRINTLN (" Failed to publish MQTT message!" );
2668
+ bool response = WS._mqtt ->publish (topic, payload, bLen, qos);
2669
+ if (!response) {
2670
+ WS_DEBUG_PRINTLN (" Failed to publish MQTT message (t: " );
2671
+ WS_DEBUG_PRINT (topic);
2672
+ WS_DEBUG_PRINT (" q: " );
2673
+ WS_DEBUG_PRINT (qos);
2674
+ WS_DEBUG_PRINT (" l: " );
2675
+ WS_DEBUG_PRINT (bLen);
2676
+ WS_DEBUG_PRINT (" hex: " );
2677
+ for (uint16_t i = 0 ; i < bLen; i++) {
2678
+ WS_DEBUG_PRINTHEX (payload[i]);
2679
+ WS_DEBUG_PRINT (" " );
2680
+ }
2681
+ WS_DEBUG_PRINTLN (" )\n " );
2663
2682
}
2683
+ return response;
2664
2684
}
2665
2685
2666
2686
/* *************************************************************/
@@ -2863,6 +2883,7 @@ void Wippersnapper::publishPinConfigComplete() {
2863
2883
WS_DEBUG_PRINTLN (" Publishing to pin config complete..." );
2864
2884
WS.publish (WS._topic_device_pin_config_complete , _message_buffer,
2865
2885
_message_len, 1 );
2886
+ WS_DEBUG_PRINTLN (" Published! (pin config complete)" );
2866
2887
}
2867
2888
2868
2889
/* *************************************************************************/
0 commit comments