package gammu

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

SMS messages manipulation.

type state =
  1. | Sent
  2. | Unsent
  3. | Read
  4. | Unread

Status of SMS message.

type udh =
  1. | No_udh
    (*

    Simple message, content in SMS.text

    *)
  2. | ConcatenatedMessages
    (*

    Linked SMS.

    *)
  3. | ConcatenatedMessages16bit
    (*

    Linked SMS with 16 bit reference.

    *)
  4. | DisableVoice
  5. | DisableFax
  6. | DisableEmail
  7. | EnableVoice
  8. | EnableFax
  9. | EnableEmail
  10. | VoidSMS
  11. | NokiaRingtone
  12. | NokiaRingtoneLong
  13. | NokiaOperatorLogoLong
  14. | NokiaWAP
  15. | NokiaWAPLong
  16. | NokiaCalendarLong
  17. | NokiaProfileLong
  18. | NokiaPhonebookLong
  19. | UserUDH
  20. | MMSIndicatorLong

Types of UDH (User Data Header).

type udh_header = {
  1. udh : udh;
    (*

    UDH type.

    *)
  2. udh_text : string;
    (*

    UDH text.

    *)
  3. id8bit : int;
    (*

    8-bit ID, when required (<= 0 otherwise).

    *)
  4. id16bit : int;
    (*

    16-bit ID, when required (<= 0 otherwise).

    *)
  5. part_number : int;
    (*

    Number of current part.

    *)
  6. all_parts : int;
    (*

    Total number of parts.

    *)
}

Structure for User Data Header.

type format =
  1. | Pager
  2. | Fax
  3. | Email
  4. | Text

Format of SMS messages. See GSM 03.40 section 9.2.3.9.

type validity =
  1. | Not_available
  2. | Relative of char
    (*

    Validity lengths for SMS messages. See GSM 03.40 section 9.2.3.12.1 for meanings.

    *)
type smsc = {
  1. smsc_location : int;
    (*

    Number of the SMSC on SIM

    *)
  2. smsc_name : string;
    (*

    Name of the SMSC

    *)
  3. smsc_number : string;
    (*

    SMSC phone number

    *)
  4. validity : validity;
    (*

    Validity of SMS messges.

    *)
  5. format : format;
    (*

    Format of sent SMS messages.

    *)
  6. default_number : string;
    (*

    Default recipient number. In old DCT3 ignored.

    *)
}

SMSC (SMS Center)

type message_type =
  1. | Deliver
    (*

    SMS in Inbox.

    *)
  2. | Status_Report
    (*

    Delivery Report

    *)
  3. | Submit
    (*

    SMS for sending or in Outbox

    *)
type coding =
  1. | Unicode_No_Compression
    (*

    Unicode

    *)
  2. | Unicode_Compression
  3. | Default_No_Compression
    (*

    Default GSM alphabet.

    *)
  4. | Default_Compression
  5. | Eight_bit
    (*

    8-bit.

    *)
type message = {
  1. replace : char;
    (*

    Message to be replaced.

    *)
  2. reject_duplicates : bool;
    (*

    Whether to reject duplicates.

    *)
  3. udh_header : udh_header;
    (*

    UDH (User Data Header)

    *)
  4. number : string;
    (*

    Sender or recipient number.

    *)
  5. other_numbers : string array;
  6. smsc : smsc;
    (*

    SMS Center

    *)
  7. memory : memory_type;
    (*

    For saved SMS: where exactly it's saved (SIM/phone).

    *)
  8. message_number : int;
    (*

    For saved SMS: location of SMS in memory.

    *)
  9. folder : int;
    (*

    For saved SMS: number of folder, where SMS is saved.

    *)
  10. inbox_folder : bool;
    (*

    For saved SMS: whether SMS is really in Inbox.

    *)
  11. state : state;
    (*

    Status (read, unread,...) of SMS message.

    *)
  12. nokia_name : string;
    (*

    Name in Nokia with SMS memory (6210/7110, etc.) Ignored in other.

    *)
  13. text : string;
    (*

    Text for SMS. May be encoded as plain 8bit ASCII or as UTF8 according to the coding field.

    *)
  14. pdu : message_type;
    (*

    Type of message.

    *)
  15. coding : coding;
    (*

    Type of coding.

    *)
  16. date_time : DateTime.t;
    (*

    Date and time, when SMS was saved or sent.

    *)
  17. smsc_time : DateTime.t;
    (*

    Date of SMSC response in DeliveryReport messages.

    *)
  18. delivery_status : char;
    (*

    In delivery reports: status.

    *)
  19. reply_via_same_smsc : bool;
    (*

    Indicates whether "Reply via same center" is set.

    *)
  20. sms_class : char;
    (*

    SMS class (0 is flash SMS, 1 is normal one).

    *)
  21. message_reference : char;
    (*

    Message reference.

    *)
}
type multi_sms = message array

Multiple SMS messages, used for Smart Messaging 3.0/EMS.

val default_received : message

Empty message with default values needed for saving a received SMS.

val get : t -> folder:int -> message_number:int -> multi_sms

Read a SMS message.

val fold : t -> ?folder:int -> ?n:int -> ?retries:int -> ?on_err:(int -> error -> unit) -> ('a -> multi_sms -> 'a) -> 'a -> 'a

fold s f a fold SMS messages through the function f with a as initial value, iterating trough SMS' *and* folders).

This function uses the GSM_GetNextSMS function from libGammu. This might be faster for some phones than using Gammu.SMS.get for each message.

Please note that this command may not mark the messages as read in the phone. To make sure they are, call Gammu.SMS.get.

  • parameter folder

    specifies the folder from where to start folding SMS (default = 0, the first one).

  • parameter n

    how many messages are to be folded (at maximum). If negative, the fold goes over all messages from the beginning of the given folder and higher numbered ones (default = -1).

  • parameter retries

    how many times to retry (first try not counted in) the retrieval of one message in case of error UNKNOWN or CORRUPTED. TODO: On some phones (symbian/gnapgen), it may just loop forever (since the location argument is ignored in their driver). (default = 2)

  • parameter on_err

    function to handle errors UNKNOWN or CORRUPTED. The location of the SMS message for which the next one failed to be read and the error are given (default: does nothing).

  • raises NOTIMPLEMENTED

    if GetNext function is not implemented in libGammu for the currently used phone.

  • raises NOTSUPPORTED

    if the mechanism is not supported by the phone.

val set : t -> message -> int * int

set s sms sets sms at the specified location and folder (given in SMS.message representation). And returns a couple for folder and location really set (after transformation).

val add : t -> message -> int * int

add s sms adds sms to the folder specified in the folder field of sms and returns the couple folder and location where the message was stored (folder may be transformed). The location fields of sms are ignored when adding SMS, put whatever you want there.

val send : t -> message -> unit

send s sms sends the sms.

type folder = {
  1. box : folder_box;
    (*

    Whether it is inbox or outbox.

    *)
  2. folder_memory : memory_type;
    (*

    Where exactly it's saved.

    *)
  3. name : string;
    (*

    Name of the folder.

    *)
}
and folder_box =
  1. | Inbox
  2. | Outbox
val folders : t -> folder array
  • returns

    SMS folders information.

type memory_status = {
  1. sim_unread : int;
    (*

    Number of unread messages on SIM.

    *)
  2. sim_used : int;
    (*

    Number of saved messages (including unread) on SIM.

    *)
  3. sim_size : int;
    (*

    Number of possible messages on SIM.

    *)
  4. templates_used : int;
    (*

    Number of used templates (62xx/63xx/7110/etc.).

    *)
  5. phone_unread : int;
    (*

    Number of unread messages in phone.

    *)
  6. phone_used : int;
    (*

    Number of saved messages in phone.

    *)
  7. phone_size : int;
    (*

    Number of possible messages on phone.

    *)
}

Status of SMS memory.

val get_status : t -> memory_status

Get information about SMS memory (read/unread/size of memory for both SIM and phone).

val set_incoming_sms : t -> bool -> unit

Enable/disable notification on incoming SMS.

val delete : t -> folder:int -> message_number:int -> unit

Deletes SMS (SMS location and folder must be set).

type encode_part_type_id =
  1. | Text
    (*

    1 text SMS.

    *)
  2. | ConcatenatedTextLong
    (*

    Contacenated SMS, when longer than 1 SMS.

    *)
  3. | ConcatenatedAutoTextLong
    (*

    Contacenated SMS, auto Default/Unicode coding.

    *)
  4. | ConcatenatedTextLong16bit
  5. | ConcatenatedAutoTextLong16bit
  6. | NokiaProfileLong
    (*

    Nokia profile = Name, Ringtone, ScreenSaver

    *)
  7. | NokiaPictureImageLong
    (*

    Nokia Picture Image + (text)

    *)
  8. | NokiaScreenSaverLong
    (*

    Nokia screen saver + (text)

    *)
  9. | NokiaRingtone
    (*

    Nokia ringtone - old SM2.0 format, 1 SMS

    *)
  10. | NokiaRingtoneLong
    (*

    Nokia ringtone contacenated, when very long

    *)
  11. | NokiaOperatorLogoLong
    (*

    Nokia 72x14 op logo or 78x21 in 2 SMS

    *)
  12. | NokiaWAPBookmarkLong
    (*

    Nokia WAP bookmark in 1 or 2 SMS

    *)
  13. | NokiaWAPSettingsLong
    (*

    Nokia WAP settings in 2 SMS

    *)
  14. | NokiaMMSSettingsLong
    (*

    Nokia MMS settings in 2 SMS

    *)
  15. | NokiaVCARD10Long
    (*

    Nokia VCARD 1.0 (only name and default number)

    *)
  16. | NokiaVCARD21Long
    (*

    Nokia VCARD 2.1 (all numbers + text)

    *)
  17. | NokiaVCALENDAR10Long
    (*

    Nokia VCALENDAR 1.0 (can be in few sms)

    *)
  18. | NokiaVTODOLong
  19. | VCARD10Long
  20. | VCARD21Long
  21. | DisableVoice
  22. | DisableFax
  23. | DisableEmail
  24. | EnableVoice
  25. | EnableFax
  26. | EnableEmail
  27. | VoidSMS
  28. | EMSSound10
    (*

    IMelody 1.0

    *)
  29. | EMSSound12
    (*

    IMelody 1.2

    *)
  30. | EMSSonyEricssonSound
    (*

    IMelody without header, SonyEricsson extension

    *)
  31. | EMSSound10Long
    (*

    IMelody 1.0 with UPI.

    *)
  32. | EMSSound12Long
    (*

    IMelody 1.2 with UPI.

    *)
  33. | EMSSonyEricssonSoundLong
    (*

    IMelody without header with UPI.

    *)
  34. | EMSPredefinedSound
  35. | EMSPredefinedAnimation
  36. | EMSAnimation
  37. | EMSFixedBitmap
    (*

    Fixed bitmap of size 16x16 or 32x32.

    *)
  38. | EMSVariableBitmap
  39. | EMSVariableBitmapLong
  40. | MMSIndicatorLong
    (*

    MMS message indicator.

    *)
  41. | WAPIndicatorLong
  42. | AlcatelMonoBitmapLong
    (*

    Variable bitmap with black and white colors

    *)
  43. | AlcatelMonoAnimationLong
    (*

    Variable animation with black and white colors

    *)
  44. | AlcatelSMSTemplateName
  45. | SiemensFile
    (*

    Siemens OTA

    *)

ID during packing SMS for Smart Messaging 3.0, EMS and other

type info = {
  1. id : encode_part_type_id;
  2. nbr : int;
  3. protected : bool;
  4. buffer : string;
  5. left : bool;
  6. right : bool;
  7. center : bool;
  8. large : bool;
  9. small : bool;
  10. bold : bool;
  11. italic : bool;
  12. underlined : bool;
  13. strikethrough : bool;
  14. ringtone_notes : int;
}

SMS information, like type, text, text properties, etc...

type multipart_info = {
  1. unicode_coding : bool;
  2. info_class : int;
  3. replace_message : char;
  4. unknown : bool;
  5. entries : info array;
}

Multipart SMS Information

val decode_multipart : ?debug:Debug.info -> ?ems:bool -> multi_sms -> multipart_info

decode_multipart sms Decode the multi part SMS sms to "readable" format. sms is modified. Return a Gammu.SMS.multipart_info associated.

  • parameter debug

    log according to debug settings from di. If not specified, use the one returned by Gammu.Debug.global.

  • parameter ems

    whether to use EMS (Enhanced Messaging Service) (default true).

OCaml

Innovation. Community. Security.