Skip to content
thyagarajan edited this page Sep 13, 2010 · 16 revisions

Welcome to the rubynokii wiki
by Thyagarajan Shanmugham

gratitude and special thanks to
pkot,dforsi oftopik at #gnokii room on irc and all the members of the gnokii development team.

RubyNokii is the ruby extension for Gnokii. RubyNokii intends to serve the ruby development community.RubyNokii facilitates for those ruby application to have sms facility without demanding internet.RubyNokii is the project which exposes the api’s which are written in C code of Gnokii to the ruby world. RubyNokii 0.1.1 is more of a demonstration of ruby extension which is wired to gnokii engine.

Before cooking the meal, few arrangement of the cooking apparatus is need. Analogically here i mean gnokii as a cooking apparatus, installing and testing the gnokii engine is the first task and to be called step 0.Please go through www.gnokii.org regarding with the installation,configuration of gnokii and kindly take note of the supported mobile phones from gnokii wiki at www.gnokii.org .Some phones like Nokia 6110 Navigator only supports one way of communication, with this we can only send sms but can not receive, I have also tested Sony Erricson w 700i works for both sending and receiving sms.

I would suggest the reader to compile the gnokii engine from source. In ubuntu , one needs two packages namely md4 and flex installed before compilation of the gnokii source. The url at http://www.developershome.com/sms/installGnokii.asp is a good introduction for compiling gnokii from source and the url at www.gnokii.org is cool for configuration. Kindly test the gnokii in the command line, without which rubynokii will never work.

After making sure of gnokii works in the command line, now spicing with rubynokii preparation. Before proceeding any further, please make sure you are installed with ruby and git. Get a clone copy of rubynokii from github.com by issuing the following command ,finally compile it to a shared object as follows

$cd
$cd projectdir
$pwd
~/projectdir
$git clone git://github.com/thyagarajan/rubynokii.git
$cd rubynokii
$ruby extconf.rb
$make

you will find a new file by name rubynokii.so compiled as a shared object. This is the file which exposes the api’s of gnokii to the ruby world.
There are four stages to operate rubynokii ,ie 0) include the rubynokii and instantiate the class BaseChildClass under RubyNokiiMod Module. 1)initialize the mobile phone 2)do activity(say sending/receiving sms) 3)close the relevant ports and quit.

Let me put it in this way by using irb,

step a:

first include the rubynokii shared object by using require command

irb(main):001:0> require ‘rubynokii’
=> true

step b:

instantiate an instance variable this_instance to class BaseChildClass under RubyNokiiMod

irb(main):002:0> this_instance = RubyNokiiMod::BaseChildClass.new
=> #

step c:

initiate the phone by issuing the businit command to this_instance
irb(main):003:0> this_instance.businit

and the debug output of the above command is something like this

Orphaned line: There are few main models that should make use of the certain drivers.
LOG: debug mask is 0×1
Config read from file /home/thyagu/.gnokiirc.
phone instance config:
model = AT
port = 00:1F:DF:AE:C4:0A
connection = bluetooth
initlength = default
serial_baudrate = 19200
serial_write_usleep = -1
handshake = software
require_dcd = 0
smsc_timeout = 10
rfcomm_channel = 1
sm_retry = 0
Initializing AT capable mobile phone …
Serial device: opening device 00:1F:DF:AE:C4:0A
Message sent: 0×00 / 0×0004
41 54 5a 0d | ATZ
write: [ATZ]
read : [ATZOK]
Message received: 0×00 / 0×000a
02 41 54 5a 0d 0d 0a 4f 4b 0d | ATZ OK
Received message type 00
Message sent: 0×00 / 0×0005
41 54 45 31 0d | ATE1
write: [ATE1]
read : [ATE1OK]
Message received: 0×00 / 0×000b
02 41 54 45 31 0d 0d 0a 4f 4b 0d | ATE1 OK
Received message type 00
Message sent: 0×00 / 0×000a
41 54 2b 43 4d 45 45 3d 31 0d | AT+CMEE=1
write: [AT+CMEE=1]
read : [AT+CMEE=1OK]
Message received: 0×00 / 0×0010
02 41 54 2b 43 4d 45 45 3d 31 0d 0d 0a 4f 4b 0d | AT+CMEE=1 OK
Received message type 00
Message sent: 0×06 / 0×0007
41 54 2b 47 4d 4d 0d | AT+GMM
write: [AT+GMM]
read : [AT+GMMNokia 3110cOK]
Message received: 0×06 / 0×001c
02 41 54 2b 47 4d 4d 0d 0d 0a 4e 6f 6b 69 61 20 | AT+GMM Nokia
33 31 31 30 63 0d 0a 0d 0a 4f 4b 0d | 3110c OK
Received message type 06
Message sent: 0×06 / 0×0008
41 54 2b 43 47 4d 49 0d | AT+CGMI
write: [AT+CGMI]
read : [AT+CGMINokiaOK]
Message received: 0×06 / 0×0017
02 41 54 2b 43 47 4d 49 0d 0d 0a 4e 6f 6b 69 61 | AT+CGMI Nokia
0d 0a 0d 0a 4f 4b 0d | OK
Received message type 06
Message sent: 0×61 / 0×0009
41 54 2b 43 53 43 53 3f 0d | AT+CSCS?
write: [AT+CSCS?]
read : [AT+CSCS?CSCS: “PCCP437”OK]
Message received: 0×61 / 0×0023
02 41 54 2b 43 53 43 53 3f 0d 0d 0a 2b 43 53 43 | AT
CSCS? +CSC
53 3a 20 22 50 43 43 50 34 33 37 22 0d 0a 0d 0a | S: “PCCP437”
4f 4b 0d | OK
Received message type 61
Initialisation completed
=> 0

step d:

Sending sms with this_instance takes a tupple value as arguments for the method sendsms. argv0 should be the message and argv1 should be the mobile phone number in the international mobile phone nmber format ex ‘+919XXXXXXXXX’ where X denotes a number.Please replace all these X’s with valid numbers.

irb(main):004:0> this_instance.sendsms [‘This is a example,test of courage is to live,not to die’,‘+9198XXXXXXXX’]

and the debug output of this command

Message sent: 0×23 / 0×0009
41 54 2b 43 53 43 41 3f 0d | AT+CSCA?
write: [AT+CSCA?]
read : [AT+CSCA?CSCA: "919840011003",145OK]
Message received: 0×23 / 0×002d
02 41 54 2b 43 53 43 41 3f 0d 0d 0a 2b 43 53 43 | AT+CSCA? CSC
41 3a 20 22 2b 39 31 39 38 34 30 30 31 31 30 30 | A: "
91984001100
33 22 2c 31 34 35 0d 0a 0d 0a 4f 4b 0d | 3",145 OK
Received message type 23
Message is : This is a example,test of courage is to live,not to die, General Data Coding
dcs: 0×0
Length: 0×37
user_data_length: 0×31
ValidityIndicator: 2
user_data: 54747A0E4ACF416150191F6EC3D96516BD3CA783DE66D0F85D9787CF65507A0EA2BF41ECB4BDCC72BFE920FA1B444E9701
Sending
Message sent: 0×63 / 0×000a
41 54 2b 43 4d 47 46 3d 30 0d | AT+CMGF=0
write: [AT+CMGF=0]
read : [AT+CMGF=0OK]
Message received: 0×63 / 0×0010
02 41 54 2b 43 4d 47 46 3d 30 0d 0d 0a 4f 4b 0d | AT+CMGF=0 OK
Received message type 63
PDU mode set
Sending initial sequence
Message sent: 0×64 / 0×000b
41 54 2b 43 4d 47 53 3d 36 33 0d | AT+CMGS=63
write: [AT+CMGS=63]
read : [AT+CMGS=63> ]
Message received: 0×64 / 0×000f
01 41 54 2b 43 4d 47 53 3d 36 33 0d 0d 0a 3e | AT+CMGS=63 >
Received message type 64
Got response 0
Sending frame: 079119890410013031000C911989041444540000AA3754747A0E4ACF416150191F6EC3D96516BD3CA783DE66D0F85D9787CF65507A0EA2BF41ECB4BDCC72BFE920FA1B444E9701

Message sent: 0×21 / 0×008f
30 37 39 31 31 39 38 39 30 34 31 30 30 31 33 30 | 0791198904100130
33 31 30 30 30 43 39 31 31 39 38 39 30 34 31 34 | 31000C9119890414
34 34 35 34 30 30 30 30 41 41 33 37 35 34 37 34 | 44540000AA375474
37 41 30 45 34 41 43 46 34 31 36 31 35 30 31 39 | 7A0E4ACF41615019
31 46 36 45 43 33 44 39 36 35 31 36 42 44 33 43 | 1F6EC3D96516BD3C
41 37 38 33 44 45 36 36 44 30 46 38 35 44 39 37 | A783DE66D0F85D97
38 37 43 46 36 35 35 30 37 41 30 45 41 32 42 46 | 87CF65507A0EA2BF
34 31 45 43 42 34 42 44 43 43 37 32 42 46 45 39 | 41ECB4BDCC72BFE9
32 30 46 41 31 42 34 34 34 45 39 37 30 31 1a | 20FA1B444E9701
write:
[079119890410013031000C911989041444540000AA3754747A0E4ACF416150191F6EC3D96516BD3CA783DE66D0F85D9787CF65507A0EA2BF41ECB4BDCC72BFE920FA1B444E9701^Z]
read :
[079119890410013031000C911989041444540000AA3754747A0E4ACF416150191F6EC3D96516BD3CA783DE66D0F85D9787CF65507A0EA2BF41ECB4BDCC72BFE920FA1B444E9701^Z
+CMGS: 228OK]
Message received: 0×21 / 0×00a3
02 30 37 39 31 31 39 38 39 30 34 31 30 30 31 33 | 079119890410013
30 33 31 30 30 30 43 39 31 31 39 38 39 30 34 31 | 031000C911989041
34 34 34 35 34 30 30 30 30 41 41 33 37 35 34 37 | 444540000AA37547
34 37 41 30 45 34 41 43 46 34 31 36 31 35 30 31 | 47A0E4ACF4161501
39 31 46 36 45 43 33 44 39 36 35 31 36 42 44 33 | 91F6EC3D96516BD3
43 41 37 38 33 44 45 36 36 44 30 46 38 35 44 39 | CA783DE66D0F85D9
37 38 37 43 46 36 35 35 30 37 41 30 45 41 32 42 | 787CF65507A0EA2B
46 34 31 45 43 42 34 42 44 43 43 37 32 42 46 45 | F41ECB4BDCC72BFE
39 32 30 46 41 31 42 34 34 34 45 39 37 30 31 1a | 920FA1B444E9701
0d 0a 2b 43 4d 47 53 3a 20 32 32 38 0d 0a 0d 0a | +CMGS: 228
4f 4b 0d | OK
Received message type 21
Message sent (reference: 228)
Send succeeded!
=> 0

step e


Before to exit , we need to close the port.Issuing a busterminate command will close the port
irb(main):005:0> this_instance.busterminate
Serial device: closing device
=> 0

TODO’s


1.Code refactoring & rewriting the code where ever it demands
2.Exception handling
3.Code Testing with various mobile phone models.
4.Building Custom application using rubynokii

This is the pre alpha release doc of rubynokii, kindly email any queries of yours to me. my email id is thyagarajan at gmail dot com.

Clone this wiki locally