README: 2006 Feb 05 - 2006 Dec 17
Sun Dec 17 19:23:00 2006
Inspired by http://www.librarything.com/ I dug out the Flic Cordless
bluetooth scanner again. I have notes from a coworker who borrowed it
and figured out how to talk to it; there's a registration-required SDK
that I will probably grab if I have any trouble (I thought I had a
copy already, but I haven't found it.)
- sudo rfcomm connect hci0 "00:A0:96:04:D2:B2" 1 &
- screen /dev/rfcomm0
- it sends:
- 79013400800202FD
- sent 02fd^f
- 09736154967502FE
- send 02fe^f
- got 3-tone downwards sequence (for "done"...)
- W<RET>
- Microvision® Flic® Barcode Scanner, ID: 4117271B, FW: 2.8.0, BT: 1.20M
- W0000000000000000590000004117271BFFFF020800
- T1<RET> just beeps
- T9<RET> low-beeps
Mon Jul 10 01:08:00 2006
sudo /etc/init.d/bluez-utils restart
- needed on kurohyou to wake it up!
sudo ifconfig bnep0 10.0.0.5
HAH:
- # LD_LIBRARY_PATH=/mnt/mmc/svnlib /mnt/mmc/py242
- Could not find platform independent libraries <prefix>
- Could not find platform dependent libraries <exec_prefix>
- Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
- 'import site' failed; use -v for traceback
- Python 2.4.2 (#1, Jul 10 2006, 01:16:26)
- [GCC 3.4.5] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> globals()
- {'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None}
What next:
- build rsync
- build a root-fs with those added
- figure out how to sync it
- make pand-reconnect reliable (or is it enough to just reboot, now?)
Mon Feb 20 16:14:00 2006
http://www.triptico.com/software/bluetooth.html
says
- /usr/bin/pand -s -M --role=NAP #server
- /usr/bin/pand --role PANU --search --persist --encrypt # laptop
oh, sigh.
- kokoneko$ sudo pand --master --nodetach --role NAP --listen
- pand[9346]: Bluetooth PAN daemon version 2.20
- pand[9347]: New connection from 00:80:37:27:1D:2E bnep0
- sudo ifconfig bnep0 up
- kokoneko$ sudo tcpdump -xv -i bnep0
- tcpdump: WARNING: bnep0: no IPv4 address assigned
- tcpdump: listening on bnep0, link-type EN10MB (Ethernet), capture size 96 bytes
- 16:20:03.306258 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto: UDP (17), length: 576) 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:80:37:27:1d:2e (oui Unknown), length: 548, xid:0x42b26e40, flags: [none]
- Client Ethernet Address: 00:80:37:27:1d:2e (oui Unknown) [|bootp]
- 0x0000: 4500 0240 0000 0000 4011 78ae 0000 0000
- 0x0010: ffff ffff 0044 0043 022c 710c 0101 0600
- 0x0020: 42b2 6e40 0000 0000 0000 0000 0000 0000
- 0x0030: 0000 0000 0000 0000 0080 3727 1d2e 0000
- 0x0040: 0000 0000 0000 0000 0000 0000 0000 0000
- 0x0050: 0000
- # sudo dhcrelay -i bnep0 -d 4.36.43.79 &
- # sudo tcpdump -lenx -s 1500 -i bnep0 port bootps or port bootpc | dhcpdump
- # sudo ifconfig bnep0 10.0.0.6
- # nevermind, use udhcpd with
- # sudo ifconfig bnep0 10.0.0.5
- # and:
- start 10.0.0.6
- end 10.0.0.9
- interface bnep0
- # consider a notify_file to let me know it did something --eichin
- # ifconfig
- bnep0 Link encap:Ethernet HWaddr 00:80:37:27:1D:2E
- inet addr:10.0.0.6 Bcast:10.255.255.255 Mask:255.0.0.0
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:245 errors:0 dropped:0 overruns:0 frame:0
- TX packets:1123 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:26261 (25.6 KiB) TX bytes:587170 (573.4 KiB)
- lo Link encap:Local Loopback
- inet addr:127.0.0.1 Mask:255.0.0.0
- UP LOOPBACK RUNNING MTU:16436 Metric:1
- RX packets:13 errors:0 dropped:0 overruns:0 frame:0
- TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:4329 (4.2 KiB) TX bytes:4329 (4.2 KiB)
- usb0 Link encap:Ethernet HWaddr 02:00:0C:42:B1:E1
- UP BROADCAST MULTICAST MTU:1500 Metric:1
- RX packets:0 errors:0 dropped:0 overruns:0 frame:0
- TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Also, a recommendation to either run brctl or udhcpd in
/etc/bluetooth/pan/dev-up
http://bluez.sourceforge.net/contrib/HOWTO-PAN
It passes the interface name as the first parameter, and the device
address of the remote device as the second. This script may look as follows:
- #!/bin/sh
- # 'dev-up' script to do dynamic bridge management on GN
- brctl addif pan0 $1 # $1 is the new if name, passed by 'pand'
- ifconfig $1 0.0.0.0
http://www.triptico.com/software/bluetooth.html
- # hack to force dhcpd to serve IPs on bnep0
- /etc/init.d/dhcp3-server restart 2>&1 > /dev/null
On the stick:
- use /etc/init.d/S55mwe (anything above 50) for my app startup
time scp -r ~/tmp/gumstix/gumstix-buildroot/build_arm_nofpu/root/opt/ root@10.0.0.6:/mnt/mmc/opt/
- real 33m0.506s
- user 0m6.612s
- sys 0m3.600s
(build rsync too?)
hmm, segv's on startup.
## later:
- close ssh session
- kill pand
- /etc/init.d/udhcpd stop
Fri Feb 17 23:48:00 2006
for interesting stuff about the protocol..
gumstix/bluetooth/python
Sun Feb 5 15:12:00 2006
strace shows socket stuff with AF_BLUETOOTH... and I note that
python has that in the socket module...
- connect(4, {sa_family=AF_BLUETOOTH, sa_data="\217&\317\237\21\0\5\21\0\0\0\0\0\0"}, 10) = -1 EINVAL (Invalid argument)
- 8026 bind(13, {sa_family=AF_BLUETOOTH, sa_data="\0\0\230\364e\267\220\356\f\10\1\0\0\0"}, 4) = 0
- bind(4, {sa_family=AF_BLUETOOTH, sa_data="\373\37\0\226\f\0\5\21\0\0\0\0\0\0"}, 10) = -1 EINVAL (Invalid argument)
- sudo rfcomm connect 0 00:80:37:27:1D:2E
- screen /dev/rfcomm
- 1240 root 280 R /usr/sbin/rfcomm -r -f /etc/bluetooth/rfcomm.conf lis
- 1335 root 392 S -sh
- 1366 root 344 S /sbin/getty -L ttyS0 115200 vt100
- 1453 root 340 R ps uaxw
- # ls /usr/sbin
- boa dropbearmulti hcid opd rfcomm
- chroot hciattach mDNSResponder pxaregs sdpd
- dropbear hciconfig obexserver rdate
- # hciconfig -a
- hci0: Type: UART
- BD Address: 00:80:37:27:1D:2E ACL MTU: 339:7 SCO MTU: 120:6
- UP RUNNING PSCAN ISCAN
- RX bytes:20485 acl:593 sco:0 events:1175 errors:0
- TX bytes:17271 acl:704 sco:0 commands:227 errors:0
- Features: 0xff 0xff 0x1d 0x80 0x18 0x18 0x00 0x80
- Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
- Link policy: RSWITCH HOLD SNIFF PARK
- Link mode: SLAVE ACCEPT
- Name: 'Gumstix (0)'
- Class: 0x820116
- Service Classes: Networking
- Device Class: Computer, Palm
- HCI Ver: 1.1 (0x1) HCI Rev: 0x750 LMP Ver: 1.2 (0x2) LMP Subver: 0x750
- Manufacturer: Infineon Technologies AG (9)
on stick:
- # rfcomm connect hci0 "00:11:9F:CF:26:8F" 9
- Can't create RFCOMM TTY: Address already in use
- [because I'm coming in over bt. But I bet that could be used directly
- with /dev/rfcomm and a precooked payload...]
- >>> s='ggFwAQANAG0AbwB0AGQAAMMAAAFYSQFbTGludXgga29rb25la28gMi42LjE0LjEtb3FvbXdlICMy\nIFRodSBOb3YgMTAgMjI6MDU6NTkgRVNU
- >>> len(s)
- 499
- >>> open("s.b64","w").write(s)
- >>> s.decode("base64")
- '\x82\x01p\x01\x00\r\x00m\x00o\x00t\x00d\x00\x00\xc3\x00\x00\x01XI\x01[Linux kokoneko 2.6.14.1-oqomwe #2 Thu Nov 10 22:05:59 EST 2005 i686 GNU/Linux\n\nThe programs included with the Ubuntu system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in /usr/share/doc//copyright.\n\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\napplicable law.\n'
- # obex_header.h/obex_object.c:
- #define OBEX_HI_MASK 0xc0
- #define OBEX_UNICODE 0x00
- #define OBEX_BYTE_STREAM 0x40
- #define OBEX_BYTE 0x80
- #define OBEX_INT 0xc0
- # but they don't really work with what we've got...
- # gnome-obex-send does use libopenobex-1.0.so.0...
- # 0x82
- #define OBEX_CMD_PUT 0x02 (more likely?)
- #define OBEX_FL_STREAM_START 0x02 / Start of streaming body /
- #define OBEX_FINAL 0x80
- # \x01\x70 \x01\x00\x0d
- #define OBEX_HDR_NAME 0x01 / Name of the object /
- # \x00 m \x00 o \x00 t \x00 d \x00 \x00 <- motd is the basename...
- # \xc3 \x00\x00\x01\x58 (+ 256 88)344
- #define OBEX_HDR_LENGTH 0xc3 / Total lenght of object /
- # \x49 \x01\x5b (+ 256 91)347
- #define OBEX_HDR_BODY_END 0x49 / Last data part of the object /
- #
- # ~/tmp/obex/libopenobex1.0-1.0.0-rel/src/obex_const.h says better stuff
- # 2-byte length, (+ 256 91)347 (+ 347 8 backslashes)355 sort of works
- # Linux kokoneko 2.6.14.1-oqomwe #2 Thu Nov 10 22:05:59 EST 2005 i686 GNU/Linux\n\nThe programs included with the Ubuntu system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in /usr/share/doc//copyright.\n\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\napplicable law.\n'
- # ltrace (gnobex.lt) helps some:
- # points to ~/tmp/deb/libbtctl-0.5.0/src/obex-client-source.c:
- # object = OBEX_ObjectNew (bc->handle, OBEX_CMD_PUT);
- # || OBEX_ObjectNew does obex_object_setcmd(... (cmd | OBEX_FINAL));
- # bfname = basename(fname)
- # uname_size = (strlen (bfname)+1)2;
- # OBEX_CharToUnicode (uname, bfname, uname_size);
- # hd.bs = uname;
- # OBEX_ObjectAddHeader (bc->handle, object,
- # OBEX_HDR_NAME, hd, uname_size, 0);
- #
- # hd.bq4 = len; # len == bytes to send
- # OBEX_ObjectAddHeader (bc->handle, object,
- # OBEX_HDR_LENGTH, hd, sizeof (uint32_t), 0);
- #
- # hd.bs = NULL;
- # OBEX_ObjectAddHeader (bc->handle, object,
- # OBEX_HDR_BODY, hd, 0, OBEX_FL_STREAM_START);
- #define OBEX_FL_STREAM_START 0x02 / Start of streaming body /
- # stream-start just sets it up and doesn't do anything
- #
- # OBEX_Request (bc->handle, object);
- # then, fillstream does
- # actual == bytes to send now, clamped by OBEX_STREAM_CHUNK (locally 4k)
- #
- # OBEX_ObjectAddHeader (bc->handle, obj, OBEX_HDR_BODY,
- # hd, actual, OBEX_FL_STREAM_DATA);
- #define OBEX_HDR_BODY 0x48 / Data part of the object /
- #define OBEX_FL_STREAM_DATA 0x04 / Body-stream data /
- # or
- # OBEX_ObjectAddHeader (bc->handle, obj, OBEX_HDR_BODY,
- # hd, 0, OBEX_FL_STREAM_DATAEND);
- #define OBEX_FL_STREAM_DATAEND 0x08 / Body stream last data /
- # so, new(PUT)
- # add header HDR_NAME(basename(fname) in unicode)
- # add header HDR_LEN(4-byte len(data to send)
- # add header HDR_BODY, OBEX_FL_STREAM_START,
- >>> open("s.txt","w").write(s.decode("base64"))
- >>>
so, now, try (from serial console):
- # rfcomm connect hci0 "00:11:9F:CF:26:8F" 9 &
- # cat s.txt > /dev/rfcomm0
and see what shows up on the phone...
eek:
- 00:A0:96:04:D2:B2 Flic Cordless
turned up...
Indeed, killing off everything rfcomm, including [krfcommd], and then
doing the above, worked - the content made it to the phone!
- # kill 216
- # rfcomm connect hci0 "00:11:9F:CF:26:8F" 9 &
- # Connected /dev/rfcomm0 to 00:11:9F:CF:26:8F on channel 9
- Press CTRL-C for hangup
- # cat s.txt > /dev/rfcomm0
- # Disconnected
- [1] + Done rfcomm connect hci0 "00:11:9F:CF:26:8F" 9
- kokoneko$ sudo pand --master --nodetach --search --role NAP --listen
... and there's a bnep0 on that end...
- kokoneko$ sudo pand --master --nodetach --role NAP --listen --ethernet atml0
connection exists problem:
- [pid 27340] recv(7, "\1\1\2\21\26\21\25", 1691, 0) = 7
- [pid 27340] send(7, "\1\2\0\0", 4, 0) = 4
- [pid 27340] ioctl(3, 0x400442c8, 0xbffff300) = -1 EEXIST (File exists)
- ah, that's "bnepconnadd = BNEPCONNADD;"
- as used in bnep_connadd
- to add role+device...
suggestion:
- --------------------------------------
- hciconfig hci0 up
- hcid
- sdpd
- /opt/kde/bin/kbluetoothd
- pand --listen --role NAP
- dund --listen
- dund --listen --msdun call dun
- echo 1 > /proc/sys/net/ipv4/ip_forward
- iptables -t nat -A POSTROUTING -j MASQUERADE -o eth0
- And set a peer called dund in /etc/ppp/peers.
hmm, --role GN doesn't help
- socket(PF_BLUETOOTH, SOCK_RAW, 4) = 3
- ioctl(3, 0x800442d2, 0xbffffa00) = 0
- ioctl(3, 0x400442c9, 0xbffff9ec) = -1 ENOENT (No such file or directory)
- bnep_conndel_req doesn't have a role, just an addr...
Sun Feb 5 01:36:00 2006
bluetooth stuff -- mostly development for the gumstix unit
gpsparser.py: starts with ../symbian/bluecamerathreaded.py
- and strips down to just the parser