The test_creg_match helper would only parse the first match, but actual
code e.g. parse_unsolicited() in src/mm-port-serial-at.c iterates over
all matches:
this updates the test to loop similarily to what is done in real code.
There were two tests assuming only the first match gets matched, so
their result were updated, and a third test was added matching the URC
received from a SIM7672 modem (including unrelated CNSMOD message)
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
When receiving a message from modem containing multiple CREG events that
have different format, the parsing happens in the order CREG regexes are
registered, and not in the order the modem sent the events.
That means that when receiving the following URC:
<CR><LF>+CEREG: 2<CR><LF><CR><LF>+CNSMOD: 8<CR><LF><CR><LF>+CEREG: 1,AAAA,01234567,7<CR><LF>
we'd incorrectly parse the `CEREG: 1` before `CEREG: 2`, and remember
the state as searching (2) instead of home (1), which can cause trouble
connecting because of waiting for state to go home which would never
happen again.
This fixes that problem by merging all the regexes together, so the
parsing should properly process the events in matching order in
parse_unsolicited()
Unfortunately changing the regex like this means that
mm_3gpp_parse_creg_response() match info handling also needs to be
reworked: matches number are increased for each regex, so we can
reliably know which regex was matched based on match count.
This is actually cleaner than the old approach that just guessed if nth
field with "item_is_lac_not_stat()", but requires careful testing.
This was validated checking that tests fail if any of the indices is
changed by iterating over them all and running the test:
grep -n 'n_matches -' src/mm-modem-helpers.c | sed -e 's/:.*//' \
| while read lineno; do
echo $lineno
git show HEAD:src/mm-modem-helpers.c \
| awk -v l=$lineno '{ if (NR == l) {
print $1,$2,$3,$4,$5 - 1,";"
} else {
print
}}' > src/mm-modem-helpers.c
ninja -C build src/tests/test-modem-helpers || break
build/src/tests/test-modem-helpers && break
done
A test case was added to make this work, as the Samsung Wave S8500
sample 'act' doesn't seem to actually be a technology value?
(case 36/42 could actually be merged but were kept separate on purpose
for easier maintenance/testing)
Fixes: #1087
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
When we get a disconnect event that we wanted to ignore, set the
DisconnectRequest property instead so clients on dbus can act on it.
Also upgrade the logs from dbg to msg (info) as there would be otherwise
no message indicating the disconnect request if it is not acted on.
This was checked with dbus-monitor:
```
$ dbus-monitor --system "type='signal',sender='org.freedesktop.ModemManager1'"
signal time=1747362238.227804 sender=:1.73798 -> destination=(null destination) serial=741 path=/org/freedesktop/ModemManager1/Bearer/0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.freedesktop.ModemManager1.Bearer"
array [
dict entry(
string "DisconnectRequest"
variant boolean true
)
]
array [
]
```
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
To report that the bearer has been killed from the modem side and
the connection should be terminated.
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
When bearer gets an event that should trigger a disconnection but we
cannot disconnect (for example because we're waiting for pppd to close),
we now trigger a new 'disconnect-request' event instead
This was tested with the following hook:
```
$ cat /etc/ModemManager/connection.d/handle-disconnect-request.sh
#!/bin/sh
if [ "$4" != disconnect-request ]; then
exit 0
fi
iface=$(mmcli -b "$2" -K | awk '/bearer.status.interface/ { print $3 }')
if pkill -f "pppd\>.*\<$iface\>"; then
logger -t mm-disconnect-request "Killed $iface pppd"
else
logger -t mm-disconnect-request "No pppd found for $iface"
fi
```
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
The next commit will introduce a new dispatcher event.
This commit should not change anything user-facing
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>