Chat freely about anything...

User avatar
By eduperez
#30187
trendchaster wrote:Hello guys,
I am using MQTT. I want to convert MAC Address into string>I tried so many things but it wont work.Any suggestion or idea will be appreciated.I implemented this one but my esp crashes at this point and again restart.
os_sprintf(abc," rdaddr: %02x:%02x:%02x:%02x:%02x:%02x\r\n tsaddr: %02x:%02x:%02x:%02x:%02x:%02x\r\n",
MAC2STR(probe_request->rdaddr), MAC2STR(probe_request->tsaddr));


For starters, you are telling os_sprintf you are going to give him 12 integers, but you are giving him just two pointers...
User avatar
By Mr.Tom
#30249 In include file user_interface.h there are definitions for both... MAC format string and MAC to string:
Code: Select all#ifndef MAC2STR
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#endif
 


Usage:
Code: Select allos_sprintf(buffer, MACSTR, MAC2STR(bss->bssid));


or yours:
Code: Select allos_sprintf(abc," rdaddr: " MACSTR "\r\n tsaddr: " MACSTR "\r\n", MAC2STR(probe_request->rdaddr), MAC2STR(probe_request->tsaddr));


NOTE: Untested :mrgreen: