Azure / azure-iot-arduino

Azure IoT library for the Arduino
Other
168 stars 95 forks source link

Convert Adafruit M0 references from WINC1500 to WiFi101 #55

Closed GregTerrell closed 6 years ago

GregTerrell commented 7 years ago

Please consider removal of the WINC1500 library references in the libary (for the Adafruit M0).

The Adafruit WINC1500 library has been deprecated for months. WiFi101 has went through numerous enhancements and fixes since the deprecated Adafruit fork. 10 months ago Adafruit updated the github readme with...

This fork is deprecated! Please use WiFi101, which now has pin-setting support Thak you! :)

I have been using the WiFi101 library on the Adafruit board for over 6 months with success. With every azure-iot-arduino update we are forced, and instruct our customers, to go in to the AzureIoTUtility\src\adapters library folder and modify the sslClient_arduino.cpp file to comment out the lines below...

#elif ARDUINO_SAMD_FEATHER_M0 
#include "Adafruit_WINC1500.h" 
#include "Adafruit_WINC1500Client.h" 
#include "Adafruit_WINC1500SSLClient.h" 
static Adafruit_WINC1500SSLClient sslClient; // for Adafruit WINC1500 
#else 

In your readme.md your instructions for the Adafruit M0

  1. Install the Adafruit WINC1500 wifi library

link to a page on Adafruit Learn with specific instructions to download the WiFi101 library.

By removing the library references only minor INO sample changes are required for WiFi101 to function with the Adafruit M0.

Near top of .INO...

#ifdef ARDUINO_SAMD_FEATHER_M0
  #define VBAT_ENABLED              1
  #define VBAT_PIN                  A7

  #define WINC_CS   8
  #define WINC_IRQ  7
  #define WINC_RST  4
  #define WINC_EN   2

  #include <WiFi101.h>
  #include <WiFiSSLClient.h>
  #include <WiFiUdp.h>
  WiFiSSLClient sslClient;
  #include "NTPClient.h"

In the initWifi() function...

 #ifdef ARDUINO_SAMD_FEATHER_M0
    Serial.println(F("WINC1500 on FeatherM0 detected."));
    Serial.println(F("Setting pins for WiFi101 library (WINC1500 on FeatherM0)"));

    //Configure pins for Adafruit ATWINC1500 Feather
    WiFi.setPins(WINC_CS, WINC_IRQ, WINC_RST, WINC_EN);

    // for the Adafruit WINC1500 we need to enable the chip
    pinMode(WINC_EN, OUTPUT);
    digitalWrite(WINC_EN, HIGH);
    Serial.println(F("Enabled WINC1500 interface for FeatherM0"));
  #endif

Thanks, Greg @ LooUQ

tameraw commented 7 years ago

@GregTerrell - We're looking into this to make the change.

JetstreamRoySprowl commented 7 years ago

Hi Greg, Thanks for the detailed write-up. I'm tasked with getting your suggestions into the Azure IoT SDK, and I've added your changes but am getting consistent failure in the sslClient.connect call. Are you able to send me the whole source for a working sketch? I understand this problem is making a lot of noise on the BBSs, but I haven't looked into that yet. Thanks, Roy

GregTerrell commented 7 years ago

Archive file attached with simplesample_http and the single file in the Azure IoT Arduino library modified to support Adafruit Feather M0 with WiFi101 library. Look for comments with "(#55).

Changes in the definitions (around line 21, 44), setup (WiFi init code at about line 80) in the INO

simplesample_http.zip

Need to alter 1 file in the Azure IoT (Arduino) libraries ...Arduino\libraries\AzureIoTUtility\src\adapters lines 17-23

JetstreamRoySprowl commented 7 years ago

@GregTerrell : I believe I have your changes integrated, although it looks like the Feather M0 can only do HTTP until this bug gets fixed. Please let me know if I missed anything. Thank you for your help improving the code!

GregTerrell commented 7 years ago

I will review your information as soon as possible, Thank you @JetstreamRoySprowl. I thought for sure our code defaults to MQTT (rather than HTTP), we will test and post our results. Your findings suggest that one of the recent releases of WiFi101 code has broke what was previously working in WiFi101.

JetstreamRoySprowl commented 7 years ago

@GregTerrell Greg, I just noticed that although the changes are in the Azure IoT SDK, they will not make it into the Arduino library repos until the release cycle, which happens at the end of this week.

GregTerrell commented 7 years ago

Thank you for the update Roy, I will be looking for the update.

I have not been able to assign time to running your bug example jig, but I will try this weekend. In the meantime. I wanted to give you an update on our experience with MQTT. Our library has been defaulted to MQTT for at least several months, running on Adafruit Feather, and yesterday we deleted the HTTP library just to further confirm we were MQTT only. And, everything worked as expected.

snobu commented 6 years ago

Just wanted to say thank you for doing this, @GregTerrell for mentioning it and the product group for implementing it. Things are so much cleaner and nicer this way.