Wi-Fi Old/en: различия между версиями

Материал из Wiren Board
м (FuzzyBot переименовал страницу Wi-Fi/en в Wi-Fi Old/en без оставления перенаправления: Часть переводимой страницы Wi-Fi.)
(Новая страница: «=== Setting in a hotspot mode ===»)
(не показаны 33 промежуточные версии 2 участников)
Строка 3: Строка 3:
* hotspot mode (enabled by default);
* hotspot mode (enabled by default);
* client mode;
* client mode;
* simultaneous operation in both modes (only in some versions of the controller; see below for details).
* simultaneous operation in both modes(only in some versions of the controller; see below for details).




Строка 9: Строка 9:


# [[File:connectors-sma-rpsma.jpg|thumb|right|300 px|Wi-Fi (RP-SMA) and GSM (SMA) terminals comparasion]] Connect antenna to the Wi-Fi connector.
# [[File:connectors-sma-rpsma.jpg|thumb|right|300 px|Wi-Fi (RP-SMA) and GSM (SMA) terminals comparasion]] Connect antenna to the Wi-Fi connector.
#: The Wiren Board Wi-Fi is available at a distance of no more than one meter without the antenna.To get a standart Wi-Fi radius of operation, you need to connect antenna to the appropriate connector of the controller. If the controller is in the closet (especially in a metal one) or a separate room, it is better to use a remote antenna.
#: The Wiren Board Wi-Fi is available at a distance of no more than one meter without the antenna.To get a standart Wi-Fi radius of operation, you need to connect antenna to the appropriate connector of the controller. If the controller is in the closet(especially in a metal one) or a separate room, it is better to use a remote antenna.
#: The antenna has standart Wi-Fi connector: RP-SMA (differs from SMA-connector for GSM antennas)[https://en.wikipedia.org/wiki/SMA_connector#Reverse_polarity_SMA RP-SMA]  
#: The antenna has standart Wi-Fi connector: RP-SMA (differs from SMA-connector for GSM antennas)[https://en.wikipedia.org/wiki/SMA_connector#Reverse_polarity_SMA RP-SMA]  
# Wiren Board controller's WI-Fi works in hotspot mode by default:
# Wiren Board controller's WI-Fi works in hotspot mode by default:
Строка 16: Строка 16:
#* adress of the controller in the created network: ''192.168.42.1''
#* adress of the controller in the created network: ''192.168.42.1''


== Setting up Wi-Fi in Linux ==
== \Wi-Fi configuration in Linux ==


The setting up is usually proceed in a standart way for Linux Debian: via file <code>/etc/network/interfaces</code>. The following are brief instructions for common tasks on Linux Debian, there is a detailed documentation on the Linux site. [https://wiki.debian.org/ru/NetworkConfiguration detailed documentation].
The configuration is usually proceed in a standart way for Linux Debian: via file <code>/etc/network/interfaces</code>. The following are brief instructions for common tasks on Linux Debian, there is a detailed documentation on the Linux site. [https://wiki.debian.org/ru/NetworkConfiguration detailed documentation].


=== Setting up in a hotspot mode ===
=== Setting in a hotspot mode ===


Access point mode is enabled by default. Operation in the access point mode is provided by the '''[https://wireless.wiki.kernel.org/en/users/documentation/hostapd hostapd]''' daemon.
Режим точки доступа включён по умолчанию. Работа в режиме точки доступа обеспечивается демоном '''[https://wireless.wiki.kernel.org/en/users/documentation/hostapd hostapd]'''.


Configuration process:
Процесс настройки:
# Enable access point mode. For this:
# Включите режим точки доступа. Для этого:
#* open file <code>/etc/default/hostapd</code> and uncomment the string(e.g.,remove the # at the beginning of the string)<syntaxhighlight lang="bash">DAEMON_CONF="/etc/hostapd.conf"</syntaxhighlight>
#* в файле <code>/etc/default/hostapd</code> раскомментируйте строку (то есть удалите знак '''#''' в начале строки)<syntaxhighlight lang="bash">DAEMON_CONF="/etc/hostapd.conf"</syntaxhighlight>
#* edit the <code>/etc/hostapd.conf</code> file like in the example:<syntaxhighlight lang="bash">
#* отредактируйте файл <code>/etc/hostapd.conf</code>, чтобы он выглядел так:<syntaxhighlight lang="bash">
interface=wlan0
interface=wlan0
#driver=nl80211 # this line should stay commented
#driver=nl80211 # оставьте эту строку закомментированной
ssid=WirenBoard # you can substitute WirenBoard with a different name for the hotspot
ssid=WirenBoard # вместо WirenBoard можете подставить другое имя для создаваемой точки доступа
channel=1
channel=1
wpa=2
wpa=2
wpa_passphrase=your_password # replace your_password with your own password
wpa_passphrase=your_password # вместо your_password подставьте пароль
wpa_key_mgmt=WPA-PSK
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_pairwise=TKIP CCMP
rsn_pairwise=TKIP CCMP  
rsn_pairwise=TKIP CCMP  
</syntaxhighlight>
</syntaxhighlight>
# Edit <code>/etc/network/interfaces</code>:
# Отредактируйте <code>/etc/network/interfaces</code>:
#* uncomment and edit  the lines(or add them, if there were none) related to the hotspot settings: <syntaxhighlight lang="bash">
#* раскомментируйте и отредактируйте (или добавьте, если их не было) строки, относящиеся к настройке в режиме точки доступа: <syntaxhighlight lang="bash">
iface wlan0 inet static
iface wlan0 inet static
       address 192.168.42.1 # here 192.168.42.1  - is the address where the Wiren Board controller will be located in the new network; you can specify a different address
       address 192.168.42.1 # здесь 192.168.42.1  - адрес, по которому в новой сети будет находиться Wiren Board; можете указать другой адрес
       netmask 255.255.255.0
       netmask 255.255.255.0
</syntaxhighlight>
</syntaxhighlight>
#* comment out the lines related to the operating in client mode:<syntaxhighlight lang="bash">
#* закомментируйте строки, относящиеся к работе в режиме клиента:<syntaxhighlight lang="bash">
#auto wlan0
#auto wlan0
#iface wlan0 inet dhcp  
#iface wlan0 inet dhcp  
Строка 50: Строка 50:
#                wpa-psk  {password}
#                wpa-psk  {password}
</syntaxhighlight>
</syntaxhighlight>
# Run the command
# Выполните команду
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
/etc/init.d/hostapd restart
/etc/init.d/hostapd restart
Строка 56: Строка 56:




=== Setting up in client mode ===
=== Настройка в режиме клиента ===


# Disable hotspot mode.
# Отключите режим точки доступа.
#: To do this, in the  <code>/etc/default/hostapd</code> file, comment out the line (e.g., add the '''#''' sign at the beginning of the line) <syntaxhighlight lang="bash">#DAEMON_CONF="/etc/hostapd.conf"</syntaxhighlight>
#: Для этого в файле <code>/etc/default/hostapd</code> закомментируйте строку (то есть добавьте знак '''#''' в начало строки)<syntaxhighlight lang="bash">#DAEMON_CONF="/etc/hostapd.conf"</syntaxhighlight>
# Edit <code>/etc/network/interfaces</code>:
# Отредактируйте <code>/etc/network/interfaces</code>:
#* comment out the lines related to the setting in access point mode: <syntaxhighlight lang="bash">
#* закомментируйте строки, относящиеся к настройке в режиме точки доступа: <syntaxhighlight lang="bash">
#iface wlan0 inet static
#iface wlan0 inet static
#      address 192.168.42.1
#      address 192.168.42.1
#      netmask 255.255.255.0
#      netmask 255.255.255.0
</syntaxhighlight>
</syntaxhighlight>
#* uncomment and edit the lines (or add them if there were none): <syntaxhighlight lang="bash">
#* раскомментируйте и отредактируйте строки (или добавьте, если их не было):<syntaxhighlight lang="bash">
auto wlan0
auto wlan0
iface wlan0 inet dhcp  
iface wlan0 inet dhcp  
                 wpa-ssid {ssid} # replace {ssid} with the name of the hotspot
                 wpa-ssid {ssid} # вместо {ssid} подставьте имя точки доступа
                 wpa-psk  {password} # replace {password} with your own password
                 wpa-psk  {password} # вместо {password} подставьте пароль
</syntaxhighlight>
</syntaxhighlight>
# To apply the changes, run the following commands
# Чтобы применить изменения, выполните команды
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ifdown wlan0
ifdown wlan0
Строка 78: Строка 78:
</syntaxhighlight>
</syntaxhighlight>


=== Setting up in hotspot and client mode simultaneously ===
=== Настройка в режиме точки доступа и клиента одновременно ===


The mode of simultaneous operation of the Wi-Fi module in both the hotspot mode and the client mode is called ''Concurrent Mode'' or ''STA+SoftAP'', and is not supported by all Wi-Fi modules. It also does not work on all versions of the Wiren Board controllers. We've found out that it works out of the box on Wiren Board controllers with Realtek 8723BU chip and Linux kernel 4.1.15. To check that, run the following commands:  
Режим одновременной работы модуля Wi-Fi и в режиме точки доступа, и в режиме клиента, называется ''Concurrent Mode'' или ''STA+SoftAP'', и поддерживается не всеми Wi-Fi модулями. Также он работает не на всех версиях Wiren Board. Проверено, что он работает из коробки на Wiren Board с чипом Realtek 8723BU и ядром Linux 4.1.15. Чтобы проверить, выполняются ли эти условия, выполните команды:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
uname -a
uname -a
lsmod | grep 8723bu
lsmod | grep 8723bu
</syntaxhighlight>
</syntaxhighlight>
''If the conditions are not met, you may still be able to configure Concurrent Mode on your Wiren Board. As a starting point, use the [http://randomstuffidosometimes.blogspot.ru/2016/03/rtl8192cu-and-rtl8188cus-in-station-and.html instructions(rus only)].''
''Если условия не выполнены, возможно, на вашем Wiren Board всё равно можно настроить Concurrent Mode. В качестве отправной точки используйте [http://randomstuffidosometimes.blogspot.ru/2016/03/rtl8192cu-and-rtl8188cus-in-station-and.html инструкцию].''


The mode of simultaneous operation of the Wi-Fi module in both the hotspot mode and the client mode is called Concurrent Mode or STA+SoftAP, and is not supported by all Wi-Fi modules. It also does not work on all versions of the Wiren Board. We have found out that it works out of the box on Wiren Board with Realtek 8723BU chip and Linux kernel 4.1.15. To check that, run the following commands:
Если условия выполнены:
 
# Выполните команду
If conditions are met:
# Run command
#:<syntaxhighlight lang="bash">
#:<syntaxhighlight lang="bash">
iwconfig
iwconfig
</syntaxhighlight>
</syntaxhighlight>
#:Its output should show two Wi-Fi interfaces: ''wlan0'' и ''wlan1''.
#:В её выводе должны быть показаны два интерфейса Wi-Fi: ''wlan0'' и ''wlan1''.
# Use the previous two instructions to configure the client mode and the hotspot mode connection, but use different interfaces. For example, leave ''wlan0'' for the hotspot and make the client on ''wlan1''. The corresponding part of ''/etc/network/interfaces'' should look like this:  
# Настройте по двум предыдущим инструкциям подключение в режиме клиента и подключение в режиме точки доступа, но используйте для них разные интерфейсы. Например, оставьте ''wlan0'' для точки доступа, а клиента сделайте на ''wlan1''. Соответствующая часть файла ''/etc/network/interfaces'' должна выглядеть так:
#: <syntaxhighlight lang="bash">
#: <syntaxhighlight lang="bash">
# Wireless interfaces
# Wireless interfaces
auto wlan1
auto wlan1
iface wlan1 inet dhcp
iface wlan1 inet dhcp
     wpa-ssid {ssid} # replace {ssid} with the hotspot name
     wpa-ssid {ssid} # вместо {ssid} подставьте имя точки доступа
     wpa-psk {password} # replace {password} with your own password
     wpa-psk {password} # вместо {password} подставьте пароль


auto wlan0
auto wlan0
Строка 110: Строка 108:




=== Universal Wi-Fi settings file ===
=== Универcальный файл настроек Wi-Fi ===


Below is the text of the file, which shows the settings for connecting to networks with different encryption settings. The file is borrowed [https://www.raspberrypi.org/forums/viewtopic.php?t=7592 from here].
Ниже дан текст файла, в котором показаны настройки для подключения к сетям с разными параметрами шифрования. Файл позаимствован [https://www.raspberrypi.org/forums/viewtopic.php?t=7592 здесь].
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
####################
####################
Строка 164: Строка 162:




=== Automatic reconnection in case of connection problems ===
=== Автоматическое переподключение при проблемах с соединением ===


The method is borrowed from here(ru): [http://alexba.in/blog/2015/01/14/automatically-reconnecting-wifi-on-a-raspberrypi/]
Способ заимствован здесь: [http://alexba.in/blog/2015/01/14/automatically-reconnecting-wifi-on-a-raspberrypi/]


For example, the controller is connected to a router with the ''192.168.0.1'' address via the ''wlan1'' interface. Then:
Допустим, контроллер подключён к роутеру с адресом ''192.168.0.1'' через интерфейс ''wlan1''. Тогда:
# in <code>/root</code> folder create script <code>wifi_autoconnect.sh</code> as in the example below: <syntaxhighlight lang="bash">
# Создайте в папке <code>/root</code> скрипт <code>wifi_autoconnect.sh</code> с содержанием: <syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash


# Substitute the name of the interface
# Подставьте имя интерфейса
WLANINTERFACE=wlan1
WLANINTERFACE=wlan1
# Substitute the address of the router or server on the Internet, access to which will be checked
# Подставьте адрес роутера или сервера в интернете, доступ к которому будет проверяться
SERVER=192.168.0.1
SERVER=192.168.0.1


Строка 188: Строка 186:
fi
fi
</syntaxhighlight>
</syntaxhighlight>
# Make file executable by running the command <syntaxhighlight lang="bash">
# Сделайте файл исполняемым, выполнив команду <syntaxhighlight lang="bash">
chmod +x /root/wifi_autoconnect.sh
chmod +x /root/wifi_autoconnect.sh
</syntaxhighlight>
</syntaxhighlight>
# Schedule the script to run every minute. For this:
# Запланируйте выполнение скрипта каждую минуту. Для этого:
## Install ''cron'': <syntaxhighlight lang="bash">
## Установите ''cron'': <syntaxhighlight lang="bash">
apt-get install cron
apt-get install cron
</syntaxhighlight>
</syntaxhighlight>
## In the end of the<code>/etc/crontab</code> file add line<syntaxhighlight lang="bash">
## Добавьте в конец файла <code>/etc/crontab</code> строку<syntaxhighlight lang="bash">
*  * * * * root /root/wifi_autoconnect.sh
*  * * * * root /root/wifi_autoconnect.sh
# be sure to add an empty line at the end of the file
# обязательно добавьте пустую строку в конец файла
</syntaxhighlight>
</syntaxhighlight>




== Limits ==
== Ограничения ==


#Wi-Fi in Wiren Board controllers in hotspot mode is relatively slow. The speed is enough to work with the web interface, but do not use the Wiren Board as a replacement for a standart router.
# Wi-Fi в Wiren Board в режиме точки доступа работает относительно медленно. Скорости вполне хватит для работы с веб-интерфейсом, но не стоит использовать Wiren Board в качестве замены роутера.
# In very rare cases, the Wi-Fi adapter on the Wiren Board controllers may not be compatible with some other Wi-Fi devices. This is a common problem of Wi-Fi implementations on chipsets from different manufacturers. If you encounter unexplained problems, we recommend to change the encryption settings, channel width, etc.
# В очень редких случаях возможна несовместимость адаптера Wi-Fi в Wiren Board с некоторыми другими устройствами Wi-Fi. Это общая проблема реализаций Wi-Fi на чипсетах разных производителей. Если вы столкнулись с необъяснимыми проблемами при работе, рекомендуем поменять настройки шифрования, ширины канала и т.п.

Версия 16:40, 23 апреля 2019

Другие языки:

The Wi-Fi function in the Wiren Board controller can be configured to operate in one of two or three modes:

  • hotspot mode (enabled by default);
  • client mode;
  • simultaneous operation in both modes(only in some versions of the controller; see below for details).


First Wi-Fi connection

  1. Wi-Fi (RP-SMA) and GSM (SMA) terminals comparasion
    Connect antenna to the Wi-Fi connector.
    The Wiren Board Wi-Fi is available at a distance of no more than one meter without the antenna.To get a standart Wi-Fi radius of operation, you need to connect antenna to the appropriate connector of the controller. If the controller is in the closet(especially in a metal one) or a separate room, it is better to use a remote antenna.
    The antenna has standart Wi-Fi connector: RP-SMA (differs from SMA-connector for GSM antennas)RP-SMA
  2. Wiren Board controller's WI-Fi works in hotspot mode by default:
    • hotspot name: WirenBoard...
    • password: none
    • adress of the controller in the created network: 192.168.42.1

\Wi-Fi configuration in Linux

The configuration is usually proceed in a standart way for Linux Debian: via file /etc/network/interfaces. The following are brief instructions for common tasks on Linux Debian, there is a detailed documentation on the Linux site. detailed documentation.

Setting in a hotspot mode

Режим точки доступа включён по умолчанию. Работа в режиме точки доступа обеспечивается демоном hostapd.

Процесс настройки:

  1. Включите режим точки доступа. Для этого:
    • в файле /etc/default/hostapd раскомментируйте строку (то есть удалите знак # в начале строки)
      DAEMON_CONF="/etc/hostapd.conf"
      
    • отредактируйте файл /etc/hostapd.conf, чтобы он выглядел так:
      interface=wlan0
      #driver=nl80211 # оставьте эту строку закомментированной
      ssid=WirenBoard # вместо WirenBoard можете подставить другое имя для создаваемой точки доступа
      channel=1
      wpa=2
      wpa_passphrase=your_password # вместо your_password подставьте пароль
      wpa_key_mgmt=WPA-PSK
      wpa_pairwise=TKIP CCMP
      rsn_pairwise=TKIP CCMP
      
  2. Отредактируйте /etc/network/interfaces:
    • раскомментируйте и отредактируйте (или добавьте, если их не было) строки, относящиеся к настройке в режиме точки доступа:
      iface wlan0 inet static
            address 192.168.42.1 # здесь 192.168.42.1  - адрес, по которому в новой сети будет находиться Wiren Board; можете указать другой адрес
            netmask 255.255.255.0
      
    • закомментируйте строки, относящиеся к работе в режиме клиента:
      #auto wlan0
      #iface wlan0 inet dhcp 
      #                wpa-ssid {ssid}
      #                wpa-psk  {password}
      
  3. Выполните команду
/etc/init.d/hostapd restart


Настройка в режиме клиента

  1. Отключите режим точки доступа.
    Для этого в файле /etc/default/hostapd закомментируйте строку (то есть добавьте знак # в начало строки)
    #DAEMON_CONF="/etc/hostapd.conf"
    
  2. Отредактируйте /etc/network/interfaces:
    • закомментируйте строки, относящиеся к настройке в режиме точки доступа:
      #iface wlan0 inet static
      #      address 192.168.42.1
      #      netmask 255.255.255.0
      
    • раскомментируйте и отредактируйте строки (или добавьте, если их не было):
      auto wlan0
      iface wlan0 inet dhcp 
                      wpa-ssid {ssid} # вместо {ssid} подставьте имя точки доступа
                      wpa-psk  {password} # вместо {password} подставьте пароль
      
  3. Чтобы применить изменения, выполните команды
ifdown wlan0
ifup wlan0

Настройка в режиме точки доступа и клиента одновременно

Режим одновременной работы модуля Wi-Fi и в режиме точки доступа, и в режиме клиента, называется Concurrent Mode или STA+SoftAP, и поддерживается не всеми Wi-Fi модулями. Также он работает не на всех версиях Wiren Board. Проверено, что он работает из коробки на Wiren Board с чипом Realtek 8723BU и ядром Linux 4.1.15. Чтобы проверить, выполняются ли эти условия, выполните команды:

uname -a
lsmod | grep 8723bu

Если условия не выполнены, возможно, на вашем Wiren Board всё равно можно настроить Concurrent Mode. В качестве отправной точки используйте инструкцию.

Если условия выполнены:

  1. Выполните команду
    iwconfig
    
    В её выводе должны быть показаны два интерфейса Wi-Fi: wlan0 и wlan1.
  2. Настройте по двум предыдущим инструкциям подключение в режиме клиента и подключение в режиме точки доступа, но используйте для них разные интерфейсы. Например, оставьте wlan0 для точки доступа, а клиента сделайте на wlan1. Соответствующая часть файла /etc/network/interfaces должна выглядеть так:
    # Wireless interfaces
    auto wlan1
    iface wlan1 inet dhcp
        wpa-ssid {ssid} # вместо {ssid} подставьте имя точки доступа
        wpa-psk {password} # вместо {password} подставьте пароль
    
    auto wlan0
    iface wlan0 inet static
      address 192.168.42.1
      netmask 255.255.255.0
    


Универcальный файл настроек Wi-Fi

Ниже дан текст файла, в котором показаны настройки для подключения к сетям с разными параметрами шифрования. Файл позаимствован здесь.

####################
#; start of wireless bits
#; this command stays for all configs
auto wlan0
###################
#; comments indicated by #;
#; commands indicated by #
#; remove the # to enable the command
####################
#; if using static IP then....#
#iface wlan0 inet static
# address UR_IP
#gateway UR_ROUTER_IP
#netmask 255.255.255.0
##################
#; otherwise use dhcp #
#iface wlan0 inet dhcp
###################
#; OPEN wireless config #
#wireless-essid UR_ESSID
#wireless-mode managed

###################
#; WEP wireless config #
#wireless-essid UR_ESSID
#wireless-key UR_KEY
#; end of WEP config

########################
#; WPA and WPA2 wireless config #
#; all command config lines above HERE to be #'ed except the entry auto wlan0
########################
wpa-driver wext
wpa-ssid UR_ESSID
#; wpa-ap-scan is 1 for visible and 2 for hidden hubs
wpa-ap-scan 1
#; wpa-proto is WPA for WPA1 (aka WPA) or RSN for WPA2
wpa-proto WPA
#; wpa-pairwise and wpa-group is TKIP for WPA1 or CCMP for WPA2
wpa-pairwise TKIP
wpa-group TKIP
wpa-key-mgmt WPA-PSK
#; use "wpa_passphrase UR_ESSID UR_KEY" to generate UR_HEX_KEY
#; enter the result below
wpa-psk UR_HEX_KEY
##########################
# end of wireless bits


Автоматическое переподключение при проблемах с соединением

Способ заимствован здесь: [1]

Допустим, контроллер подключён к роутеру с адресом 192.168.0.1 через интерфейс wlan1. Тогда:

  1. Создайте в папке /root скрипт wifi_autoconnect.sh с содержанием:
    #!/bin/bash
    
    # Подставьте имя интерфейса
    WLANINTERFACE=wlan1
    # Подставьте адрес роутера или сервера в интернете, доступ к которому будет проверяться
    SERVER=192.168.0.1
    
    # Only send two pings, sending output to /dev/null
    ping -I ${WLANINTERFACE} -c2 ${SERVER} > /dev/null
    
    # If the return code from ping ($?) is not 0 (meaning there was an error)
    if [ $? != 0 ]
    then
    # Restart the wireless interface
    ifdown --force ${WLANINTERFACE}
    ifup ${WLANINTERFACE}
    fi
    
  2. Сделайте файл исполняемым, выполнив команду
    chmod +x /root/wifi_autoconnect.sh
    
  3. Запланируйте выполнение скрипта каждую минуту. Для этого:
    1. Установите cron:
      apt-get install cron
      
    2. Добавьте в конец файла /etc/crontab строку
      *  *	* * *	root	/root/wifi_autoconnect.sh
      # обязательно добавьте пустую строку в конец файла
      


Ограничения

  1. Wi-Fi в Wiren Board в режиме точки доступа работает относительно медленно. Скорости вполне хватит для работы с веб-интерфейсом, но не стоит использовать Wiren Board в качестве замены роутера.
  2. В очень редких случаях возможна несовместимость адаптера Wi-Fi в Wiren Board с некоторыми другими устройствами Wi-Fi. Это общая проблема реализаций Wi-Fi на чипсетах разных производителей. Если вы столкнулись с необъяснимыми проблемами при работе, рекомендуем поменять настройки шифрования, ширины канала и т.п.