diff options
Diffstat (limited to 'test/push-device')
-rwxr-xr-x | test/push-device | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/push-device b/test/push-device new file mode 100755 index 0000000..614f4fa --- /dev/null +++ b/test/push-device @@ -0,0 +1,48 @@ +#!/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 "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 >" % (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] })) + else: + help_text() +else: + help_text() |