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:
- Connect a WDS client and run its connection. The AG35 has one WDS server,
at instance 0.
ClientBuilder::instanceselects another one. - Bind the data port with
Client::bind_mux_data_port. The mux ID ofrmnet_dataNisN + 1. - Set the IP family with
Client::set_ip_family. - Start the call with
Client::start_network. - Read the settings with
Client::runtime_settingsafter 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:
- The default profile (
Client::default_profile,Client::set_default_profile). The IDL says that aStartNetworkwithout a profile uses the device defaults. On EVA and EVD such a call used theProfileFamily::TETHEREDdefault. Changing theProfileFamily::EMBEDDEDdefault didn’t change the profile of such a call. - The LTE attach PDN list (
Client::lte_attach_pdn_list,Client::set_lte_attach_pdn_list). It holds the profiles for the LTE attach, in order of decreasing priority.Client::lte_attach_paramsshows the APN of the last attach.
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§
Structs§
- Apn
- Access point name (APN), at most 150 bytes.
- Auth
Preference - Authentication protocols that a profile or call may use
(
wds_auth_pref_mask_v01). - Bind
MuxData Port - Binds the client to a data port (
QMI_WDS_BIND_MUX_DATA_PORT). - CallEnd
- Why a call ended or failed to start.
- Call
EndReason - Reason why a call ended (
wds_call_end_reason_enum_v01). - Call
EndReason Type - Meaning of the code in a
VerboseCallEndReason(wds_verbose_call_end_reason_type_enum_v01). - Client
- Client of the WDS service.
- Connection
Status - State of a packet data connection (
wds_connection_status_enum_v01). - Create
Profile - Creates a 3GPP profile (
QMI_WDS_CREATE_PROFILE). - Created
Profile - The new profile.
- Default
Profile - The default 3GPP profile.
- Delete
Profile - Deletes a profile (
QMI_WDS_DELETE_PROFILE). - Endpoint
Id - A data endpoint (
data_ep_id_type_v01). - Endpoint
Type - Type of a data endpoint (
data_ep_type_enum_v01). - GetDefault
Profile - Reads the number of the default 3GPP profile
(
QMI_WDS_GET_DEFAULT_PROFILE_NUM). - GetLte
Attach Params - Reads the parameters of the last LTE attach
(
QMI_WDS_GET_LTE_ATTACH_PARAMS). - GetLte
Attach PdnList - Reads the LTE attach PDN list (
QMI_WDS_GET_LTE_ATTACH_PDN_LIST). - GetPacket
Service Status - Reads the state of the packet data connection of this client
(
QMI_WDS_GET_PKT_SRVC_STATUS). - GetProfile
List - Reads the list of profiles (
QMI_WDS_GET_PROFILE_LIST). - GetProfile
Settings - Reads the settings of a 3GPP profile (
QMI_WDS_GET_PROFILE_SETTINGS). - GetRuntime
Settings - 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). - IpFamily
Preference - IP family that a client asks for (
wds_ip_family_preference_enum_v01). - IpSupport
Type - IP versions that a PDN supports (
wds_ip_support_type_enum_v01). - Ipv6
Prefix - An IPv6 address or gateway with its prefix length
(
wds_runtime_ipv6_addr_type_v01). - LteAttach
Params - Parameters of the LTE attach.
- LteAttach
PdnList - Profiles for the LTE attach.
- Modify
Profile Settings - Sets the settings of a 3GPP profile (
QMI_WDS_MODIFY_PROFILE_SETTINGS). - MuxId
- Mux ID of a data port, from 1 to 4.
- Packet
Data Handle - Handle of a started data call (
pkt_data_handle). - Packet
Service State - State of the packet data connection.
- Packet
Service Status Indication - 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
CreateProfileandModifyProfileSettings. - Profile
Family - Family of a profile (
wds_profile_family_enum_v01). - Profile
Id - Identifies a profile (
wds_profile_identifier_type_v01). - Profile
Index - Index of a 3GPP profile.
- Profile
Info - An entry of a
ProfileList(wds_profile_info_type_v01). - Profile
List - Profiles on the modem.
- Profile
Name - Name of a profile, at most 50 bytes.
- Profile
Settings - Settings of a profile.
- Profile
Type - Technology of a profile (
wds_profile_type_enum_v01). - Requested
Settings - Settings that
GetRuntimeSettingsasks for (wds_req_settings_mask_v01). - Rmnet
Index - Index
Nof the network devicermnet_dataN. - Runtime
Settings - Settings of a data call.
- SetDefault
Profile - Sets the number of the default 3GPP profile
(
QMI_WDS_SET_DEFAULT_PROFILE_NUM). - SetIp
Family - Sets the IP family of the data calls of this client
(
QMI_WDS_SET_CLIENT_IP_FAMILY_PREF). - SetLte
Attach PdnList - Sets the LTE attach PDN list (
QMI_WDS_SET_LTE_ATTACH_PDN_LIST). - Start
Network - Starts a data call (
QMI_WDS_START_NETWORK_INTERFACE). - Started
Network - A started data call.
- Stop
Network - Ends a data call (
QMI_WDS_STOP_NETWORK_INTERFACE). - Technology
Name - Technology of a data call (
wds_technology_name_enum_v01). - Username
- User name for the authentication of a call, at most 127 bytes.
- Verbose
Call EndReason - 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.