Modem Interface APIs

Header File

Functions

int md_sms_send(const char *num, const char *sms_text, unsigned int *ref)

SMS Send API

Return

0 on success, error otherwise (mderror_e)

Parameters
  • num: [in] Sender’s number

  • sms_text: [in] message to send

  • ref: [out] GSM 03.40 TP-Message-Reference

int md_sms_read(unsigned index, struct md_smsinfo_t *smsinfo)

SMS Read

Return

0 on success, error otherwise (mderror_e)

Parameters
  • index: [in] Index in the storage to read from

  • smsinfo: [out] SMS Information structure returned after successful read

int md_sms_delete(int index, int mode)

Delete SMS

Return

0 on success, error otherwise (mderror_e)

Parameters
  • index: [in] Index in the storage to read from

  • mode: [in] SMS delete mode (sms_delmode_e)

int md_cfun_set(int cfun, int rst)

Set modem CFUN state

Return

0 on success, error otherwise (mderror_e)

Parameters
  • cfun: [in] CFUN value to set

  • rst: [in] reset after setting cfun value

int md_cfun_get(void)

Get modem CFUN state

Return

CFUN status on success, negative value as error (mderror_e)

int md_call_dial(const char *phonenum)

Initiate a call This is a non-blocking call, If operation is success Call status will be retured as URC response.

Return

0 on success, error otherwise (mderror_e)

Parameters
  • phonenum: [in] Number to call

int md_call_answer(void)

Answer a call

Return

0 on success, error otherwise (mderror_e)

int md_call_hangup(void)

End a call

Return

0 on success, error otherwise (mderror_e)

const char *md_get_imei(char *imei_buf, int len)

Get IMEI

Return

Buffer containing IMEI

Parameters
  • imei_buf: [out] Buffer to store IMEI (optional, can be NULL)

  • len: [in] Size of imei_buf

const char *md_get_imsi(char *imsi_buf, int len)

Get IMSI

Return

Buffer containing IMSI

Parameters
  • imsi_buf: [out] Buffer to store IMSI (min 16, optional, can be NULL)

  • len: [in] Size of imsi_buf

const char *md_get_ccid(char *ccid_buf, int len)

Get CCID

Return

Buffer containing IMSI

Parameters
  • ccid_buf: [out] Buffer to store CCID (min 20, optional, can be NULL)

  • len: [in] Size of ccid_buf

const char *md_get_operatorname(char *opbuf, int len)

Get Current operator name

Return

Buffer containing operator name

Parameters
  • opbuf: [out] Buffer to store name (optional, can be NULL)

  • len: [in] Size of opbuf

const char *md_get_simprovider(char *spn_buf, int len)

Get service provider name from SIM

Return

Buffer containing SPN

Parameters
  • spn_buf: [out] Buffer to store SPN (optional, can be NULL)

  • len: [in] Size of spn_buf

const char *md_get_sim_phonenum(char *num, int len)

Get MSISDN (Own number) from SIM This API may not work and is SIM dependent

Return

Buffer containing MSISDN (own number)

Parameters
  • num: [out] Buffer to store MSISDN (optional, can be NULL)

  • len: [in] Length of num

int md_get_cellinfo(struct md_cellinfo_t *info)

Get serving and neighboring cell information

Return

0 on success, error otherwise (mderror_e)

Parameters
  • info: [out] Information structure to be filled

int md_getbatt_status(uint32_t *capacity, uint32_t *voltage)

Get battery status

Return

0 on success, error otherwise (mderror_e)

Parameters
  • capacity: [out] Battery capacity in percentage (0 - 100%)

  • voltage: [out] Battery voltage in millivolts

int md_nvm_store(int index, const void *data, int len)

Store in NVM memory

Note

MT2503/MT6261 only support max 50 byte NVM storage per index

Return

0 on success, error otherwise (mderror_e)

Parameters
  • index: [in] NVM index (1 - 8)

  • data: [in] data to store

  • len: [in] Length of data

int md_nvm_read(int index, void *data, int len)

Read from NVM memory

Note

MT2503/MT6261 only support max 50 byte NVM storage per index

Return

success length of actual data is returned, error otherwise (mderror_e)

Parameters
  • index: [in] NVM index (1 - 8)

  • data: [out] Buffer to store read data

  • len: [in] Length of buffer data

int md_get_networktime(struct tm *datetime)

Read network synced time provided by Network service provider

Return

success length of actual data is returned, error otherwise (mderror_e)

Parameters
  • datetime: [out] datetime structure to be filled

Structures

struct md_smsinfo_t

SMS Information structure

Public Members

int status

SMS type GSM 03.40 TP-Message-Type-Indicator (sms_status_e)

struct tm ts

receive time in UTC

char oa_num[PH_NUM_MAX_SZ + 1]

Sender’s number

char sca_num[PH_NUM_MAX_SZ + 1]

Sender’s SMS service center number

char text[SMS_RECV_MAX_SZ + 1]

SMS Text

struct __cellinfo_t

Cell information structure

Public Members

uint16_t mcc

Mobile Country code

uint16_t mnc

Mobile Network code

uint32_t lac

Location Area code

uint32_t cellid

Cell ID

uint16_t bcch_pcid

For LTE this represents PCID (Physical Cell Identity); For GSM, Absolute Radio Frequency Channel Number of Broadcast Control Channel BCCH

uint16_t bsic

For LTE this value is 0; For GSM, Base station identity code

int signal

For LTE, RSRP value; For GSM, RSSI value

int16_t c1_rsrq

For LTE, RSRQ Value; For GSM, C1 value

int16_t c2_srxlev

For LTE, SRXLEV Value; For GSM, C2 value

struct md_cellinfo_t

Serving and Neighboring cell information

Public Members

int cell_type

Cell type mdcelltype_e

struct __cellinfo_t cell

Serving Cell information

int ncell_count

Number of valid neighboring cell available in ncell

struct __cellinfo_t ncell[6]

Neighboring cell information

Macros

SMS_RECV_MAX_SZ

Maximum recvieve SMS size

PH_NUM_MAX_SZ

Enumerations

enum mderror_e

Modem error code

Values:

enumerator MD_SUCCESS = 0

success

enumerator MD_ERR_FAILED = -1

faiure, unknown cause

enumerator MD_ERR_TIMEOUT = -2

operation timeout

enumerator MD_ERR_BUSY = -3

modem busy

enumerator MD_ERR_INVALID_PARAM = -4

Invalid parameter

enumerator MD_ERR_NOMEM = -5

No memory available

enumerator MD_ERR_NOTALLOWED = -6

Operation not allowed

enum mdcelltype_e

Cell info type

Values:

enumerator MD_CELLTYPE_GSM

GSM

enumerator MD_CELLTYPE_LTE

LTE

enum sms_status_e

SMS Status

Values:

enumerator SMS_STATUS_UNREAD
enumerator SMS_STATUS_READ
enumerator SMS_STATUS_UNSENT
enumerator SMS_STATUS_SENT
enumerator SMS_STATUS_ALL
enum sms_delmode_e

SMS delete mode

Values:

enumerator SMS_DEL_INDEXED = 0

Single message by index

enumerator SMS_DEL_READ = 1

Already read messages

enumerator SMS_DEL_READ_SENT = 2

Read and sent messages

enumerator SMS_DEL_READ_SENT_UNSENT = 3

Read ,sent and unsent messages

enumerator SMS_DEL_ALL = 4

All messages in current storage