This is che code for esp8266 to sniff MAC adreses, in the functions.h i need to modify this code so that it would send the MAC adress and RSSI to a mqtt server as one masage. Code part to modify:
if((buf[12]==0x88)||(buf[12]==0x40)||(buf[12]==0x94)||(buf[12]==0xa4)||(buf[12]==0xb4)||(buf[12]==0x08))
{
// Serial.printf("%02x\n",buf[12]);
// if(buf[12]==0x40) Serial.printf("Disconnected: ");
// if(buf[12]==0x08) Serial.printf("Data: ");
// if(buf[12]==0x88) Serial.printf("QOS: ");
// Origin MAC address starts at byte 22
// Print MAC address
for(int i=0;i<5;i++) {
Serial.printf("%02x:",buf[22+i]);
}
Serial.printf("%02x ",buf[22+5]);
// Signal strength is in byte 0
Serial.printf("%i\n",int8_t(buf[0]));
P.S. i dont need the code for sending it to an mqtt server i just need to combine the outputs of these to one masage:
First, I don't think you're using sprintf() correctly. The first argument is a character buffer and I'm assuming there's a definition like:
char MAC_1[50];
somewhere. The second argument is a format string. There needs to be one conversion character ('%') for each argument you wish to display. However, you use:
The goal of this Forum is not to write code for you; there's another place on this site for hiring consultants. This Forum is to help you overcome problems in the code you've written. Posts have given you suggestions on what to do, but I don't think they want to write the code for you. That's up to you.