Merge pull request #155 from darumsdad/master

Support for Arduino WiFi MKR 1010 and Arduino Nano 33 IOT
This commit is contained in:
Brent Rubell 2021-12-10 14:38:32 -05:00 committed by GitHub
commit d7f4bd28fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 170 additions and 1 deletions

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -27,6 +27,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -27,6 +27,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
//#define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

View file

@ -20,6 +20,11 @@
#include "wifi/AdafruitIO_MKR1000.h"
typedef AdafruitIO_MKR1000 AdafruitIO_WiFi;
#elif defined(ARDUINO_SAMD_MKR1010)
#include "wifi/AdafruitIO_MKR1010.h"
typedef AdafruitIO_MKR1010 AdafruitIO_WiFi;
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
defined(USE_AIRLIFT)

View file

@ -0,0 +1,83 @@
/*!
* @file AdafruitIO_MKR1010.h
*
* Adafruit invests time and resources providing this open source code.
* Please support Adafruit and open source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) 2015-2016 Adafruit Industries
* Authors: David Goldstein, Morgan Winters
* Licensed under the MIT license.
*
* All text above must be included in any redistribution.
*/
#ifndef ADAFRUITIO_MKR1010_H
#define ADAFRUITIO_MKR1010_H
#include "AdafruitIO.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Arduino.h"
#include "SPI.h"
#include "WiFiNINA.h"
#include "WiFiSSLClient.h"
class AdafruitIO_MKR1010 : public AdafruitIO {
public:
AdafruitIO_MKR1010(const char *user, const char *key, const char *ssid,
const char *pass)
: AdafruitIO(user, key) {
_ssid = ssid;
_pass = pass;
_client = new WiFiSSLClient;
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
_http = new HttpClient(*_client, _host, _http_port);
}
~AdafruitIO_MKR1010() {
if (_client)
delete _client;
if (_mqtt)
delete _mqtt;
}
aio_status_t networkStatus() {
switch (WiFi.status()) {
case WL_CONNECTED:
return AIO_NET_CONNECTED;
case WL_CONNECT_FAILED:
return AIO_NET_CONNECT_FAILED;
case WL_IDLE_STATUS:
return AIO_IDLE;
default:
return AIO_NET_DISCONNECTED;
}
}
const char *connectionType() { return "wifi"; }
protected:
void _connect() {
if (strlen(_ssid) == 0) {
_status = AIO_SSID_INVALID;
} else {
_disconnect();
WiFi.begin(_ssid, _pass);
_status = networkStatus();
}
}
void _disconnect() {
WiFi.disconnect();
delay(AIO_NET_DISCONNECT_WAIT);
}
const char *_ssid;
const char *_pass;
WiFiSSLClient *_client;
};
#endif ADAFRUITIO_MKR1010_H

View file

@ -129,7 +129,7 @@ protected:
_status = AIO_SSID_INVALID;
} else {
_disconnect();
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en);
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); //
// no shield? bail
if (WiFi.status() == WL_NO_SHIELD) {