Thursday, November 30, 2006

Writing a SMS Service with Free Software

So what we will do is set up a simple SMS based service using Kannel and Linux. Kannel is a famous, powerful, open source and free SMS gateway and WAP gateway. You can use it to connect to a mobile operator's SMS center (SMSC), or using a GSM mobile phone or GSM modem as a virtual SMS center. Kannel can handle multiple SMS centers and virtual SMS centers.

Kannel supports the use of AT-capable mobile phones as virtual SMS centers. Most GSM mobile phones are capable to work with AT commands these days. A small list of mobile phones and GSM modems that are known to work as virtual SMS centers with Kannel is available on its web site.

The SMSC access protocols supported by Kannel include SMPP, CIMD, UCP / EMI and SMS2000 / OIS. In addition, Kannel has an HTTP / HTTPS interface that you can use to send and receive SMS messages.

I use Fedora Core 6 as my OS (desktop). A few methods to setup kannel using FC is, log in as root. Then execute the following command on your console

yum -y install kannel

or download the tarball from Kannel web site and compile it

This will get kannel installed on your box. Next is if you are using a GSM mobile, you need to make it work with your linux box. One easy way is setup the mobile as a GSM modem, via bluetooth. In my case I use the Bluez library for bluetooth connectivity. If you don't have it get it installed. All from FC3 up come preconfigured with Bluez libraries and all. In case you are using other distributions please get Bluez libraries and install them. On FC do the following. In any case your box needs to have bluetooth support.

yum -y install bluez-libs bluez-pin bluez-utils bluez-hcidump bluez-utils-cup

That should get you all fixed up. If you are using a bluetooth USB dongle you need to do the following

modprobe hci_usb

then

modprobe usb-uhci

If all goes well, type the following

hciconfig

then your output should be something like the following

hci0: Type: USB
BD Address: 00:0F:B3:90:86:46 ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:5159 acl:5 sco:0 events:129 errors:0
TX bytes:1599 acl:5 sco:0 commands:83 errors:0

This means youe bluetooth device is all set to go. Now you just need to configure it. To test if your bluetooth is working, you can do a simple scan of all devices as follows. type

hcitool scan

which should give you an output simmiler to

Scanning ...
00:0F:B3:90:7B:6E WTM--LAP-07
00:0E:6D:CC:04:7F Dark
00:10:C6:82:A8:6F WTM-ITLAP-03

Anyway, the configuration is very simple and straight forward. If you want to bind to your mobile you need to configure Bluez.The configuration of blues will be located in /etc/bluetooth/ edit the following files and do medications as per your requirements. Add the following lines to rfcomm.conf

rfcomm0 {
bind yes;
device 00:00:0E:6D:CC:04:7F
channel 1;
comment "darkumoonu";
}

here 00:00:0E:6D:CC:04:7F is the mac address of my mobile. You need to change that accordingly . When you do a “hcitool scan” you'd get all the devices that your box finds. To make sure you are able to reach it you can even ping the device. Type l2ping mac; example

[root@darkmoon bluetooth]# l2ping 00:0E:6D:CC:04:7F
Ping: 00:0E:6D:CC:04:7F from 00:0F:B3:90:86:46 (data size 44) ...
0 bytes from 00:0E:6D:CC:04:7F id 0 time 58.93ms
0 bytes from 00:0E:6D:CC:04:7F id 1 time 17.34ms
0 bytes from 00:0E:6D:CC:04:7F id 2 time 17.31ms
0 bytes from 00:0E:6D:CC:04:7F id 3 time 16.31ms
4 sent, 4 received, 0% loss
Next you need to start the service. Do the following, type “etc/rc.d/init.d/bluetooth restart” or simply “servic bluetooth restart”

Now to talk the mobiles modem, type the following command.

rfcomm bind 00:0E:6D:CC:04:7F 1

This will essentially bind the Phones Modem to /dev/rfcomm0. Now we can check by issuing rfcomm.

[root@darkmoon bluetooth]# rfcomm
rfcomm0: 00:00:0E:6D:CC:04 channel 1 clean

You should get something like that. Ok, that about all you need to do to get your GSM device working with Linux. There is other configurations that you need to do if needed.

Ok, lets get back to Kannel. The Kannel configuration file will be localed in /etc/ edit /etc/kannel.conf

remove all the lines in the file and add the following

group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
log-file = "/tmp/kannel.log"
log-level = 0

group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = 13013
sendsms-chars = "0123456789 +-"
log-file = "/tmp/smsbox.log"
log-level = 0
access-log = "/tmp/smsaccess.log"


group = sendsms-user
username = tester
password = foobar

#Nokia Modem

# SMSC GSM
group = smsc
smsc = at
smsc-id = nokia_smsc
modemtype = nokiaphone
device = /dev/rfcomm0
speed = 9600
pin = BlueZ


group = modems
id = nokiaphone
name = "Nokia Phone"
detect-string = "Nokia Mobile Phone"
init-string = "AT+CNMI=1,2,0,0,0"
speed = 115200
enable-hwhs = "AT+IFC=2,2"
need-sleep = false
no-pin = true
no-smsc = false
sendline-sleep = 100
keepalive-cmd = "AT+CBC;+CSQ"
broken = true
message-storage = "ME"
enable-mms = true

Now do the following

[root@darkmoon etc]# service kannel start
Starting kannel bearer box: [ OK ]
Starting kannel sms box: [ OK ]

That will get Kannel started as a service. If you fail look into the logs at /tmp/ /tmp/kannel.log and tmp/smsbox.log. That will help you to get started to debug and solve the problem.

Ok, So now if kannel is working you should be able to send SMS using the kannel web interface. Example

http://127.0.0.1:13013/cgi-bin/sendsms?username=tester&password=foobar&to=&text=hello from kannel

Type that in your browser. Again. If it gives any problems get back to logs and if needed google around. There is not much help for kannel out on the web, except the kannel documentation and the mailing list. But its easy to figure out most of the issues.

If you have access to a SMSC (if you are a telecom operator) you will need the following to connect to the SMSC. Add the lines to the kannel.conf and bring the needed changes.

group = smsc
smsc = smpp
smsc-id="change"
denied-smsc-id="change"
host = "ip of your SMSC"
port = "port"
receive-port = "port"
smsc-username = "change"
smsc-password = "change"
system-type = ""
address-range = ""
interface-version = 33
source-addr-ton = 1
source-addr-npi = 1

You will need to have routes added to access the SMSC from your network. In my case, I have a FC5 box setup a SMSGW running Kannel and using SMPP to communicate to the SMSC.

So what do we do next. A simple service we can setup is one like Dhiraagu has to offer. Example the Haveeru news service. If someone sends you a SMS with the text “haveeru” we want to SMS him/her the new headlines. To do this we need to write a simple script to fatch the news from haveeru. For this perl is a good choice. So you need to have perl installed on your system. You would also need a cpan library to read the RSS feeds. Execute the following command first

cpan install XML::RSS

This will get the library installed. Next create a perl script called haveeru.pl with the following lines.

#!/usr/bin/perl

# import packages
use XML::RSS;
use LWP::Simple;
use LWP::UserAgent;


# initialize object
$rss = new XML::RSS();

# get RSS data
$raw = get('http://www.haveeru.com.mv/xml/index.php');

# parse RSS feed
$rss->parse($raw);
my $news='(*) ';

foreach my $item (@{$rss->{'items'}}) {
$title = $item->{'title'};
$url = $item->{'link'};
$news = $news . $title .' (*) ';
print("$title\n"); # we will only display the news titles
}


So now to add the service, you will need to add the following lines to the kannel.conf file.

group = sms-service
keyword = haveeru
exec = "/usr/bin/perl /home/darkmoon/perl/haveeru.pl"
accepted-smsc="change as needed"

When the subscriber sends a SMS to a set short code, with the text "haveeru", it will execute the script we have. Then the output will be sent back to the subscriber. So there you go. Now you have a SMS based service up and running. There is a lot more you can do with kannel and others; just play around. Simple and easy.

Tuesday, November 28, 2006

New iPOD addons

A new iPOD addon which is being marketed by a friend of mine. Interesting stuff ey!

Sunday, November 26, 2006

digg the dhivehi way?

I came across this web site (http://www.dhivehin.net/), I'd have to say this is something I really like. Maybe there is not much as of now, but might turn out good (I hope). What I would really like to see is a platform for IT guys to discuss and share stuff. Where people can openly ask questions, share the experiences, etc.

We have been very closed in terms of sharing the knowledge and knowhow. When IT started off in Maldives (back in late 80's and early 90's) not many were willing to share. It was very much a closed platform. Even people did not want to share the softwares they had or even explain how things work or are done ("complicated stuff, they told you"). This I guess really staled a lot during those days, and I guess we never developed enough as we should have. Even now simple things are made to look as big deals. Those days we use to have a gang of "foxpro" lovers; who competed among themselves for projects. Most of these people never evolved (most). I guess mostly the reason was there was not much knowledge sharing and R&D works. No one was really interested all, what mattered was making money out of what you just learned. Maybe this was good for the individuals. As a community I guess we did not benefit much from the pioneers of IT in Maldives. Maybe I might be wrong. I am sorry if I am being too general.

The closed source model as I would put it, is really bad for a community like us. We don't have good universities or even companies who do R&D work or even invest in technology. This I feel results in us being left behind compared to the rest of the world. Example; even if we look at Sir Lanka , they have got institutions, individuals and even communities who are doing so much contribution to technology. Sri Lanka have been contributing to projects like apache(which is the most famous web server) and other projects. Recently Google has given the Lanka Software Foundation USD 25,000 to drive open source software projects locally. So what can we do to improve? Well; I guess it all depends on individuals. Rather then us always telling "what are they doing about that". We hardly say "what can I do about this". Simple if you don't wanna be part of such contribution, just ignore such things (stop even commenting). One good starting point can be the schools. I guess the education system now "sucks"; even if you agree with me or not. Something that can be changed is to try and educate our kids more, lead them in the right directions. Now some kids finish school after doing Computing, without even writing a single line of a program. Its a problem with the system; they don't encourage such things at all. Even the teachers we bring in to teach these kids are not really good enough or have the knowledge. Anyway I don't think these things will change in a near future.

Even though this is the case, I am happy to say there is real talent in Maldives. Hardly people notice these kids and individuals. If anyone would identify these individuals and help them to improve and give them more opportunities, it would really make a difference. If people and companies would set aside the immediate commercial factors and invest on them, it sure would be a good contribution. Simple things like even a word of encouragement is a lot. Anyway I always hope to see a change. I am seeing things change and people developing. The best part of such developments is you get to share what you have learned and also learn from them.

Wednesday, November 22, 2006

The Virtual Employees

The concept might not be new, but I've heard of this term and seen it in a totally different concept. Around a year ago, my boss explained me that "I am looking for virtual staff", who will not be hired by the company and NOT work on our payroll. But will be working for us, in our premises and paid by another company. So the catch is, we pay another company a big amount (yearly) for this service.

Now I don't know how effective that will make things, but sure is being done. I hope to learn from this. So example is; if you have an IT infrastructure , and you need to give support and maintain the network. So what do you do?. Yeah! you hire another company who gives you this service. They will give support and provide you with all the needed help and work. You just relax and your employees are happy too. Why? cos they won't need to do much. They just need to get to the requirements, then pass em on to the virtual employees. So the result is "happy staff", who will not have much stress or load. Plus, you don't need to train your staff too or employee skilled people. cool ey? And yeah you still have to pay the employees and also keep the numbers same. Nothing is changed here. I hope you got the concept.


So this might be just a start, who knows in future we might get companies who will have virtual CEO's, CTO's and even HR Mangers. Even now I know some companies do this. The difference is you keep your staff as they are (with the titles), pay them and hire others to do the work. Neat! Well, I don't know much about management concepts but I am learning. Someday I'd know the advantages and the reasons. As of now I am not "experienced" enough to understand and know the "concepts and reasons"

Saturday, November 18, 2006

Lights, Camera. And.. Action

Seems we are almost connected to the rest of the world via marine fiber cables. WARF Telecom International hit the land first ( a joint venture between Wataniya, Focus Infocom, and Reliance Infocom of India ). The second cable which is owned by Dhiraagu and SLT (Sir Lanka Telecom) has also made it to the shores. This means we should get a lot of bandwidth? Well, lets hope so.

Whole of Male' is a big fiber network now. 2 companies (3 networks) already have their own fiber networks (Cable TV operators). The government owns its own network in Male' as well, and there is talk of another big investment for digital eyes (again utilizing another optical fiber network).

My guess the government will take a share of the Dhiraagu-SLT cable, example take charge of the ".MV" domain, etc (they deserve it anyway). At this point its hard to say. NCIT of Maldives, has been very quite and inactive. They have setup a building with loads of cameras (hmm! the new trend) and a lot of talk about the government network has been around for few years. Although I would like to think that, there is no proper infrastructure plan. But most likely it is goona be a good entertainment network. You'd be able to share your "prison break", mp3's and other stuff with your friends in other offices. And yeah with good network speeds (hopefully). So thats good news for all you government employees, yeah with good internet speeds (again hopefully, depending on how good your local Network is). As for the digital eyes on the roads, it will be good for the people who own them. A warning to the rest of the guys; "don't bother picking on a girl of men in blue". They'd find out. :) Also it will be good entertainment for them to monitor and watch the birds as they walk by. If you are a girl, who is hooked up with one of them. an aah! you will be so busted on that evening rides. So yeah! its a lot of entertainment on the way. The digital media age is here. Welcome the lights!

Binux

OMG! read this Micro$oft CEO says Linux "uses our intellectual property". Come on Mr. Ballmer, have you run out of things to say? or were you addressing a bunch of stupid people?. I just can't understand why this guy would say that. I mean he is the CEO of Micro$oft. hmmm! maybe thats why he said so. If you really think about the facts, he does not make any sense. I don't get it at all. So did he mean Winbows and rest of M$ code was on the public domain and the OSS community just used the code into Linux? If we really think about the whole thing, its M$ who has been using other peoples intellectual property. Yes from the very start, they have had a history of steeling code. Starting from DOS. Now they wanna claim that Linux belongs to them? This really is a good joke.

Ok I can understand if they are talking of patent. Then its the totally different case. But if M$ tries to show to the rest of the world that Linux uses or copied M$ code, then that is hilarious. Linux was a multitasking and a network OS way before Winbows. Linux has always been far ahead of Winbows and still is.

Ok Ballmer, show us the stuff (code) which was taken off M$... and yeah PROVE it. I make a promise I'd take off Linux, off my System and switch to Winbows. From what I can see, M$ knows they have lost the war. Now they are just trying to be part of the OSS world and trying to change the history. Maybe they want to rewrite it as; when Gates was in University of Washington he started a project which later become "Linux". hmmm! or maybe "Binux". Might just be true. They are on the track now. Novell owns the rights to UNIX, and a key player of the Linux world, M$ is trying to buy over them now? (who knows).

Wednesday, November 15, 2006

Finally, FOSS Java!

I think its worth a note that Sun has decided that Java will be open sourced. Its really a good news for the open source movement and for Java developers. Since Java's introduction 11 years ago, it has been leading in the middleware space. Maybe the openness of Sun, has been one of the key factors of the success of Java. The recent move to open source Java will likely bring Java to more platforms and better performance.

The way I see it, the dot Net and Java war is not over. It just started off. A lot of enterprise platforms are dominated by *nix and Micro$oft has already made its move to tap in, by supporting Novell. This move by M$, could be a step to push dot Net to the Linux world (maybe by supporting the mono project?). Lets see what happens next.

Google Reader

Yapee! Just tried the Google Reader, its really a cool service. Now I can read my favorite blogs and news from one single site. There has been any RSS readers and tools, but I guess Google always does thing better them most. Best part I like about such tools is the minimization of navigation. Example, I don't need to go into www.mvblogs.org and browse through the list and jump to each blog. I can create a list of all my favorite blogs and read everything from one spot. Plus it works some what like an email client. You are able to distinguish between unread posts and post that you have already read. Ah, so all thanks to Google.

Tuesday, November 14, 2006

good deal!

June 19, 2006

Pro-whaling countries within the International Whaling Commission celebrated yesterday after a resolution was passed which stated that the commission's 20-year moratorium on commercial whaling is "no longer necessary" and which went on to blame whales for depleting fish stocks. 33 countries voted in favour of the resolution, with 32 voting against, and China abstaining. The vote is considered a victory for Japan, which has long argued for a return to commercial whaling, and has been 'recruiting' sympathetic nations to join the IWC in order to bolster its vote.

The vote does not directly enable a return to commercial whaling, as that would require a three quarters majority, but is significant in being the first time that a major vote at the IWC has sided with the pro-whaling nations in two decades.
also...
June 20, 2006

New Zealand Prime Minister Helen Clark has accused Japan of creating a rift between Pacific Countries. She accuses Japan of influencing the voting of some member nations of the Pacific Island Forum at the International Whaling Commission by supplying vast amounts of aid to certain small pacific nations.

New Zealand provides a total of $23 million a year in aid to three of the six Pacific nations – Kiribati, the Solomons, and Tuvalu. Japan pledged approximately 45 billion yen (NZ $633 million) in aid for all Pacific nations. New Zealand's annual budget for aiding pacific nations on the other hand totals merely NZ $173 million.

Miss Clark is quoted as saying "One would hope that over time Japan might reflect on the damage this is doing to [its] relationships around the world" and that it "sprayed a lot of money around" to garner support.

The Prime Minister has ruled out any retaliation against the islands, saying it would not affect any future aid funding.

source
http://en.wikinews.org/wiki/IWC_passes_pro-whaling_resolution_after_close_vote
http://en.wikinews.org/wiki/New_Zealand_PM_faults_Japan_over_Whaling_Commission_vote

Friday, November 10, 2006

Linux at homes?

I needed an OS that could work for humans! meaning it should be able to watch movies, surf the net, chat, word process and lucky no games much (not windows) . So I decided to move to Ubuntu, only problem was the Dhiraagu ADSL usb modem was giving problems. Then I decided anyway since I too use my notebook at home, I'd dump the USB ADSL modem and go for a wifi router. That way everyone can share the net. So finally I got a D-Link DSL G604T. And installed ubuntu on my wifes notebook (yeah migrated her from windows to linux. pls note that , she did not have a choice here) . Works like a charm. And even my notebook which runs on fedora works cool. No complains thus far. So I am assuming ubuntu lives up to its name, linux for humans.

Anyway, so you'd say I am a freak and I installed ubuntu at my home. No one else would. Well, no I know a few more guys who do use nothing but linux. But the point now I wanna make is, Linux is at your homes, maybe without you knowing it. yeah! Like in my case I got down this ADSL router. This is a common device for the offices and homes now. The chance is, if you own one then you are having linux at your home/office (like it or not). Yeah this baby run on linux and acts as your firewall/gateway and AP. Its got an easy to use web interface for you to set things up and works good. If you wanna play around more you can telnet to the box, and can do a lot more.




If you do a version check on the device it should get you something like this.
Linux version 2.4.17_mvl21-malta-mips_fp_le (lily@products.adsl) (gcc version 2.95.3 20010315 (release/MontaVista)) #60 Wed Nov 10 09:49:30 CST 2004

new template

I kinda been blogging for like 3 years now. Mostly my templates been very static for long. I am not much of a visual designer. Anyway a lot of the guys think its too dark and it needs a change? daaa? ok. so a change, from black to white. :) Someone help me with this CSS shit, I hate em'.

Wednesday, November 08, 2006

dhivehi version 1.6.1a?

its amazing; the dhivehi language. It really is. Anyway its not about how rich the language or how poor and stupid it is. This is about the dhievhi version 1.6.1a, which is the bangaalhee version of dhivehi. I don't know from where it came or who invented it. Seems its is there. No one knows the origins, they talk in that language and we to them. Take for example you want to ask a bangalhee if he has had lunch or dinner, etc.
you would say " ކަލޭ ކާވައްތަރު ހުއްނަނީ؟ " , which kinda means are you edible? or close to that. but in reality when said this to a bangaalhee or any other foreigner, it means have you had food? (lunch, dinner, etc). I some times wonder, why we use this method of communication when it comes to talking with foreigners using dhivehi? common answer might be "our language is too complex and if we talk normally they won't understand" ? WOW ? is it that complex ? I don't know the answer. But it sure is funny to listen to these conversations.

Tuesday, November 07, 2006

compiz and swing

FC6 rocks, thats the first thing that i'd have to say about FC6. All most everything worked fine for me, except my IDE did not work. I use NetBeans 5.5 for some of my development work. Since FC6 came with the compiz and it had some good eye candy options, I had it enabled.

My other Java based applications (desktop apps) did not work as well. I did not get any errors. Just that The display was f*cked up. So next I installed KDE (I don't know why), and gave it a try. Seemed it was working fine with KDE. hmmm! So after a little look up, I realized that it was a problem with Java Swing when run under compiz wm. Or its a problem with compiz? I don't think thats the case. But it does not work, unless you have the desktop effects disabled. So no more eye candy. I am not sure if this is the same with XGL, my my guess is it will be.

Likely its related to the some problem with the Swing/AWT? Not so sure. But I am sure there will be workarounds to fix this problem.

Friday, November 03, 2006

...And the headlines..


* Dogs and cats are sleeping together
* Pat Robertson simultaneously converts to Judaism and Islam.
* Osama gets laid, changes his mind about destroying world.
* Scientists discover smoking is good for you.
* Microsoft is supporting Suse Linux.


-- From http://linux.slashdot.org/linux/06/11/02/1957252.shtml --

Wednesday, November 01, 2006

M$ Zend?

Zend the PHP development frame work have stuck a partnership with Microsoft. For me this looks like a move by Microsofts to dominate the WEB Server market. As PHP runs on around 22 million Web sites and is used inside 15,000 companies. Why Zend ?, Zend is a key promoter and developer of of PHP.

A lot of development of PHP based web sites is done by individuals; but mostly when it comes to hosting maybe 90% of them host them on Linux or BSD based servers. One major reason being the performance. Also there is few hosting companies and people who recommend PHP based sites to be hosted on Windows Servers. How ever this is not a news which will be very welcomed by the open source community. There will be others who might take this as a positive move too. Maybe the road to PHP#? :P So next will be mySQL? Maybe Microsoft has finally started to realize that ASP sucks ? and that they can't beat the OSS community and its best to join them, if they can't beat them? Who knows. Its a well known fact that Microsoft has used code from the open source communities. Example a lot of the network layer of initial Windows 2000 code used BSD code. Also the new vista has been working hard to mimic the look and feel of Gnome, KDE and even Mac OS X. And yeah the "power shell"? a replacement for the weak CLI in windows. Anyway thats a totally different story, which will lead no where. The best answer is stick to something which you are confabulate and easy with. Thats the best choice for you. Be it Windows, Mac, Linux or daaa! a PS3 (woo, Linux again)?

This move might be something good for most M$ Maldivian developers, who really are used to the M$ stuff. Lately PHP has also gained a lot of popularity as a web development language. We do have a few ASP guys too, but I would say most people still prefer PHP over ASP. I remember a time back in early 1990's foxpro was the thing here. Back then if you tell them about a language like VB they will joke at you. Late 90's that changed and by mid 2005 its now M$ dot NET. Even the government want to move to .NET platform and M$ SQL? People hardly look into other options like Java and Java based frameworks. Same goes for even PHP, I only know a few developers who have worked with PHP frameworks, like Cake and seagull. But these are good options to look into if you are into PHP, makes your life a lot easier. Also there is other alternatives people can look into like Ruby on Rails and Python with Zope. Personally I don't have much experience when it comes to web development, so I don't wanna comment more on the topic. But my guess is the reason why most hardcore developments with PHP is based on *nix hosting is beyond performance issues. There is a lot of advantages that you get on *nix over windows, when it comes to servers.