![]() ![]() def prettify (macstring): return ':'.join ('02x' ord (b) for b in macstring) Although if macstring is a bytearray (or bytes in Python 3), which is a more natural choice than a string given the nature of the data, then you also won't need. Otherwise, the preceding 0 is missing for bytes below 16. this is what the code posted in the link you gave does. You should probably use 02x instead of x. The actual values is only 6 bytes long if I remember well, so it's a matter of reading each byte individually and converting into its ASCII hexadecimal representation. The compiler does not know how to convert those into Strings or cStrings, so you need to do this yourself. ![]() You use a 64 bits (8 bytes) long integer. When you do something like uint64_t espChipID = ESP.getEfuseMac() I won't comment on the use of the String class, you know the pitfalls. What is clientHTTPMagicMirror? which library is being used? is there a way to post params independently? what is postAttributeFirmware, firmwareCode etc ? They are likely Strings indeed ut don't post snippets ( Snippets R Us!) I found one possible lead with this code ( MAC Address to String - #6 by beic - Programming Questions - Arduino Forum) but I don't understand it well enough to know how to adjust it to input ESP.getEfuseMac() and get out a string called efuseMac.Īny help or pointers in the right direction would be appreciated. Unless someone can suggest another workaround, I think I need efuseMac and wifiMac to be strings as well. MAC addresses are generally written in hexadecimal. I'm no expert, but I believe this is concatenating a bunch of string to form the post. String payloadMagicMirror = clientHTTPMagicMirror.getString() The code for sending the data is: int returnCodeMagicMirror = clientHTTPMagicMirror.POST( postAttributeFirmware + firmwareCode + postAttributeEfuseMac + efuseMac + postAttributeWiFiMac + wifiMac + postAttributeSensorID + sensorID + postEnd ) Although IPv6 addresses are 4 times as long as IPv4 addresses, IPv4 addresses can still be written in IPv6 notation. Each address is 32 bits in length and the 32-bit address is broken up into four 8-bit octets. My Arduino (technically an ESP32) sends some json data to my MagicMirror using HTTP POST. This is the most common notation for IPv4 addresses. I'm pretty sure that someone is going to say, "Why are you doing this? You shouldn't use a string." So here's my situation: There have been a few interesting comments on this post, I encourage you to read them if you want to learn more about this mechanism.My basic question is how can I convert the units MAC address (from ESP.getEfuseMac() and/or WiFi.macAddress() ) into a string? ![]() prepend the link-local prefix: fe80::5074:f2ff:feb1:a87fĪ converter to do the same operation in reverse is available here.replace first octet with newly calculated one: 5074:f2ff:feb1:a87f.convert octet back to hexadecimal: 01010000 -> 50.convert the first octet from hexadecimal to binary: 52 -> 01010010.reformat to IPv6 notation 5274:f2ff:feb1:a87f.take the mac address: for example 52:74:f2:b1:a8:7f.Here’s the conversion process step by step: This link-local IPv6 is infered from the NIC’s mac address.Ī mac address is 48 bits, an IPv6 address is 128 bits. def prettify (macstring): return .join 02x ord (b) for b in macstring) Although if macstring is a bytearray (or bytes in Python 3), which is a more natural choice than a string given the nature of the data, then you also wont need. ![]() Instead of getting an address via DHCP, a NIC will hop on the network with a link-local IPv6 address and with this will have to ability to do further configuration automatically (soliciting neighbors, router, et cetera). You should probably use 02x instead of x. Link-local IPv6 addresses are used as part of the IPv6 network auto-configuration process. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |