Skip to content

Commit

Permalink
lpac: fix the wrapper
Browse files Browse the repository at this point in the history
Some env variables sensitive for proper lpac functioning
can be set by upper lpac wrappers such as lpac-libmbim-wrapper.
If that's the case, we shouldn't override them,
otherwise the wrapper won't work.

Also, we shouldn't interpret values of the debug env
variables. Instead, we just pass them as is if the
corresponding uci optioins exist.

fixes #25035

Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
bam80 authored Sep 27, 2024
1 parent 77eedd8 commit 124dbf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
36 changes: 11 additions & 25 deletions utils/lpac/files/lpac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,18 @@

. /lib/config/uci.sh

APDU_BACKEND="$(uci_get lpac global apdu_backend uqmi)"
APDU_DEBUG="$(uci_get lpac global apdu_debug 0)"
: "${LPAC_APDU=$(uci_get lpac global apdu_backend)}"; export LPAC_APDU
LIBEUICC_DEBUG_APDU="$(uci_get lpac global apdu_debug)" && export LIBEUICC_DEBUG_APDU

HTTP_BACKEND="$(uci_get lpac global http_backend curl)"
HTTP_DEBUG="$(uci_get lpac global http_debug 0)"

export LPAC_HTTP="$HTTP_BACKEND"
if [ "$HTTP_DEBUG" -eq 1 ]; then
export LIBEUICC_DEBUG_HTTP="1"
fi

export LPAC_APDU="$APDU_BACKEND"
if [ "$APDU_DEBUG" -eq 1 ]; then
export LIBEUICC_DEBUG_APDU="1"
if [ "$LPAC_APDU" = "at" ]; then
export AT_DEVICE="$(uci_get lpac at device)"
AT_DEBUG="$(uci_get lpac at debug)" && export AT_DEBUG
elif [ "$LPAC_APDU" = "uqmi" ]; then
export LPAC_QMI_DEV="$(uci_get lpac uqmi device)"
LPAC_QMI_DEBUG="$(uci_get lpac uqmi debug)" && export LPAC_QMI_DEBUG
fi

if [ "$APDU_BACKEND" = "at" ]; then
AT_DEVICE="$(uci_get lpac at device /dev/ttyUSB2)"
AT_DEBUG="$(uci_get lpac at debug 0)"
export AT_DEVICE="$AT_DEVICE"
export AT_DEBUG="$AT_DEBUG"
elif [ "$APDU_BACKEND" = "uqmi" ]; then
UQMI_DEV="$(uci_get lpac uqmi device /dev/cdc-wdm0)"
UQMI_DEBUG="$(uci_get lpac uqmi debug 0)"
export LPAC_QMI_DEV="$UQMI_DEV"
export LPAC_QMI_DEBUG="$UQMI_DEBUG"
fi
export LPAC_HTTP="$(uci_get lpac global http_backend)"
LIBEUICC_DEBUG_HTTP="$(uci_get lpac global http_debug)" && export LIBEUICC_DEBUG_HTTP

/usr/lib/lpac "$@"
exec /usr/lib/lpac "$@"
8 changes: 4 additions & 4 deletions utils/lpac/files/lpac.uci
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
config global global
option apdu_backend 'uqmi'
option http_backend 'curl'
option apdu_debug '0'
option http_debug '0'
# option apdu_debug '1'
# option http_debug '1'

config at at
option device '/dev/ttyUSB2'
option debug '0'
# option debug '1'

config uqmi uqmi
option device '/dev/cdc-wdm0'
option debug '0'
# option debug '1' # value matters

0 comments on commit 124dbf5

Please sign in to comment.