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):
Initialize($device)
(this is called automatically by new, it expects that model and device are stored in the object)
$gsm->GetMemoryLocation($index,$MemoryType)
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'}->{'Name'} $gsm->{'PBEntry'}->{'Number'} $gsm->{'PBEntry'}->{'Memory'} as described above $gsm->{'PBEntry'}->{'Group'}
Also see test.pl for examples to use this.
$gsm->GetPhonebook()
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.
$gsm->GetMemoryStatus()
This routine stores a hashreference called ``Memory'' in the gsm-object you can access the information in this way:
$gsm->{'Memory'}->{$MEMORY_TYPE}->{'Used'} $gsm->{'Memory'}->{$MEMORY_TYPE}->{'Free'}
$MEMORY_TYPE is one of the available types as described in the phonebook calls.
$gsm->GetSMSStatus()
This Routine works similar to GetMemoryStatus. The Hash the information is stored in is called ``SMSStatus'' and look like this:
$gsm->{'SMSStatus'}->{'Unread'} $gsm->{'SMSStatus'}->{'Number'}
$gsm->GetSMSCenter()
This Routine gets the SMSCenter stored on the phone. It stores a hash with the following structure in the reference:
$gsm->{'SMSCenter'}->{'No'} $gsm->{'SMSCenter'}->{'Name'} $gsm->{'SMSCenter'}->{'Number'}
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:
$gsm->{'Msg'}->{'Length'} $gsm->{'Msg'}->{'Validity'} $gsm->{'Msg'}->{'MessageText'} $gsm->{'Msg'}->{'MessageCenter'} $gsm->{'Msg'}->{'Sender'} $gsm->{'Msg'}->{'Destination'} $gsm->{'Msg'}->{'Memory'} $gsm->{'Msg'}->{'Date'} $gsm->{'Msg'}->{'Type'} $gsm->{'Msg'}->{'Status'} $gsm->{'Msg'}->{'Class'} $gsm->{'Msg'}->{'EightBit'} $gsm->{'Msg'}->{'Compression'}
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.
$gsm->SendSMSMessage($msghash)
$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.
$gsm->GetRFLevel(Unittype) $gsm->GetBatteryLevel(Unittype)
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.
$gsm->GetPowerSource()
This routine either stores ``ACDC'' or ``Battery'' in the object-attribute ``PowerSource''.
$gsm->GetDisplayStatus()
This routine gets the displayy status in the object-attribute ``DisplayStatus''.
$gsm->EnterSecurityCode($sechash)
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
$gsm->GetSecurityCodeStatus()
This routine gets the securitycodestatus and stores it in the object-attribute ``SecurityCodeStatus''.
$gsm->GetIMEI()
``IMEI'' is stored into the gsm-object.
$gsm->GetRevision()
``Revision'' is stored into the gsm-object.
$gsm->GetModel()
``Model'' is stored into the gsm-object.
$gsm->GetDateTime()
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''.
$gsm->SetDateTime($time)
$time are seconds since 1970. This makes synchronizing the phone with the computer quite simple in doing:
$gsm->SetDateTime(time())
Note that internally the localtime()
call is used so beware of
daylightsavingtime-troubles if your machine is not configured
correctly.
$gsm->GetAlarm($alarm_number)
This get the alarm stored at $alarm_number. Afterwards you can access it this way in the object:
$gsm->{'Alarms'}->[0]->{'Date'} $gsm->{'Alarms'}->[0]->{'Enabled'}
$gsm->SetAlarm($index, $datetime)
This routine sets the Alarm at index $index to $datetime. $datetime is specified in the time()-Format.
$gsm->DialVoice($number)
This Routine simply dials the number specified in $number.
$gsm->GetIncomingCallnr()
If there is a number from an incoming call to retrieve it is stored into the object-Attribute ``Number''.
$gsm->GetNetworkInfo()
This routine gets the current NetworkId, CellID and LAC and stores them in a hash calles NetworkInfo. So you can access these values by
$gsm->{'NetworkInfo'}->{'NetworkCode'} $gsm->{'NetworkInfo'}->{'CellID'} $gsm->{'NetworkInfo'}->{'LAC'}
$gsm->GetCalendarNotes()
This routine gets all stored calendarnotes from the phone and stores them in the array $gsm->{'CalendarNotes'}. Each entry has the following structure:
$gsm->{'CalendarNotes'}->[0]->{'Type'} $gsm->{'CalendarNotes'}->[0]->{'Date'} $gsm->{'CalendarNotes'}->[0]->{'Text'} $gsm->{'CalendarNotes'}->[0]->{'Phone'} $gsm->{'CalendarNotes'}->[0]->{'Alarm'}
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.
$gsm->DeleteCalendarNote($index)
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.
$gsm->NetMonitor("mode")
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''.
$gsm->SendDTMF("string")
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:
$gsm->{'Bitmap'}->{'height'} $gsm->{'Bitmap'}->{'width'} $gsm->{'Bitmap'}->{'size'} $gsm->{'Bitmap'}->{'netcode'} $gsm->{'Bitmap'}->{'text'} $gsm->{'Bitmap'}->{'bitmap'} $gsm->{'Bitmap'}->{'number'} $gsm->{'Bitmap'}->{'ringtone'}
$gsm->SetBitmap()
This routine expects, that the ``Bitmap''-Attribute is filled with the information in the same structure as shown above.
$gsm->Reset("type")
This routine resets the phone ``type'' can be either ``soft'' or ``hard''. This function is not tested, so proceed with care \:)
$gsm->GetProfile(index)
This routine gets the profile at the provided index and stores it in an object-attribute named ``Profile''. This attribute has the following structure:
$gsm->{'Profile'}->{'Name'} $gsm->{'Profile'}->{'Number'} $gsm->{'Profile'}->{'KeypadTone'} $gsm->{'Profile'}->{'Lights'} $gsm->{'Profile'}->{'CallAlert'} $gsm->{'Profile'}->{'Ringtone'} $gsm->{'Profile'}->{'Volume'} $gsm->{'Profile'}->{'MessageTone'} $gsm->{'Profile'}->{'WarningTone'} $gsm->{'Profile'}->{'Vibration'} $gsm->{'Profile'}->{'CallerGroups'} $gsm->{'Profile'}->{'AutomaticAnswer'}
$gsm->SetProfile()
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.
GSM_GROUPS_NOT_SUPPORTED GSM_MAX_DESTINATION_LENGHT GSM_MAX_DEVICE_NAME_LENGTH GSM_MAX_PHONEBOOK_NAME_LENGTH GSM_MAX_PHONEBOOK_NUMBER_LENGTH GSM_MAX_SENDER_LENGTH GSM_MAX_SMS_CENTRE_LENGTH GSM_MAX_SMS_LENGTH
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, elwood@agouros.de
perl(1)
and the sourcecode of gnokii \:))))