Skip to content

Commit 44184fd

Browse files
authored
Merge pull request #158 from adafruit/small-updates
Small updates for beta.11
2 parents 9a5b56a + 3c09a55 commit 44184fd

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

src/Wippersnapper.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -733,41 +733,41 @@ bool Wippersnapper::buildWSTopics() {
733733
// Global registration topic
734734
WS._topic_description =
735735
(char *)malloc(sizeof(char) * strlen(WS._username) + strlen("/wprsnpr") +
736-
strlen(TOPIC_DESCRIPTION) + strlen("status") + 1);
736+
strlen(TOPIC_INFO) + strlen("status") + 1);
737737

738738
// 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);
743743

744744
// 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);
749749

750750
// 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);
755755

756756
// Topic for signals from device to broker
757757
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);
760760

761761
// Topic for signals from broker to device
762762
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);
765765

766766
// Create global registration topic
767767
if (WS._topic_description) {
768768
strcpy(WS._topic_description, WS._username);
769769
strcat(WS._topic_description, "/wprsnpr");
770-
strcat(WS._topic_description, TOPIC_DESCRIPTION);
770+
strcat(WS._topic_description, TOPIC_INFO);
771771
strcat(WS._topic_description, "status");
772772
} else { // malloc failed
773773
WS._topic_description = 0;
@@ -779,7 +779,7 @@ bool Wippersnapper::buildWSTopics() {
779779
strcpy(WS._topic_description_status, WS._username);
780780
strcat(WS._topic_description_status, "/wprsnpr/");
781781
strcat(WS._topic_description_status, _device_uid);
782-
strcat(WS._topic_description_status, TOPIC_DESCRIPTION);
782+
strcat(WS._topic_description_status, TOPIC_INFO);
783783
strcat(WS._topic_description_status, "status");
784784
strcat(WS._topic_description_status, "/broker");
785785
} else { // malloc failed
@@ -792,7 +792,7 @@ bool Wippersnapper::buildWSTopics() {
792792
strcpy(WS._topic_description_status_complete, WS._username);
793793
strcat(WS._topic_description_status_complete, "/wprsnpr/");
794794
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);
796796
strcat(WS._topic_description_status_complete, "status");
797797
strcat(WS._topic_description_status_complete, "/device/complete");
798798
} else { // malloc failed
@@ -941,7 +941,6 @@ void Wippersnapper::haltError(String error) {
941941
*/
942942
/**************************************************************************/
943943
bool Wippersnapper::registerBoard() {
944-
bool is_success = false;
945944
WS_DEBUG_PRINTLN("Registering hardware with IO...");
946945

947946
// Encode and publish registration request message to broker
@@ -1065,18 +1064,20 @@ void Wippersnapper::connect() {
10651064
// enable WDT
10661065
enableWDT(WS_WDT_TIMEOUT);
10671066

1067+
// TODO!
10681068
// not sure we need to track these...
10691069
_status = WS_IDLE;
10701070
WS._boardStatus = WS_BOARD_DEF_IDLE;
10711071

1072-
// build MQTT topics for WipperSnapper app, and subscribe
1072+
// build MQTT topics for WipperSnapper and subscribe
10731073
if (!buildWSTopics()) {
10741074
haltError("Unable to allocate space for MQTT topics");
10751075
}
1076-
subscribeWSTopics();
10771076
if (!buildErrorTopics()) {
10781077
haltError("Unable to allocate space for MQTT error topics");
10791078
}
1079+
WS_DEBUG_PRINTLN("Subscribing to MQTT topics...");
1080+
subscribeWSTopics();
10801081
subscribeErrorTopics();
10811082

10821083
// Run the network fsm
@@ -1096,7 +1097,8 @@ void Wippersnapper::connect() {
10961097
// Configure hardware
10971098
WS.pinCfgCompleted = false;
10981099
while (!WS.pinCfgCompleted) {
1099-
WS_DEBUG_PRINTLN("Polling for message containing hardware configuration...");
1100+
WS_DEBUG_PRINTLN(
1101+
"Polling for message containing hardware configuration...");
11001102
WS._mqtt->processPackets(10); // poll
11011103
}
11021104
// Publish that we have completed the configuration workflow

src/Wippersnapper.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@
6464
#endif
6565

6666
#define WS_VERSION \
67-
"1.0.0-beta.10" ///< WipperSnapper app. version (semver-formatted)
67+
"1.0.0-beta.11" ///< WipperSnapper app. version (semver-formatted)
6868

6969
// Reserved Adafruit IO MQTT topics
7070
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic
7171
#define TOPIC_IO_ERRORS "/errors" ///< Adafruit IO Error MQTT Topic
7272

7373
// Reserved Wippersnapper topics
74-
#define TOPIC_WS "/wprsnpr/" ///< Global /wprsnpr/ topic
75-
#define TOPIC_DESCRIPTION "/info/" ///< Device description topic
76-
#define TOPIC_SIGNALS "/signals/" ///< Device signals topic
74+
#define TOPIC_WS "/wprsnpr/" ///< Global /wprsnpr/ topic
75+
#define TOPIC_INFO "/info/" ///< Device description topic
76+
#define TOPIC_SIGNALS "/signals/" ///< Device signals topic
7777

7878
#define WS_DEBUG ///< Define to enable debugging to serial terminal
7979
#define WS_PRINTER Serial ///< Where debug messages will be printed
@@ -154,7 +154,7 @@ typedef enum {
154154
4000 ///< Session keepalive interval time, in milliseconds
155155

156156
#define WS_MQTT_MAX_PAYLOAD_SIZE \
157-
300 ///< MAXIMUM expected payload size, in bytes
157+
512 ///< MAXIMUM expected payload size, in bytes
158158

159159
class Wippersnapper_DigitalGPIO;
160160
class Wippersnapper_AnalogIO;
@@ -259,7 +259,7 @@ class Wippersnapper {
259259
Wippersnapper_ESP32_nvs *_nvs; ///< Instance of nvs
260260

261261
uint8_t _uid[6]; /*!< Unique network iface identifier */
262-
char sUID[10]; /*!< Unique network iface identifier */
262+
char sUID[13]; /*!< Unique network iface identifier */
263263
const char *_boardId; /*!< Adafruit IO+ board string */
264264
Adafruit_MQTT *_mqtt; /*!< Reference to Adafruit_MQTT, _mqtt. */
265265
char *_topic_description; /*!< MQTT topic for the device description */

src/components/register/Wippersnapper_Register.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool Wippersnapper::encodePubRegistrationReq() {
4242
strcpy(_message.str_version, WS_VERSION);
4343

4444
// encode registration request message
45-
uint8_t _message_buffer[128];
45+
uint8_t _message_buffer[256];
4646
pb_ostream_t _msg_stream =
4747
pb_ostream_from_buffer(_message_buffer, sizeof(_message_buffer));
4848

@@ -80,8 +80,7 @@ void Wippersnapper::pollRegistrationResp() {
8080
while (WS._boardStatus != WS_BOARD_DEF_OK) {
8181
WS_DEBUG_PRINT("Polling for registration message response...");
8282
WS_DEBUG_PRINTLN(WS._boardStatus);
83-
WS._mqtt->processPackets(10); // poll
84-
// WS._mqtt->ping(); // keepalive
83+
WS._mqtt->processPackets(20); // long-poll
8584
}
8685
}
8786

src/components/statusLED/Wippersnapper_StatusLED_Colors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define BLUE 0x0000FF ///< Blue (as a uint32)
2323

2424
// colors for each status state
25-
#define LED_NET_CONNECT CYAN ///< Network connection state
25+
#define LED_NET_CONNECT PINK ///< Network connection state
2626
#define LED_IO_CONNECT BLUE ///< MQTT broker connection state
2727
#define LED_IO_REGISTER_HW YELLOW ///< Hardware registration state
2828
#define LED_CONNECTED GREEN ///< Successful registration state

0 commit comments

Comments
 (0)