OpenWrt Forum Archive

Topic: UCI script to disable sta mode -- How to write?

The content of this topic has been archived on 17 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello.

I have a router with two connections on one radio. One is sta mode, and the other is ap mode. I would like to find a way to disable any and all sta mode connections via a UCI command, which I will trigger by checking to see if that sta mode connection is connected, if possible.

I need to do this as the ap mode will drop if the sta mode loses signal (It's a sort of longstanding bug).

In pseudocode, since I can't seem to find the syntax for exactly what I need:

do while true
  do for all sta in interfaces:
    if not sta_connected
    then sta disable=1
    endif
  end
  sleep 120
end

Preferably, I would disable the sta mode interfaces so as not to save it in flash (also to make it last longer), so that when I go somewhere else and turn the router on it brings up the sta interfaces and, after they have had a chance to connect, disables the disconnected one(s).

Perhaps I could also add a script activated by a button to manually bring up all the sta mode connections for if the router is still on.

button --> do for all sta in interfaces
  sta_disable=0
end

I feel as if this could be useful to a lot of people, as this keeps coming up and seems to be a wontfix, but I have not found a solution that does not involve multiple copies of config files.

Thank you, nenekofi. That looks like exactly what I was trying to find. I will test it out immediately!

Crud. That did not quite work. It is saving the disabled state in flash, so it never connects again. I know that could be fixed by enabling it every boot, but I would prefer to save wear on the flash.

Do you have a command to disable it that persists in RAM only?

I can work out the rest of the script now, but I need a selective disable for sta ifaces that does not save to flash. Is that possible?

Thanks very much, though!

The discussion might have continued from here.