project/uqmi.git
6 months agouqmid: osmocom/fsm: add member N
Alexander Couzens [Thu, 6 Feb 2025 17:28:27 +0000 (18:28 +0100)]
uqmid: osmocom/fsm: add member N

The N variable counts how often a timer timed out.
It is used in many 3gpp specs to trigger a failure case
when 3x times the timer timed out.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: modem_fsm: set timeout for GET_IMSI to 3 seconds
Alexander Couzens [Tue, 13 Aug 2024 20:39:51 +0000 (22:39 +0200)]
uqmid: modem_fsm: set timeout for GET_IMSI to 3 seconds

Every state should have a timeout. 3 seconds should be plenty
to respond to GET_IMSI.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: add preliminary support for gsmtapv3
Alexander Couzens [Sun, 19 May 2024 15:29:38 +0000 (16:29 +0100)]
uqmid: add preliminary support for gsmtapv3

gsmtap is a protocol to encapsulate debug messages. It originates
from osmocom to encapsulate GSM protocols of multiple layers.
It has been extended to encapsulate many different types of protocols
including non-3GPP messages.
gsmptap version 3 is currently under review and an initial draft exists.

uqmid will use gsmtap to copy and transmit QMI messages to a remote debug destination.
Either use wireshark or a custom utilty to receive and print those messages.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: osmocom/fsm: fix logline for 64bit timestamp
Alexander Couzens [Tue, 13 Aug 2024 19:33:30 +0000 (21:33 +0200)]
uqmid: osmocom/fsm: fix logline for 64bit timestamp

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: add support to set username, password for PDN
Alexander Couzens [Tue, 13 Aug 2024 11:09:20 +0000 (13:09 +0200)]
uqmid: add support to set username, password for PDN

Some APNs require to set a username, password in the wds profile.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: ubus: check for empty strings for configure arguments
Alexander Couzens [Tue, 13 Aug 2024 11:11:25 +0000 (13:11 +0200)]
uqmid: ubus: check for empty strings for configure arguments

Allow to pass empty string as argument via ubus

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: ubus: use talloc() for modem assigned fields when allocating it
Alexander Couzens [Sun, 19 May 2024 16:05:04 +0000 (17:05 +0100)]
uqmid: ubus: use talloc() for modem assigned fields when allocating it

talloc will take care of free'ing it together with the modem.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: wwan: add support to handle kernel network interface
Alexander Couzens [Sat, 18 May 2024 13:33:40 +0000 (14:33 +0100)]
uqmid: wwan: add support to handle kernel network interface

The kernel network interface can have different modes
- 802.3
- raw-ip
- passthrough towards rmnet/qmap

Currently uqmid will only support raw-ip.
To support higher throughput it will use the rmnet ip interface
with QMAP support.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agouqmid: service: add indications support
Alexander Couzens [Fri, 19 Apr 2024 12:31:13 +0000 (14:31 +0200)]
uqmid: service: add indications support

QMI allow baseband services to send indications (events) towards uqmid.
To some indication uqmid has to register first, other indications
are sent as soon the service has been opened.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agoadd uqmid: a daemonic version of uqmi
Alexander Couzens [Sun, 1 Oct 2023 15:38:49 +0000 (17:38 +0200)]
add uqmid: a daemonic version of uqmi

It is configured via ubus to handle QMI based modem and keep
the state of the modem in difference to uqmi as command utility.
Further it also allows to react on events (indications) of the modem.
See uqmid/examples/ for more usage.

Signed-off-by: Alexander Couzens <[email protected]>
6 months agoCMakeLists: set cmake minimum to 3.10
Alexander Couzens [Sat, 22 Feb 2025 16:22:49 +0000 (17:22 +0100)]
CMakeLists: set cmake minimum to 3.10

Drop unsupported pre_build argument of add_custom_command

Signed-off-by: Alexander Couzens <[email protected]>
6 months agocommon/utils: add system_fd_set_cloexec()
Alexander Couzens [Mon, 23 Oct 2023 14:54:28 +0000 (16:54 +0200)]
common/utils: add system_fd_set_cloexec()

Will be used by uqmid/ubus interface.
Taken from netifd/ubus interface.

Signed-off-by: Alexander Couzens <[email protected]>
7 months agouqmi nas: fix incorrect parameter order
David Bauer [Sun, 20 Apr 2025 01:27:39 +0000 (03:27 +0200)]
uqmi nas: fix incorrect parameter order

print_lte_info has been called with incorrect argument order in all places.

Fix the method signature so RSRP and RSRQ are correctly represented in
the output.

Signed-off-by: David Bauer <[email protected]>
15 months agouim: add support for ICC communication channel
David Bauer [Wed, 3 Jan 2024 14:16:19 +0000 (16:16 +0200)]
uim: add support for ICC communication channel

This creates an interface to obtain a communication channel with the ICC
of the modem. This interface can be used by other applications to
interact with the SIM card, for example LPAd applications for managing
connected eUICC.

Signed-off-by: David Bauer <[email protected]>
15 months agoqmi: fix dynamic array macro
David Bauer [Wed, 3 Jan 2024 14:16:19 +0000 (16:16 +0200)]
qmi: fix dynamic array macro

The macro was using the parameter for referencing the length field, which
used the same suffix as the parameter name.

Rename the length parameter to correctly access the length field.

Signed-off-by: David Bauer <[email protected]>
15 months agodata: add support for ICC channel
David Bauer [Wed, 3 Jan 2024 14:16:19 +0000 (16:16 +0200)]
data: add support for ICC channel

Link: https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/merge_requests/376
Signed-off-by: David Bauer <[email protected]>
19 months agouqmi: print radio interfaces in serving system command
Jean Thomas [Wed, 10 Apr 2024 11:29:22 +0000 (13:29 +0200)]
uqmi: print radio interfaces in serving system command

Add a "radio_interface" array to the NAS --get-serving-system
command.

Signed-off-by: Jean Thomas <[email protected]>
19 months agouqmi: create function to print radio interface string
Jean Thomas [Wed, 10 Apr 2024 11:29:21 +0000 (13:29 +0200)]
uqmi: create function to print radio interface string

Signed-off-by: Jean Thomas <[email protected]>
19 months agouqmi: Add basic 5G NR support
Jean Thomas [Wed, 10 Apr 2024 11:29:20 +0000 (13:29 +0200)]
uqmi: Add basic 5G NR support

* Add 5G NR to supported networks in DMS --get-capabilities.
* Add 5G NR to supported mode in NAS --set-network-modes.
* Add 5G NR signal information to NAS --get-signal-info.
* Add 5G NR system information to NAS --get-system-info.
* Add 5G NR to supported radios in NAS --get-tx-rx-info.
* Add 5G NR cell information to NAS --get-cell-location-info.

Signed-off-by: Jean Thomas <[email protected]>
19 months agouqmi: sync data from libqmi project
Jean Thomas [Wed, 10 Apr 2024 10:25:06 +0000 (12:25 +0200)]
uqmi: sync data from libqmi project

JSON files taken from libqmi at commit
20a902ac997b6d140154295e7cdf5d5e986f9b67.

Signed-off-by: Jean Thomas <[email protected]>
19 months agouqmi: support C reserved keywords in upstream JSON files
Jean Thomas [Wed, 10 Apr 2024 10:25:05 +0000 (12:25 +0200)]
uqmi: support C reserved keywords in upstream JSON files

Add a dummy prefix in case a name in the upstream JSON files is a
C reserved keyword.

This is the case with the "Register" element of the new "Configure
Profile Event List" message.

Signed-off-by: Jean Thomas <[email protected]>
20 months agoreorganize source code in common and uqmi specific parts
Alexander Couzens [Sat, 9 Mar 2024 18:57:08 +0000 (19:57 +0100)]
reorganize source code in common and uqmi specific parts

In preparation to add support for uqmid.
Move uqmi specific parts into directory uqmi/.
Move common parts used by both uqmid and uqmi into common/ directory.

Signed-off-by: Alexander Couzens <[email protected]>
20 months ago.gitignore build/ directories
Alexander Couzens [Sat, 9 Mar 2024 19:30:37 +0000 (20:30 +0100)]
.gitignore build/ directories

build is common used to build with cmake.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agouqmi: commands-uim: fix uninitialized use of card_application_state
Alexander Couzens [Sat, 9 Mar 2024 19:17:07 +0000 (20:17 +0100)]
uqmi: commands-uim: fix uninitialized use of card_application_state

Signed-off-by: Alexander Couzens <[email protected]>
20 months agodata/code-gen: add support for indications
Alexander Couzens [Sat, 9 Mar 2024 19:10:50 +0000 (20:10 +0100)]
data/code-gen: add support for indications

Indication (or also notifactions) are send by the modem towards the hosts.
They are similar to response, but without a request.
Some indication will send towards the host as soon the host has created a
session with a service. For other indication the host need to subscribe first.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agoqmi-struct.h: add missing includes
Alexander Couzens [Sat, 9 Mar 2024 19:44:07 +0000 (20:44 +0100)]
qmi-struct.h: add missing includes

To allow qmi-struct.h to be standalone includable.

20 months agomove qmi_get_error_str to into utils.c
Alexander Couzens [Tue, 17 Oct 2023 11:15:22 +0000 (14:15 +0300)]
move qmi_get_error_str to into utils.c

In prepration to allow uqmid to use it as well.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agodev.c: add missing import strings.h
Alexander Couzens [Sun, 1 Oct 2023 16:50:00 +0000 (18:50 +0200)]
dev.c: add missing import strings.h

Fix compiler warning undeclared function.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agocommands-nas: add missing includes
Alexander Couzens [Sun, 1 Oct 2023 16:30:34 +0000 (18:30 +0200)]
commands-nas: add missing includes

Signed-off-by: Alexander Couzens <[email protected]>
20 months agocommands: make `struct blob_buf status` public
Alexander Couzens [Sun, 1 Oct 2023 16:29:49 +0000 (18:29 +0200)]
commands: make `struct blob_buf status` public

status is already used by other files as public variable.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agocommands-nas: fix gcc warning
Alexander Couzens [Sun, 1 Oct 2023 16:28:10 +0000 (18:28 +0200)]
commands-nas: fix gcc warning

The compiler still thinks c could be initialized.
Even this can't happen, assign it to NULL to silence
the warning.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agodev.c: add comment to qmi_request_wait()
Alexander Couzens [Sun, 1 Oct 2023 16:48:19 +0000 (18:48 +0200)]
dev.c: add comment to qmi_request_wait()

Signed-off-by: Alexander Couzens <[email protected]>
20 months agoCMakeLists: refactor SOURCES variable to allow later adding uqmid
Alexander Couzens [Sun, 1 Oct 2023 17:10:10 +0000 (19:10 +0200)]
CMakeLists: refactor SOURCES variable to allow later adding uqmid

Rename main.c into uqmi.c.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agoCMakeLists: set no-dangling-pointer
Alexander Couzens [Tue, 17 Oct 2023 11:05:39 +0000 (14:05 +0300)]
CMakeLists: set no-dangling-pointer

As long complete callback will have a stack allocated pointer, uqmi
need to have --Wno-dangling-pointer.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agoCMakeLists: improve generated files
Alexander Couzens [Sun, 1 Oct 2023 11:47:40 +0000 (13:47 +0200)]
CMakeLists: improve generated files

Flag custom command as PRE_BUILT.
Flag all generated files as generated.
Make generated .c files depend on generated .h files.
Move all generated files to the build dir.

Signed-off-by: Alexander Couzens <[email protected]>
20 months agoCMakeLists: update cmake minimum version to 3.5
Alexander Couzens [Sun, 1 Oct 2023 11:45:26 +0000 (13:45 +0200)]
CMakeLists: update cmake minimum version to 3.5

Older versions aren't anymore supported.

Signed-off-by: Alexander Couzens <[email protected]>
22 months agouqmi: cancel all requests on SYNC indication reception
Jean Thomas [Tue, 5 Dec 2023 10:12:38 +0000 (11:12 +0100)]
uqmi: cancel all requests on SYNC indication reception

A SYNC indication might be sent by the modem on boot as a first
response, in order to indicate that all Client IDs have been
deallocated. Upon reception of this indication, cancel all current
requests, as they will never be answered.

Signed-off-by: Jean Thomas <[email protected]>
22 months agouqmi: improve response detection
Jean Thomas [Tue, 5 Dec 2023 10:12:37 +0000 (11:12 +0100)]
uqmi: improve response detection

Create a helper which checks the flags depending on the service
indicated in the received message, as the response flag is not the same
for the CTL service and the other services. This avoids considering
a CTL indication as a valid response.

Also use a mask in order to check the flags, as they are a bitmap.

Signed-off-by: Jean Thomas <[email protected]>
2 years agouqmi: add slot number to uim-sim-status output
David Bauer [Sat, 28 Oct 2023 23:01:46 +0000 (01:01 +0200)]
uqmi: add slot number to uim-sim-status output

Add the SIM-card slot-number to uim-sim-status output.

Signed-off-by: David Bauer <[email protected]>
2 years agouim: fix help formatting
David Bauer [Wed, 18 Oct 2023 10:11:17 +0000 (12:11 +0200)]
uim: fix help formatting

Signed-off-by: David Bauer <[email protected]>
2 years agouqmi: add APN profile commands
Henrik Ginstmark [Mon, 5 Sep 2022 20:07:52 +0000 (22:07 +0200)]
uqmi: add APN profile commands

Add commands to create and modify default APN profile

--get-default-profile
--get-profile-settings
--create-profile
--modify-profile

Signed-off-by: Henrik Ginstmark <[email protected]>
[change argument for default profile number]
Signed-off-by: David Bauer <[email protected]>
2 years agouim: support SIM card power-up/down
David Bauer [Sat, 7 Oct 2023 17:04:10 +0000 (19:04 +0200)]
uim: support SIM card power-up/down

Support the power-up and power-down commands for the modem's SIM card.
This allows to reset the SIM card and recover it from an illegal card
application state.

Signed-off-by: David Bauer <[email protected]>
2 years agouim: add application state to SIM status
David Bauer [Sat, 7 Oct 2023 17:03:24 +0000 (19:03 +0200)]
uim: add application state to SIM status

Parse the card application state and report it to the SIM card status
output object.

This is required to detect a card application which is in the failed
(illegal) state.

Signed-off-by: David Bauer <[email protected]>
3 years agonas: add decoding of cell_id
Henrik Ginstmark [Tue, 7 Dec 2021 20:53:57 +0000 (21:53 +0100)]
nas: add decoding of cell_id

Add decoding of lte_system_info_v2.cid, in --get-system-info, and
intrafrequency_lte_info_v2.global_cell_id, in --get-cell-location-info,
to enodeb_id and cell_id.
h´xxxxxyy -> enodeb_id = h´xxxxx, cell_id = h´yy

Add decoding of wcdma_system_info_v2.cid, in --get-system-info, to
rnc_id and cell_id.
h´xxxxyyyy -> rnc_id = h´xxxx,  cell_id = h´yyyy

Change order to
mcc-mnc-tac/lac-enodeb_id/rnc_id-cell_id.

Signed-off-by: Henrik Ginstmark <[email protected]>
3 years agouqmi: wms - added storage to read text messages
Henrik Ginstmark [Tue, 15 Mar 2022 19:35:46 +0000 (20:35 +0100)]
uqmi: wms - added storage to read text messages

Today it's hard coded to read text messages from SIM card.
Not all devices store received text messages in SIM, they store
in me, QMI_WMS_STORAGE_TYPE_NV.
I have added --storage as an argumet available to
--list-messages
--get-message
--delete-message
--get-raw-message

If --storage is omitted default storage is sim, as before.

Reviewed-by: Sergey Ryazanov <[email protected]>
Tested-by: Daniel Golle <[email protected]>
Signed-off-by: Henrik Ginstmark <[email protected]>
3 years agouqmi: corrected too short received SMS
Henrik Ginstmark [Fri, 11 Mar 2022 23:33:54 +0000 (00:33 +0100)]
uqmi: corrected too short received SMS

When characters with ascii values bigger than 0x7f are used, the
length of the received text message is too short.

Test message sent: 123äÄ123
Before correction:
root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
Raw text: 31 32 33 7b 5b 31 32 33
{
        "smsc": "+46724400001",
        "sender": "+46xxxxxxxxx",
        "timestamp": "2022-03-11 18:48:10",
        "text": "123äÄ1"
}

after correction:
root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
Raw text: 31 32 33 7b 5b 31 32 33
{
        "smsc": "+46724400001",
        "sender": "+46xxxxxxxxx",
        "timestamp": "2022-03-11 18:48:10",
        "text": "123äÄ123"
}

Signed-off-by: Henrik Ginstmark <[email protected]>
3 years agouqmi: add support for get operating mode
Oskari Lemmela [Tue, 25 Jan 2022 18:05:49 +0000 (20:05 +0200)]
uqmi: add support for get operating mode

Currently only the set operation is supported.
Add support for getting the current operating mode.

Reviewed-by: Sergey Ryazanov <[email protected]>
Signed-off-by: Henrik Ginstmark <[email protected]>
Signed-off-by: Oskari Lemmela <[email protected]>
4 years agocommand-nas: fix out-of-bounds read
Daniel Golle [Mon, 22 Nov 2021 01:19:05 +0000 (01:19 +0000)]
command-nas: fix out-of-bounds read

Limit iteration to number of array members fixing potential
out-of-bounds read.

Coverity CID: 1493471 Out-of-bounds read
Signed-off-by: Daniel Golle <[email protected]>
4 years agouqmi: use unmodified upstream JSON files
Daniel Golle [Sat, 13 Nov 2021 23:07:49 +0000 (23:07 +0000)]
uqmi: use unmodified upstream JSON files

Extend code generator to handle also identifiers starting with a
numerical character.

Suggested-by: Koen Vandeputte <[email protected]>
Acked-by: Oskari Lemmelä <[email protected]>
Signed-off-by: Daniel Golle <[email protected]>
4 years agouim: add --uim-get-sim-state
Daniel Golle [Sat, 6 Nov 2021 02:02:00 +0000 (02:02 +0000)]
uim: add --uim-get-sim-state

Provide same output as --get-pin-status for SIM/modem which require
using uim instead of dms command for that.
For now only the first present SIM card with only the first application
on the card is supported (which should cover the vast majority of
cases and allows to remain compatible with --get-pin-status output)

Suggested-by: Arjun AK <[email protected]>
Signed-off-by: Daniel Golle <[email protected]>
4 years agouqmi: add more diagnostics commands
Oskari Lemmela [Sun, 25 Mar 2018 16:23:06 +0000 (19:23 +0300)]
uqmi: add more diagnostics commands

Useful diagnostic commands for measuring connection info.
Implemented cell location, carrier aggregation and MIMO chain
info in easily parsable json format.

Compressed package size increased by 9kB.

Signed-off-by: Oskari Lemmela <[email protected]>
4 years agouqmi: sync data from libqmi project
Oskari Lemmela [Tue, 12 Oct 2021 05:16:35 +0000 (08:16 +0300)]
uqmi: sync data from libqmi project

Sync all json and header files from libqmi project.
Update code to adapt changes in libqmi files.

Signed-off-by: Oskari Lemmela <[email protected]>
4 years agouqmi: update code generator
Oskari Lemmela [Mon, 11 Oct 2021 19:14:32 +0000 (22:14 +0300)]
uqmi: update code generator

Add support for common-refs and double arrays.
Fix error message line and type parsing.

Signed-off-by: Oskari Lemmela <[email protected]>
5 years agouqmi: add timeout parameter
Zefir Kurtisi [Thu, 7 Nov 2019 11:54:08 +0000 (12:54 +0100)]
uqmi: add timeout parameter

Working with Quectel EM12 LTE-module, we observe
regular stalls of the QMI interface which cause
a request issued by uqmi to hang forever.

Most reproducibly this happens after the device
has been power-cycled and left untouched for a
while (~ 60s+). Most of the time the very first
QMI request fails, since it is not responded by
the module. This is the strace from such a run
(from --get-pin-status):

 open("/dev/cdc-wdm0", O_RDWR|O_EXCL|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 6
 fcntl64(6, F_GETFL)                     = 0x10802 (flags O_RDWR|O_NONBLOCK|O_LARGEFILE)
 fcntl64(6, F_SETFL, O_RDWR|O_NONBLOCK|O_LARGEFILE) = 0
 epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=268567076, u64=1153486808202346496}}) = 0
 write(6, "\1\17\0\0\0\0\0\1\"\0\4\0\1\1\0\2", 16) = 16
 clock_gettime(CLOCK_MONOTONIC, {tv_sec=95, tv_nsec=583444789}) = 0
 clock_gettime(CLOCK_MONOTONIC, {tv_sec=95, tv_nsec=583770264}) = 0
 epoll_pwait(3,
 [ hang forever ]

After killing the blocked uqmi process, the next
request works as expected.

We don't know whether this is a device FW issue
(we use the latest EM12GPAR01A15M4G) or whether
the device enters some undocumented power-save
mode after idling for some time.

This patch extends uqmi with a timeout option
(-t, --timeout <ms>) which if set terminates a
request after the given amount of msecs. In
our usecase it provides a means of preventing
infinitively stuck QMI requests. Since we
observe the issue only for the very first
request after cold-boot, we use a dummy access
early in qmi.sh, e.g.
  uqmi -d /dev/cdc-wdm0 --get-pin-status -t 3000 >/dev/null 2>&1

This ensures the QMI interface is un-stuck in
case it entered the stall-state observed. The
change is intentionally not included in this
commit, since you don't need it if it works
for you.

Signed-off-by: Zefir Kurtisi <[email protected]>
5 years agonas: add --get-plmn
Martin Schiller [Thu, 4 Jul 2019 11:35:37 +0000 (13:35 +0200)]
nas: add --get-plmn

This command is needed in the qmi proto handler to check if the plmn
is already set to 'auto'.

The reason for this is, that setting the plmn to 'auto' will implicitly
lead to a (delayed) network re-registration, which could further lead
to some timing related issues in the qmi proto handler.

Signed-off-by: Martin Schiller <[email protected]>
6 years agouqmi: add explicit check for message type when expecting a response
Tautvydas Belgeras [Thu, 20 Jun 2019 10:45:19 +0000 (13:45 +0300)]
uqmi: add explicit check for message type when expecting a response

When the utility sends a request it expects a response type message,
but does not explicitly check for it. When a device stays idle for
some time, it switches into a sleep mode, and notifies the utility with an
identification type message. In some configurations the device only sends
this identification message when triggered by the utility, in this case by
the request message. What the utility gets is two messages at the same time -
an identification and a response. When it tries to decode former it obviously
fails, because it is not what it expected.

Signed-off-by: Tautvydas Belgeras <[email protected]>
7 years agouqmi_add_command: fixed command argument assignment
Carlo Lobrano [Thu, 22 Jun 2017 07:40:37 +0000 (09:40 +0200)]
uqmi_add_command: fixed command argument assignment

The char *arg passed to uqmi_add_command was not assigned to cmd[idx].arg.

Signed-off-by: Carlo Lobrano <[email protected]>
8 years agouqmi: Change returned value to QMI_CMD_REQUEST for 'sync' command.
Nickolay Ledovskikh [Fri, 16 Dec 2016 11:35:15 +0000 (14:35 +0300)]
uqmi: Change returned value to QMI_CMD_REQUEST for 'sync' command.

QMI_CMD_DONE is not working properly with 'sync' command.
We must use QMI_CMD_REQUEST.

Signed-off-by: Nickolay Ledovskikh <[email protected]>
8 years agouqmi: Add sync command to release all cids.
Nickolay Ledovskikh [Wed, 7 Dec 2016 17:12:54 +0000 (20:12 +0300)]
uqmi: Add sync command to release all cids.

Signed-off-by: Nickolay Ledovskikh <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]> [add command line help]
9 years agombim: fix memory corruption issues
Felix Fietkau [Tue, 22 Nov 2016 14:20:57 +0000 (15:20 +0100)]
mbim: fix memory corruption issues

Use a common buffer that has enough headroom for the MBIM header.

Signed-off-by: Felix Fietkau <[email protected]>
9 years agonas: fix network scan
Matti Laakso [Sun, 20 Nov 2016 21:27:34 +0000 (23:27 +0200)]
nas: fix network scan

Signed-off-by: Matti Laakso <[email protected]>
9 years agowds: add option for specifying profile index
Matti Laakso [Sun, 20 Nov 2016 21:27:33 +0000 (23:27 +0200)]
wds: add option for specifying profile index

Some modems require the specification of a profile index which
determines the APN and the IP family used for the connection.

Signed-off-by: Matti Laakso <[email protected]>
9 years agowds: make APN optional
Matti Laakso [Sun, 20 Nov 2016 21:27:32 +0000 (23:27 +0200)]
wds: make APN optional

Some modem firmwares do not use the APN selected in the Start
Network command. Moreover, it is marked optional in the QMI
specification.

Signed-off-by: Matti Laakso <[email protected]>
9 years agowds: add a separate --set-ip-family option
Matti Laakso [Sun, 20 Nov 2016 21:27:31 +0000 (23:27 +0200)]
wds: add a separate --set-ip-family option

Change the current ip-family option to set the IP Family Preference
TLV in the Start Network command, and add a separate set-ip-family
option for the Set IP Family command. This is done to match how
the autoconnect and set-autoconnect options work.

Older modems don't support the Set IP Family command, and they
should use the IP Family Preference TLV. On the other hand, newer
modems, e.g., from Huawei, don't respect that TLV, and require the
use of the separate Set IP Family command.

Signed-off-by: Matti Laakso <[email protected]>
9 years agowds: fix set-autoconnect help text
Matti Laakso [Sun, 20 Nov 2016 21:27:30 +0000 (23:27 +0200)]
wds: fix set-autoconnect help text

Signed-off-by: Matti Laakso <[email protected]>
9 years agouim: add missing extra data for UIM PIN verify request
Felix Fietkau [Fri, 4 Nov 2016 14:46:06 +0000 (15:46 +0100)]
uim: add missing extra data for UIM PIN verify request

Signed-off-by: Felix Fietkau <[email protected]>
9 years agoadd UIM verify pin commands
Felix Fietkau [Fri, 4 Nov 2016 13:20:51 +0000 (14:20 +0100)]
add UIM verify pin commands

Signed-off-by: Felix Fietkau <[email protected]>
9 years agoenable uim message functions
Felix Fietkau [Fri, 4 Nov 2016 13:09:15 +0000 (14:09 +0100)]
enable uim message functions

Signed-off-by: Felix Fietkau <[email protected]>
9 years agodata: update qmi-service-uim.json from libqmi git
Felix Fietkau [Fri, 4 Nov 2016 13:04:15 +0000 (14:04 +0100)]
data: update qmi-service-uim.json from libqmi git

Signed-off-by: Felix Fietkau <[email protected]>
9 years agouqmi: fix big endian bugs in MBIM code
Bjørn Mork [Tue, 23 Aug 2016 12:31:05 +0000 (14:31 +0200)]
uqmi: fix big endian bugs in MBIM code

All MBIM integer fields are 32bit little endian.  So we need to convert
then all on big endian systems.

Fixes: e69bf24b00d8 ("uqmi: add support for MBIM devices with QMI service")
Signed-off-by: Bjørn Mork <[email protected]>
9 years agodms: add "Set FCC Authentication" request
Bjørn Mork [Sun, 21 Aug 2016 00:01:10 +0000 (02:01 +0200)]
dms: add "Set FCC Authentication" request

Many newer modems from Sierra Wireless includes a feature known as
"FCC Authentication".  The basic idea is that the radio is kept in
low power mode until the driver has told the firmware that it is
OK to switch it on.  This is done with a vendor specific QMI DMS
request with no input or output TLVs.

The "Set FCC Authentication" request is required for any modem with
the feature enabled.  Which includes most newer Lenovo branded Sierra
Wireless modems based on Qualcomm chipsets, like for example the
EM7455.

Sample session with an EM7455 in MBIM mode and the FCC Authentication
feature enabled:

 $ umbim -d /dev/cdc-wdm0 -n radio
   hwradiostate: on
   swradiostate: off
 $ uqmi -m -d /dev/cdc-wdm0 --fcc-auth
 $ umbim -d /dev/cdc-wdm0 -t 2 radio
   hwradiostate: on
   swradiostate: on

Signed-off-by: Bjørn Mork <[email protected]>
9 years agouqmi: add support for MBIM devices with QMI service
Bjørn Mork [Sun, 21 Aug 2016 00:01:09 +0000 (02:01 +0200)]
uqmi: add support for MBIM devices with QMI service

Many Qualcomm based devices offer a QMI service when running in MBIM
mode. This is useful for a number of requests which have no MBIM
counterpart.

This implementation is very basic, simply wrapping the QMI requests
in an MBIM command. It is up to the user to make sure that the MBIM
command sequence is valid, using a mix of umbim and uqmi requests.

umbim must be used to send "OPEN" before uqmi can issue any MBIM
requests. Example:

1. use umbim to open the session, using the '-n' option:

$ umbim -d /dev/cdc-wdm0 -n caps
  devicetype: 0003 - remote
  cellularclass: 0001
  voiceclass: 0001 - no-voice
  simclass: 0002
  dataclass: 003C
  smscaps: 0003
  controlcaps: 0001
  maxsessions: 0008
  deviceid: 0145820007xxxxx
  firmwareinfo: SWI9X30C_02.08.02.00
  hardwareinfo: EM7455

2. use uqmi to send an MBIM request, using the '-m' option:

$ uqmi -m -d /dev/cdc-wdm0 --get-serving-system
{
        "registration": "registered",
        "plmn_mcc": 242,
        "plmn_mnc": 1,
        "plmn_description": "TELENOR",
        "roaming": false
}

3. use umbim to close the open session, using the '-t X' option:

$ umbim -d /dev/cdc-wdm0 -t 2 caps
  devicetype: 0003 - remote
  cellularclass: 0001
  voiceclass: 0001 - no-voice
  simclass: 0002
  dataclass: 003C
  smscaps: 0003
  controlcaps: 0001
  maxsessions: 0008
  deviceid: 0145820007xxxxx
  firmwareinfo: SWI9X30C_02.08.02.00
  hardwareinfo: EM7455

Signed-off-by: Bjørn Mork <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]> [cleanup, portability fixes]
10 years agobuild: Support for out of source builds added
Bachtin, Dmitri [Thu, 19 Nov 2015 12:31:02 +0000 (13:31 +0100)]
build: Support for out of source builds added

The scripts gen-{header,code,error-list}.pl were called with
source-local paths what disallowed out of source builds.

Updated CMakeLists.txt to call the scripts with ${CMAKE_SOURCE_DIR}
prefix.

Signed-off-by: Dmitri Bachtin <[email protected]>
10 years agobuild: added _library suffix to lib variables
Bachtin, Dmitri [Fri, 20 Nov 2015 06:34:36 +0000 (07:34 +0100)]
build: added _library suffix to lib variables

It is a convention under CMake to suffix variables in the FIND_LIBRARY
calls with _LIBRARY. Added _library suffix to json, blobmsg_json and
ubox variables.

10 years agouqmi: search for ubox, blobmsg_json and json include paths
Bachtin, Dmitri [Fri, 20 Nov 2015 06:34:35 +0000 (07:34 +0100)]
uqmi: search for ubox, blobmsg_json and json include paths

CMake will search for include paths via FIND_PATH() of the following
libraries: libubox, blobmsg_json and json. This allows to build uqmi
when the dependencies are in non-standard locations by specifying
respective _include_dir variables.

10 years agowds: cast pdp_type enum to int to avoid clang considering the range check tautological
Felix Fietkau [Sun, 22 Nov 2015 11:36:28 +0000 (12:36 +0100)]
wds: cast pdp_type enum to int to avoid clang considering the range check tautological

enum overflow behavior is undefined

Signed-off-by: Felix Fietkau <[email protected]>
10 years agowds: make ipv6 address endian swap more portable
Felix Fietkau [Sun, 22 Nov 2015 11:30:46 +0000 (12:30 +0100)]
wds: make ipv6 address endian swap more portable

Signed-off-by: Felix Fietkau <[email protected]>
10 years agouqmi: Added CMake option BUILD_STATIC for a static uqmi build
Bachtin, Dmitri [Wed, 9 Sep 2015 07:35:49 +0000 (09:35 +0200)]
uqmi: Added CMake option BUILD_STATIC for a static uqmi build

Signed-off-by: Dmitri Bachtin <[email protected]>
10 years agouqmi: Add get-current-settings command-line switch
Antti Seppälä [Sat, 8 Aug 2015 07:44:38 +0000 (07:44 +0000)]
uqmi: Add get-current-settings command-line switch

Adding --get-current-settings switch which can be used to query
ip-settings among some other useful data obtained from remote end when
connected.

This is mainly useful with modems which do not provide a dhcp server for
nameserver or ip-information (especially in ipv6 networks).

Signed-off-by: Antti Seppälä <[email protected]>
Tested-by: Matti Laakso <[email protected]>
10 years agouqmi: Add IP family selection command-line switch
Antti Seppälä [Sat, 8 Aug 2015 07:44:37 +0000 (07:44 +0000)]
uqmi: Add IP family selection command-line switch

This patch adds support for (optionally) specifying ip family via a
command- line switch. The switch sends respective "Set IP Family" WDS
message to qmi-device before actually connecting.

Using this switch allows connecting to ipv6 enabled networks or networks
with dual-stack support with the appropriate hardware (dongle and FW
with ipv6 support) and configuration (AT+CGDCONT reporting ipv6 or
ipv4v6 capability).

Help text:
  --ip-family <family>:    Set ip-family for the connection (ipv4, ipv6, unspecified)

Usage example for ipv6:
  uqmi -d /dev/cdc-wdm0 --set-client-id wds,<cid> --start-network <apn> --ip-family ipv6

Dual-stack usage example:
  uqmi -d /dev/cdc-wdm0 --get-client-id wds
  uqmi -d /dev/cdc-wdm0 --set-client-id wds,<cid-1> --start-network <apn> --ip-family ipv4
  uqmi -d /dev/cdc-wdm0 --get-client-id wds
  uqmi -d /dev/cdc-wdm0 --set-client-id wds,<cid-2> --start-network <apn> --ip-family ipv6

Signed-off-by: Antti Seppälä <[email protected]>
Tested-by: Matti Laakso <[email protected]>
10 years agoadd missing license headers (LGPL v2)
Felix Fietkau [Tue, 12 May 2015 11:01:34 +0000 (13:01 +0200)]
add missing license headers (LGPL v2)

Signed-off-by: Felix Fietkau <[email protected]>
10 years agoAdd command to get IMEI from the device
Felix Fietkau [Mon, 13 Apr 2015 22:29:26 +0000 (00:29 +0200)]
Add command to get IMEI from the device

Signed-off-by: Felix Fietkau <[email protected]>
10 years agoAdd command to specify preferred PLMN
Sławomir Demeszko [Fri, 16 Jan 2015 19:30:38 +0000 (20:30 +0100)]
Add command to specify preferred PLMN

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdd command for listing device capabilities
Sławomir Demeszko [Thu, 8 Jan 2015 18:08:30 +0000 (19:08 +0100)]
Add command for listing device capabilities

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdd missing option for getting tdma signal strength
Sławomir Demeszko [Thu, 8 Jan 2015 14:15:40 +0000 (15:15 +0100)]
Add missing option for getting tdma signal strength

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoFix encoding phone number on sending sms
Sławomir Demeszko [Thu, 18 Dec 2014 15:12:15 +0000 (16:12 +0100)]
Fix encoding phone number on sending sms

Return proper length of encoded phone number with odd count of digits,
without this patch number is encoded in memory but length returned
by function is not incremented and sms cannot be send.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoMaking smsc number optional
Sławomir Demeszko [Mon, 22 Dec 2014 18:47:34 +0000 (19:47 +0100)]
Making smsc number optional

If smsc number is not provided before sending sms then
operator's default stored on simcard will be used.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoFix improper length of sms message stored in User Data Length field
Sławomir Demeszko [Mon, 22 Dec 2014 18:02:57 +0000 (19:02 +0100)]
Fix improper length of sms message stored in User Data Length field

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoFix logical expression which is always true
Sławomir Demeszko [Mon, 22 Dec 2014 17:23:50 +0000 (18:23 +0100)]
Fix logical expression which is always true

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdd mandatory field to Initiate Network Register
Sławomir Demeszko [Wed, 17 Dec 2014 18:06:16 +0000 (19:06 +0100)]
Add mandatory field to Initiate Network Register

According to json data Action field in Initiate Network Register
is mandatory. I get "Missing argument" from qmi without it.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoFix improper characters after reading Escape code for switching extension table in SMS
Sławomir Demeszko [Wed, 17 Dec 2014 16:14:53 +0000 (17:14 +0100)]
Fix improper characters after reading Escape code for switching extension table in SMS

Escape code 0x1b is a prefix indicating that next character should be
represented from extension table, but it only applies to one character,
so switching it off is needed to read further characters correctly.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdded commands to change PIN code
Sławomir Demeszko [Wed, 17 Dec 2014 14:56:32 +0000 (15:56 +0100)]
Added commands to change PIN code

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdded shared struct to allow the same option names for different functions
Sławomir Demeszko [Wed, 17 Dec 2014 12:35:33 +0000 (13:35 +0100)]
Added shared struct to allow the same option names for different functions

For example we can use one option --new-pin with commands unblock-pin
and with change-pin, without that we need to invent new name
for every new command.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdded option for enabling and disabling protection of simcard by PIN
Sławomir Demeszko [Wed, 17 Dec 2014 12:35:32 +0000 (13:35 +0100)]
Added option for enabling and disabling protection of simcard by PIN

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdd support for 16-bit reference number in concatenated SMS.
Sławomir Demeszko [Wed, 17 Dec 2014 13:34:48 +0000 (14:34 +0100)]
Add support for 16-bit reference number in concatenated SMS.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoFix character "@" added at end of received messages
Sławomir Demeszko [Mon, 8 Dec 2014 18:05:25 +0000 (19:05 +0100)]
Fix character "@" added at end of received messages

If 7 bit message encoded on 8 bit cells has one last bit occupying
whole byte it need to be padded with 7 zero bits. To not mistake
these last 7 bits with a character with code 0 (@) we need to check
length from User Data Length field and not rely on actual length
of received data. An example can be message "abcdefg" encoded
as "61 f1 98 5c 36 9f 01", it is decoded as "abcdefg@".

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoAdded support for 8 bit and 16 bit encoded SMS messages
Sławomir Demeszko [Mon, 8 Dec 2014 12:27:34 +0000 (13:27 +0100)]
Added support for 8 bit and 16 bit encoded SMS messages

Message is presented as string of hexadecimal pairs in JSON output.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
10 years agoSeparation of decoding User Data Header from decoding 7 bit message
Sławomir Demeszko [Mon, 8 Dec 2014 12:27:33 +0000 (13:27 +0100)]
Separation of decoding User Data Header from decoding 7 bit message

It is preparation for supporting 8 bit and 16 bit encoding. Moving out
this code from decode_7bit_field() allows to reuse it in caller
function where other than 7 bit decoding will take place.

Signed-off-by: SÅ‚awomir Demeszko <[email protected]>
11 years agoAdd --delete-message for deleting SMS messages
Sławomir Demeszko [Tue, 2 Dec 2014 15:26:36 +0000 (15:26 +0000)]
Add --delete-message for deleting SMS messages

Signed-off-by: Sławomir Demeszko <[email protected]>
11 years agoSEGFAULT on reading Unicode sms messages
Sławomir Demeszko [Thu, 27 Nov 2014 14:00:12 +0000 (14:00 +0000)]
SEGFAULT on reading Unicode sms messages

Added complementary blobmsg_close_table() before returning from function
on error.