@@ -733,41 +733,41 @@ bool Wippersnapper::buildWSTopics() {
733
733
// Global registration topic
734
734
WS._topic_description =
735
735
(char *)malloc (sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr" ) +
736
- strlen (TOPIC_DESCRIPTION ) + strlen (" status" ) + 1 );
736
+ strlen (TOPIC_INFO ) + strlen (" status" ) + 1 );
737
737
738
738
// Registration status topic
739
- WS._topic_description_status = ( char *) malloc (
740
- sizeof (char ) * strlen (WS._username ) + + strlen (" /wprsnpr/" ) +
741
- strlen (_device_uid) + strlen (TOPIC_DESCRIPTION ) + strlen (" status " ) +
742
- strlen (" broker" ) + 1 );
739
+ WS._topic_description_status =
740
+ ( char *) malloc ( sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr/" ) +
741
+ strlen (_device_uid ) + strlen (TOPIC_INFO ) +
742
+ strlen ( " status/ " ) + strlen (" broker" ) + 1 );
743
743
744
744
// Registration status completion topic
745
- WS._topic_description_status_complete = ( char *) malloc (
746
- sizeof (char ) * strlen (WS._username ) + + strlen (" /wprsnpr/" ) +
747
- strlen (_device_uid) + strlen (TOPIC_DESCRIPTION ) + strlen (" status " ) +
748
- strlen (" /device/complete" ) + 1 );
745
+ WS._topic_description_status_complete =
746
+ ( char *) malloc ( sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr/" ) +
747
+ strlen (_device_uid ) + strlen (TOPIC_INFO ) +
748
+ strlen ( " status " ) + strlen (" /device/complete" ) + 1 );
749
749
750
750
// Topic to signal pin configuration complete from device to broker
751
- WS._topic_device_pin_config_complete = ( char *) malloc (
752
- sizeof (char ) * strlen (WS._username ) + + strlen (" /" ) + strlen (_device_uid ) +
753
- strlen (" /wprsnpr/ " ) + strlen (TOPIC_SIGNALS) +
754
- strlen (" device/pinConfigComplete" ) + 1 );
751
+ WS._topic_device_pin_config_complete =
752
+ ( char *) malloc ( sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr/ " ) +
753
+ strlen (_device_uid ) + strlen (TOPIC_SIGNALS) +
754
+ strlen (" device/pinConfigComplete" ) + 1 );
755
755
756
756
// Topic for signals from device to broker
757
757
WS._topic_signal_device = (char *)malloc (
758
- sizeof (char ) * strlen (WS._username ) + + strlen (" /" ) + strlen (_device_uid ) +
759
- strlen (" /wprsnpr/ " ) + strlen (TOPIC_SIGNALS) + strlen (" device" ) + 1 );
758
+ sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr/ " ) +
759
+ strlen (_device_uid ) + strlen (TOPIC_SIGNALS) + strlen (" device" ) + 1 );
760
760
761
761
// Topic for signals from broker to device
762
762
WS._topic_signal_brkr = (char *)malloc (
763
- sizeof (char ) * strlen (WS._username ) + + strlen (" /" ) + strlen (_device_uid ) +
764
- strlen (" /wprsnpr/ " ) + strlen (TOPIC_SIGNALS) + strlen (" broker" ) + 1 );
763
+ sizeof (char ) * strlen (WS._username ) + strlen (" /wprsnpr/ " ) +
764
+ strlen (_device_uid ) + strlen (TOPIC_SIGNALS) + strlen (" broker" ) + 1 );
765
765
766
766
// Create global registration topic
767
767
if (WS._topic_description ) {
768
768
strcpy (WS._topic_description , WS._username );
769
769
strcat (WS._topic_description , " /wprsnpr" );
770
- strcat (WS._topic_description , TOPIC_DESCRIPTION );
770
+ strcat (WS._topic_description , TOPIC_INFO );
771
771
strcat (WS._topic_description , " status" );
772
772
} else { // malloc failed
773
773
WS._topic_description = 0 ;
@@ -779,7 +779,7 @@ bool Wippersnapper::buildWSTopics() {
779
779
strcpy (WS._topic_description_status , WS._username );
780
780
strcat (WS._topic_description_status , " /wprsnpr/" );
781
781
strcat (WS._topic_description_status , _device_uid);
782
- strcat (WS._topic_description_status , TOPIC_DESCRIPTION );
782
+ strcat (WS._topic_description_status , TOPIC_INFO );
783
783
strcat (WS._topic_description_status , " status" );
784
784
strcat (WS._topic_description_status , " /broker" );
785
785
} else { // malloc failed
@@ -792,7 +792,7 @@ bool Wippersnapper::buildWSTopics() {
792
792
strcpy (WS._topic_description_status_complete , WS._username );
793
793
strcat (WS._topic_description_status_complete , " /wprsnpr/" );
794
794
strcat (WS._topic_description_status_complete , _device_uid);
795
- strcat (WS._topic_description_status_complete , TOPIC_DESCRIPTION );
795
+ strcat (WS._topic_description_status_complete , TOPIC_INFO );
796
796
strcat (WS._topic_description_status_complete , " status" );
797
797
strcat (WS._topic_description_status_complete , " /device/complete" );
798
798
} else { // malloc failed
@@ -941,7 +941,6 @@ void Wippersnapper::haltError(String error) {
941
941
*/
942
942
/* *************************************************************************/
943
943
bool Wippersnapper::registerBoard () {
944
- bool is_success = false ;
945
944
WS_DEBUG_PRINTLN (" Registering hardware with IO..." );
946
945
947
946
// Encode and publish registration request message to broker
@@ -1065,18 +1064,20 @@ void Wippersnapper::connect() {
1065
1064
// enable WDT
1066
1065
enableWDT (WS_WDT_TIMEOUT);
1067
1066
1067
+ // TODO!
1068
1068
// not sure we need to track these...
1069
1069
_status = WS_IDLE;
1070
1070
WS._boardStatus = WS_BOARD_DEF_IDLE;
1071
1071
1072
- // build MQTT topics for WipperSnapper app, and subscribe
1072
+ // build MQTT topics for WipperSnapper and subscribe
1073
1073
if (!buildWSTopics ()) {
1074
1074
haltError (" Unable to allocate space for MQTT topics" );
1075
1075
}
1076
- subscribeWSTopics ();
1077
1076
if (!buildErrorTopics ()) {
1078
1077
haltError (" Unable to allocate space for MQTT error topics" );
1079
1078
}
1079
+ WS_DEBUG_PRINTLN (" Subscribing to MQTT topics..." );
1080
+ subscribeWSTopics ();
1080
1081
subscribeErrorTopics ();
1081
1082
1082
1083
// Run the network fsm
@@ -1096,7 +1097,8 @@ void Wippersnapper::connect() {
1096
1097
// Configure hardware
1097
1098
WS.pinCfgCompleted = false ;
1098
1099
while (!WS.pinCfgCompleted ) {
1099
- WS_DEBUG_PRINTLN (" Polling for message containing hardware configuration..." );
1100
+ WS_DEBUG_PRINTLN (
1101
+ " Polling for message containing hardware configuration..." );
1100
1102
WS._mqtt ->processPackets (10 ); // poll
1101
1103
}
1102
1104
// Publish that we have completed the configuration workflow
0 commit comments