Switching between AP and STA

This is what my wireless file looks like;


config wifi-device 'radio0'
    option type 'mac80211'
    option channel '1'
    option hwmode '11g'
    option path 'platform/10300000.wmac'
    option htmode 'HT20'
    option disabled '0'

config wifi-iface 'ap'
    option device 'radio0'
    option mode 'ap'
    option network 'lan'
    option ssid 'abc'
    option encryption 'psk2'
    option key 'abc'
    option disassoc_low_ack '0'
    option disabled '1'

config wifi-iface 'sta'
    option device 'radio0'
    option network 'wwan'
    option mode 'sta'
    option ssid 'abc'
    option encryption 'psk2'
    option key 'abc'
    option disassoc_low_ack '0'
    option disabled '0'

I know it's not correct but I don't have enough knowledge about this to fix it.
When I switch between using an AP or using the client, the interfaces seem to be one instead of two separate ones. I think I'm supposed to create another radio instance but I'm not sure.

I'm also not sure about the wwan mention, this is all made up from stuff I've found online since the default firmware build doesn't have much for wifi stuff.

This is how I think it's supposed to look but could sure use some input to know is this is correct.

config wifi-device 'radio0'
    option type 'mac80211'
    option channel '1'
    option hwmode '11g'
    option path 'platform/10300000.wmac'
    option htmode 'HT20'
    option disabled '0'

config wifi-device 'radio1'
    option type 'mac80211'
    option channel '11'
    option hwmode '11g'
    option path 'platform/10300000.wmac'
    option htmode 'HT20'
    option disabled '0'

config wifi-iface 'ap'
    option device 'radio0'
    option mode 'ap'
    option network 'lan'
    option ssid 'abc'
    option encryption 'psk2'
    option key 'abc'
    option disassoc_low_ack '0'
    option disabled '0'

config wifi-iface 'sta'
    option device 'radio1'
    option network 'wwan'
    option mode 'sta'
    option ssid 'def'
    option encryption 'psk2'
    option key 'def'
    option disassoc_low_ack '0'
    option disabled '0'

The second one is wrong since both radios have the same hardware path there's really only one radio in the hardware. radio1 and radio0 are found in dual band routers, and the path will be different.

The wifi-device block is automatically created when the router is booted after installation or any time if a new radio is detected during boot. You shouldn't change any of the existing stuff in the wifi-device block other than add your country-- which is essential to get all the channels / power levels that are legal in your country-- and other fine tuning like changing the channel to avoid neighbors, setting the cell_density and legacy_rates.

If you have changed the wifi-device block enough that the radio doesn't work at all it would be best to remove the whole /etc/config/wireless file, reboot and start over from the new default file.

Most hardware allows an AP and a STA to be configured at the same time on the same radio, but the AP will not work until the STA has connected to its AP, which means it will never work if the AP is shut down or out of radio range. The travelmate package is designed to avoid this problem it is especially useful on single-band routers.

2 Likes

Hi, thanks for the info.

The first file works perfectly but there are some weird things that happen.

For example, the only way the AP works is if both the AP and the client credentials are set in the wireless file, which I think you mention.

One of the weird things that happens is in some case, I can't recall exactly which, I might run 'ifconfig wlan0-1 down' and then see the mention of AP on the wlan0 in the logread.

It seems to work but I thought it might be broken or not working right which is why I started reading and found that maybe I needed a second 'radio'.

I'll take a look at that package, travelmate. If it can be used from the command line, it might be useful.

(Starting off - nothing here is meant to be negative, concending, etc. - just simple and obvious observations, please spare such comments, if you don't want the advice, just don't respond and I'll take that as indication you don't appreciate the assistance. Excellent.)

This is normal - but also he didn't mention it.

He did mention that you appeared to have fashioned the second wireless file yourself (I wanted to note this, because a lot of topics go off-tanget before we even know how the bad file came into existence).

It's not really been made clear, but because you have essentially a broken wireless file in the 2nd instance - you're suffering from an issue where the STA must connect first beforehand.

One issue with that- is you specified 2 channels - yet the STA's channel must be determined by connecting to the upstream AP first. (This is the problem you're experiencing).

While Travelmate will work in usual circumstances, the wireless config file still need to be repaired. That should solve your underlying issue.

As in your many various posts and the suggestion above - it is advised that you use the default wireless file that is available on a freshly flashed or reset device.

If ypu don't know how to edit the config yourself - I would advise asking how to make a configuration before you edit the file.

In another thread, it was also advised to simply install LuCI, make the config, then uninstall. Since I know ypu dont desire that- it would at least help the community assist you better if you inquired with a known default-working config.

Edit: it's also not clear, but because the 2.4 GHz device is configured twice, if your device is capable of 5.4 GHz - it seems you may have inadvertently erased that config. Using the default file will help with this too.

Im not sure if this is the "second radio" you're refrencing, but wanted to clarify that.

Hi, lleachii, yes, I do appreciate the help.

The second file is something I've made up as mentioned in my first post. I posted it to see if it even makes sense. It was never tried, never tested, just made up from digging around the Internet.

I usually have backups of the files I start changing and when I post, I typically show what I've got and/or testing at the time that I'm posting.

The first file is what I'm using now and was derived from looking at the original default wireless file which follows;

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option disabled '1'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

I believe this was the original openwrt file.
The original glinet file has two ap's and I only wanted one with one client.


config wifi-device 'mt7628'
        option type 'mt7628'
        option htmode 'HT40'
        option ht_txstream '2'
        option ht_rxstream '2'
        option hwmode '11g'
        option channel '6'
        option noscan '0'
        option txpower '20'
        option txpower_max '20'
        option country 'US'
        option region '0'
        option band '2G'
        option mimops '3'
        option wmm '1'

config wifi-iface
        option device 'mt7628'
        option network 'lan'
        option mode 'ap'
        option encryption 'psk2'
        option key 'goodlife'
        option ssid 'GL-MT300N-V2-da4'
        option wds '1'
        option disassoc_low_ack '0'
        option ifname 'ra0'

config wifi-iface 'guest2g'
        option device 'mt7628'
        option network 'guest'
        option mode 'ap'
        option wds '1'
        option ssid 'GL-MT300N-V2-da4-Guest'
        option encryption 'psk2'
        option key 'goodlife'
        option ifname 'ra1'
        option disabled '1'
        option guest '1'
        option disassoc_low_ack '0'

The original openwrt file only has an ap and I wanted to have a wifi client as well. They do not work at the same time, I only want to switch between the two and have one at a time working.

The problem is that switching between the two doesn't always work or partly works. I could install luci but am not sure if that will show me how to switch between ap and cli but it would show me the wireless file which I think is your main point.

I do have luci installed on the original glinet firmware but the glinet wireless file is very different from the openwrt one and mine is trying to find a place between them (the first file I shared).

One issue with that- is you specified 2 channels - yet the STA's channel must be determined
by connecting to the upstream AP first. (This is the problem you're experiencing).

If you mean the second file, I've never tried it. I've only used the first one to date.

Since I have a few of these little routers, I'll do as you suggest and try to use the resulting file after using luci on a default openwrt build.

1 Like

I have luci installed on a default openwrt build.

The gui wireless looked like this;

This is what my change looks like.

It's not clear at all if I need to keep both the mt7628 and radio0 devices.
When I try to enable the client;

root@GL-MT300N-V2:/etc/config# uci commit wireless && wifi
mt7628(mt7628): Interface type not supported
mt7628(mt7628): Interface type not supported

The GL firmware uses a different wireless driver entirely. Do not try to copy wireless configuration from a GL firmware config to an official OpenWrt installation or vise versa.

1 Like

I converted the router to openwrt default build but I kept settings. Maybe this is why there is a mix of glinet and openwrt? I removed the generic and then it accepted the uci command.

Yup. Never keep settings when making a major shift like this.

Reset your router to defaults. That will cause the generation of proper OpenWrt default files.

2 Likes

Looking at the default file and mine (the first one), I don't see all that much difference other than some options differences.

It is not clear what I have wrong or why it's working as it is. I only want/need one interface running at a time, either AP or client. It works but the main problem is that sometimes, switching between them loses the br-lan gateway.

After rebuilding using openwrt default again, then adding luci, then adding my wireless config using luci;


config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid 'OpenWrt'
        option encryption 'psk2'
        option key 'abc'
        option disabled '1'

I'm not understanding why I'm being told that my file posted in the first comment is not right. This looks almost identical.

The differences may appear subtle and inconsequential, but they are quite significant.

Let's look at just one entry in the config wifi-device stanza:

Those are entirely different.

The difference between the words "lose" and "loose" is just one "o" but they are completely different words and meanings. Same with "two" and "too" and "to" -- the details matter.

1 Like

Yes I understand that but that was removed;

option type 'mt7628'
option type 'mac80211'

Also, I'm comparing the file I first shared;

config wifi-device 'radio0'
    option type 'mac80211'
    option channel '1'
    option hwmode '11g'
    option path 'platform/10300000.wmac'
    option htmode 'HT20'
    option disabled '0'

config wifi-iface 'ap'
    option device 'radio0'
    option mode 'ap'
    option network 'lan'
    option ssid 'abc'
    option encryption 'psk2'
    option key 'abc'
    option disassoc_low_ack '0'
    option disabled '1'

config wifi-iface 'sta'
    option device 'radio0'
    option network 'wwan'
    option mode 'sta'
    option ssid 'abc'

With the file I've ended up with after doing all this conversion stuff;


config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid 'OpenWrt'
        option encryption 'psk2'
        option key 'abc'
        option disabled '1'

It's not clear what I'm not seeing at this point.

Are you saying that after:

  • resetting to default; and
  • enabling the default AP config

it still doesn't work?

You don't have to make any major edits to get that working, so I'm confused at the issues one could still be having.

Maybe you can try the simplest thing:

  • Reset to defaults
  • Post the unaltered, unedited default wireless config file

Then those assisting can:

  • Show you how to enable the AP
  • Show you the correct syntax to add a STA to the config

TBH - I think that would be extremely helpful to those trying to assist you - and would reduce the multiple repetitious posts saying you still don't understand the config (which has happened on a few previous threads).

That should work to bring up an AP. Of course the STA is disabled, and the STA section is also broken as it lacks an option network.

Add an option country to the device section-- use your country code you may want to redact it when posting.

If the AP does not start, check the logs.

1 Like

Are you saying that after:
resetting to default; and
enabling the default AP config
it still doesn't work?

No, I'm saying that after all these things I've done, I end up with a wireless file that is almost the same as the one I started with. As I explained before, it works, I can use AP or client but sometimes the gateway is lost.

Maybe you can try the simplest thing:
Reset to defaults
Post the unaltered, unedited default wireless config file

I've posted everything I've done in this thread. It includes all of the different variations. If I missed something, what is it and I'll post it.

Then those assisting can:
Show you how to enable the AP
Show you the correct syntax to add a STA to the config

Again, it's not clear what I am missing because I don't have any problems bringing up the interfaces but have some small problems I'm trying to solve.

I keep being told in other posts that my wireless and even network files don't look right which is why I decided to post a question specific to the wireless this time.

TBH - I think that would be extremely helpful to those trying to assist you - and would
reduce the multiple repetitious posts saying you still don't understand the config
(which has happened on a few previous threads).

No matter how I explain things or all the information I share, I'm always told it's not enough or I'm not doing it right but I keep trying to do as I'm being asked in order to get help. So yup, this comment is not clear to me either :).

To recap... I shared my current wireless config and one I was working on because I was told mine doesn't look right each time I've posted it.
The first file I show is what IS working but with small problems. I figured I'd share it to find out what it is that is not correct.

The second file I shared is what I was putting together based on posts and articles I found and was told it's garbage which is fine. It's not something I've used or will use now.

Then I was told to build a new router so went through those steps from stock manufacturer to openwrt and fixed one of the problems that was pointed out.

I ended up with a config file that is not very different other than options from what I had to begin with.
I'm not sure why you would wonder why I might be a bit unclear at this point about anything I might be doing wrong but have tried my best to follow the suggestions and information shared.

I am not in this forum to argue and fight with anyone but no matter how I share information, I'm always told I'm not doing it the right away. It would be nice to actually be shown now and then what it is that I'm not doing right so that I can learn from that and not walk away even more unsure.

So now I have a wireless file that is almost identical to what I started with. Is my new file any better than my old file? I guess I'll try it out and see what happens.

If the file works, then it's fine (but if that's the case - I don't really understand your post unless you're literally looking at the lines and just don't understand). I would just advise you not to be frustrated. I know it must be frustrating; but likewise, there's not much magic to using the default files that came with OpenWrt.

So the next step, would be to add STA config.

I assume this is the unaltered file.

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option disabled '0'
        option country 'XX

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'
        option disabled '1'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'wwan' #<---this network has to be created
        option mode 'sta'
        option ssid 'upstream_ap_SSID'
        option encryption 'none'
  • Replace XX with your actual Country
  • This will connect you to a station with name upstream_ap_SSID
  • The Travelmate package can be used to better switch between enabling and disabling between STA and AP, see: Travelmate support thread

At 70+ years of age, I'm not frustrated by much but I'm trying my best to ask, explain and take in what is being shared with me but it never seems to come across in text.

This is the unaltered file;


config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid 'OpenWrt'
        option encryption 'psk2'
        option key 'abc'
        option disabled '1'

This is my file;


config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid '012'
        option encryption 'psk2'
        option key '014'
        option disabled '0'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid '123'
        option encryption 'psk2'
        option key '456'
        option network 'wan'
        option disabled '0'

I was using 'wan' because I don't connect anything to that.
However, I noticed this was omitted over time from my network file;
config interface 'wwan' option proto 'dhcp' option device 'radio0.network1'
But, this seems to be wrong for this network. I suppose it should be 'radio0' only now.
Then, this is how my files look now;


config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd17:78ff:5e34::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'dhcp'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

config switch <-- I don't think I need this
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan <-- I don't think I need this
        option device 'switch0'
        option vlan '1'
        option ports '1 6t'

config switch_vlan <-- I don't think I need this
        option device 'switch0'
        option vlan '2'
        option ports '0 6t'

config interface 'wwan'
    option proto 'dhcp'
    option device 'radio0'
    option metric '10'

Wireless;

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option country 'US'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid '012'
        option encryption 'psk2'
        option key '014'
        option disabled '0'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid '123'
        option encryption 'psk2'
        option key '456'
        option network 'wwan'
        option disabled '0'

After editing the network file, I restart the network. I then run 'uci commit wireless && wifi' to reload the wireless as well if that's not done with the network restart.

On wireless reload, I see some errors;
Thu Jun 22 18:51:04 2023 daemon.notice netifd: radio0 (18164): sh: out of range
Thu Jun 22 18:51:06 2023 daemon.notice wpa_supplicant[1069]: wlan0: Unknown event 37
Thu Jun 22 18:51:06 2023 daemon.notice wpa_supplicant[1069]: wlan0: Unknown event 37

Using ifconfig shows wlan0 and wlan0-1 up. I leave both enabled but only use one at a time using a simple bash script to configure the interfaces this way;

If I want to use the client, I run;
'ifconfig wlan0-1 down' (If it's up)
'ifconfig wlan0 up'
Then;
'udhcpc -i wlan0' to get a dhcp IP.
Then to set the wifi gw;
'ip route replace default via wlan0'

If I want to use the AP, I run;
'ifconfig wlan0 down'
'ifconfig wlan0-1 up'
Then;
'udhcpc -i br-lan'
to set the br-lan as the gateway.

I"m not one hundred percent sure of the order of these commands but it's close.
The problems I'm seeing are something along these lines.

When wanting to use the client after the AP was up, I'll run similar commands to the above and what happens is that the br-lan gateway might not be set or there are errors like;

udhcpc: broadcasting discover

The only way to get past those is to manually set what ever gateway I want like;
'udhcpc -i br-lan' or 'udhcpc -i wlan0'.

It all works, it's just messy and I thought my network and wireless files were a huge mess but they were in fact a small mess.

Maybe I just need to look at that package being mentioned so long as it can be used from the command line.

BTW, even before adding the wwan interface, it was working as expected other than the errors/problems I've mentioned.

Also, my mistake on this error;

udhcpc: broadcasting discover

It happened because I was running the dhcp client command with the wrong interface.

It all works now, maybe because I added the wwan and I don't see many errors. One is still there;

Thu Jun 22 20:11:59 2023 daemon.err hostapd: Failed to set beacon parameters

This might be due to the small change I made in the wireless file of course.

  • There aren't any STA configs by default in any OpenWrt device I'm aware of
  • I performed an exact text search on the config, I found 3 times you posted and said:
    • Post 11 (contains STA) - "After rebuilding using openwrt default again, then adding luci, then adding my wireless config using luci"
    • Post 13 (contains STA) - "With the file I've ended up with after doing all this conversion stuff"
    • Post 18 (contains STA) - "This is the unaltered file"

Additionally, there's no network listed in this config.

So, unless I'm missing something - you're not providing the unaltered file. Perhaps others can take a look - my apologies if I'm incorrect. Likewise, apologies if you don't understand why I asked and the simplicity I was attempting to introduce to the process.

As always, I hope the best for your setup.

Despite there's no network listed - if you say it worked as expected, that seems like a good sign. If everything's working - cool! :+1: