Package gammu :: Module Core :: Class StateMachine
[hide private]
[frames] | no frames]

Class StateMachine



object --+
         |
        StateMachine

StateNachine(Locale)

StateMachine object, that is used for communication with phone.

param Locale: What locales to use for gammu error messages, default is 'auto' which does autodetection according to user locales type Locale: string

Instance Methods [hide private]
int
AddCalendar(Value)
Adds calendar entry.
int
AddCategory(Type, Name)
Adds category to phone.
hash
AddFilePart(File)
Adds file part to filesystem.
string
AddFolder(ParentFolderID, Name)
Adds folder to filesystem.
int
AddMemory(Value)
Adds memory (phonebooks or calls) entry.
tuple
AddSMS(Value)
Adds SMS to specified folder.
None
AddSMSFolder(Name)
Creates SMS folder.
int
AddToDo(Value)
Adds ToDo in phone.
None
DeleteAllCalendar()
Deletes all calendar entries.
None
DeleteAllMemory(Type)
Deletes all memory (phonebooks or calls) entries of specified type.
None
DeleteAllToDo()
Deletes all todo entries in phone.
None
DeleteCalendar(Location)
Deletes calendar entry.
None
DeleteFile(FileID)
Deletes file from filesystem.
None
DeleteFolder(FolderID)
Deletes folder on filesystem.
None
DeleteMemory(Type, Location)
Deletes memory (phonebooks or calls) entry.
None
DeleteSMS(Folder, Location)
Deletes SMS.
None
DeleteSMSFolder(ID)
Deletes SMS folder.
None
DeleteToDo(Location)
Deletes ToDo entry in phone.
None
DialService(Number, ShowNumber)
Dials number and starts voice call.
None
DialVoice(Number, ShowNumber)
Dials number and starts voice call.
None
EnterSecurityCode(Type, Code)
Entres security code.
hash
GetAlarm(Location)
Reads alarm set in phone.
hash
GetBatteryCharge()
Gets information about batery charge and phone charging state.
hash
GetCalendar(Location)
Retrieves calendar entry.
hash
GetCalendarStatus()
Retrieves calendar status (number of used entries).
string
GetCategory(Type, Location)
Reads category from phone.
hash
GetCategoryStatus(Type)
Reads category status (number of used entries) from phone.
hash
GetConfig(Section)
Gets specified config section.
datetime.datetime
GetDateTime()
Reads date and time from phone.
list
GetDisplayStatus()
Acquired display status.
hash
GetFilePart(File)
Gets file part from filesystem.
hash
GetFileSystemStatus()
Acquires filesystem status.
tuple
GetFirmware()
Reads firmware information from phone.
hash
GetFolderListing(Folder, Start)
Gets next filename from filesystem folder.
string
GetHardware()
Gets hardware information about device.
string
GetIMEI()
Reads IMEI/serial number from phone.
hash
GetLocale()
Gets locale information from phone.
string
GetManufactureMonth()
Gets month when device was manufactured.
string
GetManufacturer()
Reads manufacturer from phone.
hash
GetMemory(Type, Location)
Reads entry from memory (phonebooks or calls).
hash
GetMemoryStatus(Type)
Gets memory (phonebooks or calls) status (eg.
tuple
GetModel()
Reads model from phone.
hash
GetNetworkInfo()
Gets network information.
hash
GetNextCalendar(Start, Location)
Retrieves calendar entry.
hash
GetNextFileFolder(Start)
Gets next filename from filesystem.
hash
GetNextMemory(Type, Start, Location)
Reads entry from memory (phonebooks or calls).
 
GetNextRootFolder(Folder)
Gets next root folder from filesystem.
hash
GetNextSMS(Folder, Start, Location)
Reads next (or first if start set) SMS message.
hash
GetNextToDo(Start, Location)
Reads ToDo from phone.
string
GetOriginalIMEI()
Gets original IMEI from phone.
string
GetPPM()
Gets PPM (Post Programmable Memory) from phone.
string
GetProductCode()
Gets product code of device.
string
GetSIMIMSI()
Gets SIM IMSI from phone.
hash
GetSMS(Folder, Location)
Reads SMS message.
hash
GetSMSC(Location)
Gets SMS Service Center number and SMS settings.
list
GetSMSFolders()
Returns SMS folders information.
hash
GetSMSStatus()
Gets information about SMS memory (read/unread/size of memory for both SIM and phone).
string
GetSecurityStatus()
Queries whether some security code needs to be entered.
hash
GetSignalQuality()
Reads signal quality (strength and error rate).
hash
GetSpeedDial(Location)
Gets speed dial.
hash
GetToDo(Location)
Reads ToDo from phone.
hash
GetToDoStatus()
Gets status of ToDos (count of used entries).
None
Init(Replies)
Initialises the connection with phone.
None
PressKey(Key, Press)
Emulates key press.
None
ReadConfig(Section, Configuration)
Reads specified section of gammurc
None
Reset(Hard)
Performs phone reset.
None
ResetPhoneSettings(Type)
Resets phone settings.
hash
SendFilePart(File)
Sends file part to phone.
int
SendSMS(Value)
Sends SMS.
int
SendSavedSMS(Folder, Location)
Sends SMS saved in phone.
None
SetAlarm(DateTime, Location, Repeating, Text)
Sets alarm in phone.
None
SetAutoNetworkLogin()
Enables network auto login.
int
SetCalendar(Value)
Sets calendar entry
None
SetConfig(Section, Values)
Sets specified config section.
None
SetDateTime(Date)
Sets date and time in phone.
None
SetDebugFile(File, Global)
Sets state machine debug file.
None
SetDebugLevel(Level)
Sets state machine debug level accorting to passed string.
None
SetFileAttributes(Filename, ReadOnly, Protected, System, Hidden)
Sets file attributes.
None
SetIncomingCB(Enable)
Gets network information from phone.
None
SetIncomingCall(Enable)
Activates/deactivates noticing about incoming calls.
None
SetIncomingCallback(Callback)
Sets callback function which is called whenever any (enabled) incoming event appears.
None
SetIncomingSMS(Enable)
Enable/disable notification on incoming SMS.
None
SetIncomingUSSD(Enable)
Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services).
None
SetLocale(DateSeparator, DateFormat, AMPMTime)
Sets locale of phone.
int
SetMemory(Value)
Sets memory (phonebooks or calls) entry.
tuple
SetSMS(Value)
Sets SMS.
None
SetSMSC(Value)
Sets SMS Service Center number and SMS settings.
None
SetSpeedDial(Value)
Sets speed dial.
int
SetToDo(Value)
Sets ToDo in phone.
None
ShowStartInfo(Enable)
Enables showing information on phone display.
None
Terminate()
Terminates the connection with phone.
 
__init__(Locale)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__new__(T, S, ...)
Returns: a new object with type S, a subtype of T

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

AddCalendar(Value)

 
Adds calendar entry.
Parameters:
  • Value (hash) - Calendar entry data
Returns: int
Location of newly created entry

AddCategory(Type, Name)

 
Adds category to phone.
Parameters:
  • Type (string) - Type of category to read, one of 'ToDo', 'Phonebook'
  • Name (string) - Category name
Returns: int
Location of created category

AddFilePart(File)

 
Adds file part to filesystem.
Parameters:
  • File (hash) - File data
Returns: hash
File data for subsequent calls (Finished indicates transfer has been completed)

AddFolder(ParentFolderID, Name)

 
Adds folder to filesystem.
Parameters:
  • ParentFolderID (string) - Folder where to create subfolder
  • Name (string) - New folder name
Returns: string
New folder ID.

AddMemory(Value)

 
Adds memory (phonebooks or calls) entry.
Parameters:
  • Value (hash) - Memory entry
Returns: int
Location of created entry

AddSMS(Value)

 
Adds SMS to specified folder.
Parameters:
  • Value (hash) - SMS data
Returns: tuple
Tuple for location and folder.

AddSMSFolder(Name)

 
Creates SMS folder.
Parameters:
  • Name (string) - Name of new folder
Returns: None
None

AddToDo(Value)

 
Adds ToDo in phone.
Parameters:
  • Value (hash) - ToDo data
Returns: int
Location of created entry

DeleteAllCalendar()

 
Deletes all calendar entries.
Returns: None
None

DeleteAllMemory(Type)

 
Deletes all memory (phonebooks or calls) entries of specified type.
Parameters:
  • Type (string) - Memory type, one of 'ME', 'SM', 'ON', 'DC', 'RC', 'MC', 'MT', 'FD', 'VM'
Returns: None
None

DeleteAllToDo()

 
Deletes all todo entries in phone.
Returns: None
None

DeleteCalendar(Location)

 
Deletes calendar entry.
Parameters:
  • Location (int) - Calendar entry to delete
Returns: None
None

DeleteFile(FileID)

 
Deletes file from filesystem.
Parameters:
  • FileID (string) - File to delete
Returns: None
None

DeleteFolder(FolderID)

 
Deletes folder on filesystem.
Parameters:
  • FolderID (string) - Folder to delete
Returns: None
None

DeleteMemory(Type, Location)

 
Deletes memory (phonebooks or calls) entry.
Parameters:
  • Type (string) - Memory type, one of 'ME', 'SM', 'ON', 'DC', 'RC', 'MC', 'MT', 'FD', 'VM'
  • Location (int) - Location of entry to delete
Returns: None
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
None

DeleteSMSFolder(ID)

 
Deletes SMS folder.
Parameters:
  • ID (int) - Index of folder to delete
Returns: None
None

DeleteToDo(Location)

 
Deletes ToDo entry in phone.
Parameters:
  • Location (int) - Location of entry to delete
Returns: None
None

DialService(Number, ShowNumber)

 
Dials number and starts voice call.
Parameters:
  • Number (string) - Number to dial
Returns: None
None

DialVoice(Number, ShowNumber)

 
Dials number and starts voice call.
Parameters:
  • Number (string) - Number to dial
  • ShowNumber (bool or None) - Identifies whether to enable CLIR (None = keep default phone settings). Default is None
Returns: None
None

EnterSecurityCode(Type, Code)

 
Entres security code.
Parameters:
  • Type (string) - What code to enter, one of 'PIN', 'PUK', 'PIN2', 'PUK2'.
  • Code (string) - Code value
Returns: None
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: hash
Alarm hash

GetBatteryCharge()

 
Gets information about batery charge and phone charging state.
Returns: hash
Hash containing information about battery state (BatteryPercent and ChargeState)

GetCalendar(Location)

 
Retrieves calendar entry.
Parameters:
  • Location (int) - Calendar entry to read
Returns: hash
Hash with calendar values

GetCalendarStatus()

 
Retrieves calendar status (number of used entries).
Returns: hash
Hash with calendar status (Used)

GetCategory(Type, Location)

 
Reads category from phone.
Parameters:
  • Type (string) - Type of category to read, one of 'ToDo', 'Phonebook'
  • Location (int) - Location of category to read
Returns: string
Category name as string

GetCategoryStatus(Type)

 
Reads category status (number of used entries) from phone.
Parameters:
  • Type (string) - Type of category to read, one of 'ToDo', 'Phonebook'
Returns: hash
Hash containing information about category status (Used)

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
  • Localize
  • StartInfo
  • UseGlobalDebugFile
Parameters:
  • Section (int) - Index of config section to read. Defaults to 0.
Returns: hash
Hash containing configuration

GetDateTime()

 
Reads date and time from phone.
Returns: datetime.datetime
Date and time from phone as datetime.datetime object.

GetDisplayStatus()

 
Acquired display status.
Returns: list
List of indicators displayed on display

GetFilePart(File)

 
Gets file part from filesystem.
Parameters:
  • File (hash) - File data
Returns: hash
File data for subsequent calls (Finished indicates transfer has been completed)

GetFileSystemStatus()

 
Acquires filesystem status.
Returns: hash
Hash containing filesystem status (Used and Free)

GetFirmware()

 
Reads firmware information from phone.
Returns: tuple
Tuple from version, date and numeric version.

GetFolderListing(Folder, Start)

 
Gets next filename from filesystem folder.
Parameters:
  • Folder (string) - Folder to list
  • Start (bool) - Whether we're starting listing. Defaults to False.
Returns: hash
File data as hash

GetHardware()

 
Gets hardware information about device.
Returns: string
Hardware information as string.

GetIMEI()

 
Reads IMEI/serial number from phone.
Returns: string
IMEI of phone as string.

GetLocale()

 
Gets locale information from phone.
Returns: hash
Hash of locale settings. SetLocale lists them all.

GetManufactureMonth()

 
Gets month when device was manufactured.
Returns: string
Month of manufacture as string.

GetManufacturer()

 
Reads manufacturer from phone.
Returns: string
String with manufacturer name

GetMemory(Type, Location)

 
Reads entry from memory (phonebooks or calls). Which entry shouldbe read is defined in entry.
Parameters:
  • Type (string) - Memory type, one of 'ME', 'SM', 'ON', 'DC', 'RC', 'MC', 'MT', 'FD', 'VM'
Returns: hash
Memory entry as hash

GetMemoryStatus(Type)

 
Gets memory (phonebooks or calls) status (eg. number of used andfree entries).
Parameters:
  • Type (string) - Memory type, one of 'ME', 'SM', 'ON', 'DC', 'RC', 'MC', 'MT', 'FD', 'VM'
Returns: hash
Hash with information about memory (Used and Free)

GetModel()

 
Reads model from phone.
Returns: tuple
Tuple containing gammu identification and real model returned by phone.

GetNetworkInfo()

 
Gets network information.
Returns: hash
Hash with information about network (NetworkName, State, NetworkCode, CID and LAC)

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: hash
Hash with calendar values

GetNextFileFolder(Start)

 
Gets next filename from filesystem.
Parameters:
  • Start (bool) - Whether we're starting listing. Defaults to False.
Returns: hash
File data as hash

GetNextMemory(Type, Start, Location)

 
Reads entry from memory (phonebooks or calls). Which entry shouldbe read is defined in entry. This can be easily used for reading all entries.
Parameters:
  • Type (string) - Memory type, one of 'ME', 'SM', 'ON', 'DC', 'RC', 'MC', 'MT', 'FD', 'VM'
  • 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: hash
Memory entry as hash

GetNextRootFolder(Folder)

 
Gets next root folder from filesystem. Start with empty folder name.
Parameters:
  • Folder (string) - Previous read fodlder. 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 befaster 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: hash
Hash with SMS data

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: hash
Hash with ToDo values

GetOriginalIMEI()

 
Gets original IMEI from phone.
Returns: string
Original IMEI of phone as string.

GetPPM()

 
Gets PPM (Post Programmable Memory) from phone.
Returns: string
PPM as string

GetProductCode()

 
Gets product code of device.
Returns: string
Product code as string.

GetSIMIMSI()

 
Gets SIM IMSI from phone.
Returns: string
SIM IMSI as string

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: hash
Hash with SMS data

GetSMSC(Location)

 
Gets SMS Service Center number and SMS settings.
Parameters:
  • Location (int) - Location of entry to read. Defaults to 1
Returns: hash
Hash with SMSC information

GetSMSFolders()

 
Returns SMS folders information.
Returns: list
List of SMS folders.

GetSMSStatus()

 
Gets information about SMS memory (read/unread/size of memory for both SIM and phone).
Returns: hash
Hash with information about phone memory (SIMUnRead, SIMUsed, SIMSize, PhoneUnRead, PhoneUsed, PhoneSize and TemplatesUsed)

GetSecurityStatus()

 
Queries whether some security code needs to be entered.
Returns: string
String indicating which code needs to be entered or None if none is needed

GetSignalQuality()

 
Reads signal quality (strength and error rate).
Returns: hash
Hash containing information about signal state (SignalStrength, SignalPercent and BitErrorRate)

GetSpeedDial(Location)

 
Gets speed dial.
Parameters:
  • Location (int) - Location of entry to read
Returns: hash
Hash with speed dial (Location, MemoryLocation, MemoryNumberID, MemoryType)

GetToDo(Location)

 
Reads ToDo from phone.
Parameters:
  • Location (int) - Location of entry to read
Returns: hash
Hash with ToDo values

GetToDoStatus()

 
Gets status of ToDos (count of used entries).
Returns: hash
Hash of status (Used)

Init(Replies)

 
Initialises the connection with phone.
Parameters:
  • Replies (int) - Number of replies to wait for on each request. Defaults to 3.
Returns: None
None

PressKey(Key, Press)

 
Emulates key press.
Parameters:
  • Key (string) - What key to press
  • Press (bool) - Whether to emulate press or release.
Returns: None
None

ReadConfig(Section, Configuration)

 
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.
Returns: None
None

Reset(Hard)

 
Performs phone reset.
Parameters:
  • Hard (bool) - Whether to make hard reset
Returns: None
None

ResetPhoneSettings(Type)

 
Resets phone settings.
Parameters:
  • Type (string) - What to reset, one of 'PHONE', 'UIF', 'ALL', 'DEV', 'FACTORY'
Returns: None
None

SendFilePart(File)

 
Sends file part to phone.
Parameters:
  • File (hash) - File data
Returns: hash
File data for subsequent calls (Finished indicates transfer has been completed)

SendSMS(Value)

 
Sends SMS.
Parameters:
  • Value (hash) - SMS data
Returns: int
Message reference as integer

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: int
Message reference as integer

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 (string) - Text to be displayed on alarm. Defaults to empty.
Returns: None
None

SetAutoNetworkLogin()

 
Enables network auto login.
Returns: None
None

SetCalendar(Value)

 
Sets calendar entry
Parameters:
  • Value (hash) - Calendar entry data
Returns: int
Location of set entry

SetConfig(Section, Values)

 
Sets specified config section.
Parameters:
  • Section (int) - Index of config section to modify
  • Values (hash) - Config values, see GetConfig for description of accepted
Returns: None
None

SetDateTime(Date)

 
Sets date and time in phone.
Parameters:
  • Date (datetime.datetime) - Date to set
Returns: None
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
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 (string) - name of debug level to use, currently one of:
    • nothing
    • text
    • textall
    • binary
    • errors
    • textdate
    • textalldate
    • errorsdate
Returns: None
None

SetFileAttributes(Filename, ReadOnly, Protected, System, Hidden)

 
Sets file attributes.
Parameters:
  • Filename (string) - 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
None

SetIncomingCB(Enable)

 
Gets network information from phone.
Parameters:
  • Enable (boolean) - Whether to enable notifications, default is True
Returns: None
None

SetIncomingCall(Enable)

 
Activates/deactivates noticing about incoming calls.
Parameters:
  • Enable (boolean) - Whether to enable notifications, default is True
Returns: None
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.
Parameters:
  • Callback (function, it will get three params: StateMachine object, event type and it's data in dictionary) - callback function or None for disabling
Returns: None
None

SetIncomingSMS(Enable)

 
Enable/disable notification on incoming SMS.
Parameters:
  • Enable (boolean) - Whether to enable notifications, default is True
Returns: None
None

SetIncomingUSSD(Enable)

 
Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services).
Parameters:
  • Enable (boolean) - Whether to enable notifications, default is True
Returns: None
None

SetLocale(DateSeparator, DateFormat, AMPMTime)

 
Sets locale of phone.
Parameters:
  • DateSeparator (string) - Date separator.
  • DateFormat (string) - Date format, one of 'DDMMYYYY', 'MMDDYYYY', 'YYYYMMDD'
  • AMPMTime (bool) - Whether to use AM/PM time.
Returns: None
None

SetMemory(Value)

 
Sets memory (phonebooks or calls) entry.
Parameters:
  • Value (hash) - Memory entry
Returns: int
Location of created entry

SetSMS(Value)

 
Sets SMS.
Parameters:
  • Value (hash) - SMS data
Returns: tuple
Tuple for location and folder.

SetSMSC(Value)

 
Sets SMS Service Center number and SMS settings.
Parameters:
  • Value (hash) - SMSC information
Returns: None
None

SetSpeedDial(Value)

 
Sets speed dial.
Parameters:
  • Value (hash) - Speed dial data, see GetSpeedDial for listing.
Returns: None
None

SetToDo(Value)

 
Sets ToDo in phone.
Parameters:
  • Value (hash) - ToDo data
Returns: int
Location of created entry

ShowStartInfo(Enable)

 
Enables showing information on phone display.
Parameters:
  • Enable (bool) - Whether to enable. Defaults to True.
Returns: None
None

Terminate()

 
Terminates the connection with phone.
Returns: None
None

__init__(Locale)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__

__new__(T, S, ...)

 
Returns:
a new object with type S, a subtype of T

Overrides: object.__new__