diff --git a/examples/JeeUdp/JeeUdp.ino b/examples/JeeUdp/JeeUdp.ino index baa4f195..75b74b1f 100644 --- a/examples/JeeUdp/JeeUdp.ino +++ b/examples/JeeUdp/JeeUdp.ino @@ -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 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; // buffer for an outgoing data packet static byte outBuf[RF12_MAXDATA], outDest; diff --git a/examples/SSDP/SSDP.ino b/examples/SSDP/SSDP.ino index 494cd1ec..3aff7277 100644 --- a/examples/SSDP/SSDP.ino +++ b/examples/SSDP/SSDP.ino @@ -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 +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 = diff --git a/examples/backSoon/backSoon.ino b/examples/backSoon/backSoon.ino index c0e94933..01a503b9 100644 --- a/examples/backSoon/backSoon.ino +++ b/examples/backSoon/backSoon.ino @@ -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 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[500]; // tcp/ip send and receive buffer diff --git a/examples/etherNode/etherNode.ino b/examples/etherNode/etherNode.ino index b0c4d3ac..a53e377f 100644 --- a/examples/etherNode/etherNode.ino +++ b/examples/etherNode/etherNode.ino @@ -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 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; // buffer for an outgoing data packet static byte outBuf[RF12_MAXDATA], outDest; diff --git a/examples/getDHCPandDNS/getDHCPandDNS.ino b/examples/getDHCPandDNS/getDHCPandDNS.ino index 8c118184..4d0b5c17 100644 --- a/examples/getDHCPandDNS/getDHCPandDNS.ino +++ b/examples/getDHCPandDNS/getDHCPandDNS.ino @@ -8,7 +8,7 @@ #define REQUEST_RATE 5000 // milliseconds // ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; // remote website name const char website[] PROGMEM = "google.com"; diff --git a/examples/getStaticIP/getStaticIP.ino b/examples/getStaticIP/getStaticIP.ino index 89258e1a..5fa8bef3 100644 --- a/examples/getStaticIP/getStaticIP.ino +++ b/examples/getStaticIP/getStaticIP.ino @@ -8,7 +8,7 @@ #define REQUEST_RATE 5000 // milliseconds // ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +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 diff --git a/examples/getViaDNS/getViaDNS.ino b/examples/getViaDNS/getViaDNS.ino index 2a28489e..431aa630 100644 --- a/examples/getViaDNS/getViaDNS.ino +++ b/examples/getViaDNS/getViaDNS.ino @@ -8,7 +8,7 @@ #define REQUEST_RATE 5000 // milliseconds // ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +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 diff --git a/examples/multipacket/multipacket.ino b/examples/multipacket/multipacket.ino index 3f09a14a..08b44c24 100644 --- a/examples/multipacket/multipacket.ino +++ b/examples/multipacket/multipacket.ino @@ -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 }; +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" diff --git a/examples/multipacketSD/multipacketSD.ino b/examples/multipacketSD/multipacketSD.ino index 78134fc1..d8cbe3bd 100644 --- a/examples/multipacketSD/multipacketSD.ino +++ b/examples/multipacketSD/multipacketSD.ino @@ -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 }; +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; diff --git a/examples/nanether/nanether.ino b/examples/nanether/nanether.ino index 0133db39..d643960e 100644 --- a/examples/nanether/nanether.ino +++ b/examples/nanether/nanether.ino @@ -6,7 +6,7 @@ #define BUF_SIZE 512 -byte mac[] = { 0x00, 0x04, 0xA3, 0x21, 0xCA, 0x38 }; // Nanode MAC address. +static byte mymac[] 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. @@ -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, mymac, SS) == 0) { Serial.println( "Ethernet controller NOT initialised"); while (true) /* MT */ ; diff --git a/examples/noipClient/noipClient.ino b/examples/noipClient/noipClient.ino index 49a03922..49c78de2 100644 --- a/examples/noipClient/noipClient.ino +++ b/examples/noipClient/noipClient.ino @@ -27,7 +27,7 @@ #define MAX_ATTEMPTS 3 // MAC Address of Ethernet Shield -static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01}; +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"; diff --git a/examples/notifyMyAndroid/notifyMyAndroid.ino b/examples/notifyMyAndroid/notifyMyAndroid.ino index 26732899..b38a3645 100644 --- a/examples/notifyMyAndroid/notifyMyAndroid.ino +++ b/examples/notifyMyAndroid/notifyMyAndroid.ino @@ -12,7 +12,7 @@ const char apihost[] PROGMEM = "www.notifymyandroid.com"; -static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 }; +static byte mymac[] PROGMEM = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 }; byte Ethernet::buffer[900]; Stash stash; diff --git a/examples/ntpClient/ntpClient.ino b/examples/ntpClient/ntpClient.ino index 90a76c79..8b4f3e54 100644 --- a/examples/ntpClient/ntpClient.ino +++ b/examples/ntpClient/ntpClient.ino @@ -18,7 +18,7 @@ #include // https://github.com/njh/EtherCard // Ethernet mac address - must be unique on your network -const byte myMac[] PROGMEM = { 0x70, 0x69, 0x69, 0x2D, 0x30, 0x31 }; +static byte mymac[] PROGMEM = = { 0x70, 0x69, 0x69, 0x2D, 0x30, 0x31 }; const char NTP_REMOTEHOST[] PROGMEM = "ntp.bit.nl"; // NTP server name const unsigned int NTP_REMOTEPORT = 123; // NTP requests are to port 123 const unsigned int NTP_LOCALPORT = 8888; // Local UDP port to use @@ -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) == 0) Serial.println(F("Failed to access Ethernet controller")); if (!ether.dhcpSetup()) Serial.println(F("DHCP failed")); diff --git a/examples/persistence/persistence.ino b/examples/persistence/persistence.ino index 071549f9..4e00478d 100644 --- a/examples/persistence/persistence.ino +++ b/examples/persistence/persistence.ino @@ -5,7 +5,7 @@ #include // ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +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; diff --git a/examples/pings/pings.ino b/examples/pings/pings.ino index 42469752..0e9085dc 100644 --- a/examples/pings/pings.ino +++ b/examples/pings/pings.ino @@ -6,7 +6,7 @@ #include // ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[700]; static uint32_t timer; diff --git a/examples/rbbb_server/rbbb_server.ino b/examples/rbbb_server/rbbb_server.ino index fc0e4203..a5e29bea 100644 --- a/examples/rbbb_server/rbbb_server.ino +++ b/examples/rbbb_server/rbbb_server.ino @@ -6,7 +6,7 @@ #include // ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; static byte myip[] = { 192,168,1,203 }; byte Ethernet::buffer[500]; diff --git a/examples/stashTest/stashTest.ino b/examples/stashTest/stashTest.ino index 040202a5..671aee32 100644 --- a/examples/stashTest/stashTest.ino +++ b/examples/stashTest/stashTest.ino @@ -7,7 +7,7 @@ #include // ethernet interface mac address, must be unique on the LAN -byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[700]; diff --git a/examples/testDHCP/testDHCP.ino b/examples/testDHCP/testDHCP.ino index ff54f463..ee7239e0 100644 --- a/examples/testDHCP/testDHCP.ino +++ b/examples/testDHCP/testDHCP.ino @@ -7,7 +7,7 @@ #include -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[700]; diff --git a/examples/testDHCPOptions/testDHCPOptions.ino b/examples/testDHCPOptions/testDHCPOptions.ino index e761176e..dea17b09 100644 --- a/examples/testDHCPOptions/testDHCPOptions.ino +++ b/examples/testDHCPOptions/testDHCPOptions.ino @@ -5,7 +5,7 @@ #include -static byte mymac[] = { 0x6e, 0x1b, 0xd0, 0x2e, 0xdd, 0xa5 }; +static byte mymac[] PROGMEM = { 0x6e, 0x1b, 0xd0, 0x2e, 0xdd, 0xa5 }; byte Ethernet::buffer[700]; diff --git a/examples/thingspeak/thingspeak.ino b/examples/thingspeak/thingspeak.ino index 25d67ee9..e329317f 100644 --- a/examples/thingspeak/thingspeak.ino +++ b/examples/thingspeak/thingspeak.ino @@ -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 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; const char website[] PROGMEM = "api.thingspeak.com"; byte Ethernet::buffer[700]; uint32_t timer; diff --git a/examples/twitter/twitter.ino b/examples/twitter/twitter.ino index 3b943aaf..afd948bf 100644 --- a/examples/twitter/twitter.ino +++ b/examples/twitter/twitter.ino @@ -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 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; const char website[] PROGMEM = "arduino-tweet.appspot.com"; diff --git a/examples/udpClientSendOnly/udpClientSendOnly.ino b/examples/udpClientSendOnly/udpClientSendOnly.ino index feda2d90..c943dce2 100644 --- a/examples/udpClientSendOnly/udpClientSendOnly.ino +++ b/examples/udpClientSendOnly/udpClientSendOnly.ino @@ -1,6 +1,6 @@ #include -static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F }; +static byte mymac[] PROGMEM = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F }; byte Ethernet::buffer[700]; static uint32_t timer; diff --git a/examples/udpListener/udpListener.ino b/examples/udpListener/udpListener.ino index d814721f..82781e1c 100644 --- a/examples/udpListener/udpListener.ino +++ b/examples/udpListener/udpListener.ino @@ -19,7 +19,7 @@ static byte gwip[] = { 192,168,0,1 }; #endif // Ethernet MAC address - must be unique on your network -static byte mymac[] = { 0x70,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x70,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[500]; // TCP/IP send and receive buffer diff --git a/examples/webClient/webClient.ino b/examples/webClient/webClient.ino index bf661992..6e804e4d 100644 --- a/examples/webClient/webClient.ino +++ b/examples/webClient/webClient.ino @@ -6,7 +6,7 @@ #include // ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[700]; static uint32_t timer; diff --git a/examples/xively/xively.ino b/examples/xively/xively.ino index 23012100..48310a60 100644 --- a/examples/xively/xively.ino +++ b/examples/xively/xively.ino @@ -13,7 +13,7 @@ #define APIKEY "xxx" // ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; +static byte mymac[] PROGMEM = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; const char website[] PROGMEM = "api.xively.com"; diff --git a/src/EtherCard.cpp b/src/EtherCard.cpp index f752a9bf..4f014387 100644 --- a/src/EtherCard.cpp +++ b/src/EtherCard.cpp @@ -30,12 +30,21 @@ uint16_t EtherCard::delaycnt = 0; //request gateway ARP lookup uint8_t EtherCard::begin (const uint16_t size, const uint8_t* macaddr, - uint8_t csPin) { + uint8_t csPin, + bool macFromRam) { using_dhcp = false; #if ETHERCARD_STASH Stash::initMap(); #endif - copyMac(mymac, macaddr); + if (macFromRam) { + copyMac(mymac, macaddr); + } + else { + for (uint8_t k = 0; k < ETH_LEN; k++) { + uint8_t c = pgm_read_byte(macaddr+k); + mymac[k] = c; + } + } return initialize(size, mymac, csPin); } diff --git a/src/EtherCard.h b/src/EtherCard.h index 703b5990..23f3f8b9 100644 --- a/src/EtherCard.h +++ b/src/EtherCard.h @@ -125,10 +125,11 @@ class EtherCard : public Ethernet { * @param size Size of data buffer * @param macaddr Hardware address to assign to the network interface (6 bytes) * @param csPin Arduino pin number connected to chip select. Default = 8 + * @param macFromRam Set true to indicate whether mac is in RAM or in program space. Default = false * @return uint8_t Firmware version or zero on failure. */ static uint8_t begin (const uint16_t size, const uint8_t* macaddr, - uint8_t csPin = SS); + uint8_t csPin = SS, bool macFromRam =false); /** @brief Configure network interface with static IP * @param my_ip IP address (4 bytes). 0 for no change.