Samsung ARTIK 530 Wi-Fi Access Point (AP) and Wi-Fi Direct (P2P)

Summary

Setup Wi-Fi Access Point (AP) and Wi-Fi Direct (P2P), tested with successful result.

Setup Wi-Fi Access Point (AP)

Follow this Link.
Configure /etc/hostapd/hostapd.conf

[root@artik ~]# vi /etc/hostapd/hostapd.conf 

configuration file is as below,

#
# This will give you a minimal, insecure wireless network.
# 
# DO NOT BE SATISFIED WITH THAT!!!
#
# A complete, well commented example configuration file is
# available here:
#
#   /usr/share/doc/hostapd/hostapd.conf
#
# For more information, look here:
#
#   http://wireless.kernel.org/en/users/Documentation/hostapd
#

ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel

# Some usable default settings...
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

# Uncomment these for base WPA & WPA2 support with a pre-shared key
#wpa=3
wpa=2
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
wpa_pairwise=TKIP CCMP
#rsn_pairwise=CCMP
rsn_pairwise=CCMP

# DO NOT FORGET TO SET A WPA PASSPHRASE!!
#wpa_passphrase=YourPassPhrase
wpa_passphrase=12345678

# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211

# Customize these for your local configuration...
interface=wlan0
hw_mode=g
channel=6
ssid=ARTIK_AP_YOSUN

Configure dnsmasq

[root@artik ~]# vi /etc/dnsmasq.conf 

Add below configuration,

bind-interfaces
dhcp-range=192.168.1.2,192.168.1.100

Update the iptables rules.

[root@artik ~]# vi aproute.sh
[root@artik ~]# chmod 777 aproute.sh 

Iptable rules script is as below,

sysctl net.ipv4.ip_forward=1
iptables --flush
iptables -t nat --flush
iptables --delete-chain
iptables -t nat --delete-chain
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -j ACCEPT

Enabling Access Point

[root@artik ~]# systemctl stop connman
[root@artik ~]# ifconfig
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 178  bytes 14436 (14.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 178  bytes 14436 (14.0 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

[root@artik ~]# ifconfig eth0 up
[root@artik ~]# ifconfig eth0
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet6 fe80::f826:d7ff:fe78:e26c  prefixlen 64  scopeid 0x20<link>
        ether fa:26:d7:78:e2:6c  txqueuelen 1000  (Ethernet)
        RX packets 70127  bytes 6297182 (6.0 MiB)
        RX errors 0  dropped 418  overruns 0  frame 0
        TX packets 119  bytes 15002 (14.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 64  

[root@artik ~]# dhclient eth0
dhclient(2125) is already running - exiting. 

This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:
    http://bugzilla.redhat.com

exiting.

[root@artik ~]# service network restart
Restarting network (via systemctl):  [  OK  ]
[root@artik ~]# 
[root@artik ~]# 
[root@artik ~]# ifconfig
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 10.65.102.36  netmask 255.255.255.0  broadcast 10.65.102.255
        inet6 fe80::742a:faff:fe0e:5a07  prefixlen 64  scopeid 0x20<link>
        ether 76:2a:fa:0e:5a:07  txqueuelen 1000  (Ethernet)
        RX packets 42405  bytes 3752511 (3.5 MiB)
        RX errors 0  dropped 202  overruns 0  frame 0
        TX packets 114  bytes 14791 (14.4 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 198  bytes 16146 (15.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 198  bytes 16146 (15.7 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

[root@artik ~]# ifconfig eth0
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 10.65.102.36  netmask 255.255.255.0  broadcast 10.65.102.255
        inet6 fe80::742a:faff:fe0e:5a07  prefixlen 64  scopeid 0x20<link>
        ether 76:2a:fa:0e:5a:07  txqueuelen 1000  (Ethernet)
        RX packets 42610  bytes 3771180 (3.5 MiB)
        RX errors 0  dropped 202  overruns 0  frame 0
        TX packets 114  bytes 14791 (14.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 64  

[root@artik ~]# ifconfig wlan0 192.168.1.1 up
[root@artik ~]# ifconfig wlan0
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 70:2c:1f:24:92:40  txqueuelen 1000  (Ethernet)
        RX packets 28367  bytes 2650893 (2.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1146  bytes 141410 (138.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@artik ~]# dnsmasq -C /etc/dnsmasq.conf 
[root@artik ~]# ./aproute.sh 
net.ipv4.ip_forward = 1
[root@artik ~]# hostapd /etc/hostapd/hostapd.conf -B
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan0 with hwaddr 70:2c:1f:24:92:40 and ssid "ARTIK_AP_YOSUN"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
[root@artik ~]# 
[root@artik ~]# 
[root@artik ~]# ifconfig
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 10.65.102.36  netmask 255.255.255.0  broadcast 10.65.102.255
        inet6 fe80::742a:faff:fe0e:5a07  prefixlen 64  scopeid 0x20<link>
        ether 76:2a:fa:0e:5a:07  txqueuelen 1000  (Ethernet)
        RX packets 44384  bytes 3926291 (3.7 MiB)
        RX errors 0  dropped 202  overruns 0  frame 0
        TX packets 125  bytes 16075 (15.6 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 204  bytes 16644 (16.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 204  bytes 16644 (16.2 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 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::722c:1fff:fe24:9240  prefixlen 64  scopeid 0x20<link>
        ether 70:2c:1f:24:92:40  txqueuelen 1000  (Ethernet)
        RX packets 28367  bytes 2650893 (2.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1146  bytes 141410 (138.0 KiB)
        TX errors 32  dropped 0 overruns 0  carrier 0  collisions 0

Now the ARTIK 530 is configured ready for Wi-Fi Access Point, below test for access the internet through eth0,

[root@artik ~]# yum 
-bash: yum: command not found
[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=6.51 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=53 time=5.11 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=53 time=4.70 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=53 time=5.28 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=53 time=5.05 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=53 time=4.72 ms

--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 4.701/5.229/6.510/0.614 ms

Connect another device to ARTIK 530, here I am using my iPhone 6. As configured before the SSID and password is as below,
wpa_passphrase=12345678
ssid=ARTIK_AP_YOSUN
Connect successful,
Connected ARTIK 530 through iPhone

Allocated IP address is 192.168.1.70
Allocated IP

Test access internet though iPhone <–> ARTIK 530 <–> Internet
Access internet

Ping to connected iPhone 6 as below.

[root@artik ~]# ping 192.168.1.70
PING 192.168.1.70 (192.168.1.70) 56(84) bytes of data.
64 bytes from 192.168.1.70: icmp_seq=1 ttl=64 time=6.88 ms
64 bytes from 192.168.1.70: icmp_seq=2 ttl=64 time=29.2 ms

--- 192.168.1.70 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.882/18.064/29.246/11.182 ms
[root@artik ~]# 
        TX packets 8726  bytes 609711 (595.4 KiB)
        TX errors 0  dropped 199 overruns 0  carrier 0  collisions 0

Setup Wi-Fi Direct (P2P)

Follow this Link, tested with the P2P Wi-Fi connection to Android cell phone.
First back up the wpa_supplicant.conf

[root@artik ~]# ls /etc/wpa_supplicant/
wpa_supplicant.conf  wpa_supplicant.conf.bak
[root@artik ~]# 

Configure wpa_supplicant.conf as below,

ap_scan=2
ctrl_interface=/var/run/wpa_supplicant
update_config=0
device_name=Direct-p2p-mode
device_type=1-0050F204-1
config_methods=virtual_push_button physical_display keypad
p2p_go_intent=7
country=US
p2p_go_max_inactivity=600
p2p_go_ht40=1
disassoc_low_ack=1
p2p_listen_reg_class=81
p2p_listen_channel=36
driver_param=use_p2p_group_interface=1


#ctrl_interface=/var/run/wpa_supplicant
#ctrl_interface_group=wheel

#update_config=1
#network={
#   ssid="SA-WPGHOLDINGS"
#   psk=7607ce5c1e200e6b3cbcdc2328c04b355fd9751d55e22aa0e84ad015b81acf94
#}

Execute below command,

[root@artik ~]# systemctl stop connman
[root@artik ~]# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -Dnl80211&
[root@artik ~]# wpa_cli -iwlan0 p2p_group_add
[root@artik ~]# wpa_cli wps_pin any
Selected interface 'p2p-wlan0-1'
Device is trying to offload WPS Probe Response while not supporting this
Device is trying to offload P2P Probe Response while not supporting this
Device is trying to offload WPS Probe Response while not supporting this
Device is trying to offload P2P Probe Response while not supporting this
24190336
[root@artik ~]# wpa_cli -ip2p-wlan0-1 p2p_get_passphrase
zybQBJ8T
[root@artik ~]# ifconfig p2p-wlan0-1 192.168.1.1 up

[root@artik ~]# dnsmasq -x /var/run/dnsmasq.pid-p2p-wlan0-1 -i p2p-wlan0-0 -F192.168.1.11,192.168.1.99

Now the ARTIK main board is configured ready.

Ifconfig result,

[root@artik ~]# ifconfig
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 2500  bytes 202707 (197.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2500  bytes 202707 (197.9 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

p2p-wlan0-1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::702c:1fff:fe24:9240  prefixlen 64  scopeid 0x20<link>
        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 30  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.65.110.165  netmask 255.255.255.0  broadcast 10.65.110.255
        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

Connect from Samsung Android S4, the SSID is ‘DIRECT-bf’

DIRECT-bf

Input password generated before, ‘zybQBJ8T’
zybQBJ8T

Connected successful,
Connected

Allocated IP address 192.168.1.20,

192.168.1.20

Ping to Samsung Android S4 (IP Address 192.168.1.20),

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

--- 192.168.1.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 11.811/46.250/80.689/34.439 ms

Reference

Wi-Fi Access Point (AP)
Ethernet and Wi-Fi Networks
Updating your ARTIK Board
Wi-Fi Direct (P2P)


猜你喜欢

转载自blog.csdn.net/scruffybear/article/details/73203245
今日推荐