gammu – Mobile phone access¶
This module wraps all python-gammu functionality.
gammu.StateMachine¶
- class gammu.StateMachine(Locale)¶
StateMachine object, that is used for communication with phone.
- Parameters:
Locale (str) – What locales to use for gammu error messages, default is
autowhich does autodetection according to user locales
- AddCalendar(Value)¶
Adds calendar entry.
- Parameters:
Value (dict) – Calendar entry data, see Calendar Object
- Returns:
Location of newly created entry
- Return type:
int
- AddCategory(Type, Name)¶
Adds category to phone.
- Parameters:
Type (str) – Type of category to read, one of
ToDo,PhonebookName (str) – Category name
- Returns:
Location of created category
- Return type:
int
- AddFilePart(File)¶
Adds file part to filesystem.
- Parameters:
File (dict) – File data, see File Object
- Returns:
File data for subsequent calls (Finished indicates transfer has been completed)
- Return type:
dict
- AddFolder(ParentFolderID, Name)¶
Adds folder to filesystem.
- Parameters:
ParentFolderID (str) – Folder where to create subfolder
Name (str) – New folder name
- Returns:
New folder ID.
- Return type:
str
- AddMemory(Value)¶
Adds memory (phonebooks or calls) entry.
- Parameters:
Value (dict) – Memory entry, see Phonebook Object
- Returns:
Location of created entry
- Return type:
int
- AddSMS(Value)¶
Adds SMS to specified folder.
- Parameters:
Value (dict) – SMS data, see SMS Object
- Returns:
Tuple for location and folder.
- Return type:
tuple
- AddSMSFolder(Name)¶
Creates SMS folder.
- Parameters:
Name (str) – Name of new folder
- Returns:
None
- Return type:
None
- AddToDo(Value)¶
Adds ToDo in phone.
- Parameters:
Value (dict) – ToDo data, see Todo Object
- Returns:
Location of created entry
- Return type:
int
- AnswerCall(ID, All)¶
Accept current incoming call.
- Parameters:
ID (int) – ID of call
All (bool) – Answer all calls? Defaults to True
- Returns:
None
- Return type:
None
- CancelAllDiverts()¶
Added in version 1.31.90.
Cancels all call diverts.
- Returns:
None
- Return type:
None
- CancelCall(ID, All)¶
Deny current incoming call.
- Parameters:
ID (int) – ID of call
All (bool) – Cancel all calls? Defaults to True
- Returns:
None
- Return type:
None
- ConferenceCall(ID)¶
Initiates conference call.
- Parameters:
ID (int) – ID of call
- Returns:
None
- Return type:
None
- DeleteAllCalendar()¶
Deletes all calendar entries.
- Returns:
None
- Return type:
None
- DeleteAllMemory(Type)¶
Deletes all memory (phonebooks or calls) entries of specified type.
- Parameters:
Type (str) – Memory type, one of
ME,SM,ON,DC,RC,MC,MT,FD,VM- Returns:
None
- Return type:
None
- DeleteAllToDo()¶
Deletes all todo entries in phone.
- Returns:
None
- Return type:
None
- DeleteCalendar(Location)¶
Deletes calendar entry.
- Parameters:
Location (int) – Calendar entry to delete
- Returns:
None
- Return type:
None
- DeleteFile(FileID)¶
Deletes file from filesystem.
- Parameters:
FileID (str) – File to delete
- Returns:
None
- Return type:
None
- DeleteFolder(FolderID)¶
Deletes folder on filesystem.
- Parameters:
FolderID (str) – Folder to delete
- Returns:
None
- Return type:
None
- DeleteMemory(Type, Location)¶
Deletes memory (phonebooks or calls) entry.
- Parameters:
Type (str) – Memory type, one of
ME,SM,ON,DC,RC,MC,MT,FD,VMLocation (int) – Location of entry to delete
- Returns:
None
- Return type:
None
- DeleteSMS(Folder, Location)¶
Deletes SMS.
- Parameters:
Folder (int) – Folder where to read entry (0 is emulated flat memory)
Location (int) – Location of entry to delete
- Returns:
None
- Return type:
None
Note
In most cases you want to use Folder=0 as in this mode it will accept locations as GetNextSMS returns them.
- DeleteSMSFolder(ID)¶
Deletes SMS folder.
- Parameters:
ID (int) – Index of folder to delete
- Returns:
None
- Return type:
None
- DeleteToDo(Location)¶
Deletes ToDo entry in phone.
- Parameters:
Location (int) – Location of entry to delete
- Returns:
None
- Return type:
None
- DialService(Number)¶
Dials number and starts voice call.
- Parameters:
Number (str) – Number to dial
- Returns:
None
- Return type:
None
- DialVoice(Number, ShowNumber)¶
Dials number and starts voice call.
- Parameters:
Number (str) – Number to dial
ShowNumber (bool or None) – Identifies whether to enable CLIR (None = keep default phone settings). Default is None
- Returns:
None
- Return type:
None
- EnterSecurityCode(Type, Code, NewPIN)¶
Enters security code.
- Parameters:
Type (str) – What code to enter, one of
PIN,PUK,PIN2,PUK2,Phone.Code (str) – Code value
NewPIN (str) – New PIN value in case entering PUK
- Returns:
None
- Return type:
None
- GetAlarm(Location)¶
Reads alarm set in phone.
- Parameters:
Location (int) – Which alarm to read. Many phone support only one alarm. Default is 1.
- Returns:
Alarm dict
- Return type:
dict
- GetBatteryCharge()¶
Gets information about battery charge and phone charging state.
- Returns:
Dictionary containing information about battery state (BatteryPercent and ChargeState)
- Return type:
dict
- GetCalendar(Location)¶
Retrieves calendar entry.
- Parameters:
Location (int) – Calendar entry to read
- Returns:
Dictionary with calendar values, see Calendar Object
- Return type:
dict
- GetCalendarStatus()¶
Retrieves calendar status (number of used entries).
- Returns:
Dictionary with calendar status (Used)
- Return type:
dict
- GetCallDivert(Divert='AllTypes', Type='All')¶
Added in version 1.31.90.
Gets call diverts.
- Parameters:
Divert (Divert Type) – When to do the divert.
Type (Call Type) – What call types to divert.
- Returns:
List of call diverts.
- Return type:
- GetCategory(Type, Location)¶
Reads category from phone.
- Parameters:
Type (str) – Type of category to read, one of
ToDo,PhonebookLocation (int) – Location of category to read
- Returns:
Category name as str
- Return type:
str
- GetCategoryStatus(Type)¶
Reads category status (number of used entries) from phone.
- Parameters:
Type (str) – Type of category to read, one of
ToDo,Phonebook- Returns:
Dictionary containing information about category status (Used)
- Return type:
dict
- GetConfig(Section)¶
- Gets specified config section. Configuration consists of all params which can be defined in gammurc config file:
Model
DebugLevel
Device
Connection
SyncTime
LockDevice
DebugFile
StartInfo
UseGlobalDebugFile
- Parameters:
Section (int) – Index of config section to read. Defaults to 0.
- Returns:
Dictionary containing configuration
- Return type:
dict
- GetDateTime()¶
Reads date and time from phone.
- Returns:
Date and time from phone as datetime.datetime object.
- Return type:
datetime.datetime
- GetDisplayStatus()¶
Acquired display status. :return: List of indicators displayed on display :rtype: list
- GetFilePart(File)¶
Gets file part from filesystem.
- Parameters:
File (dict) – File data, see File Object
- Returns:
File data for subsequent calls (Finished indicates transfer has been completed), see File Object
- Return type:
dict
- GetFileSystemStatus()¶
Acquires filesystem status.
- Returns:
Dictionary containing filesystem status (Used and Free)
- Return type:
dict
- GetFirmware()¶
Reads firmware information from phone.
- Returns:
Tuple from version, date and numeric version.
- Return type:
tuple
- GetFolderListing(Folder, Start)¶
Gets next filename from filesystem folder.
- Parameters:
Folder (str) – Folder to list
Start (bool) – Whether we’re starting listing. Defaults to False.
- Returns:
File data as dict, see File Object
- Return type:
dict
- GetHardware()¶
Gets hardware information about device.
- Returns:
Hardware information as str.
- Return type:
str
- GetIMEI()¶
Reads IMEI/serial number from phone.
- Returns:
IMEI of phone as str.
- Return type:
str
- GetLocale()¶
Gets locale information from phone.
- Returns:
Dictionary of locale settings.
SetLocale()lists them all.- Return type:
dict
- GetManufactureMonth()¶
Gets month when device was manufactured.
- Returns:
Month of manufacture as str.
- Return type:
str
- GetManufacturer()¶
Reads manufacturer from phone.
- Returns:
String with manufacturer name
- Return type:
str
- GetMemory(Type, Location)¶
Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry.
- Parameters:
Type (str) – Memory type, one of
ME,SM,ON,DC,RC,MC,MT,FD,VM- Returns:
Memory entry as dict, see Phonebook Object
- Return type:
dict
- GetMemoryStatus(Type)¶
Gets memory (phonebooks or calls) status (eg. number of used and free entries).
- Parameters:
Type (str) – Memory type, one of
ME,SM,ON,DC,RC,MC,MT,FD,VM- Returns:
Dictionary with information about memory (Used and Free)
- Return type:
dict
- GetModel()¶
Reads model from phone.
- Returns:
Tuple containing gammu identification and real model returned by phone.
- Return type:
tuple
- GetNetworkInfo()¶
Gets network information.
- Returns:
Dictionary with information about network (NetworkName, State, NetworkCode, CID and LAC)
- Return type:
dict
- GetNextCalendar(Start, Location)¶
Retrieves calendar entry. This is useful for continuous reading of all calendar entries.
- Parameters:
Start (bool) – Whether to start. This can not be used together with Location
Location (int) – Last read location. This can not be used together with Start
- Returns:
Dictionary with calendar values, see Calendar Object
- Return type:
dict
- GetNextFileFolder(Start)¶
Gets next filename from filesystem.
- Parameters:
Start (bool) – Whether we’re starting listing. Defaults to False.
- Returns:
File data as dict, see File Object
- Return type:
dict
- GetNextMemory(Type, Start, Location)¶
Reads entry from memory (phonebooks or calls). Which entry should be read is defined in entry. This can be easily used for reading all entries.
- Parameters:
Type (str) – Memory type, one of
ME,SM,ON,DC,RC,MC,MT,FD,VMStart (bool) – Whether to start. This can not be used together with Location
Location (int) – Last read location. This can not be used together with Start
- Returns:
Memory entry as dict, see Phonebook Object
- Return type:
dict
- GetNextRootFolder(Folder)¶
Gets next root folder from filesystem. Start with empty folder name.
- Parameters:
Folder (str) – Previous read folder. Start with empty folder name.
- Returns:
Structure with folder information
- GetNextSMS(Folder, Start, Location)¶
Reads next (or first if start set) SMS message. This might be faster for some phones than using
GetSMS()for each message.- Parameters:
Folder (int) – Folder where to read entry (0 is emulated flat memory)
Start (bool) – Whether to start. This can not be used together with Location
Location (int) – Location last read entry. This can not be used together with Start
- Returns:
Dictionary with SMS data, see SMS Object
- Return type:
dict
- GetNextToDo(Start, Location)¶
Reads ToDo from phone.
- Parameters:
Start (bool) – Whether to start. This can not be used together with Location
Location (int) – Last read location. This can not be used together with Start
- Returns:
Dictionary with ToDo values, see Todo Object
- Return type:
dict
- GetOriginalIMEI()¶
Gets original IMEI from phone.
- Returns:
Original IMEI of phone as string.
- Return type:
str
- GetPPM()¶
Gets PPM (Post Programmable Memory) from phone.
- Returns:
PPM as string
- Return type:
str
- GetProductCode()¶
Gets product code of device. :return: Product code as string. :rtype: str
- GetSIMIMSI()¶
Gets SIM IMSI from phone.
- Returns:
SIM IMSI as string
- Return type:
str
- GetSMS(Folder, Location)¶
Reads SMS message.
- Parameters:
Folder (int) – Folder where to read entry (0 is emulated flat memory)
Location (int) – Location of entry to read
- Returns:
Dictionary with SMS data, see SMS Object
- Return type:
dict
- GetSMSC(Location)¶
Gets SMS Service Center number and SMS settings.
- Parameters:
Location (int) – Location of entry to read. Defaults to 1
- Returns:
Dictionary with SMSC information, see SMSC Object
- Return type:
dict
- GetSMSFolders()¶
Returns SMS folders information.
- Returns:
List of SMS folders.
- Return type:
list
- GetSMSStatus()¶
Gets information about SMS memory (read/unread/size of memory for both SIM and phone).
- Returns:
Dictionary with information about phone memory (SIMUnRead, SIMUsed, SIMSize, PhoneUnRead, PhoneUsed, PhoneSize and TemplatesUsed)
- Return type:
dict
- GetSecurityStatus()¶
Queries whether some security code needs to be entered.
- Returns:
String indicating which code needs to be entered or None if none is needed
- Return type:
str
- GetSignalQuality()¶
Reads signal quality (strength and error rate).
- Returns:
Dictionary containing information about signal state (SignalStrength, SignalPercent and BitErrorRate)
- Return type:
dict
- GetSpeedDial(Location)¶
Gets speed dial.
- Parameters:
Location (int) – Location of entry to read
- Returns:
Dictionary with speed dial (Location, MemoryLocation, MemoryNumberID, MemoryType)
- Return type:
dict
- GetToDo(Location)¶
Reads ToDo from phone.
- Parameters:
Location (int) – Location of entry to read
- Returns:
Dictionary with ToDo values, see Todo Object
- Return type:
dict
- GetToDoStatus()¶
Gets status of ToDos (count of used entries).
- Returns:
Dictionary of status (Used)
- Return type:
dict
- HoldCall(ID)¶
Holds call.
- Parameters:
ID (int) – ID of call
- Returns:
None
- Return type:
None
- Init(Replies)¶
Initialises the connection with phone.
- Parameters:
Replies (int) – Number of replies to wait for on each request. Defaults to 1. Higher value makes sense only on unreliable links.
- Returns:
None
- Return type:
None
- PressKey(Key, Press)¶
Emulates key press.
- Parameters:
Key (str) – What key to press
Press (bool) – Whether to emulate press or release.
- Returns:
None
- Return type:
None
- ReadConfig(Section, Configuration, Filename)¶
Reads specified section of gammurc
- Parameters:
Section (int) – Index of config section to read. Defaults to 0.
Configuration (int) – Index where config section will be stored. Defaults to Section.
Filename (str) – Path to configuration file (otherwise it is autodetected).
- Returns:
None
- Return type:
None
- ReadDevice(Wait)¶
Reads data from device. This should be used in busy wait loop in case you are waiting for incoming events on the device.
- Parameters:
Wait (bool) – Whether to wait, default is not to wait.
- Returns:
Number of bytes read
- Return type:
int
- Reset(Hard)¶
Performs phone reset.
- Parameters:
Hard (bool) – Whether to make hard reset
- Returns:
None
- Return type:
None
- ResetPhoneSettings(Type)¶
Resets phone settings.
- Parameters:
Type (str) – What to reset, one of
PHONE,UIF,ALL,DEV,FACTORY- Returns:
None
- Return type:
None
- SendDTMF(Number)¶
Sends DTMF (Dual Tone Multi Frequency) tone.
- Parameters:
Number (str) – Number to dial
- Returns:
None
- Return type:
None
- SendFilePart(File)¶
Sends file part to phone.
- Parameters:
File (dict) – File data, see File Object
- Returns:
File data for subsequent calls (Finished indicates transfer has been completed), see File Object
- Return type:
dict
- SendSMS(Value)¶
Sends SMS.
- Parameters:
Value (dict) – SMS data, see SMS Object
- Returns:
Message reference as int
- Return type:
int
- SendSavedSMS(Folder, Location)¶
Sends SMS saved in phone.
- Parameters:
Folder (int) – Folder where to read entry (0 is emulated flat memory)
Location (int) – Location of entry to send
- Returns:
Message reference as int
- Return type:
int
- SetAlarm(DateTime, Location, Repeating, Text)¶
Sets alarm in phone.
- Parameters:
DateTime (datetime.datetime) – When should alarm happen.
Location (int) – Location of alarm to set. Defaults to 1.
Repeating (bool) – Whether alarm should be repeating. Defaults to True.
Text (str) – Text to be displayed on alarm. Defaults to empty.
- Returns:
None
- Return type:
None
- SetAutoNetworkLogin()¶
Enables network auto login.
- Returns:
None
- Return type:
None
- SetCalendar(Value)¶
Sets calendar entry
- Parameters:
Value (dict) – Calendar entry data, see Calendar Object
- Returns:
Location of set entry
- Return type:
int
- SetConfig(Section, Values)¶
Sets specified config section.
- Parameters:
Section (int) – Index of config section to modify
Values (dict) – Config values, see
GetConfig()for description of accepted
- Returns:
None
- Return type:
None
- SetCallDivert(Divert, Type, Number, Timeout=0)¶
Added in version 1.31.90.
Sets call divert.
- Parameters:
Divert (Divert Type) – When to do the divert.
Type (Call Type) – What call types to divert.
Number (str) – Phone number where to divert.
Timeout (int) – Optional timeout when divert happens.
- Returns:
None
- Return type:
None
- SetDateTime(Date)¶
Sets date and time in phone.
- Parameters:
Date (datetime.datetime) – Date to set
- Returns:
None
- Return type:
None
- SetDebugFile(File, Global)¶
Sets state machine debug file.
- Parameters:
File (mixed) – File where to write debug stuff (as configured by
SetDebugLevel()). Can be either None for no file, Python file object or filename.Global (bool) – Whether to use global debug structure (overrides File)
- Returns:
None
- Return type:
None
- SetDebugLevel(Level)¶
Sets state machine debug level accorting to passed string. You need to configure output file using
SetDebugFile()to activate it.- Parameters:
Level (str) – name of debug level to use, currently one of: - nothing - text - textall - binary - errors - textdate - textalldate - errorsdate
- Returns:
None
- Return type:
None
- SetFileAttributes(Filename, ReadOnly, Protected, System, Hidden)¶
Sets file attributes.
- Parameters:
Filename (str) – File to modify
ReadOnly (bool) – Whether file is read only. Default to False.
Protected (bool) – Whether file is protected. Default to False.
System (bool) – Whether file is system. Default to False.
Hidden (bool) – Whether file is hidden. Default to False.
- Returns:
None
- Return type:
None
- SetIncomingCB(Enable)¶
Gets network information from phone.
- Parameters:
Enable (bool) – Whether to enable notifications, default is True
- Returns:
None
- Return type:
None
- SetIncomingCall(Enable)¶
Activates/deactivates noticing about incoming calls.
- Parameters:
Enable (bool) – Whether to enable notifications, default is True
- Returns:
None
- Return type:
None
- SetIncomingCallback(Callback)¶
Sets callback function which is called whenever any (enabled) incoming event appears. Please note that you have to enable each event type by calling SetIncoming* functions.
The callback function needs to accept three parameters: StateMachine object, event type and it’s data in dictionary.
- Parameters:
Callback (function) – callback function or None for disabling
- Returns:
None
- Return type:
None
- SetIncomingSMS(Enable)¶
Enable/disable notification on incoming SMS.
- Parameters:
Enable (bool) – Whether to enable notifications, default is True
- Returns:
None
- Return type:
None
- SetIncomingUSSD(Enable)¶
Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services).
- Parameters:
Enable (bool) – Whether to enable notifications, default is True
- Returns:
None
- Return type:
None
- SetLocale(DateSeparator, DateFormat, AMPMTime)¶
Sets locale of phone.
- Parameters:
DateSeparator (str) – Date separator.
DateFormat (str) – Date format, one of
DDMMYYYY,MMDDYYYY,YYYYMMDDAMPMTime (bool) – Whether to use AM/PM time.
- Returns:
None
- Return type:
None
- SetMemory(Value)¶
Sets memory (phonebooks or calls) entry.
- Parameters:
Value (dict) – Memory entry, see Phonebook Object
- Returns:
Location of created entry
- Return type:
int
- SetSMS(Value)¶
Sets SMS.
- Parameters:
Value (dict) – SMS data, see SMS Object
- Returns:
Tuple for location and folder.
- Return type:
tuple
- SetSMSC(Value)¶
Sets SMS Service Center number and SMS settings.
- Parameters:
Value (dict) – SMSC information, see SMSC Object
- Returns:
None
- Return type:
None
- SetSpeedDial(Value)¶
Sets speed dial.
- Parameters:
Value (dict) – Speed dial data, see
GetSpeedDial()for listing.- Returns:
None
- Return type:
None
- SetToDo(Value)¶
Sets ToDo in phone.
- Parameters:
Value (dict) – ToDo data, see Todo Object
- Returns:
Location of created entry
- Return type:
int
- SplitCall(ID)¶
Splits call.
- Parameters:
ID (int) – ID of call
- Returns:
None
- Return type:
None
- SwitchCall(ID, Next)¶
Switches call.
- Parameters:
ID (int) – ID of call
- Returns:
None
- Return type:
None
- Terminate(