Comments (1)
The MAC address is different that the IP address as the NetEEPROM.readMAC();
returns a pointer to an array allocated in the memory. The readIP();
, readGW();
and readSN();
return an object of type IPAddress
.
In C++, functions can return object instances, much like they can return any other type, such as int
, float
, double
and so on. But just like C, they cannot return an array. Instead of that, they can return a pointer to an array.
So what happens in the case of the first three is: somewhere in your code, before the call of NetEEPROM.readIP();
you have declared a variable ip
with type IPAddress
which is the class used by Arduino to store IP addresses.
What happens when you do something like ip = NetEEPROM.readIP();
is that the NetEEPROM.readIP();
reads the IP address and returns an IPAddress
object, which is then copied to the ip
variable through the =
operator.
After that you can manipulate it as any other object of this type.
In the case of the MAC address, there isn't such an object, so it returns a pointer to a byte
array. So to 'read' the MAC address you have to do something like byte *mac = NetEEPROM.readMAC();
. After that you can get the individual elements of the array with mac[0]
to mac[5]
. To give you an example, this is how the MAC is printed in NetEEPROM.printNet(&serial);
:
byte* mac = readMAC();
serial->print(" MAC: ");
for(uint8_t i = 0; i < 6; i++) {
serial->print("0x");
serial->print(mac[i], HEX);
if(i != 5) serial->print(".");
else serial->println();
}
free(mac);
One more thing to notice is the free(mac);
line. In the readMAC();
the array is being allocated in the memory, and it is not automatically freed. So after doing whatever you want with the MAC address, you should free it, otherwise, you will end up with all of the Arduino memory polluted with MAC arrays.
from ariadne-bootloader.
Related Issues (20)
- Compile Problem HOT 6
- Ariadne misuses W5100 and W5200 HOT 5
- network reset HOT 16
- burning bootloader to mega and some questions HOT 11
- Automatic reset for every TFTP put operation HOT 3
- Ariadne installation via Arduino Boards Manager HOT 8
- Support for ENC28J60 HOT 1
- bin-file generated from PlatformIO (avr-gcc ide) does not work with Ariadne HOT 9
- Bootloader hanging on field application -2560 HOT 7
- TFTP upload fails with the message "Timeout occurred, Connect request failed" HOT 15
- Bootloader hangs on Mega2560 HOT 9
- TFTP upload not working with mini W5100 Board HOT 1
- Bootloader burned successfully, Failed to upload bin via TFTP. HOT 3
- getting error when flashing with tftp HOT 2
- Please specify fuses for alternative ICSP programmer. HOT 2
- Cannot use http post method with ethernet.client when ariadne ethernet.reset in use HOT 2
- EEPROM.put and get does not work HOT 11
- Endless reset HOT 1
- Don't report issues here. HOT 2
- removed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ariadne-bootloader.