LTE library for using LTE network. More...
Modules | |
LTE LwM2M API definitions | |
LTE LwM2M API Definitions. | |
Files | |
file | lte_api.h |
Macros | |
#define | EXTERN extern "C" |
Functions | |
int | lte_initialize (void) |
int | lte_finalize (void) |
int | lte_set_report_restart (restart_report_cb_t restart_callback) |
int | lte_power_on (void) |
int | lte_power_off (void) |
int | lte_radio_on_sync (void) |
int | lte_radio_off_sync (void) |
int | lte_get_netinfo_sync (uint8_t pdn_num, FAR lte_netinfo_t *info) |
int | lte_activate_pdn_sync (FAR lte_apn_setting_t *apn, FAR lte_pdn_t *pdn) |
int | lte_activate_pdn (FAR lte_apn_setting_t *apn, activate_pdn_cb_t callback) |
int | lte_activate_pdn_cancel (void) |
int | lte_deactivate_pdn_sync (uint8_t session_id) |
int | lte_data_allow_sync (uint8_t session_id, uint8_t allow, uint8_t roaming_allow) |
int | lte_get_imscap_sync (FAR bool *imscap) |
int | lte_get_version_sync (FAR lte_version_t *version) |
int | lte_get_phoneno_sync (FAR char *phoneno, size_t len) |
int | lte_get_imsi_sync (FAR char *imsi, size_t len) |
int | lte_get_imei_sync (FAR char *imei, size_t len) |
int | lte_get_pinset_sync (FAR lte_getpin_t *pinset) |
int | lte_set_pinenable_sync (bool enable, FAR char *pincode, FAR uint8_t *attemptsleft) |
int | lte_change_pin_sync (int8_t target_pin, FAR char *pincode, FAR char *new_pincode, FAR uint8_t *attemptsleft) |
int | lte_enter_pin_sync (FAR char *pincode, FAR char *new_pincode, FAR uint8_t *simstat, FAR uint8_t *attemptsleft) |
int | lte_get_localtime_sync (FAR lte_localtime_t *localtime) |
int | lte_get_operator_sync (FAR char *oper, size_t len) |
int | lte_get_edrx_sync (FAR lte_edrx_setting_t *settings) |
int | lte_set_edrx_sync (FAR lte_edrx_setting_t *settings) |
int | lte_get_psm_sync (FAR lte_psm_setting_t *settings) |
int | lte_set_psm_sync (FAR lte_psm_setting_t *settings) |
int | lte_get_ce_sync (FAR lte_ce_setting_t *settings) |
int | lte_set_ce_sync (FAR lte_ce_setting_t *settings) |
int | lte_set_report_simstat (simstat_report_cb_t simstat_callback) |
int | lte_set_report_localtime (localtime_report_cb_t localtime_callback) |
int | lte_set_report_quality (quality_report_cb_t quality_callback, uint32_t period) |
int | lte_set_report_cellinfo (cellinfo_report_cb_t cellinfo_callback, uint32_t period) |
int | lte_set_report_netinfo (netinfo_report_cb_t netinfo_callback) |
int | lte_get_errinfo (FAR lte_errinfo_t *info) |
int | lte_get_siminfo_sync (uint32_t option, FAR lte_siminfo_t *siminfo) |
int | lte_get_current_edrx_sync (FAR lte_edrx_setting_t *settings) |
int | lte_get_current_psm_sync (FAR lte_psm_setting_t *settings) |
int | lte_get_quality_sync (FAR lte_quality_t *quality) |
int | lte_get_cellinfo_sync (FAR lte_cellinfo_t *cellinfo) |
int | lte_get_rat_sync (void) |
Get RAT type. More... | |
int | lte_set_rat_sync (uint8_t rat, bool persistent) |
Set RAT setting. More... | |
int | lte_get_ratinfo_sync (FAR lte_ratinfo_t *info) |
Get RAT information. More... | |
int | lte_acquire_wakelock (void) |
int | lte_release_wakelock (void) |
int | lte_get_wakelock_count (void) |
int | lte_send_atcmd_sync (FAR const char *cmd, int cmdlen, FAR char *respbuff, int respbufflen, FAR int *resplen) |
Send AT command to the modem. More... | |
int | lte_factory_reset_sync (void) |
int | lte_set_context_save_cb (context_save_cb_t callback) |
int | lte_hibernation_resume (FAR const uint8_t *res_ctx, int len) |
LTE library for using LTE network.
PDN : Packet Data Network
Route for transferring packets between the terminal and LTE networks.
APN : Access Point Name
Settings required when connecting to an LTE network.
IMSI : International Mobile Subscriber Identity
International subscriber identification number recorded on the SIM card.
IMEI : International Mobile Equipment Identifier
International identification number assigned to data communication terminals
MCC : Mobile Country Code
The mobile country code consists of three decimal digits.
MNC : Mobile Network Code
The mobile network code consists of two or three decimal digits.
eDRX : extended Discontinuous Reception
Communication technology that reduces power consumption by increasing the reception interval of various signals transmitted from LTE networks.
PSM : Power Saving Mode
Communication technology that reduces power consumption by not communicating with the LTE network for a certain period of time.
CE : Coverage Enhancement
Communication technology that attempts to resend data and eventually restores the original data even if the data is corrupted due to weak electric field communication.
RAT : Radio Access Technology
Physical connection method for a radio based communication network.
Network connection API
Radio ON / OFF, PDN connection establishment / destruction.
Communication quality and communication state API
Acquisition of radio status, communication status, and local time.
SIM card control API
Get phone number / IMSI, set the PIN, get SIM status.
Modem setting API
Get modem firmware version and IMEI. Update communication settings.
API call type
There are two types of LTE API: synchronous and asynchronous.
For some APIs, both synchronous and asynchronous APIs are available. The correspondence table of API is as follows.
Synchronous API | Asynchronous API |
---|---|
lte_initialize | |
lte_finalize | |
lte_set_report_restart | |
lte_power_on | |
lte_power_off | |
lte_set_report_netinfo | |
lte_set_report_simstat | |
lte_set_report_localtime | |
lte_set_report_quality | |
lte_set_report_cellinfo | |
lte_get_errinfo | |
lte_activate_pdn_cancel | |
lte_radio_on_sync | lte_radio_on (deprecated) |
lte_radio_off_sync | lte_radio_off (deprecated) |
lte_activate_pdn_sync | lte_activate_pdn |
lte_deactivate_pdn_sync | lte_deactivate_pdn (deprecated) |
lte_data_allow_sync | lte_data_allow (deprecated) |
lte_get_netinfo_sync | lte_get_netinfo (deprecated) |
lte_get_imscap_sync | lte_get_imscap (deprecated) |
lte_get_version_sync | lte_get_version (deprecated) |
lte_get_phoneno_sync | lte_get_phoneno (deprecated) |
lte_get_imsi_sync | lte_get_imsi (deprecated) |
lte_get_imei_sync | lte_get_imei (deprecated) |
lte_get_pinset_sync | lte_get_pinset (deprecated) |
lte_set_pinenable_sync | lte_set_pinenable (deprecated) |
lte_change_pin_sync | lte_change_pin (deprecated) |
lte_enter_pin_sync | lte_enter_pin (deprecated) |
lte_get_localtime_sync | lte_get_localtime (deprecated) |
lte_get_operator_sync | lte_get_operator (deprecated) |
lte_get_edrx_sync | lte_get_edrx (deprecated) |
lte_set_edrx_sync | lte_set_edrx (deprecated) |
lte_get_psm_sync | lte_get_psm (deprecated) |
lte_set_psm_sync | lte_set_psm (deprecated) |
lte_get_ce_sync | lte_get_ce (deprecated) |
lte_set_ce_sync | lte_set_ce (deprecated) |
lte_get_siminfo_sync | lte_get_siminfo (deprecated) |
lte_get_current_edrx_sync | lte_get_current_edrx (deprecated) |
lte_get_current_psm_sync | lte_get_current_psm (deprecated) |
lte_get_quality_sync | lte_get_quality (deprecated) |
lte_get_cellinfo_sync | |
lte_get_rat_sync | |
lte_set_rat_sync | |
lte_get_ratinfo_sync | |
lte_acquire_wakelock | |
lte_release_wakelock | |
lte_send_atcmd_sync | |
lte_factory_reset_sync | |
lte_set_context_save_cb | |
lte_hibernation_resume |
int lte_initialize | ( | void | ) |
Initialize resources used in LTE API.
int lte_finalize | ( | void | ) |
Release resources used in LTE API.
int lte_set_report_restart | ( | restart_report_cb_t | restart_callback | ) |
Register the callback to notify that the modem has started up.
The callback will be invoked if the modem starts successfully after calling lte_power_on. Some APIs have to wait until this callback is invoked. If no wait, those API return with an error. (-ENETDOWN)
The callback is also invoked when the modem is restarted. The cause of the restart can be obtained from the callback argument.
This function must be called after lte_initialize.
[in] | restart_callback | Callback function to notify that modem restarted. |
int lte_power_on | ( | void | ) |
Power on the modem.
The callback which registered by lte_set_report_restart will be invoked if the modem starts successfully.
This function must be called after lte_set_report_restart.
int lte_power_off | ( | void | ) |
Power off the modem
int lte_radio_on_sync | ( | void | ) |
With the radio on, to start the LTE network search.
int lte_radio_off_sync | ( | void | ) |
Exit LTE network searches with the radio off.
If this function is called when a PDN has already been constructed, the PDN is discarded.
int lte_get_netinfo_sync | ( | uint8_t | pdn_num, |
FAR lte_netinfo_t * | info | ||
) |
Get LTE network information.
[in] | pdn_num | Number of pdn_stat allocated by the user. The range is from LTE_PDN_SESSIONID_MIN to LTE_PDN_SESSIONID_MAX. |
[out] | info | The LTE network information. See lte_netinfo_t |
int lte_activate_pdn_sync | ( | FAR lte_apn_setting_t * | apn, |
FAR lte_pdn_t * | pdn | ||
) |
Constructs a PDN with the specified APN settings.
When constructs the initial PDN, LTE_APN_TYPE_IA must be set to the APN type.
When PDN construction is successful, an IP address is given from the LTE network.
[in] | apn | The pointer of the apn setting. See lte_apn_setting_t for valid parameters. |
[out] | pdn | The construction PDN information. See lte_pdn_t. |
int lte_activate_pdn | ( | FAR lte_apn_setting_t * | apn, |
activate_pdn_cb_t | callback | ||
) |
Constructs a PDN with the specified APN settings.
When constructs the initial PDN, LTE_APN_TYPE_IA must be set to the APN type.
When PDN construction is successful, an IP address is given from the LTE network.
[in] | apn | The pointer of the apn setting. See lte_apn_setting_t for valid parameters. |
[in] | callback | Callback function to notify that PDN activation completed. |
int lte_activate_pdn_cancel | ( | void | ) |
Cancel PDN construction.
int lte_deactivate_pdn_sync | ( | uint8_t | session_id | ) |
Discard the constructed PDN.
Discards the PDN corresponding to the session ID obtained by lte_activate_pdn.
When the discard process is successful, the IP address assigned to the modem is released to the LTE network.
[in] | session_id | The numeric value of the session ID. Use the value obtained by the lte_activate_pdn. |
int lte_data_allow_sync | ( | uint8_t | session_id, |
uint8_t | allow, | ||
uint8_t | roaming_allow | ||
) |
Allow or disallow to data communication for specified PDN.
[in] | session_id | The numeric value of the session ID. Use the value obtained by the lte_activate_pdn. |
[in] | allow | Allow or disallow to data communication for all network. Definition is as below. |
[in] | roaming_allow | Allow or disallow to data communication for roaming network. Definition is as below. |
int lte_get_imscap_sync | ( | FAR bool * | imscap | ) |
Get whether the modem supports IMS or not.
[out] | imscap | The IMS capability. As below value stored. |
int lte_get_version_sync | ( | FAR lte_version_t * | version | ) |
Acquires the FW version information of the modem.
[out] | version | The version information of the modem. See lte_version_t |
int lte_get_phoneno_sync | ( | FAR char * | phoneno, |
size_t | len | ||
) |
Get phone number from SIM.
[out] | phoneno | A character string indicating phone number. It is terminated with '\0'. The maximum number of phone number areas must be allocated. See LTE_PHONENO_LEN. |
[in] | len | Length of the buffer for storing phone number. |
int lte_get_imsi_sync | ( | FAR char * | imsi, |
size_t | len | ||
) |
Get International Mobile Subscriber Identity from SIM.
[out] | imsi | A character string indicating IMSI. It is terminated with '\0'. The maximum number of IMSI areas must be allocated. See LTE_IMSI_LEN. |
[in] | len | Length of the buffer for storing IMSI. |
int lte_get_imei_sync | ( | FAR char * | imei, |
size_t | len | ||
) |
Get International Mobile Equipment Identifier from the modem.
[out] | imei | A character string indicating IMEI. It is terminated with '\0'. The maximum number of IMEI areas must be allocated. See LTE_IMEI_LEN. |
[in] | len | Length of the buffer for storing IMEI. |
On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
int lte_get_pinset_sync | ( | FAR lte_getpin_t * | pinset | ) |
Get Personal Identification Number settings.
[out] | pinset | PIN settings information. See lte_getpin_t. |
int lte_set_pinenable_sync | ( | bool | enable, |
FAR char * | pincode, | ||
FAR uint8_t * | attemptsleft | ||
) |
Set Personal Identification Number enable.
[in] | enable | "Enable" or "Disable". Definition is as below. |
[in] | pincode | Current PIN code. Minimum number of digits is 4. Maximum number of digits is 8, end with '\0'. (i.e. Max 9 byte) |
[out] | attemptsleft | Number of attempts left. Set only if failed. |
int lte_change_pin_sync | ( | int8_t | target_pin, |
FAR char * | pincode, | ||
FAR char * | new_pincode, | ||
FAR uint8_t * | attemptsleft | ||
) |
Change Personal Identification Number.
It can be changed only when PIN is enable.
[in] | target_pin | Target of change PIN. Definition is as below. |
[in] | pincode | Current PIN code. Minimum number of digits is 4. Maximum number of digits is 8, end with '\0'. (i.e. Max 9 byte) |
[in] | new_pincode | New PIN code. Minimum number of digits is 4. Maximum number of digits is 8, end with '\0'. (i.e. Max 9 byte) |
[out] | attemptsleft | Number of attempts left. Set only if failed. |
int lte_enter_pin_sync | ( | FAR char * | pincode, |
FAR char * | new_pincode, | ||
FAR uint8_t * | simstat, | ||
FAR uint8_t * | attemptsleft | ||
) |
Enter Personal Identification Number.
[in] | pincode | Current PIN code. Minimum number of digits is 4. Maximum number of digits is 8, end with '\0'. (i.e. Max 9 byte) |
[in] | new_pincode | Always set NULL. This parameter is not currently used. If this parameter has a value in it, this API will error. |
[out] | simstat | State after PIN enter. As below value stored.
|
[out] | attemptsleft | Number of attempts left. Set only if failed. If simstat is other than PIN, PUK, PIN2, PUK2, set the number of PIN. |
int lte_get_localtime_sync | ( | FAR lte_localtime_t * | localtime | ) |
Get local time.
[out] | localtime | Local time. See lte_localtime_t. |
int lte_get_operator_sync | ( | FAR char * | oper, |
size_t | len | ||
) |
Get connected network operator information.
[out] | oper | A character string indicating network operator. It is terminated with '\0' If it is not connected, the first character is '\0'. The maximum number of network operator areas must be allocated. See LTE_OPERATOR_LEN. |
[in] | len | Length of the buffer for storing network operator. |
int lte_get_edrx_sync | ( | FAR lte_edrx_setting_t * | settings | ) |
Get eDRX settings.
[out] | settings | eDRX settings. See lte_edrx_setting_t. |
int lte_set_edrx_sync | ( | FAR lte_edrx_setting_t * | settings | ) |
Set eDRX settings.
[in] | settings | eDRX settings. |
int lte_get_psm_sync | ( | FAR lte_psm_setting_t * | settings | ) |
Get PSM settings.
[out] | settings | PSM settings. See lte_psm_setting_t. |
int lte_set_psm_sync | ( | FAR lte_psm_setting_t * | settings | ) |
Set PSM settings.
[in] | settings | PSM settings. |
int lte_get_ce_sync | ( | FAR lte_ce_setting_t * | settings | ) |
Get CE settings.
[out] | settings | CE settings. See lte_ce_setting_t. |
int lte_set_ce_sync | ( | FAR lte_ce_setting_t * | settings | ) |
Set CE settings.
[in] | settings | CE settings |
int lte_set_report_simstat | ( | simstat_report_cb_t | simstat_callback | ) |
Notifies the SIM status to the application.
The default report setting is disable.
[in] | simstat_callback | Callback function to notify that SIM state. If NULL is set, the report setting is disabled. |
int lte_set_report_localtime | ( | localtime_report_cb_t | localtime_callback | ) |
Notifies the Local time to the application.
The default report setting is disable.
[in] | localtime_callback | Callback function to notify that local time. If NULL is set, the report setting is disabled. |
int lte_set_report_quality | ( | quality_report_cb_t | quality_callback, |
uint32_t | period | ||
) |
Notifies the communication quality information to the application.
Invoke the callback at the specified report interval.
The default report setting is disable.
[in] | quality_callback | Callback function to notify that quality information. If NULL is set, the report setting is disabled. |
[in] | period | Reporting cycle in sec (1-4233600) |
int lte_set_report_cellinfo | ( | cellinfo_report_cb_t | cellinfo_callback, |
uint32_t | period | ||
) |
Notifies the LTE network cell information to the application.
Invoke the callback at the specified report interval.
The default report setting is disable.
[in] | cellinfo_callback | Callback function to notify that cell information. If NULL is set, the report setting is disabled. |
[in] | period | Reporting cycle in sec (1-4233600) |
int lte_set_report_netinfo | ( | netinfo_report_cb_t | netinfo_callback | ) |
Notifies the LTE network status to the application.
The default report setting is disable.
[in] | netinfo_callback | Callback function to notify that cell information. If NULL is set, the report setting is disabled. |
int lte_get_errinfo | ( | FAR lte_errinfo_t * | info | ) |
Get LTE API last error information.
Call this function when LTE_RESULT_ERROR is returned by callback function. The detailed error information can be obtained.
[in] | info | Pointer of error information. |
int lte_get_siminfo_sync | ( | uint32_t | option, |
FAR lte_siminfo_t * | siminfo | ||
) |
Get SIM information such as Mobile Country Code/Mobile Network Code.
[in] | option | Indicates which parameter to get. Bit setting definition is as below. |
[out] | siminfo | SIM information. See lte_siminfo_t. |
int lte_get_current_edrx_sync | ( | FAR lte_edrx_setting_t * | settings | ) |
Get current eDRX settings.
This API can be issued after connect to the LTE network with lte_activate_pdn().
Get the settings negotiated between the modem and the network.
[out] | settings | Current eDRX settings. See lte_edrx_setting_t. |
int lte_get_current_psm_sync | ( | FAR lte_psm_setting_t * | settings | ) |
Get current PSM settings.
This API can be issued after connect to the LTE network with lte_activate_pdn().
Get the settings negotiated between the modem and the network.
[OUT] | settings: Current PSM settings. See lte_psm_setting_t. |
int lte_get_quality_sync | ( | FAR lte_quality_t * | quality | ) |
Get communication quality information.
[out] | quality | Quality information. See lte_quality_t |
int lte_get_cellinfo_sync | ( | FAR lte_cellinfo_t * | cellinfo | ) |
Get LTE network cell information.
[out] | cellinfo | LTE network cell information. See lte_cellinfo_t |
int lte_get_rat_sync | ( | void | ) |
Get RAT type.
int lte_set_rat_sync | ( | uint8_t | rat, |
bool | persistent | ||
) |
Set RAT setting.
[in] | rat | RAT type. Definition is as below. |
[in] | persistent | Flag to keep RAT settings after power off the modem. Definition is as below. |
int lte_get_ratinfo_sync | ( | FAR lte_ratinfo_t * | info | ) |
Get RAT information.
[out] | info | Pointer to the structure that stores RAT information See lte_ratinfo_t. |
int lte_acquire_wakelock | ( | void | ) |
Acquire the modem wakelock. If any wakelock is acquired, modem can't enter to the sleep state. Please call this API after calling lte_initialize(). Otherwise this API will result in an error. Before calling lte_finalize(), must release all wakelocks acquired by this API.
int lte_release_wakelock | ( | void | ) |
Release the modem wakelock. If all of the wakelock are released, modem can enter to the sleep state. Please call this API after calling lte_initialize(). Otherwise this API will result in an error.
int lte_get_wakelock_count | ( | void | ) |
Get the number of wakelock counts acquired. Please call this API after calling lte_initialize(). Otherwise this API will result in an error.
On success, return the count of the current modem wakelock. On failure, negative value is returned according to <errno.h>.
int lte_send_atcmd_sync | ( | FAR const char * | cmd, |
int | cmdlen, | ||
FAR char * | respbuff, | ||
int | respbufflen, | ||
FAR int * | resplen | ||
) |
Send AT command to the modem.
[in] | cmd | The AT command data. Maximum length is LTE_AT_COMMAND_MAX_LEN. AT command is shall begin with "AT" and end with '\r'. |
[in] | cmdlen | Length of the AT command data. |
[in] | respbuff | The area to store the AT command response. |
[in] | respbufflen | Length of the AT command response buffer. |
[in] | resplen | The pointer to the area store the length of AT command response. |
int lte_factory_reset_sync | ( | void | ) |
Run factory reset on the modem.
int lte_set_context_save_cb | ( | context_save_cb_t | callback | ) |
Set callback function for context save.
[in] | callback | Callback function to notify a context data when modem entering hibernation mode. |
int lte_hibernation_resume | ( | FAR const uint8_t * | res_ctx, |
int | len | ||
) |
Resume LTE status from hibernation mode.
[in] | res_ctx | Context data for resume daemon. |
[in] | len | : Context data size. |