Tuesday, April 28, 2009

[solved] PROLINK PHS100 HSDPA workout for Debian lenny and Ubuntu intrepid


* check wethre system is up-to-date ( apt-get update && apt-get upgrade)
1. wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-0.9.7.tar.bz2
2. tar xjvf usb_modeswitch-0.9.7.tar.bz2 && cd usb_modeswitch-0.9.7 && make install
3. Edit /etc/usb_modeswitch.conf and add following section (similar to iCON 210 section) to end of the file
########################################################
# Option PROLINK PHS100
#
# Contributor: laxaman

DefaultVendor= 0x1e0e
DefaultProduct= 0xf000

TargetVendor= 0x1e0e
TargetProduct= 0x9000

# Not really necessary because IDs of target device are different
TargetClass= 0xff

MessageEndpoint=0x1
MessageContent="555342431234567800000000000006bd000000020000000000000000000000"

ResponseEndpoint=0x1


4. Create /usr/sbin/prolink_hsdpa.sh with the content given bellow and make it executable (chmod +x /usr/sbin/prolink_hsdpa.sh)
#!/bin/bash
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

PATH=/usr/bin:/bin:/usr/sbin:/sbin
modprobe -r usbserial
sleep 1
modprobe usbserial vendor=0x1e0e product=0x9000


5. Create /etc/udev/rules.d/45-prolink_hsdpa.rules with the content given bellow
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.


ACTION=="add", SUBSYSTEMS=="scsi", DRIVERS=="sr", \
ATTR{manufacturer}=="PROLINK ", \
RUN:=""

SUBSYSTEM=="usb", SYSFS{idProduct}=="f000", SYSFS{idVendor}=="1e0e", \
RUN:="/usr/sbin/usb_modeswitch"

SUBSYSTEM=="usb", SYSFS{idProduct}=="9000", SYSFS{idVendor}=="1e0e", \
RUN:="/usr/sbin/prolink_hsdpa.sh"


6. Thats it now you can plug your PROLINK PHS100 hsdpa dongle you will see some devices in /dev/ such as ttyUSB0 ttyUSB1 ttyUSB2 ttyUSB3 ttyUSB3 will the working one for data connection

7. You can use wvdial to dial your connection. If you don't have wvdial then install it (apt-get install wvdial). copy following content to /etc/wvdial.conf and type wvdial in your terminal to connect.


[Dialer Defaults]
Modem = /dev/ttyUSB3
Baud = 1843200
Modem Type = Analog Modem
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP",""
Dial Command = ATDT
Phone = *99***1#
Username = ''
Password = ''
Stupid Mode = yes

Friday, April 24, 2009

Script to add applications to fvwm-crystal menu

Following script will add applications to fvwm-crystal menu

Screenshot of fvwm-crystal:



#!/bin/bash
APP_BASE=/usr/share/fvwm-crystal/fvwm/Applications
#APP_BASE=~/.fvwm/Applications/

if [[ $1 == '' ]]
then
echo "Usage:"
echo "$0 [icon name]"
exit 0
fi


if [[ ! -e $APP_BASE ]]
then
echo "Menu base does not exists!"
exit 0
#mkdir -p $APP_BASE
fi

MENUS=($( ls $APP_BASE ));
MENU=
APP=$1
APP_NAME=`basename $1`
ICON=$2
SCRIPT=

if [[ `which $APP` == '' && ! -e $APP ]]
then
echo "$APP does not exists!"
exit 0
fi

i=0
while true
do
[[ ${MENUS[$i]} == '' ]] && break;
echo "$i. ${MENUS[$i]}"
i=`expr $i + 1`
done

OPT=''
echo "Enter Menu number to insert item:"
read OPT
if [[ $OPT -lt $i && $OPT -ge 0 ]]
then
MENU=${MENUS[$OPT]}
else
echo "wrong"
fi

if [[ $2 == '' ]]
then
ICON=$APP_NAME
fi

SCRIPT="~$ICON~$APP_NAME"


ANS=""
echo "Menu item: $APP_BASE/$MENU/$SCRIPT"
echo "Continue creating menu item? [y/n]: "
read ANS
if [[ $ANS == 'y' ]]
then
if [[ -e $SCRIPT ]]
then
echo "Script exists!";
else
echo "#!/bin/sh
exec $APP \$@
" > $APP_BASE/$MENU/$SCRIPT
chmod +x $APP_BASE/$MENU/$SCRIPT
fi
else
echo "Not creating menu item!"
fi


Save the script in /usr/bin/fvwm-crystal-menu-gen.sh and make it executable (chmod +x /usr/bin/fvwm-crystal-menu-gen.sh). Use following sytax to add applications to menus

/usr/bin/fvwm_crystal_menu_gen.sh [icon name]


If the application is in PATH you don't have to enter absolute path as just give application name. If you want to acompany an icon with a different name input it in place [icon name]

Wednesday, February 11, 2009

kannel send sms to specific port

To send sms to a specific port number ( eg: port in your j2me application ) you have to add following extra parameter to kannel send sms url

udh=

which will specify the User Data Header of the sms. For example following url will send the sms to port 6579

http://127.0.0.1:13013/cgi-bin/sendsms?username=[kannel user]&password=[kannel passwd]&to=[to phone number]&text=[message text]&udh=%06%05%04%19%B3

As you can see udh is a url-encoded string and it have a standard format as follows;

[how long the UDH is] [the format used to specify ports numbers] [the port number length] [destination port number] [source port number]

As a practical example, say I want to create a UDH to send a sms to port 2948, the UDH will be:

06 05 04 0B 84 23 F0 -> 06%05%04%0B%84%23%F0

where:

* 06 means "hey read the following 6 bytes"
* 05 is the format for numbers, in this case hexadecimal numbers
* 04 will tell the UDH that each port is represented using 4 character
* 0B84 is the destination port in hexadecimal, 2948 (decimal representation)
* 23F0 is the source port in hexadecimal, 9200 (decimal representation) or 23F0 (hexadecimal representation).

You have to keep in mind that after adding udh to the url, sms will be transfred as a binary messaage.

Ref:http://mobiforge.com/developing/story/binary-sms-sending-rich-content-devices-using-sms

kannel sms delivery report workout

1) Add one of the following options to core group of kannel configuration. If you use mysql as dlr-storage you have to configure two more groups to associate mysql with kannel. If you use dlr-storage=internal skip step 2. If you use dlr-storage=internal the data is not tangible according to my knowledge. Also keep in mind that there are other parameters for dlr-storage which we can use to connect with other databases like postgresql

dlr-storage = internal
dlr-storage = mysql

2) If you use mysql add following two groups to kannel.conf (or to separate file and include that file). Put your database username and password to the place of [db user] and [db passwd] . Group dlr-db uses to specify the table and map the feilds together. if you configure for mysql, the message will be temporarily stored in the table until it reaches the destination.

group = mysql-connection
id = mydlr
host = localhost
username = [db user]
password = [db passwd]
database = kannel
max-connections = 1

group = dlr-db
id = mydlr
table = dlr
field-smsc = smsc
field-timestamp = ts
field-destination = destination
field-source = source
field-service = service
field-url = url
field-mask = mask
field-status = status
field-boxc-id = boxc

Thats all for kannel.conf...

3) Now you have to introduce following extra parameters to your kannel send sms url

dlr-mask=
dlr-url=


dlr-mask specifies the types of reports which kannel should generate. dlr-url specifies the url which will be called when the delivery report is received. For dlr-mask you can use one of the following mask numbers or any combination of them.

1: delivery success

2: delivery failure

4: message buffered

8: smsc submit

16: smsc reject

If you want multiple report types, you simply add the values together. For dlr-url you have to provide a url-encoded url for example
url:
http://localhost/sms/inc/deliveryReport.php?user=john&passwd=1234&type=%d&receiver=%p&reply=%A&time=%t&usr=%n&message=%b
urlencoded url:
http%3A%2F%2Flocalhost%2Fsms%2Finc%2FdeliveryReport.php%3Fuser%3Djohn%26passwd%3D1234%26type%3D%25d%26receiver%3D%25p%26reply%3D%25A%26time%3D%25t%26usr%3D%25n%26message%3D%25b

If you use php to interact with kannel you can easily generate urlencoded url using urlencode() function.


finally the resulting url is like this
http://localhost:13013/cgi-bin/sendsms?username=[kannel user]&password=[kannel passwd]&to=[to phone number]&text=[message text]&dlr-url=http%3A%2F%2Flocalhost%2Fsms%2Finc%2FdeliveryReport.php%3Fuser%3Djohn%26passwd%3D1234%26type%3D%25d%26receiver%3D%25p%26reply%3D%25A%26time%3D%25t%26usr%3D%25n%26message%3D%25b&dlr-mask=7

here I have used dlr-mask=7 so it will report following three types;
1: delivery success

2: delivery failure

4: message buffered

Friday, January 16, 2009

Dictionary for English -Sinhala and Sinhala-Engliish for stardict


Stardict is both static and scanning dictionary. Nice thing of stardict is, it does not depend on the application which the text is contained (eg: ensitip works only in firefox).
1) install stardict
apt-get install stardict
2) setting up Sinhala-English English-Sinhala dictionary
download the dictionary file from www.sinhalenfoss.org.
extract the compressed file to /usr/share/stardict/dic
tar -xzvf sinhala-stardict-120908.tar.gz -C
/usr/share/stardict/dic
3) configurations
stardict will be available in 'Accessories' sub-menu start it.
Click the small button at bottom right corner of the dictionary window.
Chose a suitable key for scan modification there. otherwise stardict will scan all the time when you select a text.
4) You can also download many other dictionaries at http://stardict.sourceforge.net/Dictionaries.php,http://stardict.sourceforge.net/Dictionaries_dictd-www.dict.org.php
Oxford Advanced Learner's Dictionary is a good one for English-English.

Sunday, January 11, 2009

SMS gateway with kannel and your mobile phone (Ubuntu intrepid)

Kannel is a gateway for connecting WAP (Wireless Application Protocol) phones to the Internet. It also works as an SMS gateway, for providing SMS based services for GSM phones. Bellow is my configuration of kannel as a SMS-gateway

1) apt-get install kannel
2)copy /usr/share/doc/kannel/examples/modems.conf to /etc/kannel/ to include in kannel.conf
3)Backup /etc/kannel/kannel.conf ( mv /etc/kannel/kannel.conf /etc/kannel/kannel.conf.bak) and create a new file /etc/kannel/kannel.conf with following configuration:

group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
log-file = "/var/log/kannel/kannel.log"
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"


group = smsc
smsc = at
modemtype = auto
device=/dev/ttyUSB1
my-number =
connect-allow-ip = 127.0.0.1
log-level = 0


group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender =
log-level = 0


group = sendsms-user
username = kan
password = abc
concatenation= true
max-messages = 10


group = sms-service
keyword =
keyword-regex = .*
catch-all = yes
max-messages = 0
get-url = http://localhost/sms/inc/getsms.php?user=john&passwd=1234&mobile=%p&text=%a

include = "/etc/kannel/modems.conf"


4) in above configuration put your phone number in the place of and change the password and username under group = sendsms-user
5) Change device=/dev/ttyUSB1 to your device (eg: /dev/ttyS0, /dev/ttyACM0 ). I'm using huawei E220 in my case and using /dev/ttyUSB1 for sms-gateway and to access Internet I use /dev/ttyUSB0.
6) Now configuration is almost done... now you can test your configuration with starting the gateway with following commands. It will return the errors to the terminal.
bearerbox -v 0 smskannel.conf &
smsbox -v 0 smskannel.conf &

7) I you have problem with opening your device (eg: /dev/ttyUSB1) try changing the permissions for that device with chmod a+rw /dev/ttyUSB1
8) By default kannel will start at the boot time, so it is better you have plugged your device while booting otherwise kannel will try to probe the device continuously until you plug the device or stop kannel (to stop use '/etc/init.d/kannel stop' ).
9) kannel is configured to start as WAPBOX by default... to make it start as a SMSBOX (sms-gateway), edit /etc/default/kannel and put 'START_SMSBOX=1' instead of 'START_WAPBOX=1'
10) To send sms using terminal use following command:
lynx -dump "http://127.0.0.1:13013/cgi-bin/sendsms?username=kan&password=abc&to=[recipient no]&text=[text]"
* It is easy to write an application with php like serverside language and provide a web-gui for kannel. You can find a simple web front end for kannel here.

following link will provide brief descriptions for kannel.conf settings;
http://swik.net/User:marc/Chipmunk+Ninja+Technical+Articles/Setting+up,+Configuring,+and+Using+Kannel+to+send%2Freceive+SMS+messages/3e0s

Usefull links:
http://www.kannel.org/

http://kannel.jizz.gr/

User's guid






Thursday, January 1, 2009

Installing TinyOS-2.x in Ubuntu intrepid (8.10)

1) add bellow repository to your /etc/apt/sources.list though it is for hardy, it is working for intrepid also

deb http://tinyos.stanford.edu/tinyos/dists/ubuntu hardy main

2) with following commands you can update the apt-cache and search the required packages thin you can install the required version and all.

apt-get update
apt-cache search tinyos
apt-get install tinyos-2.1.0

3) then install python development package (headers)

apt-get install python-dev

4) Edit /opt/tinyos-2.1.0/tinyos.sh and change the CLASSPATH env-variable as bellow

CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java/tinyos.jar:.

4) Import /opt/tinyos-
2.1.0/tinyos.sh in your .bashrc; include bellow code snippet to ~/.bashrc

if [ -f /opt/tinyos-
2.1.0/tinyos.sh ] ; then
. /opt/tinyos-
2.1.0/tinyos.sh
fi

5) Now execut bash again or restart the terminal and chech your enviorenment with bellow command. It will check the enviorenment and report you the status. (Ignore the WORNING returned due to graphvis version)

tos-check-env

6) Lets compile the first application

cd $TOSROOT/apps/Blink
make micaz

for simulator

make micaz sim

have fun!~

Intel Corporation XMM7360 LTE Advanced Modem in ArchLinux

The required packages are available in ArchLinux User Repository (AUR) so it will be easier if you can use an AUR helper package like yay . ...