here is the EEFROM code im uploading
can i mix octates and bytes in the MAC array?
i now manualy set the last bit of IP and MAC to 13. how to automate it?
i can hardcode it, but just for knowledge sake.
EEPROM_settings_write_ARD.ino
//code for write/read from EEPROM the ip, mac and gateway data
//EEPROM MAC and IP setter
//http://arduino.cc/playground/Code/EEPROMWriteAnything
//http://arduino.cc/forum/index.php/topic,64673.0.html
#include <EEPROM.h>
#include <avr/eeprom.h>
// values saved in EEPROM
struct NET_t
{
byte MAC[6];
byte IP[4];
byte GATE[4];
short myPort; // should be an uint16_t myPort !!! range = 0..65535
short serverPort; // idem
}
LAN =
{
{0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x13} // *** change last bit *****
,
{10,0,0,13} // *** change ip ****
,
{10,0,0,1}
,
6666
,
9999
};
void setup(){
eeprom_write_block((const void*)&LAN, (void*)0, sizeof(LAN)); //write
//eeprom_read_block((void*)&LAN, (void*)0, sizeof(LAN)); //read
}
void loop(){
}
EEPROM_settings_read_ARD.ino
#include <EEPROM.h>
#include <avr/eeprom.h>
struct NET_t
{
byte MAC[6];
byte IP[4];
byte GATE[4];
short myPort; // should be an uint16_t myPort !!! range = 0..65535
short serverPort; // idem
}
LAN;
//http://arduino.cc/forum/index.php/topic,64673.0.html
void setup(){
//eeprom_write_block((const void*)&LAN, (void*)0, sizeof(LAN)); //write
eeprom_read_block((void*)&LAN, (void*)0, sizeof(LAN)); //read
Serial.begin(9600);
Serial.print("MAC: ");
for (int i; i < 6; i ++) {
Serial.print(LAN.MAC[i]);
Serial.print(".");
}
Serial.println();
Serial.print("IP: ");
for (int i ; i < 4; i ++) {
Serial.print(LAN.IP[i]);
Serial.print(".");
}
Serial.println();
Serial.print("GATE: ");
for (int i; i < 4; i ++) {
Serial.print(LAN.GATE[i]);
Serial.print(".");
}
Serial.println();
Serial.print("myPort: ");
Serial.println(LAN.myPort);
Serial.print("serverPort: ");
Serial.println(LAN.serverPort);
}
void loop(){
}