From 503a6b1a8bc4c8f53bfdeff6f1fe981837c42a79 Mon Sep 17 00:00:00 2001 From: Robert Schmidt <robert.schmidt@openairinterface.org> Date: Wed, 15 Feb 2023 14:30:01 +0100 Subject: [PATCH] Rework UE activation scripts new adb script --- ci-scripts/ci_ctl_adb.sh | 55 +++++++++++++++++++++++++++++++++++++++ ci-scripts/ci_ctl_qtel.py | 15 ++++++----- 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100755 ci-scripts/ci_ctl_adb.sh diff --git a/ci-scripts/ci_ctl_adb.sh b/ci-scripts/ci_ctl_adb.sh new file mode 100755 index 00000000000..25fd4d0afcd --- /dev/null +++ b/ci-scripts/ci_ctl_adb.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +usage() { + echo "usage: $0 <command> <id>" + echo "available commands: initialize, attach, detach, terminate, check" +} + +if [ $# -ne 2 ]; then + usage + exit 1 +fi + +cmd=$1 +id=$2 + +flightmode_off() { + set +x + adb -s $id shell "/data/local/tmp/on" +} + +flightmode_on() { + set +x + adb -s $id shell "/data/local/tmp/off" +} + +initialize() { + set +x + adb -s $id shell "svc data enable" # make sure data services are enabled + flightmode_on +} + +terminate() { + echo "terminate: does nothing" +} + +check() { + declare -A service=( ["0"]="IN_SERVICE" ["1"]="OUT_OF_SERVICE" ["2"]="EMERGENCY_ONLY" ["3"]="RADIO_POWERED_OFF") + declare -A data=( ["0"]="DISCONNECTED" ["1"]="CONNECTING" ["2"]="CONNECTED" ["3"]="SUSPENDED") + serv_idx=$(adb -s $id shell "dumpsys telephony.registry" | sed -n 's/.*mServiceState=\([0-3]\).*/\1/p') + data_idx=$(adb -s $id shell "dumpsys telephony.registry" | sed -n 's/.*mDataConnectionState=\([0-3]\).*/\1/p') + data_reason=$(adb -s $id shell "dumpsys telephony.registry" | sed -n 's/.*mDataConnectionReason=\([0-9a-zA-Z_]\+\).*/\1/p') + #echo "Status Check UE $id" + echo "Service State: ${service[$serv_idx]}" + echo "Data State: ${data[$data_idx]}" + echo "Data Reason: ${data_reason}" +} + +case "${cmd}" in + initialize) initialize;; + attach) flightmode_off;; + detach) flightmode_on;; + terminate) terminate;; + check) check;; + *) echo "Invalid command $cmd"; usage; exit 1;; +esac diff --git a/ci-scripts/ci_ctl_qtel.py b/ci-scripts/ci_ctl_qtel.py index 3785d7ee89a..5e4df9fab49 100644 --- a/ci-scripts/ci_ctl_qtel.py +++ b/ci-scripts/ci_ctl_qtel.py @@ -32,7 +32,7 @@ import sys import time import serial - +import subprocess as sp class qtel_ctl: #--------------- @@ -75,12 +75,15 @@ class qtel_ctl: self.__set_modem_state(self.modem,'0') - - if __name__ == "__main__": #argv[1] : usb port #argv[2] : qtel command (see function pointers dict "wup", "detach" etc ...) - command = sys.argv[2] - Module=qtel_ctl(sys.argv[1]) + if len(sys.argv) >= 3: + command = sys.argv[2] + print(command) + Module=qtel_ctl(sys.argv[1]) #calling the function to be applied - Module.cmd_dict[command]() + Module.cmd_dict[command]() + print(Module.cmd_dict[command]) + else: + print("To many arguments") -- GitLab