建議先將 MT7688 連接至 Client 模式,才好發送 Web Request。
Web.py 如下:
import mraa import time import urllib2 gpio = mraa.Gpio(21) gpio.dir(mraa.DIR_OUT) content = urllib2.urlopen("http://192.168.100.1").read() print(content) if content is not None: while True: gpio.write(1) time.sleep(0.5) gpio.write(0) time.sleep(0.5) else: gpio.write(1)
python web.py &
Reference:
https://stackoverflow.com/questions/17178483/how-do-you-send-an-http-get-web-request-in-python
https://docs.python.org/2/library/urllib2.html
https://docs.python.org/2/howto/urllib2.html#urllib-howto
https://docs.python.org/2.6/library/httplib.html
https://www.douban.com/note/102505878/
沒有留言:
張貼留言