Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

Commit d4a5a08

Browse files
committed
Merge remote-tracking branch 'upstream/master'
Conflicts: library.properties src/Adafruit_WINC1500.cpp src/Adafruit_WINC1500.h src/Adafruit_WINC1500Server.cpp src/bsp/source/nm_bsp_arduino.c src/bus_wrapper/source/nm_bus_wrapper_samd21.cpp
2 parents 8771aa0 + 570e071 commit d4a5a08

40 files changed

+3069
-658
lines changed

CHANGELOG

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
WiFi101 0.6.0 - 2015.11.27
2+
3+
* Fixed bug with AVR boards when Web Server is used
4+
5+
* Fixed UDP read bug on AVR Boards
6+
* Added missing inlcude for SSL Client
7+
* Fixed peek() function
8+
* Fixed some examples
9+
10+
WiFi101 0.5.1 - 2015.10.06
11+
12+
* Improved support for AVR Boards (Uno, Mega, Leonardo, etc.) and
13+
ARM based boards (Due and Zero).
14+
15+
WiFi101 0.5.0 - 2015.10.01
16+
17+
* Initial release
18+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Endianess.ino - Network byte order conversion functions.
3+
Copyright (c) 2015 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
21+
bool isBigEndian() {
22+
uint32_t test = 0x11223344;
23+
uint8_t *pTest = reinterpret_cast<uint8_t *>(&test);
24+
return pTest[0] == 0x11;
25+
}
26+
27+
uint32_t fromNetwork32(uint32_t from) {
28+
static const bool be = isBigEndian();
29+
if (be) {
30+
return from;
31+
} else {
32+
uint8_t *pFrom = reinterpret_cast<uint8_t *>(&from);
33+
uint32_t to;
34+
to = pFrom[0]; to <<= 8;
35+
to |= pFrom[1]; to <<= 8;
36+
to |= pFrom[2]; to <<= 8;
37+
to |= pFrom[3];
38+
return to;
39+
}
40+
}
41+
42+
uint16_t fromNetwork16(uint16_t from) {
43+
static bool be = isBigEndian();
44+
if (be) {
45+
return from;
46+
} else {
47+
uint8_t *pFrom = reinterpret_cast<uint8_t *>(&from);
48+
uint16_t to;
49+
to = pFrom[0]; to <<= 8;
50+
to |= pFrom[1];
51+
return to;
52+
}
53+
}
54+
55+
uint32_t toNetwork32(uint32_t to) {
56+
return fromNetwork32(to);
57+
}
58+
59+
uint16_t toNetwork16(uint16_t to) {
60+
return fromNetwork16(to);
61+
}
62+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
FirmwareUpdate.h - Firmware Updater for WiFi101 / WINC1500.
3+
Copyright (c) 2015 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include <WiFi101.h>
21+
#include <spi_flash/include/spi_flash.h>
22+
23+
typedef struct __attribute__((__packed__)) {
24+
uint8_t command;
25+
uint32_t address;
26+
uint32_t arg1;
27+
uint16_t payloadLength;
28+
29+
// payloadLenght bytes of data follows...
30+
} UartPacket;
31+
32+
static const int MAX_PAYLOAD_SIZE = 1024;
33+
34+
#define CMD_READ_FLASH 0x01
35+
#define CMD_WRITE_FLASH 0x02
36+
#define CMD_ERASE_FLASH 0x03
37+
#define CMD_MAX_PAYLOAD_SIZE 0x50
38+
#define CMD_HELLO 0x99
39+
40+
void setup() {
41+
Serial.begin(115200);
42+
43+
nm_bsp_init();
44+
if (m2m_wifi_download_mode() != M2M_SUCCESS) {
45+
Serial.println(F("Failed to put the WiFi module in download mode"));
46+
while (true)
47+
;
48+
}
49+
}
50+
51+
void receivePacket(UartPacket *pkt, uint8_t *payload) {
52+
// Read command
53+
uint8_t *p = reinterpret_cast<uint8_t *>(pkt);
54+
uint16_t l = sizeof(UartPacket);
55+
while (l > 0) {
56+
int c = Serial.read();
57+
if (c == -1)
58+
continue;
59+
*p++ = c;
60+
l--;
61+
}
62+
63+
// Convert parameters from network byte order to cpu byte order
64+
pkt->address = fromNetwork32(pkt->address);
65+
pkt->arg1 = fromNetwork32(pkt->arg1);
66+
pkt->payloadLength = fromNetwork16(pkt->payloadLength);
67+
68+
// Read payload
69+
l = pkt->payloadLength;
70+
while (l > 0) {
71+
int c = Serial.read();
72+
if (c == -1)
73+
continue;
74+
*payload++ = c;
75+
l--;
76+
}
77+
}
78+
79+
// Allocated statically so the compiler can tell us
80+
// about the amount of used RAM
81+
static UartPacket pkt;
82+
static uint8_t payload[MAX_PAYLOAD_SIZE];
83+
84+
void loop() {
85+
receivePacket(&pkt, payload);
86+
87+
if (pkt.command == CMD_HELLO) {
88+
if (pkt.address == 0x11223344 && pkt.arg1 == 0x55667788)
89+
Serial.print("v10000");
90+
}
91+
92+
if (pkt.command == CMD_MAX_PAYLOAD_SIZE) {
93+
uint16_t res = toNetwork16(MAX_PAYLOAD_SIZE);
94+
Serial.write(reinterpret_cast<uint8_t *>(&res), sizeof(res));
95+
}
96+
97+
if (pkt.command == CMD_READ_FLASH) {
98+
uint32_t address = pkt.address;
99+
uint32_t len = pkt.arg1;
100+
if (spi_flash_read(payload, address, len) != M2M_SUCCESS) {
101+
Serial.println("ER");
102+
} else {
103+
Serial.write(payload, len);
104+
Serial.print("OK");
105+
}
106+
}
107+
108+
if (pkt.command == CMD_WRITE_FLASH) {
109+
uint32_t address = pkt.address;
110+
uint32_t len = pkt.payloadLength;
111+
if (spi_flash_write(payload, address, len) != M2M_SUCCESS) {
112+
Serial.print("ER");
113+
} else {
114+
Serial.print("OK");
115+
}
116+
}
117+
118+
if (pkt.command == CMD_ERASE_FLASH) {
119+
uint32_t address = pkt.address;
120+
uint32_t len = pkt.arg1;
121+
if (spi_flash_erase(address, len) != M2M_SUCCESS) {
122+
Serial.print("ER");
123+
} else {
124+
Serial.print("OK");
125+
}
126+
}
127+
}
128+
129+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
This example creates a client object that connects and transfers
3+
data using always SSL.
4+
5+
It is compatible with the methods normally related to plain
6+
connections, like client.connect(host, port).
7+
8+
Written by Arturo Guadalupi
9+
last revision November 2015
10+
11+
*/
12+
13+
#include <SPI.h>
14+
#include <WiFi101.h>
15+
16+
char ssid[] = "yourNetwork"; // your network SSID (name)
17+
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
18+
int keyIndex = 0; // your network key Index number (needed only for WEP)
19+
20+
int status = WL_IDLE_STATUS;
21+
// if you don't want to use DNS (and reduce your sketch size)
22+
// use the numeric IP instead of the name for the server:
23+
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
24+
char server[] = "www.google.com"; // name address for Google (using DNS)
25+
26+
// Initialize the Ethernet client library
27+
// with the IP address and port of the server
28+
// that you want to connect to (port 80 is default for HTTP):
29+
WiFiSSLClient client;
30+
31+
void setup() {
32+
//Initialize serial and wait for port to open:
33+
Serial.begin(9600);
34+
while (!Serial) {
35+
; // wait for serial port to connect. Needed for native USB port only
36+
}
37+
38+
// check for the presence of the shield:
39+
if (WiFi.status() == WL_NO_SHIELD) {
40+
Serial.println("WiFi shield not present");
41+
// don't continue:
42+
while (true);
43+
}
44+
45+
// attempt to connect to Wifi network:
46+
while (status != WL_CONNECTED) {
47+
Serial.print("Attempting to connect to SSID: ");
48+
Serial.println(ssid);
49+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
50+
status = WiFi.begin(ssid, pass);
51+
52+
// wait 10 seconds for connection:
53+
delay(10000);
54+
}
55+
Serial.println("Connected to wifi");
56+
printWifiStatus();
57+
58+
Serial.println("\nStarting connection to server...");
59+
// if you get a connection, report back via serial:
60+
if (client.connect(server, 443)) {
61+
Serial.println("connected to server");
62+
// Make a HTTP request:
63+
client.println("GET /search?q=arduino HTTP/1.1");
64+
client.println("Host: www.google.com");
65+
client.println("Connection: close");
66+
client.println();
67+
}
68+
}
69+
70+
void loop() {
71+
// if there are incoming bytes available
72+
// from the server, read them and print them:
73+
while (client.available()) {
74+
char c = client.read();
75+
Serial.write(c);
76+
}
77+
78+
// if the server's disconnected, stop the client:
79+
if (!client.connected()) {
80+
Serial.println();
81+
Serial.println("disconnecting from server.");
82+
client.stop();
83+
84+
// do nothing forevermore:
85+
while (true);
86+
}
87+
}
88+
89+
90+
void printWifiStatus() {
91+
// print the SSID of the network you're attached to:
92+
Serial.print("SSID: ");
93+
Serial.println(WiFi.SSID());
94+
95+
// print your WiFi shield's IP address:
96+
IPAddress ip = WiFi.localIP();
97+
Serial.print("IP Address: ");
98+
Serial.println(ip);
99+
100+
// print the received signal strength:
101+
long rssi = WiFi.RSSI();
102+
Serial.print("signal strength (RSSI):");
103+
Serial.print(rssi);
104+
Serial.println(" dBm");
105+
}

examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ void loop()
7474
sendNTPpacket(timeServer); // send an NTP packet to a time server
7575
// wait to see if a reply is available
7676
delay(1000);
77-
Serial.println( Udp.parsePacket() );
7877
if ( Udp.parsePacket() ) {
7978
Serial.println("packet received");
8079
// We've received a packet, read the data from it

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Datatypes (KEYWORD1)
77
#######################################
88

9+
WiFi KEYWORD1
910
WiFi101 KEYWORD1
1011
Client KEYWORD1
1112
Server KEYWORD1
@@ -16,6 +17,7 @@ Server KEYWORD1
1617

1718
status KEYWORD2
1819
connect KEYWORD2
20+
connectSSL KEYWORD2
1921
write KEYWORD2
2022
available KEYWORD2
2123
read KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit_WINC1500
2-
version=0.5.1
2+
version=0.6.0
33
author=Arduino
44
maintainer=adafruit <[email protected]>
55
sentence=Network driver for WINC1500 module (forked off the Arduino Wifi Shield 101)

0 commit comments

Comments
 (0)