@@ -558,7 +558,7 @@ void publishI2CResponse(wippersnapper_signal_v1_I2CResponse *msgi2cResponse) {
558558 pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_I2CResponse_fields,
559559 msgi2cResponse);
560560 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 ,
562562 msgSz, 1 )) {
563563 WS_DEBUG_PRINTLN (" ERROR: Failed to publish I2C Response!" );
564564 } else {
@@ -995,9 +995,16 @@ bool cbDecodeServoMsg(pb_istream_t *stream, const pb_field_t *field,
995995 pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_ServoResponse_fields,
996996 &msgServoResp);
997997 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+ }
10011008 } else if (field->tag ==
10021009 wippersnapper_signal_v1_ServoRequest_servo_write_tag) {
10031010 WS_DEBUG_PRINTLN (" GOT: Servo Write" );
@@ -1161,12 +1168,12 @@ bool cbPWMDecodeMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
11611168 pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_PWMResponse_fields,
11621169 &msgPWMResponse);
11631170 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 ,
11651172 msgSz, 1 )) {
11661173 WS_DEBUG_PRINTLN (" ERROR: Failed to publish PWM Attach Response!" );
11671174 return false ;
11681175 }
1169- WS_DEBUG_PRINTLN (" Published!" );
1176+ WS_DEBUG_PRINTLN (" Published! (PWM Attach Response) " );
11701177
11711178#ifdef USE_DISPLAY
11721179 char buffer[100 ];
@@ -1571,12 +1578,12 @@ bool cbDecodeUARTMessage(pb_istream_t *stream, const pb_field_t *field,
15711578 pb_get_encoded_size (&msgSz, wippersnapper_signal_v1_UARTResponse_fields,
15721579 &msgUARTResponse);
15731580 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 ,
15751582 msgSz, 1 )) {
15761583 WS_DEBUG_PRINTLN (" ERROR: Failed to publish UART Attach Response!" );
15771584 return false ;
15781585 }
1579- WS_DEBUG_PRINTLN (" Published!" );
1586+ WS_DEBUG_PRINTLN (" Published! (UART Device Attached) " );
15801587
15811588 } else if (field->tag ==
15821589 wippersnapper_signal_v1_UARTRequest_req_uart_device_detach_tag) {
@@ -2653,14 +2660,27 @@ void Wippersnapper::processPackets() {
26532660 The Quality of Service to publish with.
26542661*/
26552662/* ******************************************************/
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,
26572664 uint8_t qos) {
26582665 // runNetFSM(); // NOTE: Removed for now, causes error with virtual _connect
26592666 // method when caused with WS object in another file.
26602667 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 " );
26632682 }
2683+ return response;
26642684}
26652685
26662686/* *************************************************************/
@@ -2863,6 +2883,7 @@ void Wippersnapper::publishPinConfigComplete() {
28632883 WS_DEBUG_PRINTLN (" Publishing to pin config complete..." );
28642884 WS.publish (WS._topic_device_pin_config_complete , _message_buffer,
28652885 _message_len, 1 );
2886+ WS_DEBUG_PRINTLN (" Published! (pin config complete)" );
28662887}
28672888
28682889/* *************************************************************************/
0 commit comments