|
Revision 18, 1.6 kB
(checked in by njw, 15 months ago)
|
|
added author info
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | def usage |
|---|
| 13 | puts "usage: m2a.rb <destination>" |
|---|
| 14 | exit(-1) |
|---|
| 15 | end |
|---|
| 16 | |
|---|
| 17 | usage if ARGV.length != 1 |
|---|
| 18 | $destination = ARGV[0] |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | BD_ADDR = "trebroN" |
|---|
| 22 | OBEX_DIR1 = "Bilder" |
|---|
| 23 | OBEX_DIR2 = "camera_semc" |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | def doCrudeObexAppComm |
|---|
| 27 | begin |
|---|
| 28 | cam = getObexIOObject |
|---|
| 29 | cam.puts "ls" |
|---|
| 30 | cam.close_write |
|---|
| 31 | lines = cam.readlines |
|---|
| 32 | cam = getObexIOObject |
|---|
| 33 | lines.each do |line| |
|---|
| 34 | line =~ /Bild\(\d+\).jpg/ |
|---|
| 35 | |
|---|
| 36 | if !$&.nil? |
|---|
| 37 | cam.puts "get" |
|---|
| 38 | cam.puts $& |
|---|
| 39 | cam.puts $destination+'/'+$& |
|---|
| 40 | puts "copy picture "+$&+" to to "+$destination |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | end |
|---|
| 46 | end |
|---|
| 47 | rescue Exception => ex |
|---|
| 48 | puts(ex.to_s) |
|---|
| 49 | ensure |
|---|
| 50 | |
|---|
| 51 | cam.puts "disconnect" |
|---|
| 52 | cam.close |
|---|
| 53 | end |
|---|
| 54 | end |
|---|
| 55 | |
|---|
| 56 | def getObexIOObject |
|---|
| 57 | cam = IO.popen("obexapp -a #{BD_ADDR} -C OPUSH", "w+") |
|---|
| 58 | cam.puts "cd #{OBEX_DIR1}" |
|---|
| 59 | cam.puts "cd #{OBEX_DIR2}" |
|---|
| 60 | return cam |
|---|
| 61 | end |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | doCrudeObexAppComm |
|---|