There is a router with installed OpenWRT, the router is connected to one Wi-Fi network (SSID wifinetwork1) and distributes the Internet through a LAN interface. There is another Wi-Fi network (SSID wifinetwork2) to which the router should connect when the first Wi-Fi network (SSID wifinetwork1) is unavailable. In other words, you need to get the router to work like a regular wifi adapter that automatically connects to wifi networks known to it (and if several wifi are available, then it connects to the one with the best signal). If possible, how to configure? Thanks.
travelmate package would be of help to you. you'd still need to configure two STAs, but travelmate does the switching between them for you.