Skip to main content

Crate ql_wds

Crate ql_wds 

Expand description

Rust client for Qualcomm’s QMI Wireless Data Service (WDS).

WDS (QMI service 0x01) sets up packet data calls and manages the APN profiles. This crate covers profiles, the default profile and LTE attach settings, and data calls on the rmnet_dataN network devices.

EVA and EVD firmware share these messages. The crate only uses fields that both have. EVA has IDL version 1.110 and EVD has 1.156.

§Example

use std::error::Error;
use std::time::Duration;

use ql_wds::{
    Client, ConnectionStatus, EndpointId, GetRuntimeSettings, IpFamily, IpFamilyPreference,
    ProfileIndex, RmnetIndex, StartNetwork,
};

#[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 rmnet = RmnetIndex::new(0).ok_or("no rmnet_data0")?;
    client
        .bind_mux_data_port(EndpointId::BAM_DMUX, rmnet.mux_id())
        .await?;
    client.set_ip_family(IpFamily::IPV4).await?;
    let call = client
        .start_network(&StartNetwork {
            profile_index: ProfileIndex::new(1),
            ip_family: Some(IpFamilyPreference::IPV4),
            ..StartNetwork::default()
        })
        .await?;

    let settings = client
        .runtime_settings(&GetRuntimeSettings::IP_CONFIG)
        .await?;
    println!("{settings:?}");

    // Stop the call after a minute, unless the network ends it first.
    let ended = tokio::time::timeout(Duration::from_secs(60), async {
        while events.next().await?.connection_status != ConnectionStatus::DISCONNECTED {}
        Ok::<(), ql_qmi::Error>(())
    })
    .await;
    match ended {
        Ok(result) => result?,
        Err(_elapsed) => client.stop_network(call.handle).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

The modem sends packet service status indications without a registration. Client::events returns them as PacketServiceStatusIndication. Subscribe before you start a call, otherwise the first ones are lost. On EVA and EVD the client that started a call received its indications, and another client that wasn’t bound to the data port didn’t. Other WDS indications are not decoded.

§Data call flow

Qualcomm’s netmgrd keeps running on the modem. It sets the address, netmask, MTU and link state of rmnet_dataN for every call that is bound to its mux. For each call, a client does these steps in order:

  1. Connect a WDS client and run its connection. The AG35 has one WDS server, at instance 0. ClientBuilder::instance selects another one.
  2. Bind the data port with Client::bind_mux_data_port. The mux ID of rmnet_dataN is N + 1.
  3. Set the IP family with Client::set_ip_family.
  4. Start the call with Client::start_network.
  5. Read the settings with Client::runtime_settings after the connection is up.

netmgrd does not add routes or DNS servers. The client adds the default route and the DNS servers from RuntimeSettings itself.

On EVA and EVD, the modem ends a call when the client that started it disconnects. The address is gone within about half a second. Keep the Client alive for as long as the call should run, and stop the call with Client::stop_network.

§Profiles and LTE attach

A profile contains the APN, PDP type and credentials of a call. Use Client::create_profile, Client::modify_profile_settings, Client::profile_settings, Client::profile_list and Client::delete_profile to manage profiles. The settings requests only handle 3GPP profiles. GetProfileList::THREEGPP lists them.

These settings relate to profiles:

On EVA and EVD, changing the default profile of either family didn’t change the LTE attach PDN list.

The client runs on tokio. See ql_qmi for the runtime and permission requirements.

Modules§

call 🔒
client 🔒
error 🔒
event 🔒
lte_attach 🔒
profile 🔒
text 🔒
types 🔒
wire 🔒

Structs§

Apn
Access point name (APN), at most 150 bytes.
AuthPreference
Authentication protocols that a profile or call may use (wds_auth_pref_mask_v01).
BindMuxDataPort
Binds the client to a data port (QMI_WDS_BIND_MUX_DATA_PORT).
CallEnd
Why a call ended or failed to start.
CallEndReason
Reason why a call ended (wds_call_end_reason_enum_v01).
CallEndReasonType
Meaning of the code in a VerboseCallEndReason (wds_verbose_call_end_reason_type_enum_v01).
Client
Client of the WDS service.
ConnectionStatus
State of a packet data connection (wds_connection_status_enum_v01).
CreateProfile
Creates a 3GPP profile (QMI_WDS_CREATE_PROFILE).
CreatedProfile
The new profile.
DefaultProfile
The default 3GPP profile.
DeleteProfile
Deletes a profile (QMI_WDS_DELETE_PROFILE).
EndpointId
A data endpoint (data_ep_id_type_v01).
EndpointType
Type of a data endpoint (data_ep_type_enum_v01).
GetDefaultProfile
Reads the number of the default 3GPP profile (QMI_WDS_GET_DEFAULT_PROFILE_NUM).
GetLteAttachParams
Reads the parameters of the last LTE attach (QMI_WDS_GET_LTE_ATTACH_PARAMS).
GetLteAttachPdnList
Reads the LTE attach PDN list (QMI_WDS_GET_LTE_ATTACH_PDN_LIST).
GetPacketServiceStatus
Reads the state of the packet data connection of this client (QMI_WDS_GET_PKT_SRVC_STATUS).
GetProfileList
Reads the list of profiles (QMI_WDS_GET_PROFILE_LIST).
GetProfileSettings
Reads the settings of a 3GPP profile (QMI_WDS_GET_PROFILE_SETTINGS).
GetRuntimeSettings
Reads the settings of the data call of this client (QMI_WDS_GET_RUNTIME_SETTINGS).
IpFamily
IP family of a data call (wds_ip_family_enum_v01).
IpFamilyPreference
IP family that a client asks for (wds_ip_family_preference_enum_v01).
IpSupportType
IP versions that a PDN supports (wds_ip_support_type_enum_v01).
Ipv6Prefix
An IPv6 address or gateway with its prefix length (wds_runtime_ipv6_addr_type_v01).
LteAttachParams
Parameters of the LTE attach.
LteAttachPdnList
Profiles for the LTE attach.
ModifyProfileSettings
Sets the settings of a 3GPP profile (QMI_WDS_MODIFY_PROFILE_SETTINGS).
MuxId
Mux ID of a data port, from 1 to 4.
PacketDataHandle
Handle of a started data call (pkt_data_handle).
PacketServiceState
State of the packet data connection.
PacketServiceStatusIndication
An indication of the packet service status (QMI_WDS_PKT_SRVC_STATUS_IND).
Password
Password for the authentication of a call, at most 127 bytes.
PdpType
Packet data protocol of a profile (wds_pdp_type_enum_v01).
Profile
Settings of a 3GPP profile for CreateProfile and ModifyProfileSettings.
ProfileFamily
Family of a profile (wds_profile_family_enum_v01).
ProfileId
Identifies a profile (wds_profile_identifier_type_v01).
ProfileIndex
Index of a 3GPP profile.
ProfileInfo
An entry of a ProfileList (wds_profile_info_type_v01).
ProfileList
Profiles on the modem.
ProfileName
Name of a profile, at most 50 bytes.
ProfileSettings
Settings of a profile.
ProfileType
Technology of a profile (wds_profile_type_enum_v01).
RequestedSettings
Settings that GetRuntimeSettings asks for (wds_req_settings_mask_v01).
RmnetIndex
Index N of the network device rmnet_dataN.
RuntimeSettings
Settings of a data call.
SetDefaultProfile
Sets the number of the default 3GPP profile (QMI_WDS_SET_DEFAULT_PROFILE_NUM).
SetIpFamily
Sets the IP family of the data calls of this client (QMI_WDS_SET_CLIENT_IP_FAMILY_PREF).
SetLteAttachPdnList
Sets the LTE attach PDN list (QMI_WDS_SET_LTE_ATTACH_PDN_LIST).
StartNetwork
Starts a data call (QMI_WDS_START_NETWORK_INTERFACE).
StartedNetwork
A started data call.
StopNetwork
Ends a data call (QMI_WDS_STOP_NETWORK_INTERFACE).
TechnologyName
Technology of a data call (wds_technology_name_enum_v01).
Username
User name for the authentication of a call, at most 127 bytes.
VerboseCallEndReason
Detailed reason why a call ended (wds_verbose_call_end_reason_type_v01).
Wds
Marker of the WDS service for ql_qmi::Client.

Enums§

Error
Error returned by WDS operations.