In this post, we will assume that you want to use Wi-Fi to connect your device to the internet. This can be the situation when you build a WiFi enabled IoT device using LinkIt Smart 7688.
Alternatively you can use this mode to create a device that connects to your main AP through WiFi, while provides an internet access to other devices through Ethernet. This is the reverse configuration of the dumb AP mode discussed before.
In OpenWrt term, this is WiFi Extender or Repeater or Bridge Configuration. This mode is not supported by the default settings of OpenWrt. Main reason is that WiFi driver does not support bridging when it is in client (station) mode. Thus you need an additional service from the package named relayd. Please check previous post for the instruction how to install this package and others (luci-proto-relay).
In this page, you can find detailed instruction for setting up this mode, both using LuCI and CLI. Here again we summarise the process using CLI. There are some differences as well.
First change the subnet address of lan, which might be optional but just for the sake of safety.
# uci set network.lan.ipaddr='192.168.2.1'
Create a relay network for the bridging between lan and the WiFi (wwan) which will be in station mode. This will bind lan and wwan.
# uci set network.repeater_bridge=interface
# uci set network.repeater_bridge.proto='relay'
# uci set network.repeater_bridge.network='lan wwan'
Then create a network wwan and run DHCP on it, so that the device can connect to the main AP via WiFi.
# uci set network.wwan=interface
# uci set network.wwan.proto='dhcp'
Add all network to the firewall zone
# uci set firewall.@zone[0].network='lan repeater_bridge wwan'
But prevent DHCP from running on lan network.
# uci set dhcp.lan.ignore='1'
Now, according to the OpenWrt document, you need to create a new wireless interface for wwan and set it to station mode. However for some reason creating a second interface is not allowed in MT7688. So we turn the first interface into this role instead.
# uci set wireless.default_radio0.mode='sta'
# uci set wireless.default_radio0.network='wwan'
# uci set wireless.default_radio0.ssid='your AP SSID'
# uci set wireless.default_radio0.bssid='your AP BSSID'
# uci set wireless.default_radio0.encryption='psk2'
# uci set wireless.default_radio0.key='your super secret key'
Do not forget to activate radio0 device if not done already.
# uci set wireless.radio0.disabled='0'
You may need BSSID of the target AP in the above step. To check it run following commands
# iw dev wlan0 scan > /root/ap_list
# vi /root/ap_list