Modem Interface APIs¶
Header File¶
Source: include/modem.h
#include <modem.h>
Functions¶
-
int md_sms_send(const char *num, const char *sms_text, unsigned int *ref)¶
SMS Send API
- Parameters
num – [in] Sender’s number
sms_text – [in] message to send
ref – [out] GSM 03.40 TP-Message-Reference
- Returns
0 on success, error otherwise (mderror_e)
-
int md_sms_read(unsigned index, struct md_smsinfo_t *smsinfo)¶
SMS Read
- Parameters
index – [in] Index in the storage to read from
smsinfo – [out] SMS Information structure returned after successful read
- Returns
0 on success, error otherwise (mderror_e)
-
int md_sms_delete(int index, int mode)¶
Delete SMS
- Parameters
index – [in] Index in the storage to read from
mode – [in] SMS delete mode (sms_delmode_e)
- Returns
0 on success, error otherwise (mderror_e)
-
int md_cfun_set(int cfun, int rst)¶
Set modem CFUN state
- Parameters
cfun – [in] CFUN value to set
rst – [in] reset after setting CFUN value
- Returns
0 on success, error otherwise (mderror_e)
-
int md_cfun_get(void)¶
Get modem CFUN state
- Returns
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 returned as URC response.
- Parameters
phonenum – [in] Number to call
- Returns
0 on success, error otherwise (mderror_e)
-
const char *md_get_imei(char *imei_buf, int len)¶
Get IMEI
- Parameters
imei_buf – [out] Buffer to store IMEI (optional, can be NULL)
len – [in] Size of imei_buf
- Returns
Buffer containing IMEI
-
const char *md_get_imsi(char *imsi_buf, int len)¶
Get IMSI
- Parameters
imsi_buf – [out] Buffer to store IMSI (min 16, optional, can be NULL)
len – [in] Size of imsi_buf
- Returns
Buffer containing IMSI
-
const char *md_get_ccid(char *ccid_buf, int len)¶
Get CCID
- Parameters
ccid_buf – [out] Buffer to store CCID (min 20, optional, can be NULL)
len – [in] Size of ccid_buf
- Returns
Buffer containing IMSI
-
const char *md_get_operatorname(char *opbuf, int len)¶
Get Current operator name
- Parameters
opbuf – [out] Buffer to store name (optional, can be NULL)
len – [in] Size of opbuf
- Returns
Buffer containing operator name
-
const char *md_get_simprovider(char *spn_buf, int len)¶
Get service provider name from SIM
- Parameters
spn_buf – [out] Buffer to store SPN (optional, can be NULL)
len – [in] Size of spn_buf
- Returns
Buffer containing SPN
-
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
- Parameters
num – [out] Buffer to store MSISDN (optional, can be NULL)
len – [in] Length of num
- Returns
Buffer containing MSISDN (own number)
-
int md_get_cellinfo(struct md_cellinfo_t *info)¶
Get serving and neighboring cell information
- Parameters
info – [out] Information structure to be filled
- Returns
0 on success, error otherwise (mderror_e)
-
int md_getbatt_status(uint32_t *capacity, uint32_t *voltage)¶
Get battery status
- Parameters
capacity – [out] Battery capacity in percentage (0 - 100%)
voltage – [out] Battery voltage in millivolts
- Returns
0 on success, error otherwise (mderror_e)
-
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
- Parameters
index – [in] NVM index (1 - 8)
data – [in] data to store
len – [in] Length of data
- Returns
0 on success, error otherwise (mderror_e)
-
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
- Parameters
index – [in] NVM index (1 - 8)
data – [out] Buffer to store read data
len – [in] Length of buffer data
- Returns
success length of actual data is returned, error otherwise (mderror_e)
Structures¶
-
struct md_smsinfo_t¶
SMS Information structure
-
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
-
uint16_t mcc¶
-
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
-
int cell_type¶
Macros¶
-
SMS_RECV_MAX_SZ¶
Maximum receieve SMS size
-
PH_NUM_MAX_SZ¶
Enumerations¶
-
enum mderror_e¶
Modem error code
Values:
-
enumerator MD_SUCCESS¶
success
-
enumerator MD_ERR_FAILED¶
failure, unknown cause
-
enumerator MD_ERR_TIMEOUT¶
operation timeout
-
enumerator MD_ERR_BUSY¶
modem busy
-
enumerator MD_ERR_INVALID_PARAM¶
Invalid parameter
-
enumerator MD_ERR_NOMEM¶
No memory available
-
enumerator MD_ERR_NOTALLOWED¶
Operation not allowed
-
enumerator MD_SUCCESS¶
-
enum mdcelltype_e¶
Cell info type
Values:
-
enumerator MD_CELLTYPE_GSM¶
GSM
-
enumerator MD_CELLTYPE_LTE¶
LTE
-
enumerator MD_CELLTYPE_GSM¶
-
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¶
-
enumerator SMS_STATUS_UNREAD¶
-
enum sms_delmode_e¶
SMS delete mode
Values:
-
enumerator SMS_DEL_INDEXED¶
Single message by index
-
enumerator SMS_DEL_READ¶
Already read messages
-
enumerator SMS_DEL_READ_SENT¶
Read and sent messages
-
enumerator SMS_DEL_READ_SENT_UNSENT¶
Read ,sent and unsent messages
-
enumerator SMS_DEL_ALL¶
All messages in current storage
-
enumerator SMS_DEL_INDEXED¶
