Code Monkey home page Code Monkey logo

wifi101's Introduction

WiFi101 library for for the Arduino WiFi Shield 101 and MKR1000 board

Check Arduino status Compile Examples status Spell Check status

This library implements a network driver for devices based on the ATMEL WINC1500 WiFi module.

For more information about this library please visit us at https://www.arduino.cc/en/Reference/WiFi101

License

Copyright (c) Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

wifi101's People

Contributors

aentinger avatar agdl avatar awatterott avatar cmaglie avatar dependabot[bot] avatar emanueleg avatar facchinm avatar feikname avatar giulcioffi avatar jacobhylen avatar jrowberg avatar karlsoderby avatar marcusjoh avatar mjlitke avatar oxullo avatar per1234 avatar pkgeorgiev avatar pnndra avatar rocketct avatar sandeepmistry avatar soundanalogous avatar tdicola avatar turkycat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifi101's Issues

Please add WPA support for WiFi Access Points

Currently, if you create a WiFi Access Point, you can make it open or you can use WEP security.

Could you please add the ability to use WAP security? As you may know, WEP was deprecated in 2004 and has been replaced by WAP. WEP is significantly less secure.

Thank you!

How to stop AP?

There's a beginAP method, but how can I change back to STA mode? I want to connect to a WiFi network after receiving the ssid and password.

Thanks

WiFiClass::status() doesn't return WL_NO_SHIELD when shield is missing

On my Arduino UNO board in a pristine state, with the WiFi101 shield not connected, the following program just hangs in that status() call. I've tried it with both versions 0.6 and 0.5 of the library.
I've tracked the hanging to m2m_wifi_init() -> nm_drv_init() -> wait_for_firmware_start(). This is probably expected, but I guess the question is how come nm_drv_init() does't fail earlier (in nm_bus_iface_init()?).

This has tripped me because the 101 shield I got was not particularly easy to plug in at first.

#include <WiFi101.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) { }

  Serial.println("init");
  WiFi.status();
  Serial.println("why don't I get here?");
}

v0.8.0 does not work with the Uno + WiFi 101Shield

The output of the ScanNetworks examples is:

MAC: F8:F0:5:F0:9A:85
Scanning available networks...
** Scan Networks **
MAC: F8:F0:5:F0:9A:85
Scanning available networks...
** Scan Networks **
MAC: F8:F0:5:F0:9A:85
Scanning available networks...
** Scan Networks **
MAC: F8:F0:5:F0:9A:85
Scanning available networks...

even though many access points are in range. Seems to be related to a change introduced in f558ef5. Reverting to v0.7.0, the example is fine.

WiFi101 Stack Error print facility

In trying to debug some issue with the stack, I noted that nm_debug.h has implemented a series of debug print function that are NOT enable under the Arduino IDE... Having these available would be of GREAT help in tracing future bug in the stack.

In the stack, they are of the form of:

M2M_ERR("Incorrect mon data size %u\n", u16DataSize);

the nm_debug.h file:

#ifndef _NM_DEBUG_H_
#define _NM_DEBUG_H_

#include "bsp/include/nm_bsp.h"
#include "bsp/include/nm_bsp_internal.h"

/**@defgroup  DebugDefines DebugDefines
 * @ingroup WlanDefines
 */
/**@{*/


#define M2M_LOG_NONE                                    0
#define M2M_LOG_ERROR                                   1
#define M2M_LOG_INFO                                    2
#define M2M_LOG_REQ                                     3
#define M2M_LOG_DBG                                     4

#if (defined __APS3_CORTUS__)
#define M2M_LOG_LEVEL                                   M2M_LOG_ERROR
#else
#define M2M_LOG_LEVEL                                   M2M_LOG_REQ
#endif


#define M2M_ERR(...)
#define M2M_INFO(...)
#define M2M_REQ(...)
#define M2M_DBG(...)
#define M2M_PRINT(...)

#if (CONF_WINC_DEBUG == 1)
#undef M2M_PRINT
#define M2M_PRINT(...)                          do{CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#if (M2M_LOG_LEVEL >= M2M_LOG_ERROR)
#undef M2M_ERR
#define M2M_ERR(...)                            do{CONF_WINC_PRINTF("(APP)(ERR)[%s][%d]",__FUNCTION__,__LINE__); CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#if (M2M_LOG_LEVEL >= M2M_LOG_INFO)
#undef M2M_INFO
#define M2M_INFO(...)                           do{CONF_WINC_PRINTF("(APP)(INFO)"); CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#if (M2M_LOG_LEVEL >= M2M_LOG_REQ)
#undef M2M_REQ
#define M2M_REQ(...)                            do{CONF_WINC_PRINTF("(APP)(R)"); CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#if (M2M_LOG_LEVEL >= M2M_LOG_DBG)
#undef M2M_DBG
#define M2M_DBG(...)                            do{CONF_WINC_PRINTF("(APP)(DBG)[%s][%d]",__FUNCTION__,__LINE__); CONF_WINC_PRINTF(__VA_ARGS__);CONF_WINC_PRINTF("\r");}while(0)
#endif /*M2M_LOG_DBG*/
#endif /*M2M_LOG_REQ*/
#endif /*M2M_LOG_INFO*/
#endif /*M2M_LOG_ERROR*/
#endif /*CONF_WINC_DEBUG */

/**@}*/
#endif /* _NM_DEBUG_H_ */

TLS 1.2 support advertised but no SHA-384/SHA-512 capability

Moved from arduino/Arduino#4730
@mashikawa wrote:

Hi, I purchased the Arduino Wifi 101 shield for an IoT project and found that I could not connect to certain servers via SSL. Some worked (www.google.com:443) and others did not (plot.ly:443).

Using Wireshark to monitor the TLS handshake I found that the WINC1500 hardcodes the TLS Client Hello value to 1.2 ( since firmware version 9.3.0 ), although the device does not handle ciphers longer than 256bits ( SHA-256 ). This actually makes it only TLS1.1 compatible. Some servers now implement SHA-384 and SHA-512 ciphers as part of the TLS1.2 protocol and they can respond to the TLS1.2 request with these ciphers, which the WINC1500 (Wifi101) cannot decrypt and so the connection fails. I have recreated the issue using OpenSSL and have attached the output to this request for info.

I raised a support request with Atmel ( Case 00037229 ), suggesting they allow the TLS value to be modified by the user via the software and they responded with the following message:

Created By: Anu Ramakrishnan (3/21/2016 4:09 AM)
[Recipients: Michael Kelsall]

Hi Micheal,
Yes, we do not support SHA-384 and 512. Thank you for the feedback regarding the usage of TLS1.2 mode. We have raised a bug internally for this and we will follow up to get it fixed in future releases.
We do not share firmware sources of the ATWINC1500, sorry for the inconvenience.
Regards,
Anu

This is a good response but I am now worried the issue may sit on a development list with low priority for an extended period of time..... Can anyone help to progress this as I am sure the problem will get worse as more website implement longer ciphers to improve security.

Regards,
Michael.

OpenSSL_ATWINC1500_TLS_Examples.txt

DHCP issues with MikroTik router

When you use WiFi as DHCP client the WiFi101 library does not renew automatically MCU's IP Address when the lease expires even trough WiFi.refresh() was periodically called.
Used hardware: Genuino MKR1000

How to renew IP Address (DHCP client mode)?

Is there a way to:

  1. Detect if the IP Address lease has expired?
  2. Renew the IP address if the lease has expired?

I'm using MikroTik router with default lease time of 6 minutes (yeah, crazy). When the time eclipses, my MKR1000 becomes unreachable via ping and cannot communicate with anything in my WiFi network.

Documented Library function WiFi.getSocket() does not exist

Whilst looking for a work-round to the server upload issue (#36), I discovered a library function that does not exist:
https://www.arduino.cc/en/Reference/WiFi101: WiFi.getSocket()

Errror returned:

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\laptop\Desktop\Documents\Arduino\software\WiFi101server\WiFi101server.ino:
In function 'void loop()':
WiFi101server:159:` error: 'class WiFiClient' has no member named 'getSocket'
Serial.println(WiFi.getSocket() );
exit status 1

'class WiFiClass' has no member named 'getSocket'

David

Problem using Arduino Wifi101 with UNO as a web server

I am using the sketch found at

  www.arduino.cc/en/Tutorial/Wifi101SimpleWebServerWiFi

The instructions on this web page are a bit messed up since they talk about lighting
an LED while the code is intended to write out the values of analog voltages.
However, as far as I can tell, that has nothing to do with the problem I am having
getting the sketch to work.

Here is my system configuration:

 Arduino Uno
 Arduino IDE 1.7.7
 Arduino Wifi 101 shield
 Linksys wireless router

I've also tried Arduino IDE 1.6.6 and that doesn't seem to make any difference.
Here is what I see in the Serial window when I run the code:

 Attempting to connect to SSID: linksys1
  SSID: linksys1
  IP Address: 192.168.1.108
  signal strength (RSSI):-50 dBm

When I then try to connect with 'http://192.168.1.108' with my web browser (firefox)
I then see

  new client
  client disconnected

in the Serial window. This indicates to me that I am actually successfully communicating
with the WiFi 101 (I can also ping it ... another good sign) and that the problem is with
the code or that there is something else I need to do from my browser to get the code to
work.

Testing with NTP UDP code, fails

In testing with the UdpNTPClient, I have noticed that after some time (often less that 5 to 10min)
The WiFi101 stack stops sending the NTP request packets, but return no error to the program. This has been verified using Wireshark and the test program below.

Using IDE 1.6.9, SAMD 1.6.6, on a Adafruit feather M0 WINC1500

My modified test program and output.

Sending an NTP request
packet received
Seconds since Jan 1 1900 = 3677937580
Unix time = 1468948780
The UTC time is 17:19:40

Sending an NTP request
packet received
Seconds since Jan 1 1900 = 3677937591
Unix time = 1468948791
The UTC time is 17:19:51

Sending an NTP request

Sending an NTP request
packet received
Seconds since Jan 1 1900 = 3677937613
Unix time = 1468948813
The UTC time is 17:20:13

Sending an NTP request

Sending an NTP request

Sending an NTP request

Sending an NTP request

Sending an NTP request

Sending an NTP request

Sending an NTP request

Sending an NTP request


/*

 Udp NTP Client

 Get the time from a Network Time Protocol (NTP) time server
 Demonstrates use of UDP sendPacket and ReceivePacket
 For more on NTP time servers and the messages needed to communicate with them,
 see http://en.wikipedia.org/wiki/Network_Time_Protocol

 created 4 Sep 2010
 by Michael Margolis
 modified 9 Apr 2012
 by Tom Igoe

 This code is in the public domain.

 */

#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;

char ssid[] = "xxxxx";              //  your network SSID (name)
char pass[] = "xxxxx";        // your network password
int keyIndex = 0;                     // your network key Index number (needed only for WEP)

unsigned long t1 = millis();

// My IP address for the WINC1500:
  IPAddress MYip(192, 94, 167, 14);   
// the DNS server address for the WINC1500:
  IPAddress MYdns1(4,2,2,2);  
// the GateWay address for the WINC1500:
  IPAddress MYgw(192, 94, 167, 4);   
// the Sub Net Mask for the Winc1500:
  IPAddress MYsnm(255,255,255,0); 
// DNS name of NTP server to use  
const char NTPserver [] = "1.north-america.pool.ntp.org";        //"1.north-america.pool.ntp.org"  us.pool.ntp.org


unsigned int localPort = 2390;        // local port to listen for UDP packets

IPAddress timeServer(129, 6, 15, 28); // time.nist.gov NTP server

const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message

byte packetBuffer[ NTP_PACKET_SIZE] = {0}; //buffer to hold incoming and outgoing packets

//WiFiClass::setPins(int8_t cs, int8_t irq, int8_t rst, int8_t en)

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

WiFi.setPins (8,7,4,2);   // using a Feather with a WINC1500

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }


// set manual IP address, comment this out for DHCP
  WiFi.config(MYip, MYdns1, MYgw, MYsnm); 


  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    //delay(10000);
  }

  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  Udp.begin(localPort);
}

void loop()
{

  // check if its time to make an NTP request
  if ( (millis() - t1) > 10000)
  {

    t1 = millis();
    // see if we are still connected
    if ( (WiFi.status() ==  WL_CONNECTED) )
      sendNTPpacket(timeServer);              // send an NTP packet to a time server
      else Serial.println("Not Connected");
  }  

  // wait to see if a reply is available
  //delay(1000);
  if ( Udp.parsePacket() ) 
  {
      RXpacket();
  }

  // wait ten seconds before asking for the time again
  delay(10000);
}  // end of loop

void RXpacket(void)
{
      Serial.println("Packet received");
    // We've received a packet, read the data from it
    Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer

    //the timestamp starts at byte 40 of the received packet and is four bytes,
    // or two words, long. First, esxtract the two words:

    unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
    unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
    // combine the four bytes (two words) into a long integer
    // this is NTP time (seconds since Jan 1 1900):
    unsigned long secsSince1900 = highWord << 16 | lowWord;
    Serial.print("Seconds since Jan 1 1900 = " );
    Serial.println(secsSince1900);

    // now convert NTP time into everyday time:
    Serial.print("Unix time = ");
    // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
    const unsigned long seventyYears = 2208988800UL;
    // subtract seventy years:
    unsigned long epoch = secsSince1900 - seventyYears;
    // print Unix time:
    Serial.println(epoch);


    // print the hour, minute and second:
    Serial.print("The UTC time is ");       // UTC is the time at Greenwich Meridian (GMT)
    Serial.print((epoch  % 86400L) / 3600); // print the hour (86400 equals secs per day)
    Serial.print(':');
    if ( ((epoch % 3600) / 60) < 10 ) {
      // In the first 10 minutes of each hour, we'll want a leading '0'
      Serial.print('0');
    }
    Serial.print((epoch  % 3600) / 60); // print the minute (3600 equals secs per minute)
    Serial.print(':');
    if ( (epoch % 60) < 10 ) {
      // In the first 10 seconds of each minute, we'll want a leading '0'
      Serial.print('0');
    }
    Serial.println(epoch % 60); // print the second
}

// send an NTP request to the time server at the given address
unsigned long sendNTPpacket(IPAddress& address)
{
  Serial.println("\nSending an NTP request");
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  //Serial.println("2");
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  //8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12]  = 49;
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;

  //Serial.println("3");

  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:
  if (!Udp.beginPacket(address, 123)) //; //NTP requests are to port 123)
      Serial.println("beginPacket error");

      //delay (1000);
  if (!Udp.write(packetBuffer, NTP_PACKET_SIZE) ) //;
    Serial.println("write error");
    //delay (1000);
  if (!Udp.endPacket()) //;
    Serial.println("endPacket error");
    //delay (1000);
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

UDP read not working on AVR boards

The example UDPNTPClient returns always 0 as current timestamp.

This means that UDP send is working (because the time server receive the request) but the UDP read is not (because it reads always as 0x00).

The bug appears only on AVR boards, probably the issue is due to a wrong assumption about datatype size on 8bit MCU.

PUT/POST and callback - Arduino code hangs

Hello Team,

I found a behavior that I want to expose here in order to someone tell me if it's a bug, for me it's certainly something critical since arduino code hangs.

I was making a PUT request to arduino when I notice the code hangs, the code also hangs with a POST request, my setup is the BasicWiFiServer example, just run it and issue a POST request using curl, for example

Suppose winc is at 192.168.1.60

curl -v --data "myname=manuel" http://192.168.1.60/my_form

Arduino console will print something like this

(APP)(INFO)Chip ID 1503a0
(APP)(INFO)Firmware ver : 19.4.4
(APP)(INFO)Min driver ver : 19.3.0
(APP)(INFO)Curr driver ver: 19.3.0
Attempting to connect to SSID: MOOI
SSID: MOOI
IP Address: 192.168.1.60
signal strength (RSSI): 4294967270 dBm
SOCKET_MSG_BIND CALLBACK CALL
SOCKET_MSG_BIND CALLBACK end CALL
SOCKET_MSG_ACCEPT CALLBACK CALL
SOCKET_MSG_ACCEPT CALLBACK end CALL
new client
SOCKET_MSG_RECV CALLBACK CALL
SOCKET_MSG_RECV CALLBACK end CALL
POST /my_form HTTP/1.1
User-Agent: curl/7.38.0
Host: 192.168.1.60
Accept: /
Content-Length: 13
Content-Type: application/x-www-form-urlencoded

The SOCKET_MSG_BIND CALLBACK CALL and similar are debug prints I added, if you go to source file you cann in the callback function for socket the prints, I added at the start and end of switch cases, but also I added a case for the send call back like this

    case SOCKET_MSG_SEND:
        send_ret = *(int16_t*)pvMsg;
        Serial.print("sent ");
        Serial.print(send_ret);
        Serial.print("bytes ");

just define before switch clause the send_ret variable
int16_t send_ret;

Ok, now what's the bug?, well the MCU have just hangs, bad for an embedded, actually since I got deeper on this for a f.. day, I know that the winc1500 stack fails after several calls to client.write, just to realize that if you don't call the receive for all the characters on winc1500 subsequent calls to it will stop winc1500 from getting you a dma address to write the outgoing message, for example, the function hif_send in m2m_hif.c will fails to fill the variable dma_addr which under normal circumstances it's a 32 bit address but when it fails the command just go thru but the variable stay at 0, causing a "Failed to alloc rx size" if you place asf stack to be verbose.

I found that receiving all the incoming buffer before continuing with client.prints just solve the issue, in my previous example, the content-length is 13 so you need to extract 13 chars before continuing, just put this on th code

              for(int k=0; k<13; k++){
                  c = client.read();
                  Serial.print(c);
              }

Then you will see this output on Arduino Console

(APP)(INFO)Chip ID 1503a0
(APP)(INFO)Firmware ver : 19.4.4
(APP)(INFO)Min driver ver : 19.3.0
(APP)(INFO)Curr driver ver: 19.3.0
Attempting to connect to SSID: MOOI
SSID: MOOI
IP Address: 192.168.1.60
signal strength (RSSI): 4294967269 dBm
SOCKET_MSG_BIND CALLBACK CALL
SOCKET_MSG_BIND CALLBACK end CALL
alive
alive
SOCKET_MSG_ACCEPT CALLBACK CALL
SOCKET_MSG_ACCEPT CALLBACK end CALL
new client
SOCKET_MSG_RECV CALLBACK CALL
SOCKET_MSG_RECV CALLBACK end CALL
POST /my_form HTTP/1.1
User-Agent: curl/7.38.0
Host: 192.168.1.60
Accept: /
Content-Length: 13
Content-Type: application/x-www-form-urlencoded

myname=manuel
sent 15 bytes
sent 1 bytes
sent 1 bytes
sent 23 bytes
sent 1 bytes
sent 1 bytes
sent 17 bytes
sent 1 bytes
sent 1 bytes

more sent x bytes here...

Could someone just tell me if there is something we can do to avoid a hard crash like this in case the application layer fails or miss to extract some received data?

Cheers,

WEP security does not work with WiFi101 library and MKR1000

Using a Linksys router configured with WEP wireless security & using the "ConnectWithWEP" example for simplest repro, each connection attempt with WiFi.begin(ssid, keyIndex, key); returns WL_CONNECT_FAILED. I have tried several keys and indices. I am able to connect to the network with my Android phone using any of the keys, and am able to ping the phone from my PC once connected. Let me know if you need me to investigate further or can suggest some things for me to try, as I have the setup here and ready to go.

I am using the latest code from today's updates, with my WiFiClient patch ( #16 ) on top.

As a side note, I have had no issues with open networks as well as all combinations of WPA/WPA2 security types using both AES and TKIP. These security types connect and have no issues exchanging large amounts of data with the device.

Copy-assignment operator needed in WiFiClient

Pretext:

  • WiFiServer::available(uint8_t*) returns WiFiClient as an object, not a pointer to an object.
  • WiFiClass maintains WiFiClient* _client[] cache of pointers to WiFiClient objects, indexed by client socket.
  • valid WiFiClient constructors (two of the three) assign WiFi._client[_socket] to this, attempting to cache the address for the most recently constructed WiFiClient object for a given socket.
  • WiFiClient::available(), read(), and other functions use m2m_wifi_handle_events(NULL); to load data into a buffer for the client, as stored by WiFiClass cache described above.

Problem
No existing copy-assignment operator means that the caching in WiFiClass member WiFiClient* _client[] is not always valid. Default implementation of this operator performs memory copy only. Examples provided below.

Examples::
A) WiFiClient object is stored as a global variable in a sketch

WiFiClient client;  //stack memory allocated, default ctor invoked
WiFiServer server(23);

setup() { ... }

loop() {
  client = server.available();  //(1) (2)
  if( client.available() ) //(3)
  {
    ...
  }
}

(1) compiler optimization will invoke WiFiClient(uint8_t sock, uint8_t parentsock) ctor here when client is first created (as returned by WiFiServer.available()), this constructor will set WiFi._client[socket] = this. However, since client object is a global object, memory already exists for this object, and copy-assignment operator is invoked. WiFiClass _client cache is now invalid.

(2) Subsequent calls to server.available() will return the cached object, in which the copy-assignment operator will be invoked instead of the copy constructor. WiFiClass cache is invalidated.

(3) this line will update the buffers in the cached WiFiClient object via m2m_wifi_handle_events(NULL);, which is not the same as this client object. When m2m_wifi_handle_events(NULL); finishes, the return value of this client object is _head - _tail, which have not been updated for this object. return value is always 0, even when data has been placed into the cached object.

B) WiFiClient is stored as a member of another class

class WiFi101Stream : public Stream {
private:
  WiFiServer _server = WiFiServer(23);
  WiFiClient _client;

public:
  inline int connect_client() 
  {
    if( !( _client && _client.connected() ) ) {
      WiFiClient newClient = _server.available(); //(1) (2)
      if( !newClient )
      {
        return 0;
      }

      _client = newClient;  //(4)
    }
    return 1;
  }
}

(4) Copy constructor is not invoked, only copy-assignment operator. WiFiClass cache still invalid.

Solution
I'd first like to ask why this WiFiClient caching design was used? Inter-dependent classes messing with a common cache in WiFiClass is spaghetti code, proper member encapsulation is not exercised. I imagine it was done to prevent WiFiClient objects from existing on the heap, but I doubt that a class of this very small size would cause issues if the buffers are maintained in a cleanly manner.
I have successfully tested a solution in which the WiFiServer::available() function is converted from a WiFiClient return type to WiFiClient*, in which a newly-constructed client object is first assigned to the WiFiClass _client cache and then returned. Subsequent calls to WiFiServer::available return this cached pointer. This still requires the WiFiClass _client cache to be updated by WiFiServer::available(), but at least the stored address does not have to be overwritten each time this object is passed from function to function, stored as a global object in a sketch, or encapsulated in another class as a member variable. This also prevents the copy-constructor from being invoked during every loop() (as in all of the example sketches).

However, I've assumed the existing design should not be changed (APIs/example sketches would be modified by the above change). I've instead implemented a fix by moving the logic inside the WiFiClient copy constructor to a new setMembersAndWiFiCache(const WiFiClient& other); (disclaimer: naming things is hard) function and adding a copy-assignment operator to this class, which will also call this new function. This will guarantee that if the WiFiClient object is stored in any other way than a scoped variable, the library will function properly. I will create the pull request shortly after this post is submitted and I will add a link in a comment below. I invite you to critique the naming of the new function or any other details.

v0.9.0 does not build on the Arduino 101 and Due

/Users/smistry/Documents/Arduino/libraries/WiFi101/src/WiFiMdnsResponder.cpp: In member function โ€˜bool WiFiMDNSResponder::parseRequest()โ€™:
/Users/smistry/Documents/Arduino/libraries/WiFi101/src/WiFiMdnsResponder.cpp:152:61: error: โ€˜memcmp_Pโ€™ was not declared in this scope
     if (memcmp_P(request, expectedRequestHeader, HEADER_SIZE) == 0 &&            // request header match
                                                             ^
/Users/smistry/Documents/Arduino/libraries/WiFi101/src/WiFiMdnsResponder.cpp:154:72: error: โ€˜strncasecmpโ€™ was not declared in this scope
         strncasecmp(name.c_str(), (char*)requestName, requestNameLength) == 0 && // name match
  1. The Arduino 101 does not provide memcmp_P in avr/pgmspace.h

  2. There is no strncasecmp method.

The AVR and SAMD cores build fine, however SAM core also experiences 1).

@facchinm any thoughts on how to proceed with this? This breakage was introduced in #47.

TCP RST not handled? client.connected is true but client.available is false

Hi

using the WiFiWebServer example sketch, I have encountered a serious issue.
When hitting F5 in the browser while the page is still loading, the program gets stuck in the
while (client.connected()) loop because client.connected stays "true" but "client.available" keeps returning "false".

Using Wireshark, I discovered that the browser (IE 11, Chrome) seems to be sending a TCP RST to reset the connection and then starts the new HTTP GET request. However, it seems that the library doesn't handle TCP RST so that we don't know that the connection should have been closed.

Maybe I'm on the wrong track, but this is all I was able to find out.

regards

Not reading data from client blocks data from other clients

I am in the process of writing a PASV FTP client using a Mega 2560
Uploading does not present a problem and is fast.
Downloading does. This includes using the PASV LIST command to obtain a directory listing.
In both cases, after opening the PASV port I receive 1418 bytes and then the process stalls , with the server side PASV port still open.
Occasionally 1 in 5 directory listings come through complete using void dir.
I have tested on two Unix L8 servers.
The full code is attached,
I have opened a dmz for the Arduino WiFi101 shield IP.
(Not really necessary for PASV.)
The shield is allocated a fixed IP by the router.

I have re-structured the pclient read code endlessly.
Strangely, using the server side STAT call to get the directory works seamlessly - this uses the ftp control port.
I am not aware of any default paging methods under pasv ftp.
The servers do not support block transfer.

As a (very slow) workround to get ftp download working I have coded:

  1. PASV
  2. Connect to passive port
  3. REST 0
  4. RETR filename
  5. grab 1024 bytes from PASV port
  6. stop passive port, flush PASV
  7. PASV, then connect to new PASV port
  8. REST (bytes received so far - 1)
  9. goto point 5 and repeat until the port times out or the PASV port is no longer connected
void dir(String prompt) { // this version stalls at 1418 bytes, most times
  if(!useserial) return; // no point
Serial.println(F("\n**************** PASV directory request "));
Serial.print(prompt);
Serial.println(F(" ****************\n"));
digitalWrite(led, HIGH); // signal dir retrieve

echo(F("Type A")); // A for ascii, I for binary
echo(F("REST 0")); // reset server pointer to 0

unsigned int hiPort = getport();
  if (hiPort == 0) {
  Serial.println(F("PASV rejected"));
  flashled(12);
  return;
  }
pclient.flush();
  if (pclient.connect(server, hiPort)) {
  Serial.println(F("Pasv Data port connected"));
  Serial.flush();
  }else {
  Serial.println(F("Pasv Data port connection failed"));
  flashled(12);
  return;
  }

int n = 0;
boolean error = false;
unsigned long bytes = 0;

retval = echo(prompt);
  if (retval.startsWith("5")) {
    if(useserial) Serial.println(F("LIST rejected"));
  pclient.stop(); response();
  digitalWrite(led, LOW); // signal end of dir retrieve
  return;
  }

unsigned long startTime = millis();
  while (pclient.connected() ) {
    if (millis()- startTime > 2000) { // extending this time does not fix 1418b bug
    error = true;
    break;    
    }
  n = pclient.available();
    if(n > 0) {
    byte getit[n];
    pclient.read(getit, n);
      for (int i = 0; i < n; i++) Serial.write(char(getit[i]));
    bytes += n;
    startTime = millis();
    }
  }

  if (error) Serial.print(F("\nTimeout. "));


Serial.print(F("Received ")); Serial.print(bytes); Serial.println(F(" bytes"));
Serial.println(F("\nClosing Pasv port")); Serial.flush();
pclient.flush(); pclient.stop(); // does not generate a response on my server
delay(100); client.flush();
digitalWrite(led, LOW); // signal end of dir retrieve
}
unsigned int getport(){
String retval = echo(F("PASV"));
  if (retval.startsWith("5")) return 0;

// we have to change to the new port
unsigned int portarray[6];
int pos = 1 + retval.length();
char cretval[pos];
retval.toCharArray(cretval, pos);
char *str = strtok(cretval,"(,");
  for ( byte i = 0; i < 6; i++) {
  str = strtok(NULL, "(,");
  portarray[i] = atoi(str);
    if(str == NULL) return 0;
  }
unsigned int hiPort, loPort;
hiPort = portarray[4] << 8;
loPort = portarray[5] & 255;
hiPort = hiPort | loPort;
  if(useserial) {
  Serial.print(F("Data port: ")); Serial.println(hiPort);
  }
return hiPort;
}

String echo(String request){ // send request and get response
  if (useserial) Serial.println(request);
client.println(request);
String retval = response();
  if (useserial) Serial.println();
return retval;
}

String response(){ // get server response with timeout
unsigned long starttime = millis();
unsigned long lastbyte = starttime;
boolean alldone = false;
boolean gotbyte = false;
String retval = "";
int received = 0;
  do{
    if (!client.connected() ){
    return "";
    }
    while (client.available() > 0 ) {
    char c = client.read();
    received ++;
      if (received < 127) retval = retval + String(c); // limit the string size
      if (useserial) Serial.write(c);
    lastbyte = millis();
    gotbyte = true;
    }
    // a pause of 200 mS second probably indicates message over
    if (gotbyte && (millis() - lastbyte > 200)) alldone = true;
  } while ( (millis() - starttime < timeout) && (!alldone));
return retval;
}`

FTPpassive2.zip

David

version 0.9.1 does not work with MKR1000 and Windows Remote Arduino Experience app

I have an MKR1000 and in version 0.9.0 I can load the StandardFirmataWifi version 2.5.2 on the board and connect using the Windows Remote Arduino Experience app. I can also connect with the apps that I have created. But if I update WiFi101 to 0.9.1 it doesnt connect anymore in anything. On the app I get this error

connection attempt failed : a device connection was established, but the device failed handshaking procedures.
verify that your device is configured with standard firmata.
message: catastrophic failure
pin configuration not received.

CheckWifi101FirmwareVersion unhelpful message

This example should print a more helpful message, at the very least with a link to the update utility. Ideally, it should also print a brief summary of how to accomplish the update.

Currently, the end-user experience in the case of a too-old firmware is this:

Check result: NOT PASSED
 - The firmware version on the shield do not match the
   version required by the library, you may experience
   issues or failures.

That's pretty far from the ease-of-use reputation Arduino has earned over the years. The Wifi101 pages don't even mention this example or how to upgrade:

https://www.arduino.cc/en/Main/ArduinoWiFiShield101
https://www.arduino.cc/en/Reference/WiFi101

Good usability in error messages requires not only informing users of a problem, but giving them instructions or a link to where they can find easy-to-follow instructions to solve the problem.

Cannot connect to Linksys router with "WPA/WPA2 mixed network"

help.

my new wifi 101 shield with latest firmware cannot wpa connect to linksys router running firmware 1.1.40.162464

WiFi shield present
Firmware version: 19.4.4
Firmware version required : 19.4.4

it can connect in open non encrypted to the router.
in wpa mode, i have the correct password.

MKR1000 wifi.status() not updating in AP mode

Hi,
I made a simple app to show me value of wifi.status() at different steps but it doesnt change. i configured my MKR as access point and let my andoid mobile connect to it. it is successfully connected but when i turn off wifi, my wifi.status() doesnt show new value.

void loop() {
Serial.println(WiFi.status());
}

above code keeps on showing me number 3 no matter my wifi is connected or not. i want to detect if wifi of device to which MKR is connected gets off

Errors using FQDN in Udp.beginPacket

If I use a FQDN in Udp.beginPacket, it returns an error, but it appears to make the DNS request.

Two issues:

  1. It always returns an error when using Udp.beginPacket
  2. It appears to be caching the request, so the 2nd time you make a request its NOT sent. This is
    not desirable action when asking for an NTP like request, where the returned IP address will change with each request. This function needs a way to override the caching or allowing the setting of a TTL value for the request.

This is my test code, its the same basic test code as in issue 80 and output from the program and wireshark.

68584   08:36:24.740895 192.94.167.14   4.2.2.2 DNS 75  Standard query 0x3420 A time-c.nist.gov
68585   08:36:24.756976 4.2.2.2 192.94.167.14   DNS 91  Standard query response 0x3420 A time-c.nist.gov A 129.6.15.30
68586   08:36:24.758824 192.94.167.14   time-c.nist.gov NTP 90  NTP Version 4, client
68593   08:36:24.896439 time-c.nist.gov 192.94.167.14   NTP 90  NTP Version 4, server
211257  08:36:32.359390 192.94.167.14   b.resolvers.Level3.net  DNS 88  Standard query 0xe692 A 1.north-america.pool.ntp.org
212802  08:36:32.374595 b.resolvers.Level3.net  192.94.167.14   DNS 152 Standard query response 0xe692 A 1.north-america.pool.ntp.org A 206.108.0.133 A 192.95.20.208 A 128.138.141.172 A 171.66.97.126
213958  08:36:32.385063 192.94.167.14   1.north-america.pool.ntp.org    NTP 90  NTP Version 4, client
217922  08:36:32.471639 1.north-america.pool.ntp.org    192.94.167.14   NTP 90  NTP Version 4, server
304115  08:36:42.374814 192.94.167.14   1.north-america.pool.ntp.org    NTP 90  NTP Version 4, client
305234  08:36:42.452813 1.north-america.pool.ntp.org    192.94.167.14   NTP 90  NTP Version 4, server


Attempting to connect to SSID: lafleur
Connected to wifi
SSID: lafleur
IP Address: 192.94.167.14
signal strength (RSSI):-72 dBm

Starting connection to server...

Sending an NTP request
beginPacket error
Packet received in: 119 ms
Seconds since Jan 1 1900 = 3678017792
Unix time = 1469028992
The UTC time is 15:36:32

Sending an NTP request
beginPacket error
Packet received in: 92 ms
Seconds since Jan 1 1900 = 3678017802
Unix time = 1469029002
The UTC time is 15:36:42

Sending an NTP request
beginPacket error
Packet received in: 88 ms
Seconds since Jan 1 1900 = 3678017812
Unix time = 1469029012
The UTC time is 15:36:52

Sending an NTP request
beginPacket error
Packet received in: 88 ms
Seconds since Jan 1 1900 = 3678017822
Unix time = 1469029022
The UTC time is 15:37:02
/*

 Udp NTP Client

 Get the time from a Network Time Protocol (NTP) time server
 Demonstrates use of UDP sendPacket and ReceivePacket
 For more on NTP time servers and the messages needed to communicate with them,
 see http://en.wikipedia.org/wiki/Network_Time_Protocol

 created 4 Sep 2010
 by Michael Margolis
 modified 9 Apr 2012
 by Tom Igoe

 Modified 20 July 2016
 Tom Lafleur

 This code is in the public domain.

 */

#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;

char ssid[] = "xxxxx";              //  your network SSID (name)
char pass[] = "xxxxx";        // your network password
int keyIndex = 0;                     // your network key Index number (needed only for WEP)

unsigned long t1  = millis();
unsigned long trx = millis();

// Set fixed IP address as needed
// My IP address for the WINC1500:
  IPAddress MYip(192, 94, 167, 14);   
// the DNS server address for the WINC1500:
  IPAddress MYdns1(4,2,2,2);  
// the GateWay address for the WINC1500:
  IPAddress MYgw(192, 94, 167, 4);   
// the Sub Net Mask for the Winc1500:
  IPAddress MYsnm(255,255,255,0); 
// DNS name of NTP server to use  
//const char NTPserver [] = "1.north-america.pool.ntp.org";        //"1.north-america.pool.ntp.org"  us.pool.ntp.org
const char NTPserver [] = "ntp.ucsd.edu";

unsigned int localPort = 2390;        // local port to listen for UDP packets

IPAddress timeServer(129, 6, 15, 28); // time.nist.gov NTP server

const int NTP_PACKET_SIZE = 48;       // NTP time stamp is in the first 48 bytes of the message

byte packetBuffer[ NTP_PACKET_SIZE ] = {0};     //buffer to hold incoming and outgoing packets

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;


/* *************************************************************************
 * 
 * 
 * ************************************************************************ */
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

WiFi.setPins (8,7,4,2);   // using a Feather with a WINC1500

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

// set manual IP address, comment this out for DHCP
  WiFi.config(MYip, MYdns1, MYgw, MYsnm); 

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  Udp.begin(localPort);
}


/* *************************************************************************
 * 
 * 
 * ************************************************************************ */
void loop()
{
  // check if its time to make an NTP request
  if ( (millis() - t1) > 10000)
  {  
    t1 = millis();
    // see if we are still connected
    if ( (WiFi.status() ==  WL_CONNECTED) )
        sendNTPpacket(timeServer);              // send an NTP request packet to a time server
        else Serial.println("Not Connected");
  }  

  // Lets see if a reply is available
    if ( Udp.parsePacket() ) 
      {
          RXpacket();
      }

}  // end of loop


/* ************************************************************************ */
void RXpacket(void)
{
   trx = millis() - t1;
    Serial.print("Packet received in: ");
    Serial.print( trx);
    Serial.println(" ms");
    // We've received a packet, read the data from it
    Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer

    //the timestamp starts at byte 40 of the received packet and is four bytes,
    // or two words, long. First, esxtract the two words:

    unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
    unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);

    // combine the four bytes (two words) into a long integer
    // this is NTP time (seconds since Jan 1 1900):
    unsigned long secsSince1900 = highWord << 16 | lowWord;
    Serial.print("Seconds since Jan 1 1900 = " );
    Serial.println(secsSince1900);

    // now convert NTP time into everyday time:
    Serial.print("Unix time = ");

    // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
    const unsigned long seventyYears = 2208988800UL;

    // subtract seventy years:
    unsigned long epoch = secsSince1900 - seventyYears;

    // print Unix time:
    Serial.println(epoch);

    // print the hour, minute and second:
    Serial.print("The UTC time is ");       // UTC is the time at Greenwich Meridian (GMT)
    Serial.print((epoch  % 86400L) / 3600); // print the hour (86400 equals secs per day)
    Serial.print(':');

    if ( ((epoch % 3600) / 60) < 10 ) {
      // In the first 10 minutes of each hour, we'll want a leading '0'
      Serial.print('0');
    }
    Serial.print((epoch  % 3600) / 60); // print the minute (3600 equals secs per minute)
    Serial.print(':');

    if ( (epoch % 60) < 10 ) {
      // In the first 10 seconds of each minute, we'll want a leading '0'
      Serial.print('0');
    }
    Serial.println(epoch % 60); // print the second
}


/* ************************************************************************ */
// send an NTP request to the time server at the given address
unsigned long sendNTPpacket(IPAddress& address)
{
  Serial.println("\nSending an NTP request");
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);

  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  //Serial.println("2");
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  //8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12]  = 49;
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;

  //Serial.println("3");

  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:
  //if (!Udp.beginPacket(address, 123))             //NTP requests are to port 123)
  if (!Udp.beginPacket(NTPserver, 123))             //NTP with DNS requests are to port 123)
        Serial.println("beginPacket error");

  if (!Udp.write(packetBuffer, NTP_PACKET_SIZE) ) 
        Serial.println("write error");

  if (!Udp.endPacket()) 
        Serial.println("endPacket error");
}

/* ************************************************************************ */
void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Cannot form mqtt connections using WiFiSSLClient with firmware version 19.3.0

The PubSubClient times out while attempting to connect. The underlying issue appears to be the .available() call always returning 0.

I've attempted to use the WiFi 101 shield on both the Zero and the Arduino 101 with the same results. Running this example as-is also yields the same issue.

Using non-SSL client connects successfully. I am running the latest master branch of the WiFi101 client.

AP mode server sockets refuse connection after disconnecting and reconnecting to AP

When using the AP_SimpleWebServer.ino example, the server socket is no longer in a listening state after a client disconnects from the AP and reconnects. WireShark shows a "connection refused".

Steps to reproduce:

  1. Load the AP_SimpleWebServer.ino example sketch.
  2. Connect device to created AP.
  3. Open browser to http://192.168.1.1
  4. Disconnect device from created AP.
  5. Connect device to created AP.
  6. Open browser to http://192.168.1.1

At step 6) the browser will not be able to establish a connection to the server. It looks like the WINC1500 firmware (19.4.4) is clearing server sockets after a client disconnects and re-connects to the AP.

SimpleWebServerWifi hangs after a time in MKR1000.

I intended control a home device using a MKR1000 and a web server from your Wifi101.
So i did, but the board hangs after an unpredictable time and stops responding client's requests.
In order to find the problem, i loaded the example file SimpleWebServerWifi, and tested it alone. I just changed:
-My wify name&password.
-The pin number 9 to 6 (it's the built-in led of MKR1000).
Well, i found this sketch hangs since a few minutes after uploaded, to a maximum of 2 days.
I exposed this issue in the MKR1000 forum, and at least one other guy got same behaviour.
Same issue is found with the sketch WiFiWebServer, so i think it's related to the webserver code.
I have 8 MKR1000 boards, and checked this issue in all them.
Don't know if at the end, it's hardware or software related, but would be helpfull if someone else could test by itself and report the results.
Thanks!

Arduino 101 + Wifi 101 Shield board freeze.

Moved from arduino/Arduino#4797

@apiascik:

Hello,

I'm working with the Arduino 101 (Curie) board and WiFi101 shield. I've been unsuccessful in getting even the ScanNetworks example to work. I can run the firmware detection example (it meets the firmware requirements), but execution freezes if I do anything more than that.

This might be similar to [#4545]

Observations

If I call Serial.begin, the first call to WiFiClass::scanNetworks() ultimately results in the board freezing. I observe no SPI traffic in my logic analyzer. If, however, I don't call Serial.begin, I continue to observe SPI traffic at intervals suggesting the sample is executing (scanning for networks).

I dug into the WiFi driver code and found the following. I copied the m2m_hif.c's hif_send() function (called it hif_send2() ), and updated m2m_wifi.c's m2m_wifi_request_scan() function to call hif_send2() instead of hif_send(). I then added a return statement just before completing the packet transfer:

...
reg = dma_addr << 2;
reg |= (1 << 1);
// return 0; <-- Doesn't freeze if I uncomment this.
ret = nm_write_reg(WIFI_HOST_RCV_CTRL_3, reg); <-- Freezes if I let this line execute.
if(M2M_SUCCESS != ret) goto ERR1;
...

With the return I get no real results, as I'd expect, but the sketch continues to execute. I know it's not that line that causes the issue, but at this point, I'm unfamiliar with the driver as a whole, and don't know what what executes next. I'll keep digging.

Configurations I've tried

Windows 7 x64 USB2 and Windows 7 x64 USB3 (two different computers; applied the fix for USB 3)
Arduino IDE 1.6.8
Intel Curie Board Libraries 1.0.4 and 1.0.5
WiFi 101 libraries 0.7.0, 0.8.0, and 0.9.0

All combinations of the following devices:
Arduino 101 boards:
AE6642SQ55200CR
AE6642SQ55201MY

Wifi101 Shields:
Neither of the 2 had serial numbers as far as I could tell. They were purchased and arrived within the last two weeks.

Any help would be appreciated. Please let me know if I can provide any additional information.

begin() with no encryption freezes

There seems to be a problem with begin() when it's got no encryption method.

The following code loops continually if the AP does not allow a connection or isn't present:

char ssid[] = "my network";     
char pass[] = "gegegege"; 

void setup()
{
  Serial.begin(9600);
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network:
    /status = WiFi.begin(ssid, pass);
    delay(5000);
  }

The following code, by contrast, does not loop, but freezes on the first call to begin():

char ssid[] = "my network";     

void setup()
{
  Serial.begin(9600);
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network:
    /status = WiFi.begin(ssid);
    delay(5000);
  }

The network in question works fine with other networked devices, and has no encryption in place.

WiFi.status() == WL_CONNECTED although connection lost and WiFi.RSSI() == 0

I'm using the MKR1000 with the WiFi101 lib (and WiFiiUDP) to send Multicast UDP messages. (which works fine in principle).

But after some time (this can be after 30 min or after 2..4 hours), the UDP messages are no longer sent to the network.

When this happens, the WiFi.status() is still equal to WL_CONNECTED (!), but WiFi.RSSI() is equal to 0 (I'm using a Serial(USB) debug output). Calling WiFi.begin() and upd.beginMulti(..) again does not result in a new, working connection. (and it happens if I connect a Serial-USB connection or not). Power supply is either via PC/USB or with the 800mAh battery - this also makes no difference.

thx, michael.

P.S.
I uploaded a similar test SW to both the

  • "samw25 xplained" board (using the "bare" ASF calls)
    and also to the
  • "feather-m0-wifi-atwinc1500" (which does not have the SAMW25 hardware, but a similar SAMD21+WINC1500 combination) and this board also uses an Arduino lib derived from WiFi101)

and both these boards do not seem to have this problem.

P.S.2
My WiFi RSSIs are in the -55 to -40 range - the AP is in the same room with the boards.

Use Wifi101 shield with Teensy 3.1

I would like to use the Wifi101 shiled with Teensy 3.1 from pjrc.com, I have the following questions: (1) what hardware connections should I make between the shield and Teensy? (2) when I selected the Teensy board in Arduino IDE, the Wifi101 library was compiled with many different errors (many related with the _avr source), is it possible to add support with Teensy 3.1?

Firmware Updater Bricked Wifi 101?

This is all I get when attempting to upgrade the firmware of the Wifi 101 on my official Arduino Uno:

2016/03/02 14:56:10 Connecting to programmer
2016/03/02 14:56:12 Synch with programmer
2016/03/02 14:56:12 Reading max payload size
2016/03/02 14:56:12 Flashing firmware from '/Wifi101_FirmwareUpdater/firmware/19.4.4/m2m_aio_2b0.bin'
2016/03/02 14:56:12 Error during FlashErase()

Now none of the Wifi101 examples, including Check101FirmwareVersion work. Could had something gone wrong during the upgrading process? Anything I can do to start anew?

WiFiServer concurrent clients connected question

Hello sandeepmistry,

I have a question I would like you can clarify to me please,

Does the WiFiServer library only allow one client connection at a time? I am seeing that the WiFiServer class only has one SOCKET _socket variable even if the WINC1500 supports up to 7 TCP sockets.

Perhaps I am just not understanding how _server.available can return different clients that might be available.

I will appreciate your answer,

Best

Mac addresses returned in reverse order in examples

Just in case for some bizarre reason it is different in other parts of the planet I have to state that I am using the shield in the uk.
My router reports that the mac address of the shield and of itself is in the reverse order of that shown in the example sketches.
Simply printing the mac address in the reverse order solves the issue:
byte mac[6]; WiFi.macAddress(mac); Serial.print("MAC address: "); Serial.print(mac[0], HEX); Serial.print(":"); Serial.print(mac[1], HEX); Serial.print(":"); Serial.print(mac[2], HEX); Serial.print(":"); Serial.print(mac[3], HEX); Serial.print(":"); Serial.print(mac[4], HEX); Serial.print(":"); Serial.println(mac[5], HEX);

David

no bytes available for client

Hello. I am using the wifi 101 shield with an arduino zero, and running the web server example. When I try to curl to my board's ip address, sometimes I get the output of the GET request, but most of the time it just waits and stalls after printing out "new client". It seems that client.available() is returning zero, but curl claims the request has happened. Curls output is as follows:

curl -vL http://10.1.11.252/

  • Trying 10.1.11.252...
  • Connected to 10.1.11.252 (10.1.11.252) port 80 (#0)

    GET / HTTP/1.1
    Host: 10.1.11.252
    User-Agent: curl/7.43.0
    Accept: /

Using WiFi101 shield in low power mode

Hello,
Is there a possibility to switch off the WiFi101 shield in software? For example:
digitalWrite(5, LOW); - reduces the power consumption significantly (90%). After that I execute
WiFi.init();
WiFi.begin(_ssid, _pass);
The WiFi connection is established. But:
WiFiClient client = WiFiClient();
client.connect(host, port); - is not working.

Maybe there is another possibility to switch off the WiFi101 shield in software?
Thank you very much and best regards, Walter

Malformed packets when used with Oscuino

Hi,
I've justed started this same issue on the Oscuino end, but since I'm not sure which library is generating the problem, I'm opening it here too. Maybe someone has also encountered this problem?
I'm trying to use Oscuino with the new Arduino MKR1000 board, which uses the WiFi101 library (a modified version of the WiFi library) to communicate.
Receiving messages on the board works like a charm, I've tried it both with TouchOSC and Processing, and have managed to control one of the PWM pins on the board remotely.
The problem appears when trying to send messages from the board to the computer: no matter what I try, I can't seem to create "correct" OSC messages that my receivers can interpret.
Checking with the example codes I think the issue can only lie with one of the three following calls:

Udp.beginPacket(remIP, remPort);
msg.send(Udp);
Udp.endPacket();

I've reached this conclusion because comparing the code of WifiUDP with that of EthernetUDP (with which the same code works) I've seen that the code is quite different, but I'm not savvy enough to identify which pieces of the code might be critical.
The question is: do any of these functions add/require something to/from the UDP packet? The reason I'm asking this is that going deeper and analyzing the packets with Wireshark, I've realized that (at least) precisely 4 bytes are wrong, so maybe something is screwing the 4-padding requirement of OSC up? Here are the images of the capture that make me suspect this (I'm trying to send "layer1/clip1/connect 1"):

cap1

cap2

cap3

Any help and ideas would be greatly appreciated. Thanks a lot in advance!

v0.7.0 conflicts with Adafruit_VC0706/SoftwareSerial

I'm using an Uno r3, and trying to pair the wifi shield with the Adafruit TTL camera. It appears that there is a little conflict going on however. If I do this very simple sketch:

#include <Adafruit_VC0706.h>
#include <SPI.h>
#include <WiFi101.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

I get the following compiler errors:

libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o: In function `__vector_3':

\Documents\Arduino\libraries\WiFi101\src\bsp\source/nm_bsp_arduino_avr.c:65: multiple definition of `__vector_3'

libraries\SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:229: first defined here

libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o: In function `rx_pin_read':

\Documents\Arduino\libraries\WiFi101\src\bsp\source/nm_bsp_arduino_avr.c:60: multiple definition of `__vector_4'

libraries\SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:394: first defined here

libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o: In function `rx_pin_read':

\Documents\Arduino\libraries\WiFi101\src\bsp\source/nm_bsp_arduino_avr.c:60: multiple definition of `__vector_5'

libraries\SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:394: first defined here

collect2.exe: error: ld returned 1 exit status

Doing some quick googling, I see someone else had a similar problem here:
arduino/Arduino#4534

However, they are attempting to do this with a mega (whereas I am using an UnoR3). If I comment out the same lines mentioned in the link above, my wifi shield is no longer able to connect (no errors show up, it just simply fails to connect or scan for networks).

I have not tested this with v0.8.0, as that version of the library appears to not work with the Uno r3. The above bug report appears to have been closed, suggesting it has been fixed in v0.8.0?

Server sockets accept and close connections if server.available() not called

I have written a server application which works well, up to a point.
If a html page contains more than 2 pictures, only two are uploaded.
The missing pictures can be individually uploaded.
In IE, they can forced by right click, show picture.
Refreshing the page does not alter the number of pictures uploaded.
I have had this problem before when writing servers on another platform.
The issue proved to be a shortage of sockets.

WiFi101server.txt

Code attached,
David

Wifi101 + Mega2560 + SD Card Breakout failure

I am having issues interfacing the Mega, Wifi Shield, and the Adafruit SD Breakout. I am unable to use both the SD Breakout and the Wifi Shield concurrently; doing so produces failure states. I have run the following three tests:

  1. Wifi101 + Mega2560 Only (No wiring for SD Breakout)
    --CheckWifi101FirmwareVersion works without issue / detects the shield

  2. Adafruit SD Breakout + Mega 2560
    CS to Pin 10
    CLK to Pin 52
    DO to pin 50
    DI to pin 51
    --CardInfo detects the card, and properly lists to contents of the SD card
    `
    Initializing SD card...Wiring is correct and a card is present.

Card type: SD1

Volume type is FAT16

Volume size (bytes): 2030927872
Volume size (Kbytes): 1983328
Volume size (Mbytes): 1936

Files found on the card (name, date and size in bytes):
SYSTEM~1/     2015-07-03 10:40:12
  INDEXE~1      2015-07-03 10:40:12 76
1.JPG         2000-01-01 01:00:00 48682
2.JPG         2000-01-01 01:00:00 48768
TRASH-~1/     2016-04-16 17:31:36
  INFO/         2016-04-16 17:31:36
    1JPG~1.TRA    2016-04-16 17:31:36 0
    1JPGTR~1.0OX  2016-04-16 17:31:36 57
  FILES/        2016-04-16 17:31:36
    1.JPG         2016-04-16 17:31:36 0
3.JPG         2000-01-01 01:00:00 3700
4.JPG         2000-01-01 01:00:00 3696

`

  1. Adafruit SD Breakout + Wifi101 + Mega 2650 (Failure State)
    CS to Pin 10
    CLK to Pin 52
    DO to pin 50
    DI to pin 51
    --CheckWifi101FirmwareVersion is unable to detect the shield.
    --CardInfo detects the card, but is unable to list the contents of the card, and shows only the following output:
    `
    Initializing SD card...Wiring is correct and a card is present.
Card type: SD1

Volume type is FAT16

Volume size (bytes): 2030927872
Volume size (Kbytes): 1983328
Volume size (Mbytes): 1936

Files found on the card (name, date and size in bytes):

`

Add an option to switch off WiFi completely

I am missing the option to turn off the WiFi Chip completely after disconnecting. If you connect to a WiFi and then disconnect, the power consumption stays quite high.

Could you please implement that or give some hints what has to be done to do so, so I can implement it on my own ?

Cant even complile examples for wifi101 and arduino 101

When I try to compile the example sketch to scan for available networks I get the following error.

I am running IDE 1.6.9 hourly build 2016/04/28 4:33

The board I have selected is Arduino 101

I am running library wifi101 0.9.0

I have read through all the forum posts I can find and I think I am doing all the suggested fixes for this issue.

C:\Users\chris\Documents\Arduino\libraries\WiFi101\src\WiFiMdnsResponder.cpp: In member function 'bool WiFiMDNSResponder::parseRequest()':

C:\Users\chris\Documents\Arduino\libraries\WiFi101\src\WiFiMdnsResponder.cpp:152:61: error: 'memcmp_P' was not declared in this scope

 if (memcmp_P(request, expectedRequestHeader, HEADER_SIZE) == 0 &&            // request header match

                                                         ^

C:\Users\chris\Documents\Arduino\libraries\WiFi101\src\WiFiMdnsResponder.cpp:154:72: error: 'strncasecmp' was not declared in this scope

     strncasecmp(name.c_str(), (char*)requestName, requestNameLength) == 0 && // name match

                                                                    ^

exit status 1
Error compiling for board Arduino 101.

Add Ping functionality to WiFi101 library

Please, add Ping functionality to the library. ATMEL's library has base implementation: m2m_ping_req(). Ping would be very useful in IoT project to allow easy connection test.
I will propose you a PR for this.

WiFi 101 Pin 5

The documentation for the WiFi 101 shield (www.arduino.cc/en/Main/ArduinoWiFiShield101) states
that "Digital pin 7 is used as a handshake pin between the WiFi Shield 101 and the board, and should not be used. " I have been working with a motor-control system for which I am controlling the motor from a web-page. It uses a number of digital output pins to control the motor. My system consists of an Arduino Uno board with the WiFi 101 shield. I have found that if I use Digital Pin 5, the system
doesn't work properly but when I use Pin 7 there is no problem. I am wondering if perhaps it is Digital pin 5 that "should not be used", at least for the Uno-WiFi 101 combination.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.