mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-06 00:03:00 +00:00
Offer pre-radio hook for standalone lock replay
This commit is contained in:
3 files changed
+46
No files matched your search
@@ -30,6 +30,9 @@ wait_and_exec() {
|
||||
}
|
||||
|
||||
start_service() {
|
||||
# Optional plugin handshake: reserve nr1's first-command window for the
|
||||
# platform radio-on path. The generic worker waits for this marker to clear.
|
||||
[ ! -x /usr/libexec/unisoc-modem/lock ] || : > /run/unisoc-modem-early-hook-pending
|
||||
[ -x /opt/mu300/bin/bootmark ] && /opt/mu300/bin/bootmark S19-atd-init
|
||||
procd_open_instance atd
|
||||
procd_set_param command /bin/sh -c "$(wait_and_exec /dev/stty_nr1 /opt/mu300/bin/mu300-atd)"
|
||||
|
||||
@@ -282,6 +282,15 @@ radio_on_locked() {
|
||||
radio_say "AT 通道没有回应,停止本轮,不向死通道发送 SFUN:$(echo "${out:-无回答}" | tr -s '\n' ' ')"
|
||||
return 1 ;;
|
||||
esac
|
||||
# The optional standalone LuCI plugin may have saved mode/band/cell locks.
|
||||
# This is the one safe early window: nr1 has completed SMMSWAP, the CP
|
||||
# answers, and RF is still off. A failed readback leaves the plugin's late
|
||||
# worker armed; never make radio startup depend on the plugin.
|
||||
if [ -x /usr/libexec/unisoc-modem/lock ] &&
|
||||
[ ! -e /run/unisoc-modem-lock-replay-done ]; then
|
||||
/usr/libexec/unisoc-modem/lock replay early ||
|
||||
radio_say "early lock replay unverified; late fallback remains armed"
|
||||
fi
|
||||
radio_say "AT 通道已就绪,射频为 0;发送 SFUN=4"
|
||||
at 'AT+SFUN=4' "${MU300_SFUN_TIMEOUT:-20}" >/dev/null || true
|
||||
i=0
|
||||
@@ -324,6 +333,9 @@ radio_on() {
|
||||
radio_on_locked
|
||||
rc=$?
|
||||
[ "$(cat "$lock/pid" 2>/dev/null)" = $$ ] && rm -rf "$lock"
|
||||
# Keep the generic worker away from nr1 until the handshake/radio sequence
|
||||
# has actually completed. A failed round is retried by netifd/watch.
|
||||
[ "$rc" = 0 ] && rm -f /run/unisoc-modem-early-hook-pending
|
||||
return $rc
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
"""The F50 platform offers the standalone plugin an optional pre-radio hook."""
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
TOP = Path(__file__).resolve().parents[1]
|
||||
RADIO = TOP / 'rootfs/overlay/opt/mu300/bin/mobile-data'
|
||||
ATD = TOP / 'openwrt/overlay/etc/init.d/mu300-atd'
|
||||
|
||||
|
||||
class EarlyReplayHook(unittest.TestCase):
|
||||
def test_hook_is_after_handshake_and_radio_off_check(self):
|
||||
radio = RADIO.read_text(encoding='utf-8')
|
||||
start = radio.index('radio_on_locked()')
|
||||
end = radio.index('\nradio_on() {', start)
|
||||
body = radio[start:end]
|
||||
self.assertLess(body.index("'AT+SMMSWAP=0'"), body.index("out=$(at 'AT+CFUN?'"))
|
||||
self.assertLess(body.index("out=$(at 'AT+CFUN?'"), body.index('lock replay early'))
|
||||
self.assertLess(body.index('lock replay early'), body.index("at 'AT+SFUN=4'"))
|
||||
self.assertIn('[ -x /usr/libexec/unisoc-modem/lock ]', body)
|
||||
self.assertIn('early lock replay unverified; late fallback remains armed', body)
|
||||
|
||||
def test_pending_marker_brackets_platform_radio_on(self):
|
||||
atd = ATD.read_text(encoding='utf-8')
|
||||
radio = RADIO.read_text(encoding='utf-8')
|
||||
self.assertLess(atd.index('unisoc-modem-early-hook-pending'), atd.index('radio-warmup'))
|
||||
self.assertIn('[ "$rc" = 0 ] && rm -f /run/unisoc-modem-early-hook-pending', radio)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user