Gnokii::GSM - Object interface to Gnokii


  use Gnokii::GSM;


Gnokii::GSM provides an perlinterface to routines defined in gsm-common.h of the gnokii-package. What you will find here are all the routines from that headerfile plus some utility-routines to make life a little easier for the application-developer. The whole thing is a 'little bit' objectorientated.


The first thing you need is a working reference to your phoneconnection. You get this with a new, that gets the modelname of your phone and the filename of the device. Example:

  $gsm=new("/dev/ttyS1", "6150");


The following methods are available (this will grow as Pavel and Gary implement more):


(this is called automatically by new, it expects that model and device are stored in the object)


index is the Index in the memory and MemoryType ``ME'' for the internal memory of the mobile equipment, ``SM'' for SIM, ``FD'' for the fixed dial numbers, ``ON'' for the own numbers of the holder of the SIM, ``EN'' for the emergency numbers, ``DC'' for the recently dialed numbers, ``RC'' for the recently received numbers, ``MC'' for the numbers that were missed, ``LD'' for the number dialed last, ``MT'' for both Phonememory and SIM. After the call there is a Entry in the Object stored as ``PBEntry''. It is a Hashreference with the following structure:

  $gsm->{'PBEntry'}->{'Memory'} as described above

Also see for examples to use this.


This routine get the whole phonebook of all memorytypes and stores it in an array of PBEntries in the Object.

  $gsm->WritePhonebookLocation($PBEntryHash, $index)

This routine stores the Entry in $PBentryHash at location, note that the memorytype is stored in the hash.


This routine stores a hashreference called ``Memory'' in the gsm-object you can access the information in this way:


$MEMORY_TYPE is one of the available types as described in the phonebook calls.


This Routine works similar to GetMemoryStatus. The Hash the information is stored in is called ``SMSStatus'' and look like this:


This Routine gets the SMSCenter stored on the phone. It stores a hash with the following structure in the reference:


No is the number in the memory. Name is the name of the center and Number is the phonenumber of the center.

  $gsm->GetSMSMessage($location, $index)

This routine retrieves the SMSMessage stored at $index in memorytype $location (A or B). It stores the information in a hashreference called ``Msg'' with the following structure:


I don't know if Length and Validity are actually used. The Date-Entry is in seconds since 1970.

  $gsm->DeleteSMSMessage($memory, $location)

This routine deletes the SMSMessage that's stored in memory at location.


$msghash has to be setup like the one above that's retrieved by GetSMSMessage but only the entries ``MessageText'', ``MessageCenter'' and ``Destination'' have to be filled out. Note that the ``MessageCenter'' parameter means the Index of the MessageCenter stored in the phone's memory. Validity and Class will get 4320 and -1 unless specified in the hash. The messagetext should be checked for 8Bit-Characters and if there are any {'EightBit'} should be set.


This routines stores the RFLevel and the BatteryLevel in the object under the same name. Unittype is the type of Units. Currently only 0 is supported.


This routine either stores ``ACDC'' or ``Battery'' in the object-attribute ``PowerSource''.


This routine gets the displayy status in the object-attribute ``DisplayStatus''.


Tries to enter the securitycode stored in $sechash. Sechash has the following structure:

  $sechash->{'Type'} integer (see gsm-common.h the GSM_SecurityCodeType-Enum)
  $sechash->{'Code'} the code

This routine gets the securitycodestatus and stores it in the object-attribute ``SecurityCodeStatus''.


``IMEI'' is stored into the gsm-object.


``Revision'' is stored into the gsm-object.


``Model'' is stored into the gsm-object.


This routine stores the Phonetime in the phoneobject in the Unixlike manner of seconds since 1.1.1970. The name of the attribute in the gsmobject is ``Date''.


$time are seconds since 1970. This makes synchronizing the phone with the computer quite simple in doing:


Note that internally the localtime() call is used so beware of daylightsavingtime-troubles if your machine is not configured correctly.


This get the alarm stored at $alarm_number. Afterwards you can access it this way in the object:

  $gsm->SetAlarm($index, $datetime)

This routine sets the Alarm at index $index to $datetime. $datetime is specified in the time()-Format.


This Routine simply dials the number specified in $number.


If there is a number from an incoming call to retrieve it is stored into the object-Attribute ``Number''.


This routine gets the current NetworkId, CellID and LAC and stores them in a hash calles NetworkInfo. So you can access these values by


This routine gets all stored calendarnotes from the phone and stores them in the array $gsm->{'CalendarNotes'}. Each entry has the following structure:


GetCalendarNotes calls the routine GetCalendarNote(index) which can be used also. It returns the retrieved values in $gsm->{'CalendarNote'} with the same structure.

  $gsm->WriteCalendarNote($hash, $index)

$hash is of the above structure, $index is the index on the phone where it shall be stored to. But this isn't currently working correctly.


This routine deletes the CalendarNote at $index in the phone.

There is an array @Gnokii::GSM::CALENDARTYPES which contains the names for the indexes returned by the 'Type' attribute.


As in gnokii itself mode can be one of reset, off, field, devel or next. The resulting string is stored in the object-attribute ``Screen''.


Sends ``String'' as DTMF-String to the phone, whatever that means.

  $gsm->GetBitmap("type", "callgroup")

This routine gets the bitmap of type ``type'' and the optional callgroup and stores in the object-attribute ``Bitmap''. As in gnokii type can be one of op, caller or startup. With caller the callgroup has to be supplied as second argument. ``Bitmap'' has the following structure:


This routine expects, that the ``Bitmap''-Attribute is filled with the information in the same structure as shown above.


This routine resets the phone ``type'' can be either ``soft'' or ``hard''. This function is not tested, so proceed with care \:)


This routine gets the profile at the provided index and stores it in an object-attribute named ``Profile''. This attribute has the following structure:


This routine expects, that there is an object-attribute ``Profile'' with the structure shown above, and stores it into the phone. This routine is not tested, so be careful.0

  $gsm->SendLogo($filename, $destination)

$filename is the name of a logofile and $destination is the phonenumber where You want to send it.

  $gsm->SendRingTone($filename, $destination)

$filename is the name of a rttl and $destination is the phonenumber where You want to send it.

Exported constants



All routines return the GSM_Error returned from the appropriate fbus-*-function. Take a look at gsm-common.h to see which is which.


Konstantin Agouros,


perl(1) and the sourcecode of gnokii \:))))