From 2837f73511632f0c1e9ebfc8501fda3cf7b73a11 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 09:40:38 +0100 Subject: [PATCH 01/15] Create AdafruitIO_MKR1010.cpp This new file is a copy of the original AdafruitIO_MKR1000.cpp but modified for the Arduino MKR1010 --- src/wifi/AdafruitIO_MKR1010.cpp | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/wifi/AdafruitIO_MKR1010.cpp diff --git a/src/wifi/AdafruitIO_MKR1010.cpp b/src/wifi/AdafruitIO_MKR1010.cpp new file mode 100644 index 00000000..77383b28 --- /dev/null +++ b/src/wifi/AdafruitIO_MKR1010.cpp @@ -0,0 +1,77 @@ +/*! + * @file AdafruitIO_MKR1010.cpp + * + * 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: Tony DiCola, Todd Treece, Morgan Winters + * Licensed under the MIT license. + * + * All text above must be included in any redistribution. + */ + +#if defined(ARDUINO_SAMD_MKR1010) + +#include "AdafruitIO_MKR1010.h" + +AdafruitIO_MKR1010::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::~AdafruitIO_MKR1010() { + if (_client) + delete _client; + if (_mqtt) + delete _mqtt; +} + +void AdafruitIO_MKR1010::_connect() { + if (strlen(_ssid) == 0) { + _status = AIO_SSID_INVALID; + } else { + // no shield? bail + if (WiFi.status() == WL_NO_SHIELD) + return; + + _disconnect(); + + WiFi.begin(_ssid, _pass); + _status = AIO_NET_DISCONNECTED; + } +} + +/**************************************************************************/ +/*! + @brief Disconnect the wifi network. +*/ +/**************************************************************************/ +void AdafruitIO_MKR1010::_disconnect() { + WiFi.disconnect(); + delay(AIO_NET_DISCONNECT_WAIT); +} + +aio_status_t AdafruitIO_MKR1010::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 *AdafruitIO_MKR1010::connectionType() { return "wifi"; } + +#endif // ARDUINO_ARCH_SAMD From b3633cf852b02d85fdabe77f9b9d4fd578cf7b88 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 09:42:48 +0100 Subject: [PATCH 02/15] Create AdafruitIO_MKR1010.h This new file is a copy of the original AdafruitIO_MKR1000.h but modified for the Arduino MKR1010 --- src/wifi/AdafruitIO_MKR1010.h | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/wifi/AdafruitIO_MKR1010.h diff --git a/src/wifi/AdafruitIO_MKR1010.h b/src/wifi/AdafruitIO_MKR1010.h new file mode 100644 index 00000000..4836448c --- /dev/null +++ b/src/wifi/AdafruitIO_MKR1010.h @@ -0,0 +1,50 @@ +/*! + * @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: Tony DiCola, Todd Treece, Morgan Winters + * Licensed under the MIT license. + * + * All text above must be included in any redistribution. + */ + +#ifndef ADAFRUITIO_MKR1010_H +#define ADAFRUITIO_MKR1010_H + +#if defined(ARDUINO_SAMD_MKR1010) + +#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_MKR1010(); + + aio_status_t networkStatus(); + const char *connectionType(); + +protected: + void _connect(); + void _disconnect(); + + const char *_ssid; + const char *_pass; + + WiFiSSLClient *_client; +}; + +#endif // ARDUINO_ARCH_SAMD + +#endif // ADAFRUITIO_MKR1010_H From cf8597c87d238c0cf36e2838cb21f085ca105896 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 09:46:21 +0100 Subject: [PATCH 03/15] Updated to add support for the MKR1010 Added support for the Arduino MKR1010 --- src/wifi/AdafruitIO_WINC1500.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 5f6b7fec..9bc2fe55 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -6,7 +6,7 @@ * products from Adafruit! * * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece + * Authors: Tony DiCola, Todd Treece, Morgan Winters * Licensed under the MIT license. * * All text above must be included in any redistribution. @@ -23,7 +23,8 @@ #include "Adafruit_MQTT_Client.h" #include "Arduino.h" #include "SPI.h" -#include "WiFi101.h" +//#include "WiFi101.h" // USE THIS FOR WiFi101 boards such as the MKR1000 +#include "WiFiNINA.h // USE THIS FOR WiFiNINA boards such as the MKR1010 /**************************************************************************/ /*! From 2fb6f0274234a490fad7da7a614ffc6c31ed2f6e Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 09:49:30 +0100 Subject: [PATCH 04/15] Updated to add support for the MKR1010 Added support for the Arduino MKR1010 --- src/AdafruitIO_WiFi.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AdafruitIO_WiFi.h b/src/AdafruitIO_WiFi.h index 24f39b65..003da931 100644 --- a/src/AdafruitIO_WiFi.h +++ b/src/AdafruitIO_WiFi.h @@ -7,7 +7,7 @@ * please support Adafruit and open-source hardware by purchasing * products from Adafruit! * - * Written by Tony DiCola, Todd Treece for Adafruit Industries + * Written by Tony DiCola, Todd Treece, Morgan Winters for Adafruit Industries * * BSD license, all text here must be included in any redistribution. * @@ -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) From a862fd9f735275d310523560d1b2e932294d7c71 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:04:37 +0100 Subject: [PATCH 05/15] Add support for the MKR1010 Added support for the Arduino MKR1010 --- src/wifi/AdafruitIO_WINC1500.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 9bc2fe55..3d80ade0 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -15,7 +15,7 @@ #ifndef ADAFRUITIO_WINC1500_H #define ADAFRUITIO_WINC1500_H -#if !defined(ARDUINO_SAMD_MKR1000) && defined(ARDUINO_ARCH_SAMD) && \ +#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKR1010) && defined(ARDUINO_ARCH_SAMD) && \ !defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) && !defined(ADAFRUIT_PYPORTAL) #include "AdafruitIO.h" @@ -130,7 +130,8 @@ class AdafruitIO_WINC1500 : public AdafruitIO { _status = AIO_SSID_INVALID; } else { _disconnect(); - WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); + // Comment out line below for MKR1010 + //WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); // // no shield? bail if (WiFi.status() == WL_NO_SHIELD) { From 1df91354b2560ea91cf439accf9733f358f3d3d7 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:38:54 +0100 Subject: [PATCH 06/15] Update AdafruitIO_MKR1010.cpp --- src/wifi/AdafruitIO_MKR1010.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wifi/AdafruitIO_MKR1010.cpp b/src/wifi/AdafruitIO_MKR1010.cpp index 77383b28..3a4987d6 100644 --- a/src/wifi/AdafruitIO_MKR1010.cpp +++ b/src/wifi/AdafruitIO_MKR1010.cpp @@ -6,7 +6,7 @@ * products from Adafruit! * * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece, Morgan Winters + * Authors: Tony DiCola, Todd Treece * Licensed under the MIT license. * * All text above must be included in any redistribution. From f7c62e93569cdfe97be34f9229d814c162929d37 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:39:37 +0100 Subject: [PATCH 07/15] Update AdafruitIO_MKR1010.h --- src/wifi/AdafruitIO_MKR1010.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wifi/AdafruitIO_MKR1010.h b/src/wifi/AdafruitIO_MKR1010.h index 4836448c..5f817516 100644 --- a/src/wifi/AdafruitIO_MKR1010.h +++ b/src/wifi/AdafruitIO_MKR1010.h @@ -6,7 +6,7 @@ * products from Adafruit! * * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece, Morgan Winters + * Authors: Tony DiCola, Todd Treece * Licensed under the MIT license. * * All text above must be included in any redistribution. From 91224bc95ab4f649a56e01836840db1953f3ffa1 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:40:02 +0100 Subject: [PATCH 08/15] Update AdafruitIO_WINC1500.h --- src/wifi/AdafruitIO_WINC1500.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 3d80ade0..591dd9e8 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -6,7 +6,7 @@ * products from Adafruit! * * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece, Morgan Winters + * Authors: Tony DiCola, Todd Treece * Licensed under the MIT license. * * All text above must be included in any redistribution. From 8570f62287bd28d2770d2336108013453c5b46b5 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:40:22 +0100 Subject: [PATCH 09/15] Update AdafruitIO_WiFi.h --- src/AdafruitIO_WiFi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AdafruitIO_WiFi.h b/src/AdafruitIO_WiFi.h index 003da931..93c92f64 100644 --- a/src/AdafruitIO_WiFi.h +++ b/src/AdafruitIO_WiFi.h @@ -7,7 +7,7 @@ * please support Adafruit and open-source hardware by purchasing * products from Adafruit! * - * Written by Tony DiCola, Todd Treece, Morgan Winters for Adafruit Industries + * Written by Tony DiCola, Todd Treece for Adafruit Industries * * BSD license, all text here must be included in any redistribution. * From e9ac466f97fa3c9a5126a1b48d9dd2ace131ff53 Mon Sep 17 00:00:00 2001 From: Morgan <7806037+mlwinters@users.noreply.github.com> Date: Wed, 23 Sep 2020 11:06:45 +0100 Subject: [PATCH 10/15] Update AdafruitIO_WINC1500.h --- src/wifi/AdafruitIO_WINC1500.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 591dd9e8..67ff1837 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -15,8 +15,9 @@ #ifndef ADAFRUITIO_WINC1500_H #define ADAFRUITIO_WINC1500_H -#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKR1010) && defined(ARDUINO_ARCH_SAMD) && \ - !defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) && !defined(ADAFRUIT_PYPORTAL) +#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKR1010) && \ + defined(ARDUINO_ARCH_SAMD) && !defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) && \ + !defined(ADAFRUIT_PYPORTAL) #include "AdafruitIO.h" #include "Adafruit_MQTT.h" From 55efac3adcf6ac4bf3d502922994b6c98952276a Mon Sep 17 00:00:00 2001 From: darumsdad Date: Tue, 7 Dec 2021 17:58:11 -0500 Subject: [PATCH 11/15] Changes to support MKR 1010 and Nano 33 IOT Changes to support MKR 1010 and Nano 33 IOT --- src/wifi/AdafruitIO_MKR1010.cpp | 77 --------------------------------- src/wifi/AdafruitIO_MKR1010.h | 59 +++++++++++++++++++------ src/wifi/AdafruitIO_WINC1500.h | 9 ++-- 3 files changed, 49 insertions(+), 96 deletions(-) delete mode 100644 src/wifi/AdafruitIO_MKR1010.cpp diff --git a/src/wifi/AdafruitIO_MKR1010.cpp b/src/wifi/AdafruitIO_MKR1010.cpp deleted file mode 100644 index 3a4987d6..00000000 --- a/src/wifi/AdafruitIO_MKR1010.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*! - * @file AdafruitIO_MKR1010.cpp - * - * 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: Tony DiCola, Todd Treece - * Licensed under the MIT license. - * - * All text above must be included in any redistribution. - */ - -#if defined(ARDUINO_SAMD_MKR1010) - -#include "AdafruitIO_MKR1010.h" - -AdafruitIO_MKR1010::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::~AdafruitIO_MKR1010() { - if (_client) - delete _client; - if (_mqtt) - delete _mqtt; -} - -void AdafruitIO_MKR1010::_connect() { - if (strlen(_ssid) == 0) { - _status = AIO_SSID_INVALID; - } else { - // no shield? bail - if (WiFi.status() == WL_NO_SHIELD) - return; - - _disconnect(); - - WiFi.begin(_ssid, _pass); - _status = AIO_NET_DISCONNECTED; - } -} - -/**************************************************************************/ -/*! - @brief Disconnect the wifi network. -*/ -/**************************************************************************/ -void AdafruitIO_MKR1010::_disconnect() { - WiFi.disconnect(); - delay(AIO_NET_DISCONNECT_WAIT); -} - -aio_status_t AdafruitIO_MKR1010::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 *AdafruitIO_MKR1010::connectionType() { return "wifi"; } - -#endif // ARDUINO_ARCH_SAMD diff --git a/src/wifi/AdafruitIO_MKR1010.h b/src/wifi/AdafruitIO_MKR1010.h index 5f817516..7dbb3d54 100644 --- a/src/wifi/AdafruitIO_MKR1010.h +++ b/src/wifi/AdafruitIO_MKR1010.h @@ -6,16 +6,12 @@ * products from Adafruit! * * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece + * 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 - -#if defined(ARDUINO_SAMD_MKR1010) #include "AdafruitIO.h" #include "Adafruit_MQTT.h" @@ -28,16 +24,53 @@ class AdafruitIO_MKR1010 : public AdafruitIO { public: - AdafruitIO_MKR1010(const char *user, const char *key, const char *ssid, - const char *pass); - ~AdafruitIO_MKR1010(); + 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(); - const char *connectionType(); + 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(); - void _disconnect(); + 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; @@ -45,6 +78,4 @@ class AdafruitIO_MKR1010 : public AdafruitIO { WiFiSSLClient *_client; }; -#endif // ARDUINO_ARCH_SAMD -#endif // ADAFRUITIO_MKR1010_H diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 67ff1837..faa00957 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -15,17 +15,16 @@ #ifndef ADAFRUITIO_WINC1500_H #define ADAFRUITIO_WINC1500_H -#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKR1010) && \ - defined(ARDUINO_ARCH_SAMD) && !defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) && \ - !defined(ADAFRUIT_PYPORTAL) +#if !defined(ARDUINO_SAMD_MKR1000) && defined(ARDUINO_ARCH_SAMD) && \ + !defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) && !defined(ADAFRUIT_PYPORTAL) #include "AdafruitIO.h" #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" #include "Arduino.h" #include "SPI.h" -//#include "WiFi101.h" // USE THIS FOR WiFi101 boards such as the MKR1000 -#include "WiFiNINA.h // USE THIS FOR WiFiNINA boards such as the MKR1010 +#include "WiFi101.h" + /**************************************************************************/ /*! From 007e1357e31433c13d8d0add76bad3689be2d9b2 Mon Sep 17 00:00:00 2001 From: darumsdad Date: Tue, 7 Dec 2021 18:07:57 -0500 Subject: [PATCH 12/15] updated examples updated examples --- examples/adafruitio_00_publish/config.h | 3 +++ examples/adafruitio_01_subscribe/config.h | 3 +++ examples/adafruitio_02_pubsub/config.h | 3 +++ examples/adafruitio_03_multiple_feeds/config.h | 3 +++ examples/adafruitio_04_location/config.h | 3 +++ examples/adafruitio_05_type_conversion/config.h | 3 +++ examples/adafruitio_06_digital_in/config.h | 3 +++ examples/adafruitio_07_digital_out/config.h | 3 +++ examples/adafruitio_08_analog_in/config.h | 3 +++ examples/adafruitio_09_analog_out/config.h | 3 +++ examples/adafruitio_10_dashboard_creation/config.h | 3 +++ examples/adafruitio_11_group_pub/config.h | 3 +++ examples/adafruitio_12_group_sub/config.h | 3 +++ examples/adafruitio_13_rgb/config.h | 3 +++ examples/adafruitio_14_neopixel/config.h | 3 +++ examples/adafruitio_15_temp_humidity/config.h | 3 +++ examples/adafruitio_16_servo/config.h | 3 +++ examples/adafruitio_17_time_subscribe/config.h | 3 +++ examples/adafruitio_18_device_info/config.h | 3 +++ examples/adafruitio_19_deepsleep/config.h | 3 +++ examples/adafruitio_20_shared_feed_write/config.h | 3 +++ examples/adafruitio_21_feed_read/config.h | 3 +++ examples/adafruitio_22_environmental_monitor/config.h | 3 +++ examples/adafruitio_23_ifttt/config.h | 3 +++ examples/adafruitio_24_zapier/config.h | 3 +++ examples/io_home_series/io_home_security/config.h | 3 +++ examples/io_home_series/neopixel_and_thermometer/config.h | 3 +++ 27 files changed, 81 insertions(+) diff --git a/examples/adafruitio_00_publish/config.h b/examples/adafruitio_00_publish/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_00_publish/config.h +++ b/examples/adafruitio_00_publish/config.h @@ -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" diff --git a/examples/adafruitio_01_subscribe/config.h b/examples/adafruitio_01_subscribe/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_01_subscribe/config.h +++ b/examples/adafruitio_01_subscribe/config.h @@ -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" diff --git a/examples/adafruitio_02_pubsub/config.h b/examples/adafruitio_02_pubsub/config.h index 25cd8f55..289b880f 100644 --- a/examples/adafruitio_02_pubsub/config.h +++ b/examples/adafruitio_02_pubsub/config.h @@ -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" diff --git a/examples/adafruitio_03_multiple_feeds/config.h b/examples/adafruitio_03_multiple_feeds/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_03_multiple_feeds/config.h +++ b/examples/adafruitio_03_multiple_feeds/config.h @@ -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" diff --git a/examples/adafruitio_04_location/config.h b/examples/adafruitio_04_location/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_04_location/config.h +++ b/examples/adafruitio_04_location/config.h @@ -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" diff --git a/examples/adafruitio_05_type_conversion/config.h b/examples/adafruitio_05_type_conversion/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_05_type_conversion/config.h +++ b/examples/adafruitio_05_type_conversion/config.h @@ -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" diff --git a/examples/adafruitio_06_digital_in/config.h b/examples/adafruitio_06_digital_in/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_06_digital_in/config.h +++ b/examples/adafruitio_06_digital_in/config.h @@ -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" diff --git a/examples/adafruitio_07_digital_out/config.h b/examples/adafruitio_07_digital_out/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_07_digital_out/config.h +++ b/examples/adafruitio_07_digital_out/config.h @@ -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" diff --git a/examples/adafruitio_08_analog_in/config.h b/examples/adafruitio_08_analog_in/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_08_analog_in/config.h +++ b/examples/adafruitio_08_analog_in/config.h @@ -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" diff --git a/examples/adafruitio_09_analog_out/config.h b/examples/adafruitio_09_analog_out/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_09_analog_out/config.h +++ b/examples/adafruitio_09_analog_out/config.h @@ -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" diff --git a/examples/adafruitio_10_dashboard_creation/config.h b/examples/adafruitio_10_dashboard_creation/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_10_dashboard_creation/config.h +++ b/examples/adafruitio_10_dashboard_creation/config.h @@ -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" diff --git a/examples/adafruitio_11_group_pub/config.h b/examples/adafruitio_11_group_pub/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_11_group_pub/config.h +++ b/examples/adafruitio_11_group_pub/config.h @@ -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" diff --git a/examples/adafruitio_12_group_sub/config.h b/examples/adafruitio_12_group_sub/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_12_group_sub/config.h +++ b/examples/adafruitio_12_group_sub/config.h @@ -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" diff --git a/examples/adafruitio_13_rgb/config.h b/examples/adafruitio_13_rgb/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_13_rgb/config.h +++ b/examples/adafruitio_13_rgb/config.h @@ -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" diff --git a/examples/adafruitio_14_neopixel/config.h b/examples/adafruitio_14_neopixel/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_14_neopixel/config.h +++ b/examples/adafruitio_14_neopixel/config.h @@ -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" diff --git a/examples/adafruitio_15_temp_humidity/config.h b/examples/adafruitio_15_temp_humidity/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_15_temp_humidity/config.h +++ b/examples/adafruitio_15_temp_humidity/config.h @@ -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" diff --git a/examples/adafruitio_16_servo/config.h b/examples/adafruitio_16_servo/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_16_servo/config.h +++ b/examples/adafruitio_16_servo/config.h @@ -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" diff --git a/examples/adafruitio_17_time_subscribe/config.h b/examples/adafruitio_17_time_subscribe/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_17_time_subscribe/config.h +++ b/examples/adafruitio_17_time_subscribe/config.h @@ -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" diff --git a/examples/adafruitio_18_device_info/config.h b/examples/adafruitio_18_device_info/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_18_device_info/config.h +++ b/examples/adafruitio_18_device_info/config.h @@ -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" diff --git a/examples/adafruitio_19_deepsleep/config.h b/examples/adafruitio_19_deepsleep/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_19_deepsleep/config.h +++ b/examples/adafruitio_19_deepsleep/config.h @@ -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" diff --git a/examples/adafruitio_20_shared_feed_write/config.h b/examples/adafruitio_20_shared_feed_write/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_20_shared_feed_write/config.h +++ b/examples/adafruitio_20_shared_feed_write/config.h @@ -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" diff --git a/examples/adafruitio_21_feed_read/config.h b/examples/adafruitio_21_feed_read/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_21_feed_read/config.h +++ b/examples/adafruitio_21_feed_read/config.h @@ -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" diff --git a/examples/adafruitio_22_environmental_monitor/config.h b/examples/adafruitio_22_environmental_monitor/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_22_environmental_monitor/config.h +++ b/examples/adafruitio_22_environmental_monitor/config.h @@ -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" diff --git a/examples/adafruitio_23_ifttt/config.h b/examples/adafruitio_23_ifttt/config.h index 25cd8f55..289b880f 100644 --- a/examples/adafruitio_23_ifttt/config.h +++ b/examples/adafruitio_23_ifttt/config.h @@ -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" diff --git a/examples/adafruitio_24_zapier/config.h b/examples/adafruitio_24_zapier/config.h index bcff0c95..c7b156f1 100644 --- a/examples/adafruitio_24_zapier/config.h +++ b/examples/adafruitio_24_zapier/config.h @@ -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" diff --git a/examples/io_home_series/io_home_security/config.h b/examples/io_home_series/io_home_security/config.h index bcff0c95..c7b156f1 100644 --- a/examples/io_home_series/io_home_security/config.h +++ b/examples/io_home_series/io_home_security/config.h @@ -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" diff --git a/examples/io_home_series/neopixel_and_thermometer/config.h b/examples/io_home_series/neopixel_and_thermometer/config.h index bcff0c95..c7b156f1 100644 --- a/examples/io_home_series/neopixel_and_thermometer/config.h +++ b/examples/io_home_series/neopixel_and_thermometer/config.h @@ -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" From 3e3f93f5306a997e9aa34639a73fc4388affb003 Mon Sep 17 00:00:00 2001 From: darumsdad Date: Wed, 8 Dec 2021 20:35:38 -0500 Subject: [PATCH 13/15] Changes to support MKR 1010 and Nano 33 IOT Added include guards Removed not needed code --- src/wifi/AdafruitIO_MKR1010.h | 4 +++- src/wifi/AdafruitIO_WINC1500.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wifi/AdafruitIO_MKR1010.h b/src/wifi/AdafruitIO_MKR1010.h index 7dbb3d54..776c30b3 100644 --- a/src/wifi/AdafruitIO_MKR1010.h +++ b/src/wifi/AdafruitIO_MKR1010.h @@ -12,6 +12,8 @@ * All text above must be included in any redistribution. */ +#ifndef ADAFRUITIO_MKR1010_H +#define ADAFRUITIO_MKR1010_H #include "AdafruitIO.h" #include "Adafruit_MQTT.h" @@ -78,4 +80,4 @@ class AdafruitIO_MKR1010 : public AdafruitIO { WiFiSSLClient *_client; }; - +#endif ADAFRUITIO_MKR1010_H diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index faa00957..70a9f819 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -130,8 +130,7 @@ class AdafruitIO_WINC1500 : public AdafruitIO { _status = AIO_SSID_INVALID; } else { _disconnect(); - // Comment out line below for MKR1010 - //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) { From fe6d93d435d3399945cf3b0a9c31ec3cb1943aa2 Mon Sep 17 00:00:00 2001 From: darumsdad Date: Fri, 10 Dec 2021 11:21:50 -0500 Subject: [PATCH 14/15] formatting changes formatting changes --- src/AdafruitIO_Definitions.h | 2 +- src/wifi/AdafruitIO_MKR1010.h | 22 +++++++++++----------- src/wifi/AdafruitIO_WINC1500.h | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/AdafruitIO_Definitions.h b/src/AdafruitIO_Definitions.h index 65f60365..3ddb0f93 100644 --- a/src/AdafruitIO_Definitions.h +++ b/src/AdafruitIO_Definitions.h @@ -112,7 +112,7 @@ class AdafruitIOGroupCallback { #define AIO_NET_DISCONNECT_WAIT \ 300 ///< Time to wait for a net disconnect to take effect -#define AIO_ERROR_TOPIC "/errors" ///< Adafruit IO Error MQTT Topic +#define AIO_ERROR_TOPIC "/errors" ///< Adafruit IO Error MQTT Topic #define AIO_THROTTLE_TOPIC "/throttle" ///< Adafruit IO Throttle MQTT Topic // latest fingerprint can be generated with diff --git a/src/wifi/AdafruitIO_MKR1010.h b/src/wifi/AdafruitIO_MKR1010.h index 776c30b3..c99106ff 100644 --- a/src/wifi/AdafruitIO_MKR1010.h +++ b/src/wifi/AdafruitIO_MKR1010.h @@ -26,15 +26,15 @@ 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(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; @@ -54,7 +54,7 @@ class AdafruitIO_MKR1010 : public AdafruitIO { return AIO_NET_DISCONNECTED; } } - + const char *connectionType() { return "wifi"; } protected: @@ -68,7 +68,7 @@ class AdafruitIO_MKR1010 : public AdafruitIO { _status = networkStatus(); } } - + void _disconnect() { WiFi.disconnect(); delay(AIO_NET_DISCONNECT_WAIT); diff --git a/src/wifi/AdafruitIO_WINC1500.h b/src/wifi/AdafruitIO_WINC1500.h index 70a9f819..88280ec2 100644 --- a/src/wifi/AdafruitIO_WINC1500.h +++ b/src/wifi/AdafruitIO_WINC1500.h @@ -25,7 +25,6 @@ #include "SPI.h" #include "WiFi101.h" - /**************************************************************************/ /*! @brief Class for interacting with adafruit.io (AIO) using WINC1500 From 06474339c94493b9b6b85930c7c45b471bce2194 Mon Sep 17 00:00:00 2001 From: darumsdad Date: Fri, 10 Dec 2021 13:07:56 -0500 Subject: [PATCH 15/15] Update AdafruitIO_Definitions.h Formatting change --- src/AdafruitIO_Definitions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AdafruitIO_Definitions.h b/src/AdafruitIO_Definitions.h index 3ddb0f93..65f60365 100644 --- a/src/AdafruitIO_Definitions.h +++ b/src/AdafruitIO_Definitions.h @@ -112,7 +112,7 @@ class AdafruitIOGroupCallback { #define AIO_NET_DISCONNECT_WAIT \ 300 ///< Time to wait for a net disconnect to take effect -#define AIO_ERROR_TOPIC "/errors" ///< Adafruit IO Error MQTT Topic +#define AIO_ERROR_TOPIC "/errors" ///< Adafruit IO Error MQTT Topic #define AIO_THROTTLE_TOPIC "/throttle" ///< Adafruit IO Throttle MQTT Topic // latest fingerprint can be generated with