VLAN with Failover WAN

Hello.

I have a mikrotik RB750r2 router.
I have the Port 1 as LAN input via Wireless (main router is far away)
I have the Port 2 as Switch VLAN XXX.
I have the Port 3 as Switch VLAN YYY.

I have a device on port 2 with gateway 192.168.x.x. This gateway is some km far away. (Via Wireless).
How can i make a failover gateway if wifi fails?

I have a router with internet at same area with 192.168.y.y IP.
If wifi breaks i can’t make changes to my devices. Only if i drive 100km.
Device doesn’t not support failover or multiple gateways.

NOTE: Now i can make changes as internal network LAN. If WiFi breaks and there is a Solution i don’t have problem if i can’t access directly. I want only to have internet the device from the local router. Is important to don’t mix the local router network with vlan network.
Is there any solution?

Thank you.

You could define multiple routes with different distances and check gateway set, to disable once offline on primary.