วันจันทร์ที่ 1 สิงหาคม พ.ศ. 2559

Hack Smart Plug

Smart Plug ของ Kankun เป็น Openwrt
login ด้วย
root password p9z34c
เปลียน password ด้วย passwd
ปิดเปิด ด้วย Web
เข้าที่ /www
สร้าง index.html

<!DOCTYPE html>
<html>
<head>
<title>SmartPlug1</title>
</head>
<body>

<h1>Smart 1  try On / Off</h1>
<a href="./cgi-bin/relay.cgi?on"> ON </a> <br/>
<a href="./cgi-bin/relay.cgi?off"> OFF </a>
</body>
</html>


สร้าง โดย เรียก cgi-bin


  • relay.cgi อย่าลืม chmod 777 ด้วย

#!/bin/sh
echo "Content-Type: text/plain"
echo "Cache-Control: no-cache, must-revalidate"
echo "Expires: Sat, 26 Jul 1997 05:00:00 GMT"
echo

RELAY_CTRL=/sys/class/leds/tp-link:blue:relay/brightness

case "$QUERY_STRING" in
 state) 
  case "`cat $RELAY_CTRL`" in
   0) echo "OFF"
   ;;
   1) echo "ON"
   ;;
  esac
 ;;
 on) 
  echo 1 > $RELAY_CTRL
  echo OK
 ;;
 off) 
  echo 0 > $RELAY_CTRL
  echo OK
 ;;
esac


ดู status


2 ความคิดเห็น:

  1. เวลา config เข้า Network router ให้ config ที่ Network ให้ reset และ connect to OK-SP3 และ Set config network เลย

    ตอบลบ
  2. การใช้ Schedule หรือ Crontab -e
    min hour * * *

    echo "0 23 * * * uci set wireless.@wifi-device[0].disabled=1; wifi" >> /etc/crontabs/root
    echo "0 7 * * * uci set wireless.@wifi-device[0].disabled=0; wifi" >> /etc/crontabs/root
    echo "root" > /etc/crontabs/cron.update
    /etc/init.d/cron enable
    /etc/init.d/cron start
    /etc/init.d/cron restart

    ตอบลบ