-->
Page 1 of 3

Cannot change STATION MAC

PostPosted: Sun Jul 02, 2017 10:21 am
by diffstorm
Hi All,

The following code does not work properly, so STA MAC is not changing, it stays as it is.

I call it after setup of WiFi.mode to WIFI_AP_STA.

Code: Select allshort id = 0xAA55;
    mac[0] = 1 + (chip_id >> 24) & 0xff;
    mac[1] = (chip_id >> 16) & 0xff;
    mac[2] = (chip_id >> 8) & 0xff;
    mac[3] = chip_id & 0xff;
    mac[4] = highByte(id);
    mac[5] = lowByte(id);

    ret = wifi_set_macaddr(STATION_IF, mac);
    yield();
   


Please help.
Another question, is it possible AP and STA macs can be same?

Thanks.

Re: Cannot change STATION MAC

PostPosted: Mon Jul 03, 2017 4:33 am
by diffstorm
Any help will be appreciated.

I have tried to use it in user_init function, in Arduino I used the early_init function which is in user_init.
It still does not change, I cannot change STA MAC.
Code: Select allextern void early_init();

  void early_init(void) {
      // all the existing code
      WiFi.mode(WIFI_AP_STA);
      MAC_Write(44);
  }


Please help if there is any way.

Thanks

Re: Cannot change STATION MAC

PostPosted: Mon Jul 03, 2017 5:09 am
by torntrousers
There's an example here: https://github.com/HarringayMakerSpace/ ... no#L27-L35

That code changes the AP Mac, to change the Station Mac change SOFTAP_IF to STATION_IF.

Re: Cannot change STATION MAC

PostPosted: Mon Jul 03, 2017 8:19 am
by diffstorm
Hi, Thanks for the answer.

I could not find where is the InitVariant function called in the example code.

So, what is InitVariant?
If it is called in user_init or similar place, I need to read a file to get an ID before setting MAC address.
Is it possible in this setup?

Thanks.