1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/usr/bin/python
import sys
import dbus
def help_text():
print "Usage: %s <device-path> <record-type> <...>" % (sys.argv[0])
print " If type is Text, parameters are <encoding> <language> <representation>"
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])
print "e.g. < %s /org/neard/nfc0/device0 MIME raw application/xml '<your><xml tags></your>' >" % (sys.argv[0])
print "e.g. < %s /org/neard/nfc0/device0 WiFiAssociation >" % (sys.argv[0])
sys.exit(1)
if len(sys.argv) < 2:
help_text()
bus = dbus.SystemBus()
device = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
"org.neard.Device")
if len(sys.argv) == 6:
if sys.argv[2] in ["Text"]:
device.Push(({ "Type" : "Text",
"Encoding" : sys.argv[3],
"Language" : sys.argv[4],
"Representation" : sys.argv[5] }))
else:
help_text()
elif len(sys.argv) == 4:
if sys.argv[2] in ["URI"]:
device.Push(({ "Type" : "URI",
"URI" : sys.argv[3] }))
elif sys.argv[2] in ["SmartPoster"]:
device.Push(({ "Type" : "SmartPoster",
"URI" : sys.argv[3] }))
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",
"MIME" : "application/vnd.wfa.wsc"}))
else:
help_text()
else:
help_text()
elif len(sys.argv) == 3:
if sys.argv[2] in ["WiFiAssociation"]:
device.Push(({ "Type" : "MIME",
"MIME" : "x/nfctl" }))
else:
help_text()
else:
help_text()
|