<!--
Author: Xianjun jiao
SPDX-FileCopyrightText: 2019 UGent
SPDX-License-Identifier: AGPL-3.0-or-later
-->

**NOTE** the terminal session mentioned in the following text can also be setup via USB-UART instead of Ethernet.

**NOTE** adrv9361z7035 has ultra low TX power in 5GHz. Move **CLOSER** when you use that board in 5GHz!!!

- Power on two SDR boards. Call one board "AP board" and the other "client board". On each board, the TX and RX antenna should vertical/orthogonal to each other as much as possible to gain a good TX/RX isolation.
- Connect a computer to the AP board via Ethernet cable. The computer should have static IP 192.168.10.1. Open a terminal on the computer, and then in the terminal:
  ```
  ssh root@192.168.10.122
  (password: openwifi)
  cd openwifi
  ./fosdem.sh
  (It will create a WiFi AP by hostapd program with config file: hostapd-openwifi.conf)
  (Wait for the script completed)
  cat /proc/interrupts
  (Execute the "cat ..." command for several times)
  (You should see the number of "sdr,tx_itrpt1" grows, because it sends the "openwifi" beacon periodically)
  ```
- Connect another computer to the client board via Ethernet cable. The computer should have static IP 192.168.10.1. Open a terminal on the computer, and then in the terminal:
  ```
  ssh root@192.168.10.122
  (password: openwifi)
  service network-manager stop
  cd openwifi
  ./wgd.sh
  (Wait for the script completed)
  ifconfig sdr0 up
  iwlist sdr0 scan
  (The "openwifi" AP should be listed in the scanning results)
  wpa_supplicant -i sdr0 -c wpa-openwifi.conf
  ("iwconfig sdr0 essid openwifi" could also work. Less info compared to wpa_supplicant)
  ```
  If wpa-openwifi.conf is not on board, please create it with [this content](https://github.com/open-sdr/openwifi/blob/master/user_space/wpa-openwifi.conf).
- Now the client is trying to associate with the AP. You should see like:
  ```
  root@analog:~/openwifi# wpa_supplicant -i sdr0 -c wpa-openwifi.conf 
  Successfully initialized wpa_supplicant
  sdr0: CTRL-EVENT-SCAN-STARTED 
  sdr0: SME: Trying to authenticate with 66:55:44:33:22:8c (SSID='openwifi' freq=5220 MHz)
  sdr0: Trying to associate with 66:55:44:33:22:8c (SSID='openwifi' freq=5220 MHz)
  sdr0: Associated with 66:55:44:33:22:8c
  sdr0: CTRL-EVENT-CONNECTED - Connection to 66:55:44:33:22:8c completed [id=0 id_str=]
  ```
  The AP board terminal should print like:
  ```
  ...
  sdr0: STA 66:55:44:33:22:4c IEEE 802.11: authenticated
  sdr0: STA 66:55:44:33:22:4c IEEE 802.11: associated (aid 1)
  sdr0: AP-STA-CONNECTED 66:55:44:33:22:4c
  sdr0: STA 66:55:44:33:22:4c RADIUS: starting accounting session 613E16DE-00000000
  ```
  If not, please adjust antenna/distance and re-run the commands on the client side.

- After association is done, in another terminal of client (**DO NOT** terminate wpa_supplicant in the original client terminal!):
  ```
  dhclient sdr0
  (Wait for it completed)
  ifconfig sdr0
  (Now you should see the IP address like 192.168.13.x allocated by AP)
  ping 192.168.13.1
  (Ping the AP)
  ```
  Now the communication link should be already setup between the AP and the client.
