很简单的代码,shell和python都能实现,只是python容易写一些

import os
import time

a = 1

while True:
    a = a + 1
    ip = os.system(u"ping -c1 -w1 192.168.43.165")
        #print (ip)    #一般代码执行正常返回0,异常返回1,但termux异常返回256,所以实际以断开wifi后的print(ip)值为准
    if ip == 0 and a == 2:
        print("true")
        os.system(u"play ~/欢迎光临.wav")
        #os.system(u"play /sdcard/Download/荒野大镖客口哨now.mp3")
    if ip == 256:
        a = 1
    time.sleep(6)