diff --git a/scripts/boot/5g-dial.sh b/scripts/boot/5g-dial.sh index 714670f..74ed1b2 100644 --- a/scripts/boot/5g-dial.sh +++ b/scripts/boot/5g-dial.sh @@ -7,38 +7,23 @@ source "${SCRIPT_DIR}/common.sh" STEP="5g-dial" -disable_interfaces() { - local raw_list="$1" - local iface - local nmcli_available=0 +run_dial() { + local rc - if [[ -z "${raw_list}" ]]; then + export TERM="${TERM:-xterm}" + export LANG="${LANG:-C.UTF-8}" + export LC_ALL="${LC_ALL:-C.UTF-8}" + + blitz_log "${STEP}" "dial-env" "start" "TERM=${TERM} LANG=${LANG} LC_ALL=${LC_ALL} interface=${BLITZ_5G_INTERFACE}" 0 + + if blitz_run "${STEP}" "dial" python3 rndis_dial.py --serial-port "${BLITZ_5G_SERIAL_PORT}" --interface "${BLITZ_5G_INTERFACE}"; then return 0 fi - if command -v nmcli >/dev/null 2>&1; then - nmcli_available=1 - fi - for iface in ${raw_list//,/ }; do - if [[ -z "${iface}" ]]; then - continue - fi - blitz_log "${STEP}" "disable-interface" "start" "iface=${iface}" 0 - if [[ "${nmcli_available}" -eq 1 ]]; then - nmcli device disconnect "${iface}" >/dev/null 2>&1 || true - fi - if ip link show dev "${iface}" >/dev/null 2>&1; then - if ip link set dev "${iface}" down; then - blitz_log "${STEP}" "disable-interface" "success" "iface=${iface}" 0 - else - rc=$? - blitz_log "${STEP}" "disable-interface" "failure" "iface=${iface}" "${rc}" - return "${rc}" - fi - else - blitz_log "${STEP}" "disable-interface" "success" "iface=${iface} not present, skipping" 0 - fi - done + rc=$? + blitz_log "${STEP}" "dial-retry" "start" "first dial attempt failed rc=${rc}; retrying after 3s" "${rc}" + sleep 3 + blitz_run "${STEP}" "dial-retry" python3 rndis_dial.py --serial-port "${BLITZ_5G_SERIAL_PORT}" --interface "${BLITZ_5G_INTERFACE}" } wait_for_serial() { @@ -101,8 +86,6 @@ if [[ -z "${BLITZ_5G_INTERFACE:-}" ]]; then exit 1 fi -disable_interfaces "${BLITZ_5G_DISABLE_INTERFACES:-}" - route_output="$(blitz_route_ready "${BLITZ_TIME_SERVER_IP}" "${BLITZ_5G_INTERFACE}" || true)" if [[ -n "${route_output}" ]]; then blitz_log "${STEP}" "dial" "already_up" "target_ip=${BLITZ_TIME_SERVER_IP} interface=${BLITZ_5G_INTERFACE} route=${route_output}" 0 @@ -112,7 +95,7 @@ fi wait_for_serial "${BLITZ_5G_SERIAL_PORT}" "${BLITZ_5G_SERIAL_WAIT_SEC}" pushd "${BLITZ_5G_DIAL_DIR}" >/dev/null -blitz_run "${STEP}" "dial" python3 rndis_dial.py --serial-port "${BLITZ_5G_SERIAL_PORT}" --interface "${BLITZ_5G_INTERFACE}" +run_dial popd >/dev/null wait_for_route "${BLITZ_TIME_SERVER_IP}" "${BLITZ_5G_ROUTE_WAIT_SEC}" "${BLITZ_5G_INTERFACE}" diff --git a/scripts/boot/common.sh b/scripts/boot/common.sh index 8caef70..29a70e0 100644 --- a/scripts/boot/common.sh +++ b/scripts/boot/common.sh @@ -55,7 +55,6 @@ blitz_load_boot_env() { export BLITZ_5G_DIAL_DIR="${BLITZ_5G_DIAL_DIR:-/home/nvidia/5g-test/5G}" export BLITZ_5G_SERIAL_PORT="${BLITZ_5G_SERIAL_PORT:-/dev/ttyUSB7}" export BLITZ_5G_INTERFACE="${BLITZ_5G_INTERFACE:-eth0}" - export BLITZ_5G_DISABLE_INTERFACES="${BLITZ_5G_DISABLE_INTERFACES:-}" export BLITZ_5G_SERIAL_WAIT_SEC="${BLITZ_5G_SERIAL_WAIT_SEC:-60}" export BLITZ_5G_ROUTE_WAIT_SEC="${BLITZ_5G_ROUTE_WAIT_SEC:-30}" export BLITZ_TIME_SERVER_IP="${BLITZ_TIME_SERVER_IP:-${default_time_server}}" diff --git a/scripts/boot/robot-boot.env b/scripts/boot/robot-boot.env index b23d0c1..289d6ff 100644 --- a/scripts/boot/robot-boot.env +++ b/scripts/boot/robot-boot.env @@ -1,13 +1,12 @@ # Boot-time settings for the robot-side autostart chain. # Override machine-specific values in robot-boot.env.local. -BLITZ_BOOT_DELAY_SEC="30" +BLITZ_BOOT_DELAY_SEC="60" BLITZ_LOG_FILE="/var/log/blitz-robot/startup.log" BLITZ_5G_DIAL_DIR="/home/nvidia/5g-test/5G" BLITZ_5G_SERIAL_PORT="/dev/ttyUSB7" BLITZ_5G_INTERFACE="eth0" -BLITZ_5G_DISABLE_INTERFACES="eno3" BLITZ_5G_SERIAL_WAIT_SEC="60" BLITZ_5G_ROUTE_WAIT_SEC="30" diff --git a/scripts/boot/systemd/blitz-b-side-omnid.service.in b/scripts/boot/systemd/blitz-b-side-omnid.service.in index 93d3502..2269ace 100644 --- a/scripts/boot/systemd/blitz-b-side-omnid.service.in +++ b/scripts/boot/systemd/blitz-b-side-omnid.service.in @@ -1,7 +1,7 @@ [Unit] Description=Blitz robot b-side omnid After=blitz-time-sync.service blitz-ros-receiver.service -Requires=blitz-time-sync.service blitz-ros-receiver.service +Wants=blitz-time-sync.service blitz-ros-receiver.service [Service] Type=simple diff --git a/scripts/boot/systemd/blitz-ros-receiver.service.in b/scripts/boot/systemd/blitz-ros-receiver.service.in index 317121b..fbafd6c 100644 --- a/scripts/boot/systemd/blitz-ros-receiver.service.in +++ b/scripts/boot/systemd/blitz-ros-receiver.service.in @@ -1,7 +1,7 @@ [Unit] Description=Blitz robot ROS receiver After=blitz-time-sync.service -Requires=blitz-time-sync.service +Wants=blitz-time-sync.service [Service] Type=simple diff --git a/scripts/boot/systemd/blitz-time-sync.service.in b/scripts/boot/systemd/blitz-time-sync.service.in index 3f87363..36fd79b 100644 --- a/scripts/boot/systemd/blitz-time-sync.service.in +++ b/scripts/boot/systemd/blitz-time-sync.service.in @@ -1,7 +1,7 @@ [Unit] Description=Blitz robot private chrony sync After=blitz-5g-dial.service -Requires=blitz-5g-dial.service +Wants=blitz-5g-dial.service [Service] Type=oneshot