🚧 WIP - Decode checkin response
This commit is contained in:
parent
9b67169e56
commit
74b2cc1fc6
5 changed files with 24 additions and 45 deletions
|
|
@ -286,6 +286,20 @@ bool cbDecodeBrokerToDevice(pb_istream_t *stream, const pb_field_t *field,
|
|||
switch (field->tag) {
|
||||
case wippersnapper_signal_BrokerToDevice_checkin_response_tag:
|
||||
WS_DEBUG_PRINTLN("GOT: Checkin Response");
|
||||
// todo: prints are for debug, remove after behavior is confirmed
|
||||
WS_DEBUG_PRINTLN("Decoding Checkin Response...");
|
||||
WsV2.CheckInModel->DecodeCheckinResponse(stream);
|
||||
WS_DEBUG_PRINTLN("Parsing checkin response...");
|
||||
WsV2.CheckInModel->ParseCheckinResponse();
|
||||
WS_DEBUG_PRINTLN("Checkin Response Decoded!");
|
||||
WS_DEBUG_PRINT("total gpio pins: ");
|
||||
WS_DEBUG_PRINTLN(WsV2.CheckInModel->getTotalGPIOPins());
|
||||
WS_DEBUG_PRINT("total analog pins: ");
|
||||
WS_DEBUG_PRINTLN(WsV2.CheckInModel->getTotalAnalogPins());
|
||||
WS_DEBUG_PRINT("reference voltage: ");
|
||||
WS_DEBUG_PRINTLN(WsV2.CheckInModel->getReferenceVoltage());
|
||||
// set flag so we don't keep the polling loop open
|
||||
WsV2.got_checkin_response = true;
|
||||
break;
|
||||
default:
|
||||
WS_DEBUG_PRINTLN("ERROR: BrokerToDevice message type not found!");
|
||||
|
|
@ -827,12 +841,12 @@ bool Wippersnapper_V2::PublishCheckinRequest() {
|
|||
return false;
|
||||
|
||||
WS_DEBUG_PRINTLN("Listening for new packets!");
|
||||
bool gotPacket = false;
|
||||
while (!gotPacket) {
|
||||
WsV2.feedWDTV2();
|
||||
WsV2._mqttV2->processPackets(10); // 1min poll for incoming packets
|
||||
WsV2.got_checkin_response = false;
|
||||
while (!WsV2.got_checkin_response) {
|
||||
runNetFSMV2();
|
||||
WsV2._mqttV2->processPackets(10); // fast poll for incoming packets
|
||||
}
|
||||
WS_DEBUG_PRINTLN("Timed out listening for new packets!");
|
||||
WS_DEBUG_PRINTLN("Got and processed the checkin response!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,9 +262,11 @@ public:
|
|||
#ifdef ARDUINO_ARCH_ESP32
|
||||
ws_ledc *_ledcV2 = nullptr; ///< Pointer to LEDC object
|
||||
#endif
|
||||
bool got_checkin_response;
|
||||
|
||||
private:
|
||||
void _initV2();
|
||||
|
||||
// MQTT topics
|
||||
char *_topicB2d;
|
||||
char *_topicD2b;
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmprqswwnpf"
|
||||
#include <Arduino.h>
|
||||
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
|
||||
# 16 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
|
||||
#include "ws_manager.h"
|
||||
|
||||
|
||||
Wippersnapper_Manager manager;
|
||||
|
||||
|
||||
#define WS_DEBUG
|
||||
|
||||
|
||||
#define API_PIN 0
|
||||
void setup();
|
||||
void loop();
|
||||
#line 27 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
|
||||
void setup() {
|
||||
|
||||
manager.checkAPIVersion(API_PIN);
|
||||
manager.provision();
|
||||
|
||||
Serial.begin(115200);
|
||||
while(!Serial) {;}
|
||||
Serial.println("Adafruit Wippersnapper API Manager Demo");
|
||||
Serial.print("Running Wippersnapper API Version: ");
|
||||
Serial.println(manager.getAPIVersion());
|
||||
manager.connect();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
|
@ -73,11 +73,8 @@ bool CheckinModel::EncodeCheckinRequest() {
|
|||
&_CheckinRequest);
|
||||
}
|
||||
|
||||
bool CheckinModel::DecodeCheckinResponse(uint8_t *buf, size_t len) {
|
||||
// Create a stream that reads from a buffer.
|
||||
pb_istream_t stream = pb_istream_from_buffer(buf, len);
|
||||
// Decode the message.
|
||||
return pb_decode(&stream, wippersnapper_checkin_CheckinResponse_fields,
|
||||
bool CheckinModel::DecodeCheckinResponse(pb_istream_t *stream) {
|
||||
return pb_decode(stream, wippersnapper_checkin_CheckinResponse_fields,
|
||||
&_CheckinResponse);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public:
|
|||
void CreateCheckinRequest(const char *hardware_uid,
|
||||
const char *firmware_version);
|
||||
bool EncodeCheckinRequest();
|
||||
bool DecodeCheckinResponse(uint8_t *buf, size_t len);
|
||||
bool DecodeCheckinResponse(pb_istream_t *stream);
|
||||
void ParseCheckinResponse();
|
||||
// TODO: Do we need this?
|
||||
wippersnapper_checkin_CheckinRequest GetCheckinRequest() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue