-
• #2
I don't think we have a function for that :-)
-
• #3
Do you mean when running Espruino on the ESP8266 itself, or when running on an Espruino board connected to the ESP8266?
If it's on the Espruino board I'm not sure there's a function, but you can add one with a simple bit of code. Something like:
wifi.getMAC = function(callback) { var mac; at.cmdReg("AT+CIFSR\r\n", 1000, "+CIFSR", function(d) { if (d.indexOf("STAMAC")>=0) mac=JSON.parse(d.slice(d.indexOf(',')+1)); }, function(d) { if (d!="OK") callback("CIFSR failed: "+d); else callback(null, mac); }); } // wifi.getMAC(function(err,mac) { console.log(mac); });
-
• #4
running Espruino on ESP8266, like esptool.py does:
esptool.py --port /dev/cu.usbserial --baud 115200 read_mac
Connecting...
MAC: 18:fe:34:05:99:c9inside esptool.py
// OTP ROM addresses ESP_OTP_MAC0 = 0x3ff00050 ESP_OTP_MAC1 = 0x3ff00054 def read_mac(self): mac0 = self.read_reg(self.ESP_OTP_MAC0) mac1 = self.read_reg(self.ESP_OTP_MAC1) if ((mac1 >> 16) & 0xff) == 0: oui = (0x18, 0xfe, 0x34) elif ((mac1 >> 16) & 0xff) == 1: oui = (0xac, 0xd0, 0x74) else: raise FatalError("Unknown OUI") return oui + ((mac1 >> 8) & 0xff, mac1 & 0xff, (mac0 >> 24) & 0xff)
-
• #5
Well, you could try
peek32(0x3ff00050).toString(16)
andpeek32(0x3ff00054).toString(16)
? -
• #6
thats it - thanks !
-
• #9
@Kolban there's some code in network.c that will properly format the Mac address into a string. Check out how WIZnet does it
networkPutAddressAsString(data, "mac", &gWIZNETINFO.mac[0], 6, 16, ':');
-
• #10
Perfect ... added to Issue #722 as a task to be done before completion of that issue.
-
• #11
Should be in an upcoming build thanks to Kolban's fix :-).
can someone please explain how to get the wifi mac