blob: 15d913ef1fae6b82426781969f48f103cd263644 [file] [log] [blame]
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001#!/bin/sh
2
3CLI=wpa_cli
4
5pbc()
6{
7 echo "Starting PBC mode"
8 echo "Push button on the station within two minutes"
9 if ! $CLI wps_pbc | grep -q OK; then
10 echo "Failed to enable PBC mode"
11 fi
12}
13
14enter_pin()
15{
16 echo "Enter a PIN from a station to be enrolled to the network."
Hai Shalom74f70d42019-02-11 14:42:39 -080017 printf "Enrollee PIN: "
Dmitry Shmidtfb45fd52015-01-05 13:08:17 -080018 read pin
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080019 cpin=`$CLI wps_check_pin "$pin" | tail -1`
20 if [ "$cpin" = "FAIL-CHECKSUM" ]; then
21 echo "Checksum digit is not valid"
Hai Shalom74f70d42019-02-11 14:42:39 -080022 printf "Do you want to use this PIN (y/n)? "
Dmitry Shmidtfb45fd52015-01-05 13:08:17 -080023 read resp
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080024 case "$resp" in
25 y*)
26 cpin=`echo "$pin" | sed "s/[^1234567890]//g"`
27 ;;
28 *)
29 return 1
30 ;;
31 esac
32 fi
33 if [ "$cpin" = "FAIL" ]; then
34 echo "Invalid PIN: $pin"
35 return 1
36 fi
37 echo "Enabling Enrollee PIN: $cpin"
38 $CLI wps_pin any "$cpin"
39}
40
41show_config()
42{
43 $CLI status wps
44}
45
46main_menu()
47{
48 echo "WPS AP"
49 echo "------"
50 echo "1: Push button (activate PBC)"
51 echo "2: Enter Enrollee PIN"
52 echo "3: Show current configuration"
53 echo "0: Exit wps-ap-cli"
54
Hai Shalom74f70d42019-02-11 14:42:39 -080055 printf "Command: "
Dmitry Shmidtfb45fd52015-01-05 13:08:17 -080056 read cmd
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080057
58 case "$cmd" in
59 1)
60 pbc
61 ;;
62 2)
63 enter_pin
64 ;;
65 3)
66 show_config
67 ;;
68 0)
69 exit 0
70 ;;
71 *)
72 echo "Unknown command: $cmd"
73 ;;
74 esac
75
76 echo
77 main_menu
78}
79
80
81main_menu