refactor to wippersnapper
This commit is contained in:
parent
da44044b17
commit
6ed9af4baa
9 changed files with 123 additions and 123 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# BlinkaConnect_Arduino
|
||||
Arduino Library for BlinkaConnect web application.
|
||||
# WipperSnapper_Arduino
|
||||
Arduino Library for WipperSnapper web application.
|
||||
|
||||
## Adding Hardware
|
||||
[Hardware Specification for adding boards to BlinkaConnect](https://github.com/adafruit/BlinkaConnect_Boards)
|
||||
[Hardware Specification for adding boards to WipperSnapper](https://github.com/adafruit/WipperSnapper_Boards)
|
||||
|
||||
Communication between this library and the MQTT broker uses protocol buffers for serialized data. The raw protocol buffers used by this project are located [here](https://github.com/adafruit/BlinkaConnect_ProtoBuf). This library contains compiled `.pb.h` and `.pb.c` protocol buffer messages generated by [nanopb](https://github.com/nanopb/nanopb).
|
||||
Communication between this library and the MQTT broker uses protocol buffers for serialized data. The raw protocol buffers used by this project are located [here](https://github.com/adafruit/WipperSnapper_ProtoBuf). This library contains compiled `.pb.h` and `.pb.c` protocol buffer messages generated by [nanopb](https://github.com/nanopb/nanopb).
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// BlinkaConnect Example
|
||||
// WipperSnapper Example
|
||||
//
|
||||
// Adafruit invests time and resources providing this open source code.
|
||||
// Please support Adafruit and open source hardware by purchasing
|
||||
|
|
@ -19,7 +19,7 @@ void setup() {
|
|||
// wait for serial monitor to open
|
||||
while(! Serial);
|
||||
|
||||
Serial.print("Connecting to Adafruit BlinkaConnect");
|
||||
Serial.print("Connecting to Adafruit WipperSnapper");
|
||||
|
||||
bc.connect();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "BlinkaConnect_Networking.h"
|
||||
#include "WipperSnapper_Networking.h"
|
||||
|
||||
/******** WiFi *************/
|
||||
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
#define NINA_GPIO0 6 // Not connected
|
||||
#endif
|
||||
|
||||
BlinkaConnect_WiFi bc(WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
|
||||
WipperSnapper_WiFi bc(WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
|
||||
NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
|
||||
#else
|
||||
BlinkaConnect_WiFi bc(WIFI_SSID, WIFI_PASS);
|
||||
WipperSnapper_WiFi bc(WIFI_SSID, WIFI_PASS);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
name=Adafruit BlinkaConnect
|
||||
name=Adafruit WipperSnapper
|
||||
version=0.0.1
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <adafruitio@adafruit.com>
|
||||
sentence=Arduino library to access BlinkaConnect
|
||||
paragraph=Arduino library to access BlinkaConnect
|
||||
sentence=Arduino library to access WipperSnapper
|
||||
paragraph=Arduino library to access WipperSnapper
|
||||
category=Communication
|
||||
url=https://github.com/adafruit/Adafruit_IO_Arduino
|
||||
architectures=*
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/*!
|
||||
* @file BlinkaConnect.cpp
|
||||
* @file WipperSnapper.cpp
|
||||
*
|
||||
* @mainpage Adafruit BlinkaConnect Wrapper
|
||||
* @mainpage Adafruit WipperSnapper Wrapper
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* This is the documentation for Adafruit's BlinkaConnect wrapper for the
|
||||
* This is the documentation for Adafruit's WipperSnapper wrapper for the
|
||||
* Arduino platform. It is designed specifically to work with the
|
||||
* Adafruit IO+ BlinkaConnect IoT platform.
|
||||
* Adafruit IO+ WipperSnapper IoT platform.
|
||||
*
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
|
|
@ -30,22 +30,22 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "BlinkaConnect.h"
|
||||
#include "WipperSnapper.h"
|
||||
|
||||
bc_board_status_t _boardStatus; // TODO: move to header
|
||||
ws_board_status_t _boardStatus; // TODO: move to header
|
||||
|
||||
uint16_t BlinkaConnect::bufSize;
|
||||
uint8_t BlinkaConnect::_buffer[128];
|
||||
char BlinkaConnect:: _value[45];
|
||||
Timer<16U, &millis, char *> BlinkaConnect::t_timer;
|
||||
BlinkaConnect::pinInfo BlinkaConnect::bc_pinInfo;
|
||||
char BlinkaConnect::timerPin[3];
|
||||
uint16_t WipperSnapper::bufSize;
|
||||
uint8_t WipperSnapper::_buffer[128];
|
||||
char WipperSnapper:: _value[45];
|
||||
Timer<16U, &millis, char *> WipperSnapper::t_timer;
|
||||
WipperSnapper::pinInfo WipperSnapper::ws_pinInfo;
|
||||
char WipperSnapper::timerPin[3];
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Instantiates the BlinkaConnect client object.
|
||||
@brief Instantiates the WipperSnapper client object.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
BlinkaConnect::BlinkaConnect() {
|
||||
WipperSnapper::WipperSnapper() {
|
||||
_mqtt = 0; // MQTT Client object
|
||||
_deviceId = "myDevice"; // Adafruit IO+ device name
|
||||
_hw_vid = 0; // Hardware's usb vendor id
|
||||
|
|
@ -62,10 +62,10 @@ BlinkaConnect::BlinkaConnect() {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initializes BlinkaConnect object
|
||||
@brief Initializes WipperSnapper object
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void BlinkaConnect::_init() {
|
||||
void WipperSnapper::_init() {
|
||||
// dynamically allocate memory for reserved topics
|
||||
_topic_description = (char *)malloc(sizeof(char) * strlen(_deviceId) + strlen(TOPIC_DESCRIPTION) + strlen("/devices/") + 1);
|
||||
_topic_description_status = (char *)malloc(sizeof(char) * strlen(_deviceId) + strlen(TOPIC_SIGNALS) + strlen("/devices/") + strlen("/status") + 1);
|
||||
|
|
@ -109,10 +109,10 @@ void BlinkaConnect::_init() {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief BlinkaConnect destructor
|
||||
@brief WipperSnapper destructor
|
||||
*/
|
||||
/**************************************************************************/
|
||||
BlinkaConnect::~BlinkaConnect() {
|
||||
WipperSnapper::~WipperSnapper() {
|
||||
// re-allocate topics
|
||||
free(_topic_description);
|
||||
free(_topic_signals_in);
|
||||
|
|
@ -127,7 +127,7 @@ BlinkaConnect::~BlinkaConnect() {
|
|||
array is used as an unique identifier for the message type.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::encode_unionmessage(pb_ostream_t *stream, const pb_msgdesc_t *messagetype, void *message)
|
||||
bool WipperSnapper::encode_unionmessage(pb_ostream_t *stream, const pb_msgdesc_t *messagetype, void *message)
|
||||
{
|
||||
pb_field_iter_t iter;
|
||||
|
||||
|
|
@ -153,15 +153,15 @@ bool BlinkaConnect::encode_unionmessage(pb_ostream_t *stream, const pb_msgdesc_t
|
|||
@brief ISR which reads the value of a digital pin and updates pinInfo.
|
||||
*/
|
||||
/****************************************************************************/
|
||||
bool BlinkaConnect::cbDigitalRead(char *pinName) {
|
||||
bool WipperSnapper::cbDigitalRead(char *pinName) {
|
||||
BC_DEBUG_PRINT("cbDigitalRead(");BC_DEBUG_PRINT(pinName);BC_DEBUG_PRINTLN(")");
|
||||
|
||||
// Read and store pinName into struct.
|
||||
bc_pinInfo.pinValue = digitalRead((unsigned)atoi(pinName));
|
||||
ws_pinInfo.pinValue = digitalRead((unsigned)atoi(pinName));
|
||||
|
||||
// debug TODO remove
|
||||
BC_DEBUG_PRINT("Pin Values: "); BC_DEBUG_PRINT(bc_pinInfo.pinValue);
|
||||
BC_DEBUG_PRINT(" "); BC_DEBUG_PRINTLN(bc_pinInfo.prvPinValue);
|
||||
BC_DEBUG_PRINT("Pin Values: "); BC_DEBUG_PRINT(ws_pinInfo.pinValue);
|
||||
BC_DEBUG_PRINT(" "); BC_DEBUG_PRINTLN(ws_pinInfo.prvPinValue);
|
||||
return true; // repeat every xMS
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ bool BlinkaConnect::cbDigitalRead(char *pinName) {
|
|||
otherwise false;
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::sendPinEvent() {
|
||||
bool WipperSnapper::sendPinEvent() {
|
||||
uint8_t buffer[128]; // message buffer, TODO: Make this a shared buffer
|
||||
bool status = false;
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ bool BlinkaConnect::sendPinEvent() {
|
|||
// Encode payload
|
||||
strcpy(msg.pin_name, "D"); // TODO: hotfix for broker to identify in desc., remove
|
||||
strcat(msg.pin_name, timerPin);
|
||||
itoa(bc_pinInfo.pinValue, msg.pin_value, 10);
|
||||
itoa(ws_pinInfo.pinValue, msg.pin_value, 10);
|
||||
|
||||
// Encode PinEventRequest message
|
||||
status = encode_unionmessage(&stream, pin_v1_PinEventRequest_fields, &msg);
|
||||
|
|
@ -208,7 +208,7 @@ bool BlinkaConnect::sendPinEvent() {
|
|||
*/
|
||||
/**************************************************************************/
|
||||
// Process pin events from the broker
|
||||
bool BlinkaConnect::pinEvent() {
|
||||
bool WipperSnapper::pinEvent() {
|
||||
// strip "D" or "A" from "circuitpython-style" pin_name
|
||||
char* pinName = signalMessage.payload.pin_event.pin_name + 1;
|
||||
// Set pin value
|
||||
|
|
@ -223,17 +223,17 @@ bool BlinkaConnect::pinEvent() {
|
|||
@brief Configures a pin's mode, direction, pull and period.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::pinConfig()
|
||||
bool WipperSnapper::pinConfig()
|
||||
{
|
||||
BC_DEBUG_PRINT("Pin Name: ");BC_DEBUG_PRINTLN(signalMessage.payload.pin_config.pin_name);
|
||||
BC_DEBUG_PRINT("Mode: ");BC_DEBUG_PRINTLN(signalMessage.payload.pin_config.mode);
|
||||
BC_DEBUG_PRINT("Direction : ");BC_DEBUG_PRINTLN(signalMessage.payload.pin_config.direction);
|
||||
BC_DEBUG_PRINT("Pull enabled: ");BC_DEBUG_PRINTLN(signalMessage.payload.pin_config.pull);
|
||||
|
||||
bc_pinInfo.PinNameFull = signalMessage.payload.pin_config.pin_name;
|
||||
ws_pinInfo.PinNameFull = signalMessage.payload.pin_config.pin_name;
|
||||
// strip "D" or "A" from "circuitpython-style" pin_name
|
||||
char* pinName = signalMessage.payload.pin_config.pin_name + 1;
|
||||
bc_pinInfo.pinName = pinName;
|
||||
ws_pinInfo.pinName = pinName;
|
||||
|
||||
// TODO: Check for pullup, configure!
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ bool BlinkaConnect::pinConfig()
|
|||
auto task = t_timer.every(timerMs, cbDigitalRead, timerPin);
|
||||
}
|
||||
BC_DEBUG_PRINTLN("Configuring digital pin direction");
|
||||
pinMode(atoi(bc_pinInfo.pinName), signalMessage.payload.pin_config.direction);
|
||||
pinMode(atoi(ws_pinInfo.pinName), signalMessage.payload.pin_config.direction);
|
||||
break;
|
||||
default:
|
||||
BC_DEBUG_PRINTLN("Unable to obtain pin configuration from message.")
|
||||
|
|
@ -273,7 +273,7 @@ bool BlinkaConnect::pinConfig()
|
|||
payload and payload length.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void BlinkaConnect::cbSignalTopic(char *data, uint16_t len) {
|
||||
void WipperSnapper::cbSignalTopic(char *data, uint16_t len) {
|
||||
BC_DEBUG_PRINTLN("cbSignalTopic()");
|
||||
memcpy(_buffer, data, len);
|
||||
bufSize = len;
|
||||
|
|
@ -285,7 +285,7 @@ void BlinkaConnect::cbSignalTopic(char *data, uint16_t len) {
|
|||
NOTE: Should be executed in-order after a new _buffer is recieved.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::decodeSignalMessage() {
|
||||
bool WipperSnapper::decodeSignalMessage() {
|
||||
// create a stream which reads from buffer
|
||||
pb_istream_t stream = pb_istream_from_buffer(_buffer, bufSize);
|
||||
// decode the message
|
||||
|
|
@ -305,7 +305,7 @@ bool BlinkaConnect::decodeSignalMessage() {
|
|||
type.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::executeSignalMessageEvent() {
|
||||
bool WipperSnapper::executeSignalMessageEvent() {
|
||||
// Executes signal message event based on payload type
|
||||
switch(signalMessage.which_payload) {
|
||||
case signal_v1_CreateSignalRequest_pin_config_tag:
|
||||
|
|
@ -379,10 +379,10 @@ void cbDescriptionStatus(char *data, uint16_t len) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Connects to Adafruit IO+ BlinkaConnect broker.
|
||||
@brief Connects to Adafruit IO+ WipperSnapper broker.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void BlinkaConnect::connect() {
|
||||
void WipperSnapper::connect() {
|
||||
BC_DEBUG_PRINTLN("::connect()");
|
||||
_status = BC_IDLE;
|
||||
_boardStatus = BC_BOARD_DEF_IDLE;
|
||||
|
|
@ -404,7 +404,7 @@ void BlinkaConnect::connect() {
|
|||
// subscribe
|
||||
_mqtt->subscribe(_topic_description_sub);
|
||||
|
||||
BC_DEBUG_PRINT("Connecting to BlinkaConnect.");
|
||||
BC_DEBUG_PRINT("Connecting to WipperSnapper.");
|
||||
|
||||
// Connect network interface
|
||||
_connect();
|
||||
|
|
@ -426,10 +426,10 @@ void BlinkaConnect::connect() {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Disconnects from Adafruit IO+ BlinkaConnect.
|
||||
@brief Disconnects from Adafruit IO+ WipperSnapper.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void BlinkaConnect::disconnect() {
|
||||
void WipperSnapper::disconnect() {
|
||||
_disconnect();
|
||||
}
|
||||
|
||||
|
|
@ -438,7 +438,7 @@ void BlinkaConnect::disconnect() {
|
|||
@brief Checks and handles network interface connection.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_status_t BlinkaConnect::checkNetworkConnection(uint32_t timeStart) {
|
||||
ws_status_t WipperSnapper::checkNetworkConnection(uint32_t timeStart) {
|
||||
if (status() < BC_NET_CONNECTED) {
|
||||
BC_DEBUG_PRINTLN("connection failed, reconnecting...");
|
||||
unsigned long startRetry = millis();
|
||||
|
|
@ -461,7 +461,7 @@ bc_status_t BlinkaConnect::checkNetworkConnection(uint32_t timeStart) {
|
|||
@brief Checks and handles connection to MQTT broker.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_status_t BlinkaConnect::checkMQTTConnection(uint32_t timeStart) {
|
||||
ws_status_t WipperSnapper::checkMQTTConnection(uint32_t timeStart) {
|
||||
while(mqttStatus() != BC_CONNECTED && millis() - timeStart < 60000) {
|
||||
}
|
||||
if (mqttStatus() != BC_CONNECTED) {
|
||||
|
|
@ -475,7 +475,7 @@ bc_status_t BlinkaConnect::checkMQTTConnection(uint32_t timeStart) {
|
|||
@brief Pings MQTT broker to keep connection alive.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void BlinkaConnect::ping() {
|
||||
void WipperSnapper::ping() {
|
||||
if (millis() > (_prv_ping + 60000)) {
|
||||
_mqtt->ping();
|
||||
_prv_ping = millis();
|
||||
|
|
@ -487,7 +487,7 @@ void BlinkaConnect::ping() {
|
|||
@brief Processes incoming commands and handles network connection.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_status_t BlinkaConnect::run() {
|
||||
ws_status_t WipperSnapper::run() {
|
||||
uint32_t timeStart = millis();
|
||||
// increment software timer
|
||||
t_timer.tick();
|
||||
|
|
@ -500,7 +500,7 @@ bc_status_t BlinkaConnect::run() {
|
|||
// Ping broker if keepalive elapsed
|
||||
ping();
|
||||
|
||||
// Process all incoming packets from BlinkaConnect MQTT Broker
|
||||
// Process all incoming packets from WipperSnapper MQTT Broker
|
||||
_mqtt->processPackets(500);
|
||||
|
||||
// Handle incoming signal message
|
||||
|
|
@ -521,11 +521,11 @@ bc_status_t BlinkaConnect::run() {
|
|||
memcpy(_buffer_state, _buffer, sizeof(_buffer));
|
||||
}
|
||||
// Send updated pin value to broker
|
||||
if ( bc_pinInfo.pinValue != bc_pinInfo.prvPinValue ) {
|
||||
BC_DEBUG_PRINT("Pin Values: "); BC_DEBUG_PRINT(bc_pinInfo.pinValue);
|
||||
BC_DEBUG_PRINT(" "); BC_DEBUG_PRINT(bc_pinInfo.prvPinValue);
|
||||
if ( ws_pinInfo.pinValue != ws_pinInfo.prvPinValue ) {
|
||||
BC_DEBUG_PRINT("Pin Values: "); BC_DEBUG_PRINT(ws_pinInfo.pinValue);
|
||||
BC_DEBUG_PRINT(" "); BC_DEBUG_PRINT(ws_pinInfo.prvPinValue);
|
||||
sendPinEvent();
|
||||
bc_pinInfo.prvPinValue = bc_pinInfo.pinValue;
|
||||
ws_pinInfo.prvPinValue = ws_pinInfo.pinValue;
|
||||
}
|
||||
|
||||
return status();
|
||||
|
|
@ -533,10 +533,10 @@ bc_status_t BlinkaConnect::run() {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Sends board description message to BlinkaConnect
|
||||
@brief Sends board description message to WipperSnapper
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool BlinkaConnect::sendBoardDescription() {
|
||||
bool WipperSnapper::sendBoardDescription() {
|
||||
BC_DEBUG_PRINT("Publishing board description...");
|
||||
uint8_t buffer[128]; // message stored in this buffer
|
||||
size_t message_length;
|
||||
|
|
@ -574,7 +574,7 @@ bool BlinkaConnect::sendBoardDescription() {
|
|||
@brief Sends board description message and verifies broker's response
|
||||
*/
|
||||
/***************************************************************************/
|
||||
bool BlinkaConnect::sendGetHardwareDescription(){
|
||||
bool WipperSnapper::sendGetHardwareDescription(){
|
||||
// Send hardware characteristics to broker
|
||||
if (!sendBoardDescription()) {
|
||||
_boardStatus = BC_BOARD_DEF_SEND_FAILED;
|
||||
|
|
@ -595,11 +595,11 @@ bool BlinkaConnect::sendGetHardwareDescription(){
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Returns the network status.
|
||||
@return BlinkaConnect network status.
|
||||
@return WipperSnapper network status.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_status_t BlinkaConnect::status() {
|
||||
bc_status_t net_status = networkStatus();
|
||||
ws_status_t WipperSnapper::status() {
|
||||
ws_status_t net_status = networkStatus();
|
||||
|
||||
// if we aren't connected, return network status
|
||||
if (net_status != BC_NET_CONNECTED) {
|
||||
|
|
@ -615,10 +615,10 @@ bc_status_t BlinkaConnect::status() {
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Returns the board definition status
|
||||
@return BlinkaConnect board definition status
|
||||
@return WipperSnapper board definition status
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_board_status_t BlinkaConnect::getBoardStatus() {
|
||||
ws_board_status_t WipperSnapper::getBoardStatus() {
|
||||
return _boardStatus;
|
||||
}
|
||||
|
||||
|
|
@ -628,7 +628,7 @@ bc_board_status_t BlinkaConnect::getBoardStatus() {
|
|||
@return True if connected, otherwise False.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bc_status_t BlinkaConnect::mqttStatus() {
|
||||
ws_status_t WipperSnapper::mqttStatus() {
|
||||
// if the connection failed,
|
||||
// return so we don't hammer IO
|
||||
if (_status == BC_CONNECT_FAILED) {
|
||||
|
|
@ -675,7 +675,7 @@ bc_status_t BlinkaConnect::mqttStatus() {
|
|||
value
|
||||
*/
|
||||
/**************************************************************************/
|
||||
const __FlashStringHelper *BlinkaConnect::statusText() {
|
||||
const __FlashStringHelper *WipperSnapper::statusText() {
|
||||
switch (_status) {
|
||||
// CONNECTING
|
||||
case BC_IDLE:
|
||||
|
|
@ -683,29 +683,29 @@ const __FlashStringHelper *BlinkaConnect::statusText() {
|
|||
case BC_NET_DISCONNECTED:
|
||||
return F("Network disconnected.");
|
||||
case BC_DISCONNECTED:
|
||||
return F("Disconnected from BlinkaConnect.");
|
||||
return F("Disconnected from WipperSnapper.");
|
||||
// FAILURE
|
||||
case BC_NET_CONNECT_FAILED:
|
||||
return F("Network connection failed.");
|
||||
case BC_CONNECT_FAILED:
|
||||
return F("BlinkaConnect connection failed.");
|
||||
return F("WipperSnapper connection failed.");
|
||||
case BC_FINGERPRINT_INVALID:
|
||||
return F("BlinkaConnect SSL fingerprint verification failed.");
|
||||
return F("WipperSnapper SSL fingerprint verification failed.");
|
||||
case BC_AUTH_FAILED:
|
||||
return F("BlinkaConnect authentication failed.");
|
||||
return F("WipperSnapper authentication failed.");
|
||||
// SUCCESS
|
||||
case BC_NET_CONNECTED:
|
||||
return F("Network connected.");
|
||||
case BC_CONNECTED:
|
||||
return F("BlinkaConnect connected.");
|
||||
return F("WipperSnapper connected.");
|
||||
case BC_CONNECTED_INSECURE:
|
||||
return F("BlinkaConnect connected. **THIS CONNECTION IS INSECURE** SSL/TLS "
|
||||
return F("WipperSnapper connected. **THIS CONNECTION IS INSECURE** SSL/TLS "
|
||||
"not supported for this platform.");
|
||||
case BC_FINGERPRINT_UNSUPPORTED:
|
||||
return F("BlinkaConnect connected over SSL/TLS. Fingerprint verification "
|
||||
return F("WipperSnapper connected over SSL/TLS. Fingerprint verification "
|
||||
"unsupported.");
|
||||
case BC_FINGERPRINT_VALID:
|
||||
return F("BlinkaConnect connected over SSL/TLS. Fingerprint valid.");
|
||||
return F("WipperSnapper connected over SSL/TLS. Fingerprint valid.");
|
||||
default:
|
||||
return F("Unknown status code");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef BLINKACONNECT_H
|
||||
#define BLINKACONNECT_H
|
||||
#ifndef WIPPERSNAPPER_H
|
||||
#define WIPPERSNAPPER_H
|
||||
|
||||
// Nanopb
|
||||
#include <nanopb/pb_common.h>
|
||||
|
|
@ -33,9 +33,9 @@
|
|||
#include <arduino-timer.h>
|
||||
|
||||
// Internal libraries
|
||||
#include "BlinkaConnect_Boards.h"
|
||||
#include "WipperSnapper_Boards.h"
|
||||
|
||||
// Reserved BlinkaConnect topics
|
||||
// Reserved WipperSnapper topics
|
||||
#define TOPIC_DESCRIPTION "/description" ///< Device description topic
|
||||
#define TOPIC_SIGNALS "/signals/" ///< Device signals topic
|
||||
|
||||
|
|
@ -75,9 +75,9 @@ typedef enum {
|
|||
BC_FINGERPRINT_VALID = 24, // Valid BC_SSL_FINGERPRINT
|
||||
|
||||
BC_BOARD_DESC_INVALID = 25 // Unable to send board description
|
||||
} bc_status_t;
|
||||
} ws_status_t;
|
||||
|
||||
// BlinkaConnect board definition status
|
||||
// WipperSnapper board definition status
|
||||
typedef enum {
|
||||
BC_BOARD_DEF_IDLE,
|
||||
BC_BOARD_DEF_SEND_FAILED,
|
||||
|
|
@ -86,15 +86,15 @@ typedef enum {
|
|||
BC_BOARD_DEF_INAVLID_VID,
|
||||
BC_BOARD_DEF_INVALID_PID,
|
||||
BC_BOARD_DEF_UNSPECIFIED
|
||||
} bc_board_status_t;
|
||||
} ws_board_status_t;
|
||||
|
||||
|
||||
|
||||
class BlinkaConnect {
|
||||
class WipperSnapper {
|
||||
|
||||
public:
|
||||
BlinkaConnect();
|
||||
virtual ~BlinkaConnect();
|
||||
WipperSnapper();
|
||||
virtual ~WipperSnapper();
|
||||
|
||||
void connect();
|
||||
virtual void _connect() = 0;
|
||||
|
|
@ -103,18 +103,18 @@ class BlinkaConnect {
|
|||
virtual void _disconnect() = 0;
|
||||
|
||||
const __FlashStringHelper *statusText();
|
||||
virtual bc_status_t networkStatus() = 0;
|
||||
bc_status_t status();
|
||||
bc_status_t mqttStatus();
|
||||
bc_board_status_t getBoardStatus();
|
||||
virtual ws_status_t networkStatus() = 0;
|
||||
ws_status_t status();
|
||||
ws_status_t mqttStatus();
|
||||
ws_board_status_t getBoardStatus();
|
||||
|
||||
bool sendBoardDescription();
|
||||
bool sendGetHardwareDescription();
|
||||
|
||||
bc_status_t checkNetworkConnection(uint32_t timeStart);
|
||||
bc_status_t checkMQTTConnection(uint32_t timeStart);
|
||||
ws_status_t checkNetworkConnection(uint32_t timeStart);
|
||||
ws_status_t checkMQTTConnection(uint32_t timeStart);
|
||||
void ping();
|
||||
bc_status_t run();
|
||||
ws_status_t run();
|
||||
|
||||
bool decodeSignalMessage();
|
||||
bool executeSignalMessageEvent();
|
||||
|
|
@ -139,7 +139,7 @@ class BlinkaConnect {
|
|||
int pinValue;
|
||||
int prvPinValue; // holds prv. pin state
|
||||
};
|
||||
static pinInfo bc_pinInfo;
|
||||
static pinInfo ws_pinInfo;
|
||||
|
||||
static Timer<16, millis, char *> t_timer;
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ class BlinkaConnect {
|
|||
void _init();
|
||||
|
||||
protected:
|
||||
bc_status_t _status = BC_IDLE; /*!< Adafruit IO connection status */
|
||||
ws_status_t _status = BC_IDLE; /*!< Adafruit IO connection status */
|
||||
uint32_t _last_mqtt_connect = 0; /*!< Previous time when client connected to
|
||||
Adafruit IO, in milliseconds */
|
||||
uint32_t _prv_ping = 0;
|
||||
|
|
@ -179,8 +179,8 @@ class BlinkaConnect {
|
|||
Adafruit_MQTT_Subscribe *_topic_signals_out_sub;
|
||||
Adafruit_MQTT_Subscribe *_subscription;
|
||||
|
||||
static char _value[45]; /*!< Data to send back to BlinkaConnect, max. IO data len */
|
||||
static char _prv_value[45]; /*!< Data to send back to BlinkaConnect, max. IO data len */
|
||||
static char _value[45]; /*!< Data to send back to WipperSnapper, max. IO data len */
|
||||
static char _prv_value[45]; /*!< Data to send back to WipperSnapper, max. IO data len */
|
||||
};
|
||||
|
||||
#endif // ADAFRUIT_BLINKACONNECT_H
|
||||
#endif // ADAFRUIT_WIPPERSNAPPER_H
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* @file BlinkaConnect_Boards.h
|
||||
* @file WipperSnapper_Boards.h
|
||||
*
|
||||
* This file determines board type at compile-time
|
||||
*
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef ADAFRUIT_BLINKACONNECT_BOARDS_H
|
||||
#define ADAFRUIT_BLINKACONNECT_BOARDS_H
|
||||
#ifndef ADAFRUIT_WIPPERSNAPPER_BOARDS_H
|
||||
#define ADAFRUIT_WIPPERSNAPPER_BOARDS_H
|
||||
|
||||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
#define USB_VID 0x239A
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
#define USB_VID 0x239A
|
||||
#define USB_PID 0x8021
|
||||
#else
|
||||
#warning "Board not identified within BlinkaConnect_Boards.h!"
|
||||
#warning "Board not identified within WipperSnapper_Boards.h!"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // ADAFRUIT_BLINKACONNECT_BOARDS_H
|
||||
#endif // ADAFRUIT_WIPPERSNAPPER_BOARDS_H
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* @file BlinkaConnect_Networking.h
|
||||
* @file WipperSnapper_Networking.h
|
||||
*
|
||||
* This file includes network interfaces at compile-time.
|
||||
*
|
||||
|
|
@ -13,16 +13,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef BLINKACONNECT_NETWORKING_H
|
||||
#define BLINKACONNECT_NETWORKING_H
|
||||
#ifndef WIPPERSNAPPER_NETWORKING_H
|
||||
#define WIPPERSNAPPER_NETWORKING_H
|
||||
|
||||
#if defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
|
||||
defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_METRO_M4_EXPRESS) || \
|
||||
defined(USE_AIRLIFT)
|
||||
#include "network_interfaces/BlinkaConnect_AIRLIFT.h"
|
||||
typedef BlinkaConnect_AIRLIFT BlinkaConnect_WiFi;
|
||||
#include "network_interfaces/WipperSnapper_AIRLIFT.h"
|
||||
typedef WipperSnapper_AIRLIFT WipperSnapper_WiFi;
|
||||
#else
|
||||
#warning "Must define network interface in config.h!"
|
||||
#endif
|
||||
|
||||
#endif // BLINKACONNECT_NETWORKING_H
|
||||
#endif // WIPPERSNAPPER_NETWORKING_H
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/*!
|
||||
* @file BlinkaConnect_AIRLIFT.h
|
||||
* @file WipperSnapper_AIRLIFT.h
|
||||
*
|
||||
* This is a driver for using the Adafruit AirLift
|
||||
* ESP32 Co-Processor with BlinkaConnect.
|
||||
* ESP32 Co-Processor with WipperSnapper.
|
||||
*
|
||||
* The ESP32 uses SPI to communicate. Three lines (CS, ACK, RST) are required
|
||||
* to communicate with the ESP32.
|
||||
|
|
@ -17,10 +17,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef BLINKACONNECT_AIRLIFT_H
|
||||
#define BLINKACONNECT_AIRLIFT_H
|
||||
#ifndef WIPPERSNAPPER_AIRLIFT_H
|
||||
#define WIPPERSNAPPER_AIRLIFT_H
|
||||
|
||||
#include "BlinkaConnect.h"
|
||||
#include "WipperSnapper.h"
|
||||
#include "Adafruit_MQTT.h"
|
||||
#include "Adafruit_MQTT_Client.h"
|
||||
#include "Arduino.h"
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
@brief Class for interacting with AirLift Co-Processors.
|
||||
*/
|
||||
/****************************************************************************/
|
||||
class BlinkaConnect_AIRLIFT : public BlinkaConnect {
|
||||
class WipperSnapper_AIRLIFT : public WipperSnapper {
|
||||
|
||||
public:
|
||||
/**************************************************************************/
|
||||
|
|
@ -58,9 +58,9 @@ public:
|
|||
a SPIClass
|
||||
*/
|
||||
/**************************************************************************/
|
||||
BlinkaConnect_AIRLIFT(const char *ssid, const char *ssidPassword,
|
||||
WipperSnapper_AIRLIFT(const char *ssid, const char *ssidPassword,
|
||||
int ssPin, int ackPin, int rstPin,
|
||||
int gpio0Pin, SPIClass *wifi): BlinkaConnect() {
|
||||
int gpio0Pin, SPIClass *wifi): WipperSnapper() {
|
||||
_wifi = wifi;
|
||||
_ssPin = ssPin;
|
||||
_ackPin = ackPin;
|
||||
|
|
@ -79,7 +79,7 @@ public:
|
|||
@brief Destructor for the Adafruit IO AirLift class.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
~BlinkaConnect_AIRLIFT() {
|
||||
~WipperSnapper_AIRLIFT() {
|
||||
if (_mqtt)
|
||||
delete _mqtt;
|
||||
}
|
||||
|
|
@ -101,10 +101,10 @@ public:
|
|||
/********************************************************/
|
||||
/*!
|
||||
@brief Returns the network status of an ESP32 module.
|
||||
@return bc_status_t
|
||||
@return ws_status_t
|
||||
*/
|
||||
/********************************************************/
|
||||
bc_status_t networkStatus() {
|
||||
ws_status_t networkStatus() {
|
||||
switch (WiFi.status()) {
|
||||
case WL_CONNECTED:
|
||||
return BC_NET_CONNECTED;
|
||||
|
|
@ -119,7 +119,7 @@ public:
|
|||
|
||||
/*******************************************************************/
|
||||
/*!
|
||||
@brief Returns the type of network connection used by BlinkaConnect
|
||||
@brief Returns the type of network connection used by WipperSnapper
|
||||
@return AIRLIFT
|
||||
*/
|
||||
/*******************************************************************/
|
||||
|
|
@ -177,4 +177,4 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
#endif //BLINKACONNECT_AIRLIFT_H
|
||||
#endif //WIPPERSNAPPER_AIRLIFT_H
|
||||
Loading…
Reference in a new issue