ndef: Implement static handover
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 20 Jun 2013 12:46:17 +0000 (14:46 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 20 Jun 2013 12:46:17 +0000 (14:46 +0200)
static handover is going through a different D-Bus path as it would not
make sense to handle both static and dynamic handover from the same code
path.
Static handover means an application explicitely requires to send a
handover select without having previously received a handover request.
This could typically be used for handling WiFi handover through
configuration token from the registrar perspective. The registrar
(a.k.a. the Access Point) would send a configuration token via Handover
and expects the Enrolle (a.k.a. the WiFi STA) to initiate the WiFi
association.

src/device.c
src/ndef.c
test/push-device

index 27fbf4f..2c5b047 100644 (file)
@@ -234,6 +234,8 @@ static char *sn_from_message(DBusMessage *msg)
                                return NEAR_DEVICE_SN_SNEP;
                        else if (g_strcmp0(value, "Handover") == 0)
                                return NEAR_DEVICE_SN_HANDOVER;
+                       else if (g_strcmp0(value, "StaticHandover") == 0)
+                               return NEAR_DEVICE_SN_HANDOVER;
                        else if (g_strcmp0(value, "MIME") == 0)
                                return NEAR_DEVICE_SN_SNEP;
                        else
index cac70f9..6790f8c 100644 (file)
@@ -3339,6 +3339,10 @@ struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg)
                                ndef = build_ho_record(
                                        RECORD_TYPE_WKT_HANDOVER_REQUEST, msg);
                                break;
+                       } else if (g_strcmp0(value, "StaticHandover") == 0) {
+                               ndef = build_ho_record(
+                                       RECORD_TYPE_WKT_HANDOVER_SELECT, msg);
+                               break;
                        } else if (g_strcmp0(value, "MIME") == 0) {
                                ndef = build_mime_record(msg);
                                break;
index 0f48d8f..b0b0c55 100755 (executable)
@@ -9,11 +9,13 @@ def help_text():
        print "         If type is URI, parameters are <uri>"
        print "         If type is SmartPoster, parameters are <uri>"
        print "         If type is Handover, parameters are <carrier>"
+       print "         If type is StaticHandover, parameters are <carrier>"
        print "         If type is MIME, parameters are <mime_type> (only wifi_wsc)"
        print "e.g. < %s /org/neard/nfc0/device0 Text UTF-8 en-US hello,Type2! >" % (sys.argv[0])
        print "e.g. < %s /org/neard/nfc0/device0 URI http://www.nfc-forum.com >" % (sys.argv[0])
        print "e.g. < %s /org/neard/nfc0/device0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0])
        print "e.g. < %s /org/neard/nfc0/device0 Handover bluetooth,wifi >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/device0 StaticHandover bluetooth,wifi >" % (sys.argv[0])
        print "e.g. < %s /org/neard/nfc0/device0 MIME wifi_wsc>" % (sys.argv[0])
        sys.exit(1)
 
@@ -44,6 +46,9 @@ elif len(sys.argv) == 4:
        elif sys.argv[2] in ["Handover"]:
                device.Push(({ "Type" : "Handover",
                                "Carrier" : sys.argv[3] }))
+       elif sys.argv[2] in ["StaticHandover"]:
+               device.Push(({ "Type" : "StaticHandover",
+                               "Carrier" : sys.argv[3] }))
        elif sys.argv[2] in ["MIME"]:
                if sys.argv[3] in ["wifi_wsc"]:
                        device.Push(({ "Type" : "MIME",