Skip to content

Commit

Permalink
update examples to keep MAC in PROGMEM instead of RAM
Browse files Browse the repository at this point in the history
fixes njh#397 (ntpClient example)
  • Loading branch information
nuno-silva committed Nov 22, 2020
1 parent c2ba420 commit 3b67762
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions examples/JeeUdp/JeeUdp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Config {
} config;

// ethernet interface mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

// buffer for an outgoing data packet
static byte outBuf[RF12_MAXDATA], outDest;
Expand Down Expand Up @@ -261,7 +261,7 @@ void setup (){
loadConfig();

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
Expand Down
4 changes: 2 additions & 2 deletions examples/SSDP/SSDP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const char SSDP_NOTIFY[] PROGMEM = "NOTIFY * HTTP/1.1\r\nHOST: 239.255.255.250:1
static byte myip[] = { 192,168,0,67 };
static byte gwip[] = { 192,168,0,250 };
static byte ssdp[] = { 239,255,255,250 };
static byte mymac[] = { 0x74,0x99,0x69,0x2D,0x30,0x40 }; // if you change it you must update SSDP_RESPONSE and XML_DESCRIP
const static byte mymac[] PROGMEM = { 0x74,0x99,0x69,0x2D,0x30,0x40 }; // if you change it you must update SSDP_RESPONSE and XML_DESCRIP
byte Ethernet::buffer[750]; // tcp ip send and receive buffer
unsigned long timer=9999;
const char pageA[] PROGMEM =
Expand Down Expand Up @@ -99,7 +99,7 @@ void addip(int udppos) { // add current ip to the request and send it

void setup(){
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
ether.begin(sizeof Ethernet::buffer, mymac, SS);
ether.begin(sizeof Ethernet::buffer, mymac, SS, false);
ether.staticSetup(myip, gwip);
ENC28J60::disableMulticast(); //disable multicast filter means enable multicast reception
Serial.begin(115200);
Expand Down
4 changes: 2 additions & 2 deletions examples/backSoon/backSoon.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

Expand Down Expand Up @@ -43,7 +43,7 @@ void setup(){
Serial.println("\n[backSoon]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
Expand Down
4 changes: 2 additions & 2 deletions examples/etherNode/etherNode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Config {
} config;

// ethernet interface mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

// buffer for an outgoing data packet
static byte outBuf[RF12_MAXDATA], outDest;
Expand Down Expand Up @@ -217,7 +217,7 @@ void setup(){
loadConfig();

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
Expand Down
4 changes: 2 additions & 2 deletions examples/getDHCPandDNS/getDHCPandDNS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define REQUEST_RATE 5000 // milliseconds

// ethernet interface mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// remote website name
const char website[] PROGMEM = "google.com";

Expand All @@ -28,7 +28,7 @@ void setup () {
Serial.println("\n[getDHCPandDNS]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");

if (!ether.dhcpSetup())
Expand Down
4 changes: 2 additions & 2 deletions examples/getStaticIP/getStaticIP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define REQUEST_RATE 5000 // milliseconds

// ethernet interface mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// ethernet interface ip address
static byte myip[] = { 192,168,1,203 };
// ethernet interface ip netmask
Expand Down Expand Up @@ -36,7 +36,7 @@ void setup () {
Serial.println("\n[getStaticIP]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");

ether.staticSetup(myip, gwip, NULL, mask);
Expand Down
4 changes: 2 additions & 2 deletions examples/getViaDNS/getViaDNS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define REQUEST_RATE 5000 // milliseconds

// ethernet interface mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// ethernet interface ip address
static byte myip[] = { 192,168,1,203 };
// ethernet interface ip netmask
Expand All @@ -34,7 +34,7 @@ void setup () {
Serial.println("\n[getViaDNS]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");

ether.staticSetup(myip, gwip, NULL, mask);
Expand Down
4 changes: 2 additions & 2 deletions examples/multipacket/multipacket.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define TCP_FLAGS_ACK_V 0x10 //as declared in net.h
static byte myip[] = { 192,168,0,66 };
static byte gwip[] = { 192,168,0,250 };
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x39 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x39 };
byte Ethernet::buffer[900]; // tcp ip send and receive buffer
const char pageA[] PROGMEM =
"HTTP/1.0 200 OK\r\n"
Expand Down Expand Up @@ -48,7 +48,7 @@ const char pageE[] PROGMEM =

void setup(){
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
ether.begin(sizeof Ethernet::buffer, mymac , SS);
ether.begin(sizeof Ethernet::buffer, mymac , SS, false);
ether.staticSetup(myip, gwip);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/multipacketSD/multipacketSD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define TCP_FLAGS_ACK_V 16 //as declared in net.h
static byte myip[] = { 192,168,0,66 };
static byte gwip[] = { 192,168,0,250 };
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x39 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x39 };
byte Ethernet::buffer[700]; // tcp/ip send and receive buffer
unsigned long cur;
unsigned long pos;
Expand Down Expand Up @@ -103,7 +103,7 @@ void setup()
if (res==NO_ERROR) Serial.println("SD started");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
ether.begin(sizeof Ethernet::buffer, mymac , SS);
ether.begin(sizeof Ethernet::buffer, mymac , SS, false);
ether.staticSetup(myip, gwip);
Serial.println("ETH started");
}
Expand Down
4 changes: 2 additions & 2 deletions examples/nanether/nanether.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define BUF_SIZE 512

byte mac[] = { 0x00, 0x04, 0xA3, 0x21, 0xCA, 0x38 }; // Nanode MAC address.
const byte mac[] PROGMEM = { 0x00, 0x04, 0xA3, 0x21, 0xCA, 0x38 }; // Nanode MAC address.

uint8_t ip[] = { 192, 168, 1, 8 }; // The fallback board address.
uint8_t dns[] = { 192, 168, 1, 20 }; // The DNS server address.
Expand All @@ -24,7 +24,7 @@ void setup(void)
Serial.println("Initialising the Ethernet controller");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mac, SS) == 0) {
if (ether.begin(sizeof Ethernet::buffer, mac, SS, false) == 0) {
Serial.println( "Ethernet controller NOT initialised");
while (true)
/* MT */ ;
Expand Down
4 changes: 2 additions & 2 deletions examples/noipClient/noipClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define MAX_ATTEMPTS 3

// MAC Address of Ethernet Shield
static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
const static byte mymac[] PROGMEM = {0xDD,0xDD,0xDD,0x00,0x00,0x01};

// Insert your hostname and authentication string
const char noIP_host[] PROGMEM = "myhost.no-ip.info";
Expand Down Expand Up @@ -213,7 +213,7 @@ void setup () {
Serial.println();

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (!ether.begin(sizeof Ethernet::buffer, mymac, SS))
if (!ether.begin(sizeof Ethernet::buffer, mymac, SS, false))
Serial.println(F( "Failed to access Ethernet controller"));
else
Serial.println(F("Ethernet controller initialized"));
Expand Down
4 changes: 2 additions & 2 deletions examples/notifyMyAndroid/notifyMyAndroid.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const char apihost[] PROGMEM = "www.notifymyandroid.com";

static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };
const static byte mymac[] PROGMEM = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };

byte Ethernet::buffer[900];
Stash stash;
Expand Down Expand Up @@ -59,7 +59,7 @@ void setup () {
Serial.println("\nStarting Notify My Android Example");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
Expand Down
2 changes: 1 addition & 1 deletion examples/ntpClient/ntpClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void setup() {
Serial.println(F("\n[EtherCard NTP Client]"));

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, myMac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, myMac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
Expand Down
4 changes: 2 additions & 2 deletions examples/persistence/persistence.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

// the buffersize must be relatively large for DHCP to work; when
// using static setup a buffer size of 100 is sufficient;
Expand Down Expand Up @@ -46,7 +46,7 @@ void setup () {
Serial.println(F("\n[Persistence+readPacketSlice]"));

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
Expand Down
4 changes: 2 additions & 2 deletions examples/pings/pings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;
Expand All @@ -21,7 +21,7 @@ void setup () {
Serial.println("\n[pings]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
Expand Down
4 changes: 2 additions & 2 deletions examples/rbbb_server/rbbb_server.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,203 };

byte Ethernet::buffer[500];
Expand Down Expand Up @@ -34,7 +34,7 @@ void setup () {
Serial.begin(57600);
Serial.println(F("\n[RBBB Server]"));
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
ether.staticSetup(myip);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/stashTest/stashTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <avr/eeprom.h>

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];

Expand Down Expand Up @@ -50,7 +50,7 @@ void setup () {
Serial.println("\n[stashTest]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
ether.begin(sizeof Ethernet::buffer, mymac, SS);
ether.begin(sizeof Ethernet::buffer, mymac, SS, false);

#if 1
Stash buf;
Expand Down
4 changes: 2 additions & 2 deletions examples/testDHCP/testDHCP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];

Expand All @@ -24,7 +24,7 @@ void setup () {
Serial.println();

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));

Serial.println(F("Setting up DHCP"));
Expand Down
4 changes: 2 additions & 2 deletions examples/testDHCPOptions/testDHCPOptions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <EtherCard.h>

static byte mymac[] = { 0x6e, 0x1b, 0xd0, 0x2e, 0xdd, 0xa5 };
const static byte mymac[] PROGMEM = { 0x6e, 0x1b, 0xd0, 0x2e, 0xdd, 0xa5 };

byte Ethernet::buffer[700];

Expand All @@ -28,7 +28,7 @@ void setup () {
}
Serial.println();

if (ether.begin(sizeof Ethernet::buffer, mymac, 8) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, 8, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));

// Add callback for the NTP option (DHCP Option number 42)
Expand Down
4 changes: 2 additions & 2 deletions examples/thingspeak/thingspeak.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define APIKEY "beef1337beef1337" // put your key here

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const char website[] PROGMEM = "api.thingspeak.com";
byte Ethernet::buffer[700];
uint32_t timer;
Expand All @@ -41,7 +41,7 @@ void initialize_ethernet(void){
//delay(500);

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0){
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0){
Serial.println( "Failed to access Ethernet controller");
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/twitter/twitter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define TOKEN "Insert-your-token-here"

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

const char website[] PROGMEM = "arduino-tweet.appspot.com";

Expand Down Expand Up @@ -60,7 +60,7 @@ void setup () {
Serial.println("\n[Twitter Client]");

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
Expand Down
4 changes: 2 additions & 2 deletions examples/udpClientSendOnly/udpClientSendOnly.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <EtherCard.h>

static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F };
const static byte mymac[] PROGMEM = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F };
byte Ethernet::buffer[700];
static uint32_t timer;

Expand All @@ -13,7 +13,7 @@ void setup () {
Serial.begin(9600);

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
if (ether.begin(sizeof Ethernet::buffer, mymac, SS, false) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
Expand Down
Loading

0 comments on commit 3b67762

Please sign in to comment.