Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this codes are for writing and reaeding from EEPROM the ip, mac and gateway data
- /* EEPROM_settings_write_ARD
- //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>
- struct NET_t
- {
- byte IP[4];
- byte MAC[6];
- byte GATE[4];
- short myPort; // should be an uint16_t myPort !!! range = 0..65535
- short serverPort; // idem
- }
- LAN =
- {
- {
- 10,0,0,13 } // change ip
- ,
- {
- 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x03 } // will take ip as last 4 bits
- ,
- {
- 10,0,0,1 }
- ,
- 6666
- ,
- 9999
- };
- void setup(){
- for (int i=0; i<4; i++)
- {
- LAN.MAC[i+2] = LAN.IP[i];
- }
- 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
- /*
- //EEPROM MAC and IP setter
- //http://arduino.cc/playground/Code/EEPROMWriteAnything
- #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(){
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement