Tuesday, November 29, 2005

Music secrets revealed


" Using Sox, LAME, FLAC, and madplay - I put together this "dictionary" of shell commands that can be run to convert audio from one format to other, including dialup-modem-streamable lofi mono MP3 files, and including shorter clips of music."

-Derek Silvers is the founder and sole programmer of http://cdbaby.com

Well done!

See the article here:
www.oreillynet.com/pub/wlg/5894


Here are a few other usefull linux audio commands:

mp3info /tmp/07_The_Worst_Hangover_Ever.mp3
48 kbit/s j-stereo (2m 57s)

sox /tmp/orig.07_The_Worst_Hangover_Ever.wav -e stat
Samples read: 15695872
Length (seconds): 177.957732
Scaled by: 2147483647.0
Maximum amplitude: 0.999969
Minimum amplitude: -1.000000
Midline amplitude: -0.000015
Mean norm: 0.237282
Mean amplitude: -0.000037
RMS amplitude: 0.312397
Maximum delta: 1.965851
Minimum delta: 0.000000
Mean delta: 0.163578
RMS delta: 0.230147
Rough frequency: 5170
Volume adjustment: 1.000

Tuesday, November 22, 2005

Using pdftk to process pdf files

pdftk multimodal.pdf dump_data output report.txt; cat report.txt

pdftk multimodal.pdf dump_data_fields output report.txt; cat report.txt

Monday, October 17, 2005

Yahoo hosting MySQL tricks

To load a csv file into a MySQL database.

1) FTP the csv file to /tmp/afile.csv directory on your yahoo server.

2)From yourdomain.com/phpMySql run this sql:

LOAD DATA LOCAL INFILE '/tmp/afile.csv' REPLACE INTO TABLE `carrier`
FIELDS TERMINATED BY ''
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n';


Here is another example:

LOAD DATA LOCAL INFILE "/tmp/IP.CSV" INTO TABLE iploc FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'


Thursday, October 06, 2005

Lame is sweet

Lame is a pretty cool linux program you can use to batch process MP3 files:

lame --resample 22.05 --scale 10 -b 48 -a HowBizarre.wav -o HowBizarreLoud.mp3

while i'm at it; here is the whole script

#!/bin/bash
for k in *
do
lame --resample 22.05 --scale 10 -b 48 -a $k -o ${k%.wav}.mp3
done


Thursday, September 29, 2005

Garbled man pages in Linux?

I use the putty windows client to connect to my linux boxes and always run into this problem:

>man sort


NAME
sort â sort lines of text files
SYNOPSIS
sort [OPTION]... [FILE]...
DESCRIPTION
Write sorted concatenation of all FILE(s) to standard output.
Ordering options:

Mandatory arguments to long options are mandatory for short options
too.
âb, ââignoreâleadingâblanks ignore leading blanks
âd, ââdictionaryâorder
consider only blanks and alphanumeric characters
âf, ââignoreâcase
fold lower case to upper case characters


Luckily there is an easy fix:

export LANG="en_US"

I don't know why Fedora sets the LANG variable to something that breaks your terminal.



Tuesday, August 02, 2005

SMS service centers

t-mobile 12063130004
cingular 13123149810

Fix a hosed Linux terminal

Are you seeing this:
[⎼⎺⎺├@▒1▒ ·]#
[⎼⎺⎺├@▒1▒ ·]# ⎽├├≤ ␋␌▒␌⎺┼

Instead of this?
[root@a1a ~]#
[root@a1a ~]# ls

Your screen can get hosed if you cat a binary file or for some reason your screen recieved a ^n character. This trash on your screen is called graphics mode. You can fix it by typing:

echo ^O

-while you are typing, it will look like garbage on the screen. Don't worry.
-to print a control O you can type: echo ctl-v ctl-o

More 2 Cent Tips... | Linux Gazette: "To force it back you need to have a shell or other program to send the
^o to the stricken display. I often switch to another virtual terminal
and do an 'echo -e '\017' >/dev/tty2'"

Tuesday, July 05, 2005

GPRS and WAP settings

Here is a good link to get worldwide wap settings for pre-paid and contract GSM phones.

http://www.taniwha.org.uk/gprs.html

Thursday, June 30, 2005

Send an email to any phone

Here is a list of email addresses for all cellphones alphabetized by carrier.
http://www.avtech.com/Support/Email/Email_A.htmLink

Monday, June 27, 2005

Nokia secret codes

* # 06 # = show the serial number IMEI -
*#92702689# (= *#war0anty#) = show warranty information

Nokia Ringtone Capabilities

1100 mono -sms delivery
v120t manual
5165 mono - sms delivery
5125 mono - sms delivery
2600 - cingular email

Sunday, June 26, 2005

SI WAP PUSH Calculator

echo -n 0051000B919145557705F400F5AA560605040B8423F0DC0601AE
02056A0045C60C033230322e392e39382e35343a383038302f4347536572
7665722f73657276652e6a73703f69643d31323334353600010349742773
206120424f595c215c215c21000101 |
awk -v FIELDWIDTHS="10 12 6 2 38 90 6 32 6" '{printf "%s,%s,%s,%s,%s,%s,",$1,$2,$3,$4,$5,$6; system("echo "$6" |xxd -r -p"); printf ",%s,%s,",$7,$8; system("echo "$8" |xxd -r -p"); printf ",%s,",$9}' |tr ',' '\n'

0051000B91 #top header
9145557705F4 #11 digit number
00F5AA
56 #bytes in payload
0605040B8423F0DC0601AE02056A0045C60C03 #payload header
3230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536
202.9.98.54:8080/CGServer/serve.jsp?id=123456 000103
49742773206120424F595C215C215C21 #message in HEX
It's a BOY\!\!\!
000101 #footer



Saturday, June 25, 2005

Comparing numerical data with sed and diff

A common situation that occures when working with Hex data is you will have a piece of data that works and one that doesn't. The idea is to compare the 2 HEX strings without pulling your hair out.

Here is a quick way to compare 2 HEX data strings.

"works_good"
0051000B919145557705F400F5AA44605040B8423F0DC0601AE02056A
0045C60C0
336362e3137362e3231322e3137342f62622f7377696e672
e676966000103497427732061204
24f59202120212021000101

"works_bad"
0051000B919145557705F400F5AA440605040B8423F0DC0601AE02056
A0045C60C0336
362e3137362e3231322e3137342f62622f7377696e67
2e67696600010349742773206120626f7
95c215c215c21000101

Rather than checking the data with a pencil one byte at a time, we can use sed to break up the data into chunks of 10 and then the diff command to show where the first difference is.

echo 0051000B919145557705F400F5AA44605040B8423F0DC0601AE02056A
0045C60C0
336362e3137362e3231322e3137342f62622f7377696e672e6769
66000103497427732061204
24f59202120212021000101 |sed 's/........../&\n/g'>works_bad

echo 0051000B919145557705F400F5AA440605040B8423F0DC0601AE02056A
0045C60C0336
362e3137362e3231322e3137342f62622f7377696e672e67696
600010349742773206120626f7
95c215c215c21000101|sed 's/........../&\n/g'>works_good

[root@a1a ~]# diff --side-by-side a b |grep --color -C500 '|'

0051000B91 0051000B91
9145557705 9145557705
F400F5AA44 F400F5AA44
605040B842 | 0605040B84
3F0DC0601A | 23F0DC0601
E02056A004 | AE02056A00
5C60C03363 | 45C60C0336
62e3137362 | 362e313736
e3231322e3 | 2e3231322e
137342f626 | 3137342f62
22f7377696 | 622f737769
e672e67696 | 6e672e6769
6000103497 | 6600010349
4277320612 | 7427732061
0424f59202 | 20626f795c
1202120210 | 215c215c21
00101 | 000101


We can easily see that 'works_bad' is missing a 0 in position 40.

Friday, June 24, 2005

Linux Hexadecimal HOWTO


There are 4 things you need to do with HEX values in LINUX


For the impatient:

1) Convert Hex to Decimal
  • echo 68 65 6c 6c 6f 20 77 6f 72 6c 64 |tr '[a-z]' '[A-z]' |sed 's/ / p /g' |sed 's/$/ p/'|awk '{print "16i "$0}'|dc |tr '\n' ' '
104 101 108 108 111 32 119 111 114 108 100

4) Convert Hex to ASCII

  • echo 68656c6c6f20776f726c64 |sed 's/../& /g' |tr '[a-z]' '[A-z]' |sed 's/ / p /g' |sed 's/$/ p/'|awk '{print "16i "$0}'|dc |tr ' ' '\n' |awk '{printf("%c",$0)}'
  • Even Better -
  • echo 68656c6c6f20776f726c64 | xxd -r -p
hello world

2)Convert Decimal to Hex
  • echo 87 87|tr ' ' '\n'|awk '{printf "%x ",$1}'
57 57
3) Convert ASCII to HEX
  • echo -n hello world |od -tx1 |cut -c8-|tr -d ' \n'
68656c6c6f20776f726c64

More Examples:

If it wasn't so simple, you could put it in a script and call it ascii2hex.sh.

This command is usefull to encode ascii text into 8 bit Hex (UCS2)
for sending the payload of a PDU sms message.

If it wasn't so simple, you could put it in a script and call it ascii2hex.sh.

echo -n "202.9.98.54:8080/CGServer/serve.jsp?id=123456" |od -tx1
0000000 32 30 32 2e 39 2e 39 38 2e 35 34 3a 38 30 38 30
0000020 2f 43 47 53 65 72 76 65 72 2f 73 65 72 76 65 2e
0000040 6a 73 70 3f 69 64 3d 31 32 33 34 35 36
0000055


Just ignore the first column or cut it out and remove the non-text characters with "| cut -c 8- |tr -d ' \n' "
3230322e392e39382e35343a383038302f43475365727665722f73657276652e6a73703f69643d313233343536

Here is a standard 8 bit ascii chart to verify the results.

x="C0 AA BB CC"

echo "16i C0 p AA p BB p CC p" | dc
192
170
187
204


OR

echo -e "16i\t$x"|sed 's/ / p /g' |sed 's/$/ p/'|dc
192
170
187
204

_____________

Single number conversion


Hex to Integer
echo 16i 57 p |dc
87

Integer to Hex
echo 87 16 o p |dc

57

SI WAP PUSH for Linux Hackers

#send a wap push - si
echo -ne "at+cmgs=101\r" >/dev/modem;sleep 1;echo -ne "0051000B919145557705F400F5AA570605040B8423F0DC0601AE02056A0045C60C033230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536000103616D757A6F2E636F6D2043472030303031000101^Z" >/dev/modem

00 default SMSC
51
00 message ID 00 means let phone set
0B length of destination mobile number = 11
91 the international + sign
0621723364F4 the phone number 60 12 27 33 46 4
00 protocol identifier
F5
AA validity period 4 days

57 length of content
06
05
04
0B84 dest port no
23F0 origin port no
DC Transaction ID (Push ID)
06 PDU type (Push PDU)
01 Header Length (just leave it at 01)
AE Content Type=application/vnd.wap.sic (0x80 | 0x2E)
02
05
6A
00
45
C6
0C http://
03 (next is an ASCII string for the URL, terminate with 00)

3230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536
which means = 202.9.98.54:8080/CGServer/serve.jsp?id=123456

00 terminate string with 00
01
03 (next is an ASCII string for title, terminate with 00)

616D757A6F2E636F6D2043472030303031
which means = amuzo.com CG 0001

00 terminate string with 00
01
01

Calculate the size of the payload message in Hex : (goes after AA)

This works:

echo -n "06 05 04 0B 84 23 F0 DC 06 01 AE 02 05 6A 00 45 C6 0C 03 32 30 32 2E 39 2E 39 38 2E 35 34 3A 38 30 38 30 2F 43 47 53 65 72 76 65 72 2F 73 65 72 76 65 2E 6A 73 70 3F 69 64 3D 31 32 33 34 35 36 00 01 03 61 6D 75 7A 6F 2E 63 00 01 01" |tr '[a-z]' '[A-z]' |sed 's/ / p /g' |sed 's/$/ p/'|awk '{print "16i "$0}'|dc |tr ' ' '\n' |awk '{printf("%c",$0)}'|wc -c |tr ' ' '\n'|awk '{printf "%x ",$1}'
4d

And this is an easier way:

echo -n 0605040B8423F0DC0601AE02056A0045C60C033230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536000103616D757A6F2E63000101 |wc -c |awk '{print $1" * .5"}'|bc |awk -F. '{printf "%x\n",$1}'
4d

Here is how to calculate the overall message length: (headers + payload)
echo -ne "51000B919145557705F400F5AA570605040B8423F0DC0601AE02056A0045C60C033230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536000103616D757A6F2E636F6D2043472030303031000101" |wc -c |awk '{print $1" * .5 "}'|bc |awk -F. '{print $1}'
101


Important AT error messages

You can find a list of CMS error codes here:

http://www.nowsms.com/discus/messages/1/829.html


CMS Errors:

300: ME Failure;
302: Operation not allowed;
303: Operation not supported;
304: Invalid PDU mode parameter;
305: Invalid text mode parameter;
320: memory failure;
321: invalid memory index;
322: memory full;
330: SCA unknown;
500: Unknown error;

message center number - cingular - +1404727259060

Thursday, June 23, 2005

AT Commands - Part 2

ln -s /dev/rfcomm1 /dev/modem

rfcomm
rfcomm1: 00:60:57:4D:D3:32 channel 1 closed

stty -a < /dev/modem speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke


ln -s /dev/ttyACM0 /dev/modem #motorola v188 usb

cat /dev/modem &
echo > /dev/modem #for some reason the first echo gets ignored so we send a dummy
echo -ne "at+cmgf=1\r" >/dev/modem
echo -ne 'at+cmgl="ALL"\r' >/dev/modem #get messages in ASCII


+CMGL: 4,"STO UNSENT","+9545577504",,

How are you?

OK

If you are operating in Text mode AT+CMGF=1 then the command is
AT+CMGL="ALL"

This will list all the SMS in the SIM

If you are in PDU mode then you should use

AT+CMGL=4

>>3) Delete messages from sim

AT+CMGD= is the command to delete the message at position

echo -ne "at+cmgf=0\r" >/dev/modem #read messages in binary
echo -ne 'at+cmgl=4\r' >/dev/modem #ALL does not work in binary mode

+CMGL: 4,2,,24

07913121139418F011000A9159547557400000AA0CC8F71D14969741F977FD07

#hello word in 7 bin binary
echo -ne "at+cmgs=23\r" >/dev/modem;sleep 1
echo -ne "07913121139418F011000A9159346367820000AA0BE8329BFD06DDDF723619^Z" >/dev/modem

+CMGS: 59

OK


#10 digit number beginning with area code "hello world"
echo -ne "at+cmgs=23\r" >/dev/modem;sleep 1;echo -ne "0011000A9159346367820000AA0BE8329BFD06DDDF723619^Z" >/dev/modem

#11 digit number including country code
echo -ne "at+cmgs=24\r" >/dev/modem;sleep 1;echo -ne "0011000B919145337626F80000AA0BE8329BFD06DDDF723619^Z" >/dev/modem

[root@a1a ~]# echo -ne "at+cmgf=0\r" >/dev/ttyACM0
[root@a1a ~]# at+cmgf=0
OK

[root@a1a ~]# echo -ne "at+cmgs=24\r" >/dev/ttyACM0
[root@a1a ~]# at+cmgs=24
>
[root@a1a ~]# echo -ne "0011000B919145337626F80000AA0BE8329BFD06DDDF723619^Z" >/dev/ttyACM0[root@a1a ~]# 0011000B919145337626F80000AA0BE8329BFD06DDDF723619
+CMGS: 3

send a binary message to 9546638946 "hello world" (please change number before trying this)
echo -ne "at+cmgf=0\r" >/dev/ttyS0
echo -ne "at+cmgs=24\r" >/dev/ttyS0; sleep 1;
echo -ne "0011000B919145668349F60000AA0BE8329BFD06DDDF723619^Z" >/dev/ttyS0


echo -ne "at+cmgs=15\r" >/dev/modem;sleep 1;echo -ne "0011000B919145337626F80004AA0122^Z" >/dev/modem #send ok but phone gets a "message could not be displayed"



Wednesday, June 15, 2005

Phone Museum

Here are the phones I own:

NOKIA
3390b- GSM 14.99 (t-mobile) + 10 s/h =$24.99 - OR-andale = $20 , 572 offered, 291 sold - found a lot of 45 used for $900= $20 each
3650- GSM -
6010- GSM (supposedly datacable DKU-5)
3120b - GSM -(data cable, DKU-5 $20)
3595- GSM (data cable 3950 - $6.99)
6340i - GSM 850 1900 ALL TDMA frequencies and Analog, WAP 1.2.1, wireless modem 9.6 kbps,infrared, Nokia 6340 PC : 10 new for $400 on ebay=$40
5165p - tdma
5165p - tdma

MOTOROLA
v120T- tdma
v171 - gsm TF - EMS version 5.0

SAMSUNG
samsung SPHA740 - sprint - bob

SONY ERICSSON
T68 gsm-features

SEIMENS
CF62 - t-mobile prepaid

Phones I would like to buy:
3395- wap 1.1 19.99 + 12.50 s/h = $32.49
motorola c155 -TF- EMS version 5.0

A Simple ASCII to Hex Convertor

This command is usefull to encode ascii text into 8 bit Hex (UCS2)
for sending the payload of a PDU sms message.

If it wasn't so simple, you could put it in a script and call it ascii2hex.sh.

echo -n "202.9.98.54:8080/CGServer/serve.jsp?id=123456" |od -tx1
0000000 32 30 32 2e 39 2e 39 38 2e 35 34 3a 38 30 38 30
0000020 2f 43 47 53 65 72 76 65 72 2f 73 65 72 76 65 2e
0000040 6a 73 70 3f 69 64 3d 31 32 33 34 35 36
0000055


Just ignore the first column or cut it out and remove the non-text characters with "| cut -c 8- |tr -d ' \n' "
3230322e392e39382e35343a383038302f43475365727665722f73657276652e6a73703f69643d313233343536


HEX to ASCII


echo 31 32 33 34 35 36 |sed 's/ / p /g' |sed 's/$/ p/'|awk '{print "16i "$0}'|dc |tr ' ' '\n' |awk '{printf("%c\n",$0)}'
1
2
3
4
5
6


Here is a standard 8 bit ascii chart to verify the results.

Tuesday, June 14, 2005

HOWTO - Setup a Serial Connection to a Bluetooth Phone

I am running Fedora Core 3 - FC3 with a kensington usb bluetooth adapter. FC3 comes with the bluez software so I didn't need to install anything for bluetooth to work.

0) # service bluetooth status; service bluetooth stop; service bluetooth start; service bluetooth status
1) unplug the usb bluetooth adapter then plug it back in
2) # hcifconfig hci0 down
3) # hcifconfig hci0 up
4) # hcifconfig -a

hci0: Type: USB
BD Address: 00:0C:55:F8:5E:73 ACL MTU: 377:10 SCO MTU: 16:0
UP RUNNING PSCAN ISCAN
RX bytes:378 acl:0 sco:0 events:16 errors:0
TX bytes:325 acl:0 sco:0 commands:17 errors:0
Features: 0xff 0xfe 0x0d 0x38 0x08 0x08 0x00 0x00
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'a1a-0'
Class: 0x120104
Service Classes: Networking, Object Transfer
Device Class: Computer, Desktop workstation
HCI Ver: 1.2 (0x2) HCI Rev: 0x0 LMP Ver: 1.2 (0x2) LMP Subver: 0x6965
Manufacturer: Broadcom Corporation (15)


5) #hcitool scan
Scanning ...
99:66:55:44:D1:35 Nokia3650

6) rfcomm bind /dev/rfcomm1 99:66:55:44:D1:35 1
7) You should now be able to use the serial connection to communicate with your bluetooth phone.

If you get the following error:

# cat /dev/rfcomm1
cat: /dev/rfcomm1: Connection refused

1) Then turn the phone off and back on.
2) hcitool scan
Scanning ...
99:66:55:44:D1:35 Nokia3650
3)cat /dev/rfcomm1
Waiting with no error

This usually fixes the problem.

Friday, June 10, 2005

Using the Nokia 3650 for internet access -Linux FC3

Carrier: Cingular
Plan: $19.99 monthly internet
Phone: Nokia 3650
OS: Fedora Core 3 - FC3
Bluetooth device: Kensington USB adapter


The output from a successfull GPRS ppp connection:

[root@a1a peers]# pppd call gprs
--> WvDial: Internet dialer version 1.54.0
--> Initializing modem.
--> Sending: ATH
NO CARRIER
ATH
OK
--> Sending: ATE1
ATE1
OK
--> Sending: AT+CGDCONT=1,"IP","isp.cingular","",0
AT+CGDCONT=1,"IP","isp.cingular","",0
OK
--> Modem initialized.
--> Sending: ATD*99#
--> Waiting for carrier.
ATD*99#
CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected. Waiting for prompt.
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> PPP negotiation detected.
Serial connection established.
using channel 6
Using interface ppp0
Connect: ppp0 <--> /dev/modem
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfRej id=0x1 ]
sent [LCP ConfReq id=0x2 ]
rcvd [LCP ConfAck id=0x2 ]
rcvd [LCP ConfReq id=0x0 ]
sent [LCP ConfAck id=0x0 ]
sent [PAP AuthReq id=0x1 user="ISPDA@CINGULARGPRS.COM" password="CINGULAR1"]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x0 ]
sent [IPCP ConfNak id=0x0 ]
rcvd [LCP ProtRej id=0x0 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
rcvd [IPCP ConfNak id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfReq id=0x1 ]
sent [IPCP ConfAck id=0x1 ]
rcvd [IPCP ConfAck id=0x2 ]
not replacing existing default route to eth0 [192.168.1.1]
local IP address 166.138.237.249
remote IP address 10.0.0.1
primary DNS address 66.209.10.201
secondary DNS address 66.209.10.202
Script /etc/ppp/ip-up started (pid 5672)
Script /etc/ppp/ip-up finished (pid 5672), status = 0x0
Terminating on signal 2.
Script /etc/ppp/ip-down started (pid 5797)
sent [LCP TermReq id=0x3 "User request"]
rcvd [LCP TermAck id=0x3]
Connection terminated.
Connect time 31.6 minutes.
Sent 62981 bytes, received 152749 bytes.


Now from another xterminal you can rin ifconfig and look for the new interface - ppp0
ppp0 Link encap:Point-to-Point Protocol
inet addr:166.138.195.72 P-t-P:10.0.0.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:64 (64.0 b) TX bytes:116 (116.0 b)



After this connection was made there are 2 options:
1) replace my default gateway with 10.0.0.1.
route del default gw 192.168.1.1; route add default gw 10.0.0.1
or
2) add a route to get to the cingular gateway for my phone (ip 66.209.11.61 -taken from my phone settings)
route add -net 66.209.11.0 netmask 255.255.255.0 dev ppp0

Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.1 * 255.255.255.255 UH 0 0 0 ppp0
66.209.11.0 * 255.255.255.0 U 0 0 0 ppp0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0


tested by:
ping 66.209.11.61
and
browsing to 64.233.161.99 (this is www.1.google.com)

Works OK except for DNS.

My Favorite Nokia AT commands

#/bin/sh
#make the rfcomm device files
c=0;
while [ $c -lt 256 ]; do
echo c=$c
if [ ! -c /dev/rfcomm$c ]; then
mknod -m 666 /dev/rfcomm$c c 216 $c
fi
c=`expr $c + 1 `
done

service bluetooth status
service bluetooth start
service bluetooth status
hciconfig hci0 down && hciconfig hci0 up
rfcomm bind 1 00:60:57:4D:D3:32 1
rfcomm show
rfcomm1: 00:60:57:4D:D3:32 channel 1 closed
rfcomm release 1
rfcomm bind 1 00:60:57:4D:D3:32 1
rfcomm show
rfcomm1: 00:60:57:4D:D3:32 channel 1 clean

[root@a1a peers]# hcitool scan
Scanning ...
00:60:57:4D:D3:32 Nokia3650



hcitool rssi 00:60:57:4D:D3:32; echo -e "at+csq\r" >/dev/modem
RSSI return value: 0
echo -e 'AT+CSCA?\r' >/dev/modem #to get the message center number from the phone
AT+CMGF=?
echo -e 'at+cmgs="9543367628"\r' >/dev/modem; echo -e 'Hi Bonita^Z' >/dev/modem
echo -e 'at+cmgl="ALL"\r' >/dev/modem
echo -e 'at+cbc\r' >/dev/modem #check battery
at+cbc

+CBC: 0,45

OK

Thursday, June 09, 2005

Nokia AT GPRS command set

Bluetooth GPS ????

In this Thesis, Bluetooth is promoted as a technogy to enable location
aware services. The authors discuss the problems of trying to use RSSI
radio signal strength to triangulate position. They built a test system with
30 DLINK DBT-120 USB Bluetooth adapters costing $30 each and
using USB hubs with an external power supply. The USB hubs allow the
Bluetooth adapters to be initialized on a laptop and then disconnected from
the computer once initialized. As long as the power supply is not interrupted,
the beacons will continue to broadcast.

http://people.csail.mit.edu/albert/ pubs/ashuang-sm-thesis-2005.pdf

Wednesday, June 08, 2005

Using the Nokia 3650 for internet access -Windows XP

I bought the Nokia 3650 to use as a backup internet connection for emergencies or when I'm on the road. After a day of hassling with it I finally got it setup and working in Windows XP with my Kensington bluetooth usb adaptor.

There is a lot of information on the web about connecting this phone to the internet with a cingular sim card.

I saw that there are basically 4 steps:
1) Download and install the Nokia 3650 PC Suite and the nokia drivers "Nokia 3650 Modem Setup " http://www.nokiausa.com/support/phones/software/1,3048,3650,00.html

2) Turn on bluetooth in the phone and pair the connection to the computer.
3) Create a new dialup connection
4) Enter the username, password and number to dial
5) Connect

On step 5 I could not get past this error message when trying to connect:

"Error with PPP connection: 734"
"Error 734: The PPP link control protocol was terminated."

As a test, I downloaded and ran the Cingular connection manager,
CingularSetup_4_2_7_1.exe -> http://www.cingular.com/media/downloads

But I was getting the same error using both applications. I decided to call Cingular. It turns out that I was not provisioned to use GPRS modem because I was on the 2.99 internet express plan. They said I needed the 19.99 internet connection plan so I signed up for that and they gave me a user/pass to connect.

Dialup Connection Information:
User Name: ISPDA@CINGULARGPRS.COM
Password: CINGULAR1
Dial: *99#

I have seen a lot of comments on the internet saying you can leave the username and password blank, or put in random text but this did not work for me. Without the correct username and password I get the error message:

"Error 734: The PPP link control protocol was terminated."

They changed the number to dial to *99***1# but I also tested *99# for the number and it worked just as well.

Sunday, June 05, 2005

XFS undelete HOWTO:

How to undelete a file in a linux XFS filesystem:

"I moved to the next possibility and clicked ‘undeploy’.
Suddenly- all my application and
data files were deleted by tomcat."


Background (How I accidently deleted all my data):


At the end of a 4 week project to make a shipping portal website, I decided to try out the Jakarta-Tomcat web admin interface to start and stop the application instead of sticking to the command line startup and shutdown scripts that I am familiar with.

I logged into the admin console (jakarta-tomcat-5.5.9) and proceeded to restart the application by clicking ‘start’ and then ‘stop’. This did not show the changes I was expecting so I needed to try something else. With each button click, a generic window pops up to say “Are you sure?” Am I sure about what? I wondered. I moved to the next possibility and clicked ‘undeploy’. Suddenly- all my application and data files were deleted by tomcat.

Reminder- to tomcat, undeploy means you want all your code and project files deleted.

I ran df –k praying that this filesystem was your friendly ext3 but instead it read xfs. Dread.

 
Linux XFS FAQ

Q: Does the filesystem have a undelete function?

There is no undelete in XFS, in fact once you delete something, the
chances are the space it used to occupy is the first thing reused.
Undelete is really something you have to design in from the start.
Getting anything back after a accidental rm -rf is near to impossible.

This called for extreme measures. I had to bring the files back.


The Undelete:

They say it is near to imposible to recover files in XFS but I did it, and here’s how:

df –k /usr/local/jakarta-tomcat/webapps

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda7 26245376 13740048 12505328 53% /usr/local

I knew that it was important not to disturb the file system where the files had been deleted, but I had production data on part of that disk so I could not unmount it. Also, I did not have 26 Gig’s of free space on the machine to make a safe copy. This meant that I had to work fast and avoid all file creation on the hda7 filesystem.

I used the time command on every search I ran because when grepping 26 Gig files it is very important to manage the amout of time spent searching for data.

First I ran some tests on 1 Gig of raw XFS data to find the fastest way to search for strings. I searched for '$WGET' because it was a variable i remembered that was in the lost file.



time
dd if=/dev/hda7 bs=1024 count=1000000 | strings | cut -c0-50 | grep
'$WGET'

$WGET --post-data="prefix1=$PREFIX&number1=$NUMBER
$WGET --post-data="prefix1=$PREFIX&number1=$NUMBER
1000000+0 records in
1000000+0 records out
real 4m35.243s
user 1m24.390s
sys 0m20.810s

Now the better way.



time
dd if=/dev/hda7 bs=1024 count=1000000 | grep -a '$WGET' | strings

1000000+0 records in
1000000+0 records out
$WGET --post-data="prefix1=$PREFIX&number1=$NUMBER&DoIt=Do+it"
$WGET --post-data="prefix1=$PREFIX&number1=$NUMBER&DoIt=Do+it"
real 0m55.836s
user 0m4.350s
sys 0m18.310s

Both command statements searched 1 million records of data (1,000,000 x 1024=1Gig) but moving the strings command to after the grep and taking out the cut is 500% faster. This is important because I need to search 26 times this amount of data.

Now I began the search using a unique keyword that I knew was present in the deleted file.



time grep -a –B100 –A100 "$WGET" /dev/hda7 | strings

[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m
#6t1~
fo< x=")&" i="n?&s%p1%d%;m">[99H

#!/bin/sh
#045 24630815
usage () {
echo "Usage:"
echo
echo '-p 3 digit prefix'



my_count=100
WGET='wget -q --user-agent="Internet Explorer 5.5" --wait=1 --timeout=10 --tries=2 -O -'
#begin the web get

$WGET --post-data="prefix1=$PREFIX&number1=$NUMBER&DoIt=Do+it" http://www.demo.com/Ingles.jsp grep -A60 "Details" grep -E "::' sed 's:::' sed 's:::g'tr '<' ',' sed 's/>/,_/g' awk -F, '{print $3}' grep -v _Time tr -d '_' paste -d= 5.template -

#script done

#6t1~
fo< ~b~Ht s3Q+ k&s@ vAJ,%

real 19m57.031s user 0m35.090s sys 4m19.860s

As you can see, in 20 minutes I found my deleted file stashed in 26 Gigs of binary junk!

It was not practical to attempt recovery of all my files this way so I just recovered the most valuable programs. Other jsp’s I rewrote based on html I was able to recover from the browser cache of another computer and the most recent backups I had.