Skip to main content

Crate ql_nas

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(&register).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:

  1. ConfigSigInfo2 with the same values in both states. The low_power example has the values.
  2. IndicationRegister with sig_info and err_rate set to false with the screen off and true with the screen on. sys_info is always true.
  3. With the screen on: GetSysInfo and GetSigInfo, for the changes that the indications missed.
  4. SetSysInfoIndReportingLimit with SysInfoLimit::SRV_STATUS with the screen off and an empty mask with the screen on. mcm_ril_service keeps 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§

AcquisitionOrder
Order in which the modem tries radio technologies, at most Self::MAX.
CellAccessStatus
Call barring of a cell (nas_cell_access_status_e_type_v01).
CellBroadcastCapability
Cell broadcast capability (nas_cell_broadcast_cap_enum_type_v01).
CellLocationInfo
Cell information.
ChangeDuration
How long a preference change lasts (nas_change_duration_enum_v01).
Client
Client of the NAS service.
CommonSysInfo
System information of every radio technology (nas_common_sys_info_type_v01).
ConfigSigInfo2
Sets when the modem sends signal strength indications (QMI_NAS_CONFIG_SIG_INFO2).
GetCellLocationInfo
Reads the serving and neighbor cells (QMI_NAS_GET_CELL_LOCATION_INFO).
GetSigInfo
Reads the signal strength (QMI_NAS_GET_SIG_INFO).
GetSysInfo
Reads the system information (QMI_NAS_GET_SYS_INFO).
GetSysInfoIndReportingLimit
Reads the limit of system information indications (QMI_NAS_GET_SYS_INFO_IND_REPORTING_LIMIT).
GetSystemSelectionPreference
Reads the system selection preference (QMI_NAS_GET_SYSTEM_SELECTION_PREFERENCE).
GsmSignal
GSM signal strength.
GsmSysInfo
GSM system information (nas_gsm_sys_info_type_v01).
GwAcquisitionOrder
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).
IndicationRegister
Sets which indications the modem sends to this client (QMI_NAS_INDICATION_REGISTER).
LteCell
A measured LTE cell (nas_lte_ngbr_cell_type_v01).
LteDisableCause
Why LTE is disabled (nas_lte_disable_cause_enum_type_v01).
LteIntraFrequency
LTE serving cell and its intra-frequency neighbors (nas_lte_intra_freq_type_v01).
LteSignal
LTE signal strength (nas_lte_sig_info_type_v01).
LteSignalAveragingPeriod
Averaging period of LTE signal strength (nas_lte_sig_avg_prd_enum_type_v01).
LteSignalReportConfig
LTE signal report configuration (nas_lte_sig_rpt_config_type_v01).
LteSignalReportRate
How often the modem reports LTE signal strength (nas_lte_sig_rpt_rate_enum_type_v01).
LteSysInfo
LTE system information (nas_lte_sys_info_type_v01).
ManualNetwork
Network for manual selection (nas_mnc_pcs_digit_include_status_type_v01).
ModePreference
Radio access technologies (mode_pref_mask_type_v01).
Nas
Marker of the NAS service for ql_qmi::Client.
NetworkReject
Network reject reporting (nas_reg_network_reject_v01).
NetworkSelectionPreference
Network selection preference (nas_net_sel_pref_enum_v01).
Plmn
A network ID: the mobile country code (MCC) and mobile network code (MNC).
RadioInterface
Radio interface (nas_radio_if_enum_v01).
RegistrationReject
A registration reject (nas_reg_reject_info_type_v01).
RoamPreference
Roaming preference (nas_roam_pref_enum_v01).
RoamStatus
Roaming status (nas_roam_status_enum_type_v01).
ServiceDomain
Service domain (nas_service_domain_enum_type_v01).
ServiceDomainPreference
Service domain preference (nas_srv_domain_pref_enum_type_v01).
ServiceRegistrationRestriction
Registration restriction (nas_srv_reg_restriction_enum_v01).
ServiceStatus
Service status (nas_service_status_enum_type_v01 and nas_true_service_status_enum_type_v01).
ServiceStatusInfo
Service status of a 3GPP radio technology (nas_3gpp_srv_status_info_type_v01).
SetSysInfoIndReportingLimit
Limits the indications of system information to some changes (QMI_NAS_LIMIT_SYS_INFO_IND_REPORTING).
SetSystemSelectionPreference
Sets the system selection preference (QMI_NAS_SET_SYSTEM_SELECTION_PREFERENCE).
SignalInfo
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.
SysInfoIndReportingLimit
Limit of system information indications.
SysInfoIndication
A system information indication (QMI_NAS_SYS_INFO_IND).
SysInfoLimit
Changes that trigger a system information indication (nas_limit_sys_info_ind_mask_type_v01).
SystemSelectionPreference
The system selection preference.
TdscdmaSignal
TD-SCDMA signal strength (nas_tdscdma_sig_info_type_v01).
TdscdmaSysInfo
TD-SCDMA system information (nas_tdscdma_sys_info_type_v01).
ThreeGppSysInfo
System information of every 3GPP radio technology (nas_3gpp_only_sys_info_type_v01).
Thresholds
Signal thresholds of one measurement, at most Self::MAX.
UsagePreference
Usage setting (nas_usage_pref_enum_v01).
VoiceDomainPreference
Voice domain preference (nas_voice_domain_pref_enum_type_v01).
WcdmaSignal
WCDMA signal strength (nas_common_sig_info_param_type_v01).
WcdmaSysInfo
WCDMA system information (nas_wcdma_sys_info_type_v01).

Enums§

Error
Error returned by NAS operations.
Event
A NAS indication.
NetworkSelection
Network selection (nas_net_sel_pref_type_v01).