]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpadebug: Add WSC request through Android beam
authorJouni Malinen <j@w1.fi>
Sat, 4 May 2013 15:50:48 +0000 (18:50 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 4 May 2013 15:50:48 +0000 (18:50 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

wpadebug/res/layout/main.xml
wpadebug/src/w1/fi/wpadebug/MainActivity.java

index 890d60a79881d4de244eec4ffafd1cffb646ffb4..3e9059f6b9bf79a1bf9cc1d6c46a423b8e31b81b 100644 (file)
                    android:onClick="runId"
                    />
        </LinearLayout>
+       <TextView
+           android:layout_width="wrap_content"
+           android:layout_height="wrap_content"
+           android:text="NFC commands"
+           />
+       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                     android:layout_width="match_parent"
+                     android:layout_height="wrap_content"
+                     android:orientation="horizontal"
+                     >
+               <Button
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="WPS handover request"
+                   android:onClick="nfcWpsHandoverRequest"
+                   />
+       </LinearLayout>
 </LinearLayout>
index 74e441e96ceab12bc44ed4c4ef68951894b710a3..1407932c8faddf291df018424a419a0f03ca6c31 100644 (file)
@@ -20,10 +20,14 @@ import android.content.Intent;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.widget.EditText;
+import android.widget.Toast;
 import android.util.Log;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiConfiguration;
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
 
 public class MainActivity extends Activity
 {
@@ -180,4 +184,25 @@ public class MainActivity extends Activity
        intent.putExtra(EXTRA_MESSAGE, sb.toString());
        startActivity(intent);
     }
+
+    public void nfcWpsHandoverRequest(View view)
+    {
+       NfcAdapter nfc;
+       nfc = NfcAdapter.getDefaultAdapter(this);
+       if (nfc == null) {
+           Toast.makeText(this, "NFC is not available",
+                          Toast.LENGTH_LONG).show();
+           return;
+       }
+
+       NdefMessage msg;
+       msg = new NdefMessage(new NdefRecord[] {
+               NdefRecord.createMime("application/vnd.wfa.wsc",
+                                     new byte[0])
+           });
+
+       nfc.setNdefPushMessage(msg, this);
+       Toast.makeText(this, "NFC push message (WSC) configured",
+                      Toast.LENGTH_LONG).show();
+    }
 }