Crate ql_nas
Expand description
Rust client for Qualcomm’s QMI Network Access Service (NAS).
NAS (QMI service 0x03) reports the registration, serving cell and signal strength of the modem and sets the allowed radio technologies. This crate covers the GSM, WCDMA, LTE and TD-SCDMA parts of the system information, signal strength and system selection messages, and the LTE part of the cell location. CDMA, HDR and NR5G TLVs stay undecoded.
EVA and EVD firmware share these messages. The crate only uses fields that
both have. EVA has IDL version 1.186 and EVD has 1.220. EVD adds messages,
optional TLVs and enum values, such as RadioInterface::NR5G and
ModePreference::NR5G.
§Example
use std::error::Error;
use ql_nas::Client;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn Error>> {
let (client, connection) = Client::builder().connect()?;
tokio::spawn(connection.run());
let sys_info = client.sys_info().await?;
if let Some(plmn) = sys_info.lte.and_then(|lte| lte.threegpp.plmn) {
println!("LTE on {}-{}", plmn.mcc(), plmn.mnc());
}
println!("{:?}", client.sig_info().await?);
Ok(())
}Client has a method for every request of this crate. Each request method
returns the request, so you can set a timeout with .timeout() before you
await it.
Client::qmi returns the typed ql_qmi::Client for custom requests.
§Indications
Client::indication_register enables indications for this client.
Client::events receives the ones that this crate decodes as
Event. Subscribe before you enable them, otherwise the first ones
are lost.
use std::error::Error;
use ql_nas::{Client, Event, IndicationRegister};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn Error>> {
let (client, connection) = Client::builder().connect()?;
tokio::spawn(connection.run());
let mut events = client.events()?;
let register = IndicationRegister {
sys_info: Some(true),
sig_info: Some(true),
..IndicationRegister::default()
};
client.indication_register(®ister).await?;
loop {
match events.next().await? {
Event::SigInfo(signal) => println!("{signal:?}"),
indication => println!("{indication:?}"),
}
}
}§Registration and signal
GetSysInfo and the indication Event::SysInfo hold the service
status and serving system of each radio technology. GetSigInfo and
Event::SigInfo hold the signal strength. mcm_ril_service keeps
a cache of both. A client of this crate reads the values directly.
SetSystemSelectionPreference and GetSystemSelectionPreference set
and read the allowed radio technologies, the roaming preference and the
network selection.
§Low power mode
mcm_ril_service changes NAS settings of its own client when its screen
state changes (MCM_NW_SCREEN_ON_OFF). It doesn’t change the operating
mode or any power save setting. To do the same, send these requests in
order:
ConfigSigInfo2with the same values in both states. Thelow_powerexample has the values.IndicationRegisterwithsig_infoanderr_rateset tofalsewith the screen off andtruewith the screen on.sys_infois alwaystrue.- With the screen on:
GetSysInfoandGetSigInfo, for the changes that the indications missed. SetSysInfoIndReportingLimitwithSysInfoLimit::SRV_STATUSwith the screen off and an empty mask with the screen on.mcm_ril_servicekeeps the empty mask while a network selection runs.
The header says that the modem keeps the indication registration per
client. On EVA and EVD it also keeps the ConfigSigInfo2 signal
settings and the SetSysInfoIndReportingLimit mask per client. On both,
a client that sent the screen off requests didn’t receive any NAS
indication in a 3 minute test.
The client runs on tokio. See ql_qmi for the runtime and permission
requirements.
Modules§
- cell_
location 🔒 - client 🔒
- error 🔒
- event 🔒
- indication_
register 🔒 - plmn 🔒
- signal 🔒
- sys_
info 🔒 - system_
selection 🔒 - types 🔒
- wire 🔒
Structs§
- Acquisition
Order - Order in which the modem tries radio technologies, at most
Self::MAX. - Cell
Access Status - Call barring of a cell (
nas_cell_access_status_e_type_v01). - Cell
Broadcast Capability - Cell broadcast capability (
nas_cell_broadcast_cap_enum_type_v01). - Cell
Location Info - Cell information.
- Change
Duration - How long a preference change lasts (
nas_change_duration_enum_v01). - Client
- Client of the NAS service.
- Common
SysInfo - System information of every radio technology
(
nas_common_sys_info_type_v01). - Config
SigInfo2 - Sets when the modem sends signal strength indications
(
QMI_NAS_CONFIG_SIG_INFO2). - GetCell
Location Info - Reads the serving and neighbor cells (
QMI_NAS_GET_CELL_LOCATION_INFO). - GetSig
Info - Reads the signal strength (
QMI_NAS_GET_SIG_INFO). - GetSys
Info - Reads the system information (
QMI_NAS_GET_SYS_INFO). - GetSys
Info IndReporting Limit - Reads the limit of system information indications
(
QMI_NAS_GET_SYS_INFO_IND_REPORTING_LIMIT). - GetSystem
Selection Preference - Reads the system selection preference
(
QMI_NAS_GET_SYSTEM_SELECTION_PREFERENCE). - GsmSignal
- GSM signal strength.
- GsmSys
Info - GSM system information (
nas_gsm_sys_info_type_v01). - GwAcquisition
Order - Acquisition order of GSM and WCDMA
(
nas_gw_acq_order_pref_enum_type_v01). - HsSupport
- HSDPA and HSUPA support of a cell (
nas_hs_support_enum_type_v01). - Indication
Register - Sets which indications the modem sends to this client
(
QMI_NAS_INDICATION_REGISTER). - LteCell
- A measured LTE cell (
nas_lte_ngbr_cell_type_v01). - LteDisable
Cause - Why LTE is disabled (
nas_lte_disable_cause_enum_type_v01). - LteIntra
Frequency - LTE serving cell and its intra-frequency neighbors
(
nas_lte_intra_freq_type_v01). - LteSignal
- LTE signal strength (
nas_lte_sig_info_type_v01). - LteSignal
Averaging Period - Averaging period of LTE signal strength
(
nas_lte_sig_avg_prd_enum_type_v01). - LteSignal
Report Config - LTE signal report configuration (
nas_lte_sig_rpt_config_type_v01). - LteSignal
Report Rate - How often the modem reports LTE signal strength
(
nas_lte_sig_rpt_rate_enum_type_v01). - LteSys
Info - LTE system information (
nas_lte_sys_info_type_v01). - Manual
Network - Network for manual selection
(
nas_mnc_pcs_digit_include_status_type_v01). - Mode
Preference - Radio access technologies (
mode_pref_mask_type_v01). - Nas
- Marker of the NAS service for
ql_qmi::Client. - Network
Reject - Network reject reporting (
nas_reg_network_reject_v01). - Network
Selection Preference - Network selection preference (
nas_net_sel_pref_enum_v01). - Plmn
- A network ID: the mobile country code (MCC) and mobile network code (MNC).
- Radio
Interface - Radio interface (
nas_radio_if_enum_v01). - Registration
Reject - A registration reject (
nas_reg_reject_info_type_v01). - Roam
Preference - Roaming preference (
nas_roam_pref_enum_v01). - Roam
Status - Roaming status (
nas_roam_status_enum_type_v01). - Service
Domain - Service domain (
nas_service_domain_enum_type_v01). - Service
Domain Preference - Service domain preference (
nas_srv_domain_pref_enum_type_v01). - Service
Registration Restriction - Registration restriction (
nas_srv_reg_restriction_enum_v01). - Service
Status - Service status (
nas_service_status_enum_type_v01andnas_true_service_status_enum_type_v01). - Service
Status Info - Service status of a 3GPP radio technology
(
nas_3gpp_srv_status_info_type_v01). - SetSys
Info IndReporting Limit - Limits the indications of system information to some changes
(
QMI_NAS_LIMIT_SYS_INFO_IND_REPORTING). - SetSystem
Selection Preference - Sets the system selection preference
(
QMI_NAS_SET_SYSTEM_SELECTION_PREFERENCE). - Signal
Info - Signal strength of the GSM, WCDMA, LTE and TD-SCDMA radio technologies.
- SysInfo
- Service status and serving system of the GSM, WCDMA, LTE and TD-SCDMA radio technologies.
- SysInfo
IndReporting Limit - Limit of system information indications.
- SysInfo
Indication - A system information indication (
QMI_NAS_SYS_INFO_IND). - SysInfo
Limit - Changes that trigger a system information indication
(
nas_limit_sys_info_ind_mask_type_v01). - System
Selection Preference - The system selection preference.
- Tdscdma
Signal - TD-SCDMA signal strength (
nas_tdscdma_sig_info_type_v01). - Tdscdma
SysInfo - TD-SCDMA system information (
nas_tdscdma_sys_info_type_v01). - Three
GppSys Info - System information of every 3GPP radio technology
(
nas_3gpp_only_sys_info_type_v01). - Thresholds
- Signal thresholds of one measurement, at most
Self::MAX. - Usage
Preference - Usage setting (
nas_usage_pref_enum_v01). - Voice
Domain Preference - Voice domain preference (
nas_voice_domain_pref_enum_type_v01). - Wcdma
Signal - WCDMA signal strength (
nas_common_sig_info_param_type_v01). - Wcdma
SysInfo - WCDMA system information (
nas_wcdma_sys_info_type_v01).
Enums§
- Error
- Error returned by NAS operations.
- Event
- A NAS indication.
- Network
Selection - Network selection (
nas_net_sel_pref_type_v01).