Gammu internals  1.38.0
AT phones communication
Collaboration diagram for AT phones communication:

Data Structures

struct  GSM_AT_SMS_Cache
 
struct  GSM_Phone_ATGENData
 

Macros

#define GSM_USED_AT
 
#define GSM_USED_BLUEAT
 
#define GSM_USED_IRDAAT
 
#define MAX_VCALENDAR_LOCATION   50
 
#define GSM_AT_MAXPDULEN   400
 
#define AT_PBK_MAX_MEMORIES   200
 
#define ATGEN_WaitForAutoLen(s, cmd, type, time, request)   ATGEN_WaitFor(s, cmd, strlen(cmd), type, time, request)
 

Enumerations

enum  GSM_AT_SMS_Modes { SMS_AT_PDU = 1, SMS_AT_TXT }
 
enum  GSM_AT_Reply_State {
  AT_Reply_OK = 1, AT_Reply_Connect, AT_Reply_Error, AT_Reply_Unknown,
  AT_Reply_CMSError, AT_Reply_CMEError, AT_Reply_SMSEdit
}
 
enum  GSM_AT_Manufacturer {
  AT_Nokia = 1, AT_Alcatel, AT_Siemens, AT_HP,
  AT_Falcom, AT_Ericsson, AT_Sagem, AT_Samsung,
  AT_Mitsubishi, AT_Sharp, AT_Option, AT_Motorola,
  AT_Wavecom, AT_Philips, AT_Huawei, AT_Qualcomm,
  AT_ZTE, AT_Unknown
}
 
enum  GSM_AT_Charset {
  AT_CHARSET_HEX = 1, AT_CHARSET_GSM, AT_CHARSET_UCS2, AT_CHARSET_UCS_2,
  AT_CHARSET_UTF8, AT_CHARSET_UTF_8, AT_CHARSET_PCCP437, AT_CHARSET_IRA,
  AT_CHARSET_ASCII, AT_CHARSET_ISO88591, AT_CHARSET_ISO88592, AT_CHARSET_ISO88593,
  AT_CHARSET_ISO88594, AT_CHARSET_ISO88595, AT_CHARSET_ISO88596
}
 
enum  GSM_AT_Charset_Preference {
  AT_PREF_CHARSET_NORMAL = 1, AT_PREF_CHARSET_UNICODE, AT_PREF_CHARSET_IRA, AT_PREF_CHARSET_GSM,
  AT_PREF_CHARSET_RESET
}
 
enum  GSM_AT_Feature { AT_AVAILABLE = 1, AT_NOTAVAILABLE }
 
enum  GSM_SamsungCalendar { SAMSUNG_NONE = 1, SAMSUNG_ORG, SAMSUNG_SSH }
 
enum  GSM_AT_NeededMemoryInfo {
  AT_Status, AT_NextEmpty, AT_Total, AT_First,
  AT_Sizes
}
 

Functions

GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s)
 
GSM_Error ATGEN_HandleCMEError (GSM_StateMachine *s)
 
GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s)
 
GSM_Error ATGEN_WaitFor (GSM_StateMachine *s, const char *cmd, size_t len, int type, int time, GSM_Phone_RequestID request)
 
GSM_Error ATGEN_ParseReply (GSM_StateMachine *s, const unsigned char *input, const char *format,...)
 
GSM_Error ATGEN_EncodeText (GSM_StateMachine *s, const unsigned char *input, const size_t inlength, unsigned char *output, const size_t outlength, size_t *resultlength)
 
GSM_Error ATGEN_DecodeText (GSM_StateMachine *s, const unsigned char *input, const size_t length, unsigned char *output, const size_t outlength, const gboolean guess, const gboolean phone)
 
GSM_Error ATGEN_SetCharset (GSM_StateMachine *s, GSM_AT_Charset_Preference Prefer)
 
int ATGEN_ExtractOneParameter (unsigned char *input, unsigned char *output)
 
GSM_Error ATGEN_DecodeDateTime (GSM_StateMachine *s, GSM_DateTime *dt, unsigned char *_input)
 
#define _GNU_SOURCE
 
#define _GNU_SOURCE
 

Detailed Description

This module implements standard AT commands.

See also
http://www.etsi.org
http://www.3gpp.org

Macro Definition Documentation

§ _GNU_SOURCE [1/2]

#define _GNU_SOURCE

Definition at line 17 of file at-sms.c.

§ _GNU_SOURCE [2/2]

#define _GNU_SOURCE

Definition at line 17 of file atgen.c.

§ AT_PBK_MAX_MEMORIES

#define AT_PBK_MAX_MEMORIES   200

Maximal length of phonebook memories list.

Definition at line 233 of file atgen.h.

§ ATGEN_WaitForAutoLen

#define ATGEN_WaitForAutoLen (   s,
  cmd,
  type,
  time,
  request 
)    ATGEN_WaitFor(s, cmd, strlen(cmd), type, time, request)

Wrapper around ATGEN_WaitFor which automatically sets length of request. It accepts same parameters as GSM_WaitFor except length.

Definition at line 437 of file atgen.h.

§ GSM_AT_MAXPDULEN

#define GSM_AT_MAXPDULEN   400

Maximal length of PDU cache line. It has to be at least 160 * 2 (message can be 160 bytes and hex representation needs twice more space).

Definition at line 210 of file atgen.h.

§ GSM_USED_AT

#define GSM_USED_AT

Definition at line 36 of file atgen.h.

§ GSM_USED_BLUEAT

#define GSM_USED_BLUEAT

Definition at line 39 of file atgen.h.

§ GSM_USED_IRDAAT

#define GSM_USED_IRDAAT

Definition at line 42 of file atgen.h.

§ MAX_VCALENDAR_LOCATION

#define MAX_VCALENDAR_LOCATION   50

Definition at line 45 of file atgen.h.

Enumeration Type Documentation

§ GSM_AT_Charset

Character set definitions.

Enumerator
AT_CHARSET_HEX 

Hex encoded GSM.

AT_CHARSET_GSM 

GSM charset.

AT_CHARSET_UCS2 

Hex encoded UCS2.

AT_CHARSET_UCS_2 

Hex encoded UCS2.

AT_CHARSET_UTF8 

UTF-8.

AT_CHARSET_UTF_8 

UTF-8.

AT_CHARSET_PCCP437 

CP-437, not fully supported.

AT_CHARSET_IRA 

IRA, what is same as 7-bit ASCII.

AT_CHARSET_ASCII 

7-bit ASCII.

AT_CHARSET_ISO88591 

ISO-8859-1, supported only with iconv.

AT_CHARSET_ISO88592 

ISO-8859-2, supported only with iconv.

AT_CHARSET_ISO88593 

ISO-8859-3, supported only with iconv.

AT_CHARSET_ISO88594 

ISO-8859-4, supported only with iconv.

AT_CHARSET_ISO88595 

ISO-8859-5, supported only with iconv.

AT_CHARSET_ISO88596 

ISO-8859-6, supported only with iconv.

Definition at line 90 of file atgen.h.

§ GSM_AT_Charset_Preference

Character set preference indication.

Enumerator
AT_PREF_CHARSET_NORMAL 

Prefer standard GSM character set.

AT_PREF_CHARSET_UNICODE 

Prefer Unicode character set to get text without any possible garbling caused by conversion.

AT_PREF_CHARSET_IRA 

IRA is ASCII character set. This might be useful for some operations where we only want to transmit ASCII characters and we don't want to take care about encoding or encoding of some transmitted characters is not possible to GSM.

AT_PREF_CHARSET_GSM 

For some operations, using standard GSM charset is best as it avoids problems with various broken phones and we don't need full charset anyway.

AT_PREF_CHARSET_RESET 

This option just sets again charset in phone. Useful after something what resets this information in phone.

Definition at line 156 of file atgen.h.

§ GSM_AT_Feature

Enumerator
AT_AVAILABLE 
AT_NOTAVAILABLE 

Definition at line 186 of file atgen.h.

186  {
187  AT_AVAILABLE = 1,
GSM_AT_Feature
Definition: atgen.h:186

§ GSM_AT_Manufacturer

Manufacturer identification. This is usually used to enable some hacks which are specific for all phones from one manufacturer.

Enumerator
AT_Nokia 
AT_Alcatel 
AT_Siemens 
AT_HP 
AT_Falcom 
AT_Ericsson 
AT_Sagem 
AT_Samsung 
AT_Mitsubishi 
AT_Sharp 
AT_Option 
AT_Motorola 
AT_Wavecom 
AT_Philips 
AT_Huawei 
AT_Qualcomm 
AT_ZTE 
AT_Unknown 

Definition at line 66 of file atgen.h.

66  {
67  AT_Nokia = 1,
68  AT_Alcatel,
69  AT_Siemens,
70  AT_HP,
71  AT_Falcom,
73  AT_Sagem,
74  AT_Samsung,
76  AT_Sharp,
77  AT_Option,
79  AT_Wavecom,
80  AT_Philips,
81  AT_Huawei,
83  AT_ZTE,
Definition: atgen.h:83
Definition: atgen.h:76
Definition: atgen.h:70
Definition: atgen.h:73
GSM_AT_Manufacturer
Definition: atgen.h:66
Definition: atgen.h:67

§ GSM_AT_NeededMemoryInfo

Enumerator
AT_Status 
AT_NextEmpty 
AT_Total 
AT_First 
AT_Sizes 

Definition at line 197 of file atgen.h.

197  {
198  AT_Status,
199  AT_NextEmpty,
200  AT_Total,
201  AT_First,
202  AT_Sizes
GSM_AT_NeededMemoryInfo
Definition: atgen.h:197

§ GSM_AT_Reply_State

Enumerator
AT_Reply_OK 
AT_Reply_Connect 
AT_Reply_Error 
AT_Reply_Unknown 
AT_Reply_CMSError 
AT_Reply_CMEError 
AT_Reply_SMSEdit 

Definition at line 52 of file atgen.h.

§ GSM_AT_SMS_Modes

Enumerator
SMS_AT_PDU 
SMS_AT_TXT 

Definition at line 47 of file atgen.h.

47  {
48  SMS_AT_PDU = 1,
GSM_AT_SMS_Modes
Definition: atgen.h:47

§ GSM_SamsungCalendar

Enumerator
SAMSUNG_NONE 
SAMSUNG_ORG 
SAMSUNG_SSH 

Definition at line 191 of file atgen.h.

191  {
192  SAMSUNG_NONE = 1,
193  SAMSUNG_ORG,
194  SAMSUNG_SSH,
GSM_SamsungCalendar
Definition: atgen.h:191

Function Documentation

§ ATGEN_DecodeDateTime()

GSM_Error ATGEN_DecodeDateTime ( GSM_StateMachine s,
GSM_DateTime dt,
unsigned char *  _input 
)

This function parses datetime strings in the format: [YY[YY]/MM/DD,]hh:mm[:ss[+TZ]] , [] enclosed parts are optional (or the same hex/unicode encoded).

Todo:
Too many static buffers are used here.

§ ATGEN_DecodeText()

GSM_Error ATGEN_DecodeText ( GSM_StateMachine s,
const unsigned char *  input,
const size_t  length,
unsigned char *  output,
const size_t  outlength,
const gboolean  guess,
const gboolean  phone 
)

Decodes text from phone encoding to internal representation.

Parameters
sState machine structure.
inputInput string.
lengthLength of string to convert.
outputStorage for converted text.
outlengthSize of output storage.
guessAllow guessing whether input is really encoded.
phoneWhether input is phone number, used only when guessing.
Returns
Error code.

§ ATGEN_DispatchMessage()

GSM_Error ATGEN_DispatchMessage ( GSM_StateMachine s)

§ ATGEN_EncodeText()

GSM_Error ATGEN_EncodeText ( GSM_StateMachine s,
const unsigned char *  input,
const size_t  inlength,
unsigned char *  output,
const size_t  outlength,
size_t *  resultlength 
)

Encodes text to current phone charset.

Parameters
sState machine structure.
inputInput string.
inlengthLength of string to convert.
outputStorage for converted text.
outlengthSize of output storage.
resultlengthLengt of output text will be stored here.
Returns
Error code.

§ ATGEN_ExtractOneParameter()

int ATGEN_ExtractOneParameter ( unsigned char *  input,
unsigned char *  output 
)

§ ATGEN_HandleCMEError()

GSM_Error ATGEN_HandleCMEError ( GSM_StateMachine s)

Generates error code from current CME error according to specifications.

Parameters
sState machine structure.

§ ATGEN_HandleCMSError()

GSM_Error ATGEN_HandleCMSError ( GSM_StateMachine s)

Generates error code from current CMS error according to specifications.

Parameters
sState machine structure.

§ ATGEN_ParseReply()

GSM_Error ATGEN_ParseReply ( GSM_StateMachine s,
const unsigned char *  input,
const char *  format,
  ... 
)

Parses AT formatted reply. This is a bit like sprintf parser, but specially focused on AT replies and can automatically convert text encoding and decode some special fields.

Parser tokens:
  • @i - Number, expects pointer to int.
  • @n - Quoted number, expects pointer to int.
  • @I - Optional number (string can be empty), expects pointer to int.
  • @l - Number, expects pointer to long int.
  • @s - String, will be converted from phone encoding, stripping quotes, expects pointer to unsigned char and size of storage. Encoding is somehow guessed.
  • @u - String in utf-8, expects pointer to unsigned char and size of storage.
  • @t - String with length as first element (eg. "5,test1"), will be converted from phone encoding, stripping quotes, expects pointer to unsigned char and size of storage. Encoding is somehow guessed.
  • @T - String with length as first element (eg. "5,test1"), same as @t, just with utf-8 encoding.
  • @e - String, will be converted from phone encoding, stripping quotes, expects pointer to unsigned char and size of storage. No encoding guessing.
  • @S - String with Samsung specials (0x02 at beginning and 0x03 at the end, encoded in utf-8), otherwise same as @s.
  • @p - String with phone number hint for heuristics, otherwise same as @s.
  • @r - Raw string, no conversion will be done, only stripped quotes, expects pointer to char and size of storage.
  • @d - Date, expects pointer to GSM_DateTime.
  • @@ - @ literal.
  • @0 - Ignore rest of input, same as .* regular expression.
Special behaviour:
Any space is automatically treated as [[:space:]]* regular expression. So use space whenever some weird implementation in phone can insert it space.
Parameters
sState machine structure.
inputInput string to parse.
formatFormat string for parser.
...Pointers to various buffers as defined by format string.

§ ATGEN_SetCharset()

GSM_Error ATGEN_SetCharset ( GSM_StateMachine s,
GSM_AT_Charset_Preference  Prefer 
)

Sets charset in phone according to preference.

Parameters
sState machine structure.
PreferWhat charset setting is prefered.
Returns
Error code.

§ ATGEN_WaitFor()

GSM_Error ATGEN_WaitFor ( GSM_StateMachine s,
const char *  cmd,
size_t  len,
int  type,
int  time,
GSM_Phone_RequestID  request 
)

Wrapper around GSM_WaitFor, which automatically sets correct Motorola mode. It accepts same parameters as GSM_WaitFor.