Samsung ARTIK Wi-Fi Client Configuration

Summary

Setup Samsung ARTIK Wi-Fi Client, and configured auto connect to Wi-Fi after reboot, with successful result.
ARTIK 530 attached the Antenna,
ARTIK 530 attached the Antenna

Wi-Fi Client Configuration

Follow this Link to configure the Wi-Fi Client, the ifcfg-eth0 configuration is setup already as below,

[root@artik ~]# cat /etc/redhat-release 
Fedora release 24 (Twenty Four)
[root@artik ~]# 
[root@artik ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
PERSISTENT_DHCLIENT="yes"
[root@artik ~]# 

Setting as below,

[root@artik connman]# cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

update_config=1
network={
    ssid="SA-WPGHOLDINGS"
    psk=XXXXce5c1e200e6b3cbcdc2328c04b355fd9751d55e22aa0e84ad015b81aXXXX
}
[root@artik connman]# 

wpa_supplicant already configured start automatically,

[root@artik connman]# systemctl status wpa_supplicant
● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/usr/lib/systemd/system/wpa_supplicant.service; disabled; vendor preset
   Active: active (running) since Tue 2017-06-13 00:47:55 EDT; 2h 0min ago
 Main PID: 2045 (wpa_supplicant)
   CGroup: /system.slice/wpa_supplicant.service
           └─2045 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -

Jun 13 00:47:55 artik systemd[1]: Started WPA supplicant.
Jun 13 00:47:55 artik wpa_supplicant[2045]: Successfully initialized wpa_supplicant
Jun 13 00:47:55 artik wpa_supplicant[2045]: WPS: Converting push_button to virtual_push_bu
Jun 13 00:47:55 artik wpa_supplicant[2045]: WPS: Converting push_button to virtual_push_bu
Jun 13 00:47:55 artik wpa_supplicant[2045]: WPS: Converting push_button to virtual_push_bu
Jun 13 00:47:58 artik wpa_supplicant[2045]: wlan0: Trying to associate with c0:56:27:a8:fd
Jun 13 00:47:58 artik wpa_supplicant[2045]: wlan0: Associated with c0:56:27:a8:fd:d6
Jun 13 00:47:58 artik wpa_supplicant[2045]: wlan0: WPA: Key negotiation completed with c0:
Jun 13 00:47:58 artik wpa_supplicant[2045]: wlan0: CTRL-EVENT-CONNECTED - Connection to c0
Jun 13 00:47:58 artik wpa_supplicant[2045]: p2p0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE
lines 1-17/17 (END)

Reboot WIFI cannot connect automatically issue

You can configure your system to automatically reconnect Wi-Fi after each reboot. However the system init script provided on the website cannot work properly, the Wi-Fi cannot connect after reboot, refer to this Link to solve this problem.

The root cause is when executing the command dhclient wlan0, the wlan0 interface is not up, caused command execution fail, so need to wait until wlan0 is up, below updated init script can work properly.

The updated init script is as below,

#! /bin/bash
# chkconfig: - 99 10

start()
{
    i=1
    while ! ifconfig wlan0 2>>/tmp/wlan_err.log >>/tmp/wlan.log
    do
        echo "-------- run $i --------" >>/tmp/wlan.log
        ifconfig wlan0 2>>/tmp/wlan_err.log >>/tmp/wlan.log
        sleep 1
        i=$((i + 1))
    done

#    echo "-------- starting wpa_supplicant --------" >>/tmp/wlan.log
#    /usr/sbin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf >>/tmp/wlan.log &

    i=1
    while ! wpa_cli status wlan0 | grep -iq "wpa_state=completed"
    do
        echo "-------- run $i --------" >>/tmp/wlan.log
        sleep 1
        i=$((i + 1))
    done

    echo "-------- starting dhcpclient --------" >>/tmp/wlan.log
    /usr/sbin/dhclient wlan0 >>/tmp/wlan.log
}

stop()
{
kill dhclient
}

restart()
{
stop
start
}


case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  *)
    echo "Usage:$0 {start|stop|restart}"
esac

exit 0

Below shell script experiment the command return (0 or 1).

#! /bin/bash
if ! ifconfig wlan0 >> null
then
echo "does not exist wlan0"
fi
if ! ifconfig wlan1 >> null
then
echo "doesn't exist wlan1"
fi

Below is the startup log when executing the init script, you can see until wlan0 is up and can grep the characters "wpa_state=completed", then execute command dhclient wlan0.

[root@artik ~]# cat /tmp/wlan_err.log 
wlan0: error fetching interface information: Device not found
wlan0: error fetching interface information: Device not found
wlan0: error fetching interface information: Device not found
wlan0: error fetching interface information: Device not found
wlan0: error fetching interface information: Device not found
wlan0: error fetching interface information: Device not found
[root@artik ~]# cat /tmp/wlan.log 
-------- run 1 --------
-------- run 2 --------
-------- run 3 --------
wlan0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 70:2c:1f:24:92:40  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

-------- run 1 --------
-------- run 2 --------
-------- run 3 --------
-------- run 4 --------
-------- starting dhcpclient --------

The Ethernet and Wi-Fi connect result is as below,

[root@artik ~]# ifconfig
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 10.65.103.38  netmask 255.255.255.0  broadcast 10.65.103.255
        inet6 fe80::742a:faff:fe0e:5a07  prefixlen 64  scopeid 0x20<link>
        ether 76:2a:fa:0e:5a:07  txqueuelen 1000  (Ethernet)
        RX packets 85290  bytes 7447811 (7.1 MiB)
        RX errors 0  dropped 412  overruns 0  frame 0
        TX packets 124  bytes 13321 (13.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 64  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 179  bytes 14535 (14.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 179  bytes 14535 (14.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p2p0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC>  mtu 1500
        ether 72:2c:1f:24:92:40  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.65.109.168  netmask 255.255.255.0  broadcast 10.65.109.255
        inet6 fe80::722c:1fff:fe24:9240  prefixlen 64  scopeid 0x20<link>
        ether 70:2c:1f:24:92:40  txqueuelen 1000  (Ethernet)
        RX packets 101955  bytes 30356888 (28.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8891  bytes 619061 (604.5 KiB)
        TX errors 0  dropped 199 overruns 0  carrier 0  collisions 0

[root@artik connman]# cat /etc/resolv.conf 
; generated by /usr/sbin/dhclient-script
search wpgholdings.com
nameserver 10.65.11.81
nameserver 10.65.11.82
[root@artik connman]# 



[root@artik ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=53 time=495 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=53 time=5.27 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=53 time=11.8 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 5.277/170.722/495.066/229.361 ms
[root@artik ~]# 

Reference

Samsung ARTIK Configuring Ethernet
Where do the antennas go?
Ethernet and Wi-Fi Networks
ARTIK Wi-Fi Client Configuration
Wifi didn’t setup automatically


猜你喜欢

转载自blog.csdn.net/scruffybear/article/details/73177174