├── img └── ttl.png ├── ubus ├── qplayer.txt ├── pnshelper.txt ├── network.wireless.txt ├── led.txt ├── dlna.txt ├── nightmode.txt ├── workday.txt ├── network.device.txt ├── wifitool.txt ├── ai_crontab.txt ├── network.txt ├── miio.txt ├── system.txt ├── network.interface.txt ├── network.interface.lan.txt ├── network.interface.loopback.txt ├── notify.txt ├── messagingagent.txt ├── voip.txt ├── upnp-disc.txt ├── volctl.txt ├── service.txt ├── mibrain.txt ├── alarm.txt ├── mediaplayer.txt ├── mibt.txt ├── all.txt └── readme.md ├── ssh ├── usr │ ├── sbin │ │ └── sshd │ └── bin │ │ └── ssh-keygen ├── etc │ ├── init.d │ │ ├── factory_stop │ │ ├── umount │ │ ├── sysctl │ │ ├── touchpad │ │ ├── logrotate │ │ ├── wifitool │ │ ├── notify │ │ ├── sysfixtime │ │ ├── xiaomi_dns_server │ │ ├── volctl │ │ ├── statpoints_daemon │ │ ├── work_day_sync_service │ │ ├── nano_httpd │ │ ├── quickplayer │ │ ├── mico_ai_crontab │ │ ├── pass │ │ ├── mibrain_service │ │ ├── pns_ubus_helper │ │ ├── syslog-ng │ │ ├── alsa │ │ ├── dropbear1 │ │ ├── voip │ │ ├── boot_check │ │ ├── mitv-disc │ │ ├── check_bootloader │ │ ├── odhcp6c │ │ ├── dhcpc │ │ ├── messagingagent │ │ ├── done │ │ ├── sshd │ │ ├── cron │ │ ├── led │ │ ├── telnet │ │ ├── bluetooth │ │ ├── miio │ │ ├── mediaplayer │ │ ├── system │ │ ├── mount_data │ │ ├── boot │ │ ├── dlnainit │ │ ├── silentboot │ │ ├── dnsmasq │ │ ├── alarm │ │ ├── check_mac │ │ ├── network │ │ ├── dropbear │ │ ├── pns │ │ └── wireless │ ├── ssh │ │ ├── ssh_host_ed25519_key.pub │ │ ├── 1.sh │ │ ├── ssh_host_ecdsa_key.pub │ │ ├── ssh_host_.pub │ │ ├── ssh_host_rsa_key.pub │ │ ├── ssh_host_ed25519_key │ │ ├── ssh_host_ecdsa_key │ │ ├── ssh_host_dsa_key.pub │ │ ├── ssh_host_dsa_key │ │ ├── ssh_host_rsa_key │ │ └── sshd_config │ └── dropbear │ │ ├── dropbear_dss_host_key │ │ ├── dropbear_rsa_host_key │ │ ├── dropbear_ecdsa_host_key │ │ ├── dropbear_ed25519_host_key │ │ ├── openssh │ │ ├── dropbear_ecdsa_host_key │ │ ├── dropbear_ed25519_host_key │ │ ├── dropbear_dss_host_key │ │ └── dropbear_rsa_host_key │ │ └── authorized_keys ├── root │ └── .ssh │ │ └── authorized_keys └── readme.md ├── server ├── build.sh ├── main.go ├── web │ └── main.go ├── ubus │ └── ubus.go ├── echo │ └── main.go └── http1 │ └── main.go ├── .gitignore ├── password └── sn.js └── readme.md /img/ttl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/img/ttl.png -------------------------------------------------------------------------------- /ubus/qplayer.txt: -------------------------------------------------------------------------------- 1 | 'qplayer' @41f40184 2 | "play":{"play":"String","light":"Integer"} 3 | -------------------------------------------------------------------------------- /ssh/usr/sbin/sshd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/usr/sbin/sshd -------------------------------------------------------------------------------- /ssh/etc/init.d/factory_stop: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=50 4 | 5 | start() { 6 | true 7 | } -------------------------------------------------------------------------------- /ssh/usr/bin/ssh-keygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/usr/bin/ssh-keygen -------------------------------------------------------------------------------- /server/build.sh: -------------------------------------------------------------------------------- 1 | # https://www.jianshu.com/p/efaef7940207 2 | CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o z 3 | -------------------------------------------------------------------------------- /ubus/pnshelper.txt: -------------------------------------------------------------------------------- 1 | 'pnshelper' @e56be10e 2 | "event_notify":{"src":"Integer","event":"Integer","detail":"String"} 3 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_ed25519_key.pub: -------------------------------------------------------------------------------- 1 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlhRbS6Q2WVTiuGM5fSqCyAE8qgUe7TPZCHPH0TK+7X root@debian 2 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/dropbear_dss_host_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/etc/dropbear/dropbear_dss_host_key -------------------------------------------------------------------------------- /ssh/etc/dropbear/dropbear_rsa_host_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/etc/dropbear/dropbear_rsa_host_key -------------------------------------------------------------------------------- /ssh/etc/dropbear/dropbear_ecdsa_host_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/etc/dropbear/dropbear_ecdsa_host_key -------------------------------------------------------------------------------- /ubus/network.wireless.txt: -------------------------------------------------------------------------------- 1 | 'network.wireless' @01c2f7ee 2 | "up":{} 3 | "down":{} 4 | "status":{} 5 | "notify":{} 6 | "get_validate":{} 7 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/dropbear_ed25519_host_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/birdsofsummer/xiaoai-crack/HEAD/ssh/etc/dropbear/dropbear_ed25519_host_key -------------------------------------------------------------------------------- /ubus/led.txt: -------------------------------------------------------------------------------- 1 | 'led' @78abec6a 2 | "show":{"L":"Integer","pos":"Integer","rgb":"String"} 3 | "shut":{"L":"Integer"} 4 | "status":{} 5 | "shut_all":{} 6 | -------------------------------------------------------------------------------- /ssh/etc/init.d/umount: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006 OpenWrt.org 3 | 4 | STOP=99 5 | stop() { 6 | sync 7 | /bin/umount -a -d -r 8 | } 9 | -------------------------------------------------------------------------------- /ssh/etc/init.d/sysctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006 OpenWrt.org 3 | 4 | START=11 5 | start() { 6 | [ -f /etc/sysctl.conf ] && sysctl -p -e >&- 7 | } 8 | -------------------------------------------------------------------------------- /ssh/etc/ssh/1.sh: -------------------------------------------------------------------------------- 1 | for type in rsa dsa ecdsa ed25519 2 | do 3 | key=ssh_host_${type}_key 4 | echo $type $key 5 | ssh-keygen -N '' -t $type -f $key 2>&- >&- 6 | done 7 | 8 | -------------------------------------------------------------------------------- /ubus/dlna.txt: -------------------------------------------------------------------------------- 1 | 'dlna' @4ce6e9ae 2 | "demo":{"mac":"String","action":"String"} 3 | "play":{"mac":"String","action":"String"} 4 | "status":{"mac":"String","action":"String"} 5 | -------------------------------------------------------------------------------- /ubus/nightmode.txt: -------------------------------------------------------------------------------- 1 | 'nightmode' @1cb6eb2d 2 | "set":{"total":"String","light":"String","volume":"String","start":"String","stop":"String"} 3 | "status":{} 4 | "current":{} 5 | -------------------------------------------------------------------------------- /ubus/workday.txt: -------------------------------------------------------------------------------- 1 | 'workday' @62cfc3c6 2 | "get_config":{"name":"String"} 3 | "get_version":{} 4 | "get_ts":{} 5 | "sync_config":{"force":"Boolean","check_ts":"Boolean"} 6 | -------------------------------------------------------------------------------- /ubus/network.device.txt: -------------------------------------------------------------------------------- 1 | 'network.device' @6c48ce6a 2 | "status":{"name":"String"} 3 | "set_alias":{"alias":"Array","device":"String"} 4 | "set_state":{"name":"String","defer":"Boolean"} 5 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "./echo" 6 | ) 7 | 8 | func main() { 9 | fmt.Println("zzz") 10 | echo.Test1() 11 | echo.Test2() 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /ubus/wifitool.txt: -------------------------------------------------------------------------------- 1 | 'wifitool' @1ce770e0 2 | "getrssi":{"get_rssi":"String"} 3 | "setswitch":{"set_switch":"String"} 4 | "pushrssi":{"push_rssi":"Integer"} 5 | "getbssid":{"get_bssid":"String"} 6 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_ecdsa_key.pub: -------------------------------------------------------------------------------- 1 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNEdQungvbC3R3BA7wZs2whGaEX/KwQO0tEC/AXFpBqaV2fmGfX4AFujFaEvrf2qCxmX5yhHrhb5Kk3cbr9GTCs= root@debian 2 | -------------------------------------------------------------------------------- /ubus/ai_crontab.txt: -------------------------------------------------------------------------------- 1 | 'ai_crontab' @c85e9773 2 | "new":{"personal_skill":"String"} 3 | "notify":{"src":"String","event":"String","id":"String"} 4 | "remove_all":{} 5 | "dump":{"busy":"Integer","free":"Integer"} 6 | -------------------------------------------------------------------------------- /ubus/network.txt: -------------------------------------------------------------------------------- 1 | 'network' @51d67f39 2 | "restart":{} 3 | "reload":{} 4 | "add_host_route":{"target":"String","v6":"Boolean","interface":"String"} 5 | "get_proto_handlers":{} 6 | "add_dynamic":{"name":"String"} 7 | -------------------------------------------------------------------------------- /ubus/miio.txt: -------------------------------------------------------------------------------- 1 | 'miio' @efe16487 2 | "renew":{} 3 | "register":{"ssid":"String","psk":"String","uid":"String","country":"String"} 4 | "drop":{} 5 | "token_write":{"token":"String","session_id":"String","ttl":"String"} 6 | "miio_restore_status":{} 7 | -------------------------------------------------------------------------------- /ssh/etc/init.d/touchpad: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=92 4 | 5 | USE_PROCD=1 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /bin/touchpad 10 | procd_set_param respawn 3600 5 0 11 | procd_close_instance 12 | } 13 | -------------------------------------------------------------------------------- /ssh/etc/init.d/logrotate: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | STOP=02 4 | 5 | stop() { 6 | # do log rotate before reboot 7 | logger -s -p 1 -t "Lastword" "Rebooting..................." 8 | 9 | [ -x /usr/sbin/easy_logcut ] && easy_logcut 10 | sync 11 | } 12 | 13 | -------------------------------------------------------------------------------- /ssh/etc/init.d/wifitool: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=70 4 | 5 | USE_PROCD=1 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /bin/wifitool 10 | procd_set_param respawn 3600 5 0 11 | procd_close_instance 12 | } 13 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/openssh/dropbear_ecdsa_host_key: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MHcCAQEEIOmpnIDNCj2CoQbUtBPiogMoSLmfXC0jUlKZ7QH+DAJ8oAoGCCqGSM49 3 | AwEHoUQDQgAE/HOTuOMIXwOkiHKnFUx7/W1HoxM4/k4x9av4llUvZkUb2intwzdU 4 | 2v95fgTQ20KnKNOhtxk/FjQpEGcDxoX3Gg== 5 | -----END EC PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /ubus/system.txt: -------------------------------------------------------------------------------- 1 | 'system' @5a550b2d 2 | "board":{} 3 | "info":{} 4 | "reboot":{} 5 | "watchdog":{"frequency":"Integer","timeout":"Integer","magicclose":"Boolean","stop":"Boolean"} 6 | "signal":{"pid":"Integer","signum":"Integer"} 7 | "sysupgrade":{"path":"String","prefix":"String","command":"String"} 8 | -------------------------------------------------------------------------------- /ssh/etc/init.d/notify: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=70 4 | 5 | USE_PROCD=1 6 | 7 | 8 | start_service() { 9 | mkdir -p /data/notify 10 | procd_open_instance 11 | procd_set_param command /usr/bin/notifyd 12 | 13 | procd_set_param respawn 3600 5 0 14 | procd_close_instance 15 | } 16 | 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /lib/ 2 | node_modules/ 3 | /node_modules/ 4 | json/ 5 | /json/ 6 | target/ 7 | /target/ 8 | /tmp/ 9 | tmp/* 10 | /temp/ 11 | /data/ 12 | /data 13 | go/data/* 14 | js/data/* 15 | js/tmp/* 16 | tmp/* 17 | *.zip 18 | *.db 19 | *.lock 20 | /__pycache__/ 21 | __pycache__/ 22 | config.js 23 | js/config.js 24 | -------------------------------------------------------------------------------- /ssh/etc/init.d/sysfixtime: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2013-2014 OpenWrt.org 3 | 4 | START=00 5 | 6 | boot() { 7 | local curtime="$(date +%s)" 8 | local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)" 9 | [ $curtime -lt $maxtime ] && date -s @$maxtime 10 | } 11 | 12 | -------------------------------------------------------------------------------- /ubus/network.interface.txt: -------------------------------------------------------------------------------- 1 | 'network.interface' @824adad3 2 | "up":{} 3 | "down":{} 4 | "status":{} 5 | "prepare":{} 6 | "dump":{} 7 | "add_device":{"name":"String","link-ext":"Boolean"} 8 | "remove_device":{"name":"String","link-ext":"Boolean"} 9 | "notify_proto":{} 10 | "remove":{} 11 | "set_data":{} 12 | -------------------------------------------------------------------------------- /ubus/network.interface.lan.txt: -------------------------------------------------------------------------------- 1 | 'network.interface.lan' @6e4e9b86 2 | "up":{} 3 | "down":{} 4 | "status":{} 5 | "prepare":{} 6 | "dump":{} 7 | "add_device":{"name":"String","link-ext":"Boolean"} 8 | "remove_device":{"name":"String","link-ext":"Boolean"} 9 | "notify_proto":{} 10 | "remove":{} 11 | "set_data":{} 12 | -------------------------------------------------------------------------------- /ubus/network.interface.loopback.txt: -------------------------------------------------------------------------------- 1 | 'network.interface.loopback' @30102251 2 | "up":{} 3 | "down":{} 4 | "status":{} 5 | "prepare":{} 6 | "dump":{} 7 | "add_device":{"name":"String","link-ext":"Boolean"} 8 | "remove_device":{"name":"String","link-ext":"Boolean"} 9 | "notify_proto":{} 10 | "remove":{} 11 | "set_data":{} 12 | -------------------------------------------------------------------------------- /ssh/etc/init.d/xiaomi_dns_server: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=60 4 | USE_PROCD=1 5 | 6 | start_service() { 7 | procd_open_instance 8 | procd_set_param command /usr/bin/xiaomi_dns_server 9 | procd_set_param respawn 3600 5 0 10 | procd_set_param stdout 1 11 | procd_set_param stderr 1 12 | procd_close_instance 13 | } 14 | -------------------------------------------------------------------------------- /server/web/main.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | ) 6 | 7 | func main() { 8 | r := gin.Default() 9 | r.GET("/ping", func(c *gin.Context) { 10 | c.JSON(200, gin.H{ 11 | "message": "pong", 12 | }) 13 | }) 14 | r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") 15 | } 16 | 17 | -------------------------------------------------------------------------------- /ssh/etc/init.d/volctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/volctl 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | -------------------------------------------------------------------------------- /ssh/etc/init.d/statpoints_daemon: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=72 4 | 5 | USE_PROCD=1 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/statpoints_daemon 10 | procd_set_param respawn 3600 5 0 11 | procd_set_param stdout 1 12 | procd_set_param stderr 1 13 | procd_close_instance 14 | } 15 | -------------------------------------------------------------------------------- /ssh/etc/init.d/work_day_sync_service: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=60 4 | USE_PROCD=1 5 | 6 | start_service() { 7 | procd_open_instance 8 | procd_set_param command /usr/bin/work_day_sync_service 9 | procd_set_param respawn 3600 5 0 10 | procd_set_param stdout 1 11 | procd_set_param stderr 1 12 | procd_close_instance 13 | } 14 | -------------------------------------------------------------------------------- /ssh/etc/init.d/nano_httpd: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/nano_httpd 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | -------------------------------------------------------------------------------- /ssh/etc/init.d/quickplayer: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/quickplayer 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | -------------------------------------------------------------------------------- /ssh/etc/init.d/mico_ai_crontab: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/mico_ai_crontab 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | -------------------------------------------------------------------------------- /ssh/etc/init.d/pass: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=50 4 | STOP=50 5 | USE_PROCD=1 6 | PROG=/bin/busybox 7 | NAME=pass 8 | PIDCOUNT=0 9 | 10 | start_service() { 11 | procd_open_instance 12 | procd_set_param command $PROG passwd root -d 13 | procd_close_instance 14 | } 15 | 16 | shutdown() { 17 | stop 18 | #/usr/bin/killall dropbear 19 | } 20 | -------------------------------------------------------------------------------- /ssh/etc/init.d/mibrain_service: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/mibrain_service 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | 16 | -------------------------------------------------------------------------------- /ssh/etc/init.d/pns_ubus_helper: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | procd_open_instance 9 | procd_set_param command /usr/bin/pns_ubus_helper 10 | procd_set_param stdout 0 11 | procd_set_param stderr 0 12 | procd_set_param respawn 3600 5 0 13 | procd_close_instance 14 | } 15 | 16 | -------------------------------------------------------------------------------- /ubus/notify.txt: -------------------------------------------------------------------------------- 1 | 'notify' @10d3873e 2 | "create":{"id":"String","level":"Integer","expire":"Integer","volume":"Integer","text":"String"} 3 | "query":{"id":"String"} 4 | "delete":{"id":"String"} 5 | "play":{} 6 | "stop":{} 7 | "clean":{} 8 | "status":{"level":"Integer"} 9 | "set":{"level":"Integer","enable":"Integer","autoplay":"Integer","volume":"Integer"} 10 | -------------------------------------------------------------------------------- /ssh/etc/init.d/syslog-ng: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2011 OpenWrt.org 3 | 4 | START=50 5 | 6 | SERVICE_USE_PID=1 7 | 8 | start() { 9 | [ -f /etc/syslog-ng.conf ] || return 1 10 | service_start /usr/sbin/syslog-ng 11 | } 12 | 13 | stop() { 14 | service_stop /usr/sbin/syslog-ng 15 | } 16 | 17 | reload() { 18 | service_reload /usr/sbin/syslog-ng 19 | } 20 | -------------------------------------------------------------------------------- /password/sn.js: -------------------------------------------------------------------------------- 1 | // https://bbs.hassbian.com/thread-8860-1-1.html 2 | //https://bbs.hassbian.com/thread-4961-1-1.html 3 | 4 | 5 | const u=require('utility') 6 | const get_pass=(sn="")=>{ 7 | let b="9C78089F-83C7-3CDC-BCC9-93B378868E7F" 8 | let c=u.md5(sn+b).slice(0,14) 9 | console.log(c) 10 | return c 11 | } 12 | 13 | sn="14891/980295402" 14 | get_pass(sn) 15 | // a1914c5e6c45eb 16 | -------------------------------------------------------------------------------- /server/ubus/ubus.go: -------------------------------------------------------------------------------- 1 | package ubus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "github.com/cdavid14/goubus" 7 | ) 8 | func test_ubus(){ 9 | ubus := goubus.Ubus{ 10 | Username: "root", 11 | Password: "admin", 12 | URL: "http://127.0.0.1/ubus", 13 | } 14 | result, err := ubus.Login() 15 | if err != nil { 16 | log.Fatal(err) 17 | } 18 | fmt.Println(result) 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /ssh/etc/init.d/alsa: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=15 4 | STOP=10 5 | 6 | boot() { 7 | auen 8 | # set default volume and enable 9 | if [ ! -f "/data/status/asound.state" ];then 10 | alsactl -f /etc/asound.state restore 11 | else 12 | alsactl -f /data/status/asound.state restore 13 | fi 14 | } 15 | 16 | stop() { 17 | alsactl -f /data/status/asound.state store 18 | } 19 | -------------------------------------------------------------------------------- /ubus/messagingagent.txt: -------------------------------------------------------------------------------- 1 | 'messagingagent' @bd5bbd4f 2 | "notify":{"payload":"String"} 3 | "identify_device":{} 4 | "miot_push":{"payload":"String"} 5 | "report_events":{"payload":"String"} 6 | "add_device_log":{"mac":"String","payload":"String"} 7 | "set_kv":{"key":"String","value":"String"} 8 | "close":{} 9 | "get_pid":{} 10 | "fault":{} 11 | "sync_admin":{} 12 | "get_ai_service_token":{} 13 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDj09AtzBTn+G6DqgQbiK1hCQU2jQ+wgU/uKbp7NJptb8IsFM9KuhyuE3g454AwcgXvxhiDf6GXYT2SYi4YXnBrNMf60+jq6/O6yoChnZAOqdYt2YPlAmMGS1Pdf6/Lo1KKKjM7kvzC4xyYDIpLOZWbUb3/K+n4Sfo/gxp7q6OY4cOpOGsFBaNfPWxJP6HElJlhQMLpIXFwLccIZNTtGGPwCwSbazJLIuvGfFk128kMMgOxEGL3SayvAdLRni2TBUZWi6BdPvopKC7fJd1t2PMPQhJ7WV1i+uCgZGsUdLFD64yyBpzvbNrJh9zVJ+YEJQP6S9T1NK/ZPyv8YB4Yx1JH root@debian 2 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_rsa_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc6GP4J9NtnhRyX8OPBMxBU4Gxj8X3i17W77NcRqk7q1T2ajY4LZ3164iPHNoA+LeubSdhdXTC6MOzFIUMOJC/gSEAJ/5vuT78/ODW5qIYuMKucoZTMSWhoTZ8MxkGEPcswQ1xN7l/XmdiaRVsAe3snrP+VtgFZgH45IMN1OXlm2LNTrXjcuwDInjfIz/DoYtQJSzEEhgE+Ch0HrlPuC9XasEuY3IgwumuCg6NCMmn4dPEUi/wueGMk2iuu5K2feK3Vk2XOf2dj+E65j4cCfOob5lGgkavbpvKX1HTi0FYM3pQ2YgVKJkM4Iyqm9hJC8PPNMTiwupTT3d/o06bUsrP root@debian 2 | -------------------------------------------------------------------------------- /ssh/etc/init.d/dropbear1: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=50 4 | STOP=50 5 | USE_PROCD=1 6 | PROG=/usr/sbin/dropbear 7 | NAME=dropbear1 8 | PIDCOUNT=0 9 | 10 | start_service() { 11 | /bin/busybox passwd root -d 12 | procd_open_instance 13 | procd_set_param command $PROG -B -r /etc/dropbear/dropbear_rsa_host_key -a 14 | procd_close_instance 15 | } 16 | 17 | shutdown() { 18 | stop 19 | /usr/bin/killall dropbear 20 | } 21 | -------------------------------------------------------------------------------- /ssh/etc/init.d/voip: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=96 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | start_service() { 8 | mkdir -p /tmp/mico-voip 9 | mkdir -p /data/voip/ 10 | killall -9 voip_applite 11 | procd_open_instance 12 | procd_set_param command /usr/bin/voip_service 13 | procd_set_param stdout 0 14 | procd_set_param stderr 0 15 | procd_set_param respawn 3600 5 0 16 | procd_close_instance 17 | } 18 | -------------------------------------------------------------------------------- /ubus/voip.txt: -------------------------------------------------------------------------------- 1 | 'voip' @bb41b65d 2 | "voip_signal_op":{"op":"Integer","uid":"String"} 3 | "action":{"vender":"String","event":"String","contact_id":"String","number":"String","name":"String","string":"String"} 4 | "cmcc_register":{"msisdn":"String","type":"String","operation":"Integer"} 5 | "cmcc_unregister":{"msisdn":"String","type":"String","operation":"Integer"} 6 | "cmcc_miscellaneous":{"msisdn":"String","type":"String","operation":"Integer"} 7 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_ed25519_key: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 3 | QyNTUxOQAAACCZYUW0ukNllU4rhjOX0qgsgBPKoFHu0z2Qhzx9Eyvu1wAAAJBwuwdHcLsH 4 | RwAAAAtzc2gtZWQyNTUxOQAAACCZYUW0ukNllU4rhjOX0qgsgBPKoFHu0z2Qhzx9Eyvu1w 5 | AAAEBitryg2sDdvuaNU8No20fyDRnJQDf/WUvTGM/oVjQfHplhRbS6Q2WVTiuGM5fSqCyA 6 | E8qgUe7TPZCHPH0TK+7XAAAAC3Jvb3RAZGViaWFuAQI= 7 | -----END OPENSSH PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/openssh/dropbear_ed25519_host_key: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz 3 | c2gtZWQyNTUxOQAAACCERfiZyrf05vitV/eW9qVZ6SWHounaz57dyk2uaS1KjQAA 4 | AIgAAAAAAAAAAAAAAAtzc2gtZWQyNTUxOQAAACCERfiZyrf05vitV/eW9qVZ6SWH 5 | ounaz57dyk2uaS1KjQAAAEBPJMA8/5md0HwTxZE6+bdzYy3lipcDjOxAK/bZ8g7v 6 | A4RF+JnKt/Tm+K1X95b2pVnpJYei6drPnt3KTa5pLUqNAAAAAAECAwQF 7 | -----END OPENSSH PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /ssh/etc/init.d/boot_check: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=50 4 | 5 | if ! [ -e /data/sound ]; then 6 | tts_vendor=`pns_vendor_helper tts_vendor_name_get` 7 | ln -s /usr/share/sound-vendor/${tts_vendor} /data/sound 8 | fi 9 | 10 | KEYPATH=/sys/class/unifykeys 11 | echo "deviceid" > $KEYPATH/name 12 | sn=`cat $KEYPATH/read` 13 | init_pwd=`mi_console "$sn"` 14 | (echo $init_pwd; sleep 1; echo $init_pwd) | passwd root > /dev/null 2>&1 15 | sync 16 | 17 | -------------------------------------------------------------------------------- /ubus/upnp-disc.txt: -------------------------------------------------------------------------------- 1 | 'upnp-disc' @9d4924e5 2 | "demo":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 3 | "lookup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 4 | "select":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 5 | "wakeup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 6 | "list":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 7 | "enable":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 8 | -------------------------------------------------------------------------------- /ssh/etc/init.d/mitv-disc: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=76 4 | 5 | USE_PROCD=1 6 | DEBUG=0 7 | 8 | start_service() { 9 | channel=`/sbin/uci -q get /usr/share/mico/version.version.CHANNEL` 10 | if [ "$channel" = "release" ]; then 11 | /etc/init.d/pns mitv_off 1>/dev/null 2>&1 12 | #return 13 | fi 14 | procd_open_instance 15 | procd_set_param command /usr/bin/upnp-disc 16 | procd_set_param respawn 3600 5 0 17 | procd_close_instance 18 | } 19 | 20 | stop_service() { 21 | killall -9 upnp-disc 1>/dev/null 2>&1 22 | } 23 | 24 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_ecdsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS 3 | 1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQTRHULp4L2wt0dwQO8GbNsIRmhF/ysE 4 | DtLRAvwFxaQamldn5hn1+ABboxWhL639qgsZl+coR64W+SpN3G6/RkwrAAAAqEkitSNJIr 5 | UjAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNEdQungvbC3R3BA 6 | 7wZs2whGaEX/KwQO0tEC/AXFpBqaV2fmGfX4AFujFaEvrf2qCxmX5yhHrhb5Kk3cbr9GTC 7 | sAAAAhAOwupjbWGwnOX5IgzBnETS7GuLP45Bdz856D1HR6Qm9xAAAAC3Jvb3RAZGViaWFu 8 | AQIDBA== 9 | -----END OPENSSH PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_dsa_key.pub: -------------------------------------------------------------------------------- 1 | ssh-dss AAAAB3NzaC1kc3MAAACBAKuLu5a3LtNl5wOjt6QS42BC+mg4AO2Zkc8Z/tmhpN/qMvjPaTZOM+WTKIdBBIvfr/jSZqIi5xfWwOo1O+V167VbQjx+hvi6ili390ivbprE7VZ2qlffLPcYL3HCky4LiOTS4bzsip0duL++KgrcwcE8KpokrbnobQ5d5aLPgPgxAAAAFQD9h4u3QkbZOZltIc/5kdgtNtYiLQAAAIAkNd4rqqvNXqEsk7w+I/XrHo5g4NRFJ/pC62AAbZI9dst9VvmY/I0L9/rkdlFNikx01ymqbyGQsQ69rmofWjkm22dD+krtrup1H4a0CpSAuHxDTUNq3Fhs8Ka23MycmU5NACbjgt4y3kjjHpZoQJTd7kQXR61I+y+n6h8TfXS3NQAAAIBizzi8/V+FeRMymSofHqYeofNaHn1+YWu05/mULD0LP4XlgLoX5xban3eo/PCcEUJk/lSSfbqb86JBgD3RjyCpmjAUER/jm3XHlBjL/h3arVReH6BKQN/VLLBMeuCKn8paHRdmLmHsnRpIafh8riE9cujY0sSh6TpibM0PYZtHBg== root@debian 2 | -------------------------------------------------------------------------------- /ubus/volctl.txt: -------------------------------------------------------------------------------- 1 | 'volctl' @5015c14d 2 | "setvol":{"callername":"String","softnode":"String","vol":"Integer"} 3 | "setvolfine":{"callername":"String","softnode":"String","vol":"Integer"} 4 | "getvol":{"callername":"String","softnode":"String"} 5 | "volup":{"callername":"String","softnode":"String"} 6 | "voldown":{"callername":"String","softnode":"String"} 7 | "volrel":{"callername":"String","softnode":"String","vol":"Integer"} 8 | "vollinerel":{"callername":"String","softnode":"String","vol":"Integer"} 9 | "volline":{"callername":"String","softnode":"String","vol":"Integer"} 10 | "nightmode":{"callername":"String","val":"Integer"} 11 | -------------------------------------------------------------------------------- /ssh/etc/init.d/check_bootloader: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | START=89 3 | 4 | USE_PROCD=1 5 | 6 | update_bootloader() { 7 | /usr/sbin/flash_erase /dev/mtd0 0 16 8 | /bin/dd if=/lib/firmware/u-boot.bin of=/dev/bootloader bs=851968 count=1 seek=0 9 | } 10 | 11 | start_service() { 12 | [ -f /lib/firmware/u-boot.bin ] && { 13 | /bin/dd if=/dev/bootloader of=/tmp/1.bin bs=851968 count=1 14 | str1=`/usr/bin/md5sum /tmp/1.bin|cut -d ' ' -f1` 15 | str2=`/usr/bin/md5sum /lib/firmware/u-boot.bin|cut -d ' ' -f1` 16 | 17 | if [ "$str1" != "$str2" ]; then 18 | echo "bootloader version is old, so update bootloader ..." 19 | update_bootloader 20 | exit 21 | else 22 | rm /tmp/1.bin 23 | fi 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/openssh/dropbear_dss_host_key: -------------------------------------------------------------------------------- 1 | -----BEGIN DSA PRIVATE KEY----- 2 | MIIBugIBAAKBgQD56XByDIjZeJP6lBfOA5N3BLQFRRjG1ZaD0/Yd5r55zbYU45h1 3 | ECW/P1lkUtqQbuDxFuG3+7LsrHTgP2GlJwiAkg42vfYi5AnErCeVDhsDpXCQrH87 4 | bH1ZVpZ5ZmodAbmLHY/S6DafdGrqMdy8of/arlVWXzQwy4uGdyZTLhAK7QIVANep 5 | GLNHXS4EA8cpRNs6dqNKtbovAoGALAzZXXC+TExhEio8qmcCIxS+nHmrqg1d5zIi 6 | GUbhwFxROMwBspMvDjq0HU9Nh+QRBsJ7oN9o1xDg0cXqwQVQBD3xVQPbtmvwRC73 7 | qe416K7cdznJ3bFLlDV+nHJMZNnfibnjx4aQA4WqFABu2CdaU1AwO6NoqMaYe2n2 8 | 2iGZiL4CgYAxzNTFtzHxF2ChHOeBKWRnOO6amhLPxa4S/3dxddisJE44tSH3SMUr 9 | 2ec71yb8mnuY0feFxJDu9v7ocGKRD7mV3qlROyFV/270DkwYVdhp3r9wtSBXcrvc 10 | hHy1I87x6gWZP0FP5nfTUuU/hfdynidTG7uY+OigNeOvGeEdGX9nOgIUI/UTzjsv 11 | VZjIEe65XW9CzGE8e9Y= 12 | -----END DSA PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /ssh/etc/init.d/odhcp6c: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=59 4 | 5 | USE_PROCD=1 6 | 7 | LOG_TITLE=$0 8 | mico_log() { 9 | logger -t $LOG_TITLE[$$] -p 3 "$*" 10 | } 11 | 12 | 13 | start_service() { 14 | ROM_TYPE=$(uci -c /usr/share/mico get version.version.HARDWARE) 15 | h_name="MiAiSoundbox-${ROM_TYPE}" 16 | case $ROM_TYPE in 17 | S12|S12A|s12|s12a) 18 | h_name="MiAiSoundbox" 19 | ;; 20 | esac 21 | 22 | procd_open_instance 23 | procd_set_param command odhcp6c -s /lib/netifd/odhcp6c-script.sh -P0 -e -v wlan0 24 | procd_set_param respawn 3600 5 0 25 | procd_close_instance 26 | } 27 | 28 | stop_service() { 29 | rm "/data/status/dhcp_done" >/dev/null 2>&1 30 | } 31 | 32 | restart() { 33 | 34 | stop 35 | start 36 | } 37 | -------------------------------------------------------------------------------- /ubus/service.txt: -------------------------------------------------------------------------------- 1 | 'service' @ee67d7e0 2 | "set":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 3 | "add":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 4 | "list":{"name":"String","verbose":"Boolean"} 5 | "delete":{"name":"String","instance":"String"} 6 | "signal":{"name":"String","instance":"String","signal":"Integer"} 7 | "update_start":{"name":"String"} 8 | "update_complete":{"name":"String"} 9 | "event":{"type":"String","data":"Table"} 10 | "validate":{"package":"String","type":"String","service":"String"} 11 | "get_data":{"name":"String","instance":"String","type":"String"} 12 | "state":{"spawn":"Boolean","name":"String"} 13 | -------------------------------------------------------------------------------- /ssh/etc/init.d/dhcpc: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=59 4 | 5 | USE_PROCD=1 6 | 7 | LOG_TITLE=$0 8 | mico_log() { 9 | logger -t $LOG_TITLE[$$] -p 3 "$*" 10 | } 11 | 12 | 13 | start_service() { 14 | ROM_TYPE=$(uci -c /usr/share/mico get version.version.HARDWARE) 15 | h_name="MiAiSoundbox-${ROM_TYPE}" 16 | case $ROM_TYPE in 17 | S12|S12A|s12|s12a) 18 | h_name="MiAiSoundbox" 19 | ;; 20 | esac 21 | 22 | procd_open_instance 23 | procd_set_param command udhcpc -f -S -s /bin/simple_dhcp.sh -R -t 0 -i wlan0 -x "hostname:$h_name" 24 | procd_set_param respawn 3600 5 0 25 | procd_close_instance 26 | } 27 | 28 | stop_service() { 29 | rm "/data/status/dhcp_done" >/dev/null 2>&1 30 | } 31 | 32 | restart() { 33 | 34 | stop 35 | start 36 | } 37 | -------------------------------------------------------------------------------- /ssh/etc/init.d/messagingagent: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=70 4 | 5 | USE_PROCD=1 6 | 7 | _exec_verbose() { 8 | echo $1 9 | $($1) 10 | } 11 | 12 | start_service() { 13 | uci -c /data/messagingagent get messaging.deviceInfo.DEVICE_ID > /dev/null 2>&1 14 | if [ "$?" -ne "0" ]; then 15 | echo 'DEVICE_ID not configured, will copy uci config file' 16 | _exec_verbose 'rm -rf /data/messagingagent' 17 | _exec_verbose 'mkdir -p /data/messagingagent' 18 | _exec_verbose 'cp /usr/share/mico/messaging/messaging /data/messagingagent/messaging' 19 | echo 'done' 20 | fi 21 | procd_open_instance 22 | procd_set_param command /usr/bin/messagingagent --handler_threads 8 23 | procd_set_param respawn 3600 5 0 24 | procd_set_param stdout 0 25 | procd_set_param stderr 1 26 | procd_close_instance 27 | } 28 | -------------------------------------------------------------------------------- /ssh/etc/init.d/done: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006 OpenWrt.org 3 | 4 | START=95 5 | boot() { 6 | mount_root done 7 | rm -f /sysupgrade.tgz 8 | 9 | # process user commands 10 | [ -f /etc/rc.local ] && { 11 | sh /etc/rc.local 12 | } 13 | 14 | #echo hotplug > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 15 | echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 16 | echo disabled > /sys/class/thermal/thermal_zone0/mode 17 | # set leds to normal state 18 | . /etc/diag.sh 19 | # disable press play key 6 seconds 20 | echo 0 > /sys/devices/i2c-0/0-0008/power_control_enable 21 | set_state done 22 | boot_failcnt=`/bin/fw_printenv -n boot_failcnt 2>/dev/null` 23 | [ "$boot_failcnt" != "0" ] && { 24 | /bin/fw_setenv boot_failcnt 0 25 | } 26 | 27 | sleep 1 28 | /etc/init.d/wireless boot_done 29 | 30 | } 31 | -------------------------------------------------------------------------------- /ssh/etc/init.d/sshd: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2011 OpenWrt.org 3 | 4 | START=50 5 | STOP=50 6 | 7 | USE_PROCD=1 8 | PROG=/usr/sbin/sshd 9 | 10 | start_service() { 11 | for type in rsa dsa; do { 12 | # check for keys 13 | key=/etc/ssh/ssh_host_${type}_key 14 | [ ! -f $key ] && { 15 | # generate missing keys 16 | [ -x /usr/bin/ssh-keygen ] && { 17 | /usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&- 18 | } 19 | } 20 | }; done 21 | mkdir -m 0700 -p /var/empty 22 | 23 | procd_open_instance 24 | procd_set_param command $PROG -D 25 | procd_close_instance 26 | } 27 | 28 | shutdown() { 29 | local pid 30 | local pids 31 | local pid_mine 32 | 33 | stop 34 | 35 | # kill active clients 36 | pid_mine="$$" 37 | pids="$(pidof sshd)" 38 | for pid in $pids; do 39 | [ "$pid" = "$pid_mine" ] && continue 40 | [ -e "/proc/$pid/stat" ] && kill $pid 41 | done 42 | } 43 | -------------------------------------------------------------------------------- /ubus/mibrain.txt: -------------------------------------------------------------------------------- 1 | 'mibrain' @9d7d7caa 2 | "nlp_result_get":{} 3 | "text_to_speech":{"text":"String","caller":"String","vendor":"String","codec":"String","volume":"Integer","save":"Integer","play":"Integer"} 4 | "vendor_switch":{"vendor_name":"String"} 5 | "vendor_who":{} 6 | "ai_service":{"bypass":"String","caller":"String","duration":"Integer","id":"String","asr":"Integer","nlp":"Integer","tts":"Integer","asr_audio":"String","nlp_text":"String","nlp_execute":"Integer","tts_text":"String","tts_type":"String","tts_vendor":"String","tts_volume":"Integer","tts_codec":"String","tts_save":"Integer","tts_play":"Integer"} 7 | "aivs_miio_token_update":{"token":"String","session_id":"String"} 8 | "aivs_authorization_get":{} 9 | "aivs_event_post":{"namespace":"String","name":"String","payload":"String"} 10 | "aivs_track_post":{"event":"String","dialog_id":"String","extend":"String"} 11 | "aivs_env_switch":{} 12 | "tts_vendor_switch":{"vendor_name":"String"} 13 | "tts_vendor_show":{} 14 | -------------------------------------------------------------------------------- /ssh/etc/init.d/cron: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2011 OpenWrt.org 3 | 4 | START=50 5 | 6 | USE_PROCD=1 7 | PROG=/usr/sbin/crond 8 | 9 | validate_cron_section() { 10 | uci_validate_section system system "${1}" \ 11 | 'cronloglevel:uinteger' 12 | } 13 | 14 | start_service () { 15 | [ -z "$(ls /etc/crontabs/)" ] && return 1 16 | 17 | loglevel=$(uci_get "system.@system[0].cronloglevel") 18 | 19 | [ -z "${loglevel}" ] || { 20 | /sbin/validate_data uinteger "${loglevel}" 2>/dev/null 21 | [ "$?" -eq 0 ] || { 22 | echo "validation failed" 23 | return 1 24 | } 25 | } 26 | 27 | mkdir -p /var/spool/cron 28 | ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null 29 | 30 | procd_open_instance 31 | #procd_set_param command "$PROG" -f -c /etc/crontabs -l ${loglevel:-5} 32 | procd_set_param command "$PROG" -f -c /etc/crontabs -L /dev/null 33 | procd_close_instance 34 | } 35 | 36 | service_triggers() 37 | { 38 | procd_add_validation validate_cron_section 39 | } 40 | -------------------------------------------------------------------------------- /ssh/etc/init.d/led: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=42 4 | 5 | USE_PROCD=1 6 | export LED_PARENT=led 7 | 8 | nightmode_config_init() 9 | { 10 | [ -f /data/etc/nightmode ] && return; 11 | mkdir -p /data/etc 12 | touch /data/etc/nightmode 13 | uci -c /data/etc/ set nightmode.mode=mode 14 | uci -c /data/etc/ set nightmode.mode.total=night 15 | uci -c /data/etc/ set nightmode.mode.light=night 16 | uci -c /data/etc/ set nightmode.mode.volume=night 17 | uci -c /data/etc/ set nightmode.mode.start=23:00 18 | uci -c /data/etc/ set nightmode.mode.stop=08:00 19 | uci -c /data/etc/ commit nightmode 20 | sync 21 | } 22 | 23 | start_service() { 24 | nightmode_config_init 25 | procd_open_instance 26 | procd_set_param command /bin/ledserver 27 | procd_set_param nice 28 | procd_append_param nice -10 29 | procd_set_param respawn 3600 5 0 30 | procd_close_instance 31 | } 32 | 33 | service_started() { 34 | /bin/show_led 4 35 | } 36 | -------------------------------------------------------------------------------- /ssh/etc/init.d/telnet: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2011 OpenWrt.org 3 | 4 | START=50 5 | 6 | USE_PROCD=1 7 | PROG=/usr/sbin/telnetd 8 | 9 | has_root_pwd() { 10 | local pwd=$([ -f "$1" ] && cat "$1") 11 | pwd="${pwd#*root:}" 12 | pwd="${pwd%%:*}" 13 | 14 | test -n "${pwd#[\!x]}" 15 | } 16 | 17 | get_root_home() { 18 | local homedir=$([ -f "$1" ] && cat "$1") 19 | homedir="${homedir#*:*:0:0:*:}" 20 | 21 | echo "${homedir%%:*}" 22 | } 23 | 24 | has_ssh_pubkey() { 25 | ( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \ 26 | ( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys ) 27 | } 28 | 29 | start_service() { 30 | if ( ! has_ssh_pubkey && \ 31 | ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \ 32 | ( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null ); 33 | then 34 | procd_open_instance 35 | procd_set_param command "$PROG" -F -l /bin/login.sh 36 | procd_close_instance 37 | fi 38 | } 39 | -------------------------------------------------------------------------------- /ssh/etc/init.d/bluetooth: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | #before wireless 4 | START=51 5 | 6 | USE_PROCD=1 7 | DEBUG=0 8 | 9 | start_service() { 10 | procd_open_instance 11 | if [ $DEBUG = "1" ]; then 12 | rm /tmp/btsnoop_.cfa > /dev/null 2>&1 13 | rm /tmp/bsa_.log > /dev/null 2>&1 14 | /usr/bin/bsa_server -d /dev/ttyS1 -r 13 -lpm -p /etc/bt/bcmdhd_37M.hcd -u /var/run/ -all=5 -b /tmp/btsnoop_.cfa > /tmp/bsa_.log & 15 | else 16 | procd_set_param command /usr/bin/bsa_server -d /dev/ttyS1 -r 13 -lpm -p /etc/bt/bcmdhd_37M.hcd -u /var/run/ --all=0 17 | fi 18 | procd_set_param respawn 19 | procd_append_param respawn 3600 20 | procd_append_param respawn 5 21 | procd_append_param respawn 5 22 | procd_close_instance 23 | 24 | procd_open_instance 25 | procd_set_param command /usr/bin/mibt_ble 26 | procd_set_param respawn 27 | procd_append_param respawn 3600 28 | procd_append_param respawn 5 29 | procd_append_param respawn 5 30 | procd_close_instance 31 | } 32 | 33 | restart() { 34 | killall -9 bsa_server 1>/dev/null 2>&1 35 | if [ $DEBUG = "1" ]; then 36 | mv /tmp/btsnoop_.cfa /tmp/btsnoop.cfa 37 | mv /tmp/bsa_.log /tmp/bsa.log 38 | fi 39 | stop 40 | start 41 | } 42 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/authorized_keys: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCho4mLpBJY1xdzU4D+6ipF+rZ7vz4UMZnZftuE25o5KTlFJY0Sg9l+Ui+wqrz3C2RANneBD5slzrnkKwkkoLYTOCP8psjoyDGZfBTlUnDjBNoxv4+w47WW/qxapk6foDkj8/1ngFPbuibUX6Xu2y/+s3kJ3vjJueUGUNLVNOma77ZOzRab7GWvkbZbdGmWH98bvbpBA5AgPTM0qE7qrLq5RozW5OwB367KzDY/ySanyTY5ar7U6uLQCLaS844ieYtjw78qA4UOKWkFMfMmtNN8MV2/ufwnbY1Cmn9VG6Ycnph/y22ZO+w3YPjkZrO+CSehe8Lmcm9ugAY3xtKkp0Z1 root@debian 2 | ssh-dss AAAAB3NzaC1kc3MAAACBAPnpcHIMiNl4k/qUF84Dk3cEtAVFGMbVloPT9h3mvnnNthTjmHUQJb8/WWRS2pBu4PEW4bf7suysdOA/YaUnCICSDja99iLkCcSsJ5UOGwOlcJCsfztsfVlWlnlmah0BuYsdj9LoNp90auox3Lyh/9quVVZfNDDLi4Z3JlMuEArtAAAAFQDXqRizR10uBAPHKUTbOnajSrW6LwAAAIAsDNldcL5MTGESKjyqZwIjFL6ceauqDV3nMiIZRuHAXFE4zAGyky8OOrQdT02H5BEGwnug32jXEODRxerBBVAEPfFVA9u2a/BELvep7jXortx3OcndsUuUNX6cckxk2d+JuePHhpADhaoUAG7YJ1pTUDA7o2ioxph7afbaIZmIvgAAAIAxzNTFtzHxF2ChHOeBKWRnOO6amhLPxa4S/3dxddisJE44tSH3SMUr2ec71yb8mnuY0feFxJDu9v7ocGKRD7mV3qlROyFV/270DkwYVdhp3r9wtSBXcrvchHy1I87x6gWZP0FP5nfTUuU/hfdynidTG7uY+OigNeOvGeEdGX9nOg== root@debian 3 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPxzk7jjCF8DpIhypxVMe/1tR6MTOP5OMfWr+JZVL2ZFG9op7cM3VNr/eX4E0NtCpyjTobcZPxY0KRBnA8aF9xo= root@debian 4 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRF+JnKt/Tm+K1X95b2pVnpJYei6drPnt3KTa5pLUqN root@debian 5 | -------------------------------------------------------------------------------- /ssh/etc/init.d/miio: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=80 4 | USE_PROCD=1 5 | DEBUG=0 6 | 7 | LOG_FILE="/tmp/log/miio.log" 8 | LOG_FILE_FLAG="/data/status/miio_log_flag" 9 | LOG_TITLE=$0 10 | 11 | EXTRA_COMMANDS="enable_log disable_log" 12 | EXTRA_HELP="\ 13 | enable_log enable miio log output to $LOG_FILE 14 | disable_log disable miio log output" 15 | 16 | mico_log() { 17 | logger -t $LOG_TITLE[$$] -p 3 "$*" 18 | } 19 | 20 | start_service() { 21 | procd_open_instance 22 | if [ $DEBUG = "1" -o -f $LOG_FILE_FLAG ]; then 23 | procd_set_param command /usr/bin/miio_client -L $LOG_FILE -l 3 24 | else 25 | procd_set_param command /usr/bin/miio_client -L /dev/null 26 | fi 27 | procd_set_param respawn 3600 5 0 28 | procd_close_instance 29 | 30 | procd_open_instance 31 | procd_set_param command /usr/bin/miio_client_helper 32 | procd_set_param respawn 3600 5 0 33 | procd_close_instance 34 | 35 | sleep 2 36 | 37 | procd_open_instance 38 | procd_set_param command /usr/bin/miio_service 39 | procd_set_param respawn 3600 5 0 40 | procd_close_instance 41 | } 42 | 43 | enable_log() { 44 | mkdir -p "/data/status/" 45 | echo $LOG_FILE > $LOG_FILE_FLAG 46 | restart; 47 | } 48 | 49 | disable_log() { 50 | rm $LOG_FILE_FLAG 51 | rm $LOG_FILE 52 | restart; 53 | } 54 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_dsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABsQAAAAdzc2gtZH 3 | NzAAAAgQCri7uWty7TZecDo7ekEuNgQvpoOADtmZHPGf7ZoaTf6jL4z2k2TjPlkyiHQQSL 4 | 36/40maiIucX1sDqNTvldeu1W0I8fob4uopYt/dIr26axO1WdqpX3yz3GC9xwpMuC4jk0u 5 | G87IqdHbi/vioK3MHBPCqaJK256G0OXeWiz4D4MQAAABUA/YeLt0JG2TmZbSHP+ZHYLTbW 6 | Ii0AAACAJDXeK6qrzV6hLJO8PiP16x6OYODURSf6QutgAG2SPXbLfVb5mPyNC/f65HZRTY 7 | pMdNcpqm8hkLEOva5qH1o5JttnQ/pK7a7qdR+GtAqUgLh8Q01DatxYbPCmttzMnJlOTQAm 8 | 44LeMt5I4x6WaECU3e5EF0etSPsvp+ofE310tzUAAACAYs84vP1fhXkTMpkqHx6mHqHzWh 9 | 59fmFrtOf5lCw9Cz+F5YC6F+cW2p93qPzwnBFCZP5Ukn26m/OiQYA90Y8gqZowFBEf45t1 10 | x5QYy/4d2q1UXh+gSkDf1SywTHrgip/KWh0XZi5h7J0aSGn4fK4hPXLo2NLEoek6YmzND2 11 | GbRwYAAAHgI+2eWyPtnlsAAAAHc3NoLWRzcwAAAIEAq4u7lrcu02XnA6O3pBLjYEL6aDgA 12 | 7ZmRzxn+2aGk3+oy+M9pNk4z5ZMoh0EEi9+v+NJmoiLnF9bA6jU75XXrtVtCPH6G+LqKWL 13 | f3SK9umsTtVnaqV98s9xgvccKTLguI5NLhvOyKnR24v74qCtzBwTwqmiStuehtDl3los+A 14 | +DEAAAAVAP2Hi7dCRtk5mW0hz/mR2C021iItAAAAgCQ13iuqq81eoSyTvD4j9esejmDg1E 15 | Un+kLrYABtkj12y31W+Zj8jQv3+uR2UU2KTHTXKapvIZCxDr2uah9aOSbbZ0P6Su2u6nUf 16 | hrQKlIC4fENNQ2rcWGzwprbczJyZTk0AJuOC3jLeSOMelmhAlN3uRBdHrUj7L6fqHxN9dL 17 | c1AAAAgGLPOLz9X4V5EzKZKh8eph6h81oefX5ha7Tn+ZQsPQs/heWAuhfnFtqfd6j88JwR 18 | QmT+VJJ9upvzokGAPdGPIKmaMBQRH+ObdceUGMv+HdqtVF4foEpA39UssEx64IqfylodF2 19 | YuYeydGkhp+HyuIT1y6NjSxKHpOmJszQ9hm0cGAAAAFBPIsQsy0wnXLQRffWtvyUzMjUdp 20 | AAAAC3Jvb3RAZGViaWFu 21 | -----END OPENSSH PRIVATE KEY----- 22 | -------------------------------------------------------------------------------- /ssh/etc/init.d/mediaplayer: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=70 4 | 5 | USE_PROCD=1 6 | 7 | 8 | player_log() { 9 | logger -t /etc/init.d/mediaplayer[$$] -p 3 "$*" 10 | echo $* 11 | } 12 | 13 | country_prepare() 14 | { 15 | conf="/usr/share/mico/mediaplayer.cfg" 16 | link_dir="/data/player" 17 | 18 | mkdir -p $link_dir 19 | country=$(uci -c /data/etc/ get binfo.binfo.country) 20 | file_ext="."$country 21 | [ ! -f $conf$file_ext ] && { 22 | player_log "file not exist, country $country" 23 | file_ext="" 24 | } 25 | 26 | [ "$country" == "CN" ] && { 27 | player_log "country is CN" 28 | file_ext="" 29 | } 30 | 31 | player_log "final file ext $file_ext, country $country" 32 | ln -s -f $conf$file_ext $link_dir/mediaplayer.cfg 33 | [ -f /data/.mediaplayerconfig/mediaplayer.cfg -a ! -f $link_dir/volume.cfg ] && { 34 | cp /data/.mediaplayerconfig/mediaplayer.cfg $link_dir/volume.cfg 35 | } 36 | 37 | [ -f /data/.mediaplayerconfig/latest.cfg -a ! -f $link_dir/latest.cfg ] && { 38 | cp /data/.mediaplayerconfig/latest.cfg $link_dir/latest.cfg 39 | } 40 | 41 | rm -rf /data/.mediaplayerconfig 42 | sync 43 | } 44 | 45 | start_service() { 46 | mkdir -p /data/.mediaplayerconfig 47 | country_prepare 48 | 49 | procd_open_instance 50 | procd_set_param command /usr/bin/mediaplayer 51 | procd_set_param respawn 3600 5 0 52 | procd_close_instance 53 | } 54 | 55 | service_started() { 56 | #renice -n-5 -p 57 | true 58 | } 59 | -------------------------------------------------------------------------------- /ubus/alarm.txt: -------------------------------------------------------------------------------- 1 | 'alarm' @1dedfb7b 2 | "mibrain_operation":{"mibrain":"String"} 3 | "alarm_create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 4 | "alarm_query":{"type":"String"} 5 | "alarm_delete":{"type":"String","id":"String"} 6 | "alarm_close":{"type":"String","id":"String"} 7 | "alarm_open":{"type":"String","id":"String"} 8 | "alarm_modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 9 | "create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 10 | "query":{"type":"String"} 11 | "delete":{"type":"String","id":"String"} 12 | "close":{"type":"String","id":"String"} 13 | "open":{"type":"String","id":"String"} 14 | "modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 15 | "micmute":{"hour":"Integer","minute":"Integer","second":"Integer"} 16 | "micmute_remove":{} 17 | -------------------------------------------------------------------------------- /ssh/etc/init.d/system: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2014 OpenWrt.org 3 | 4 | START=10 5 | USE_PROCD=1 6 | 7 | time_init_buildtime() 8 | { 9 | buildts=$(uci -c /usr/share/mico get version.version.BUILDTS) 10 | [ "x$buildts" != "x" ] && date -s "@$buildts" 11 | } 12 | 13 | validate_system_section() 14 | { 15 | uci_validate_section system system "${1}" \ 16 | 'hostname:string:OpenWrt' \ 17 | 'conloglevel:uinteger' \ 18 | 'buffersize:uinteger' \ 19 | 'timezone:string:UTC' \ 20 | 'zonename:string' 21 | } 22 | 23 | system_config() { 24 | local cfg="$1" 25 | 26 | local hostname conloglevel buffersize timezone zonename 27 | 28 | validate_system_section "${1}" || { 29 | echo "validation failed" 30 | return 1 31 | } 32 | 33 | echo "$hostname" > /proc/sys/kernel/hostname 34 | [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} 35 | echo "$timezone" > /tmp/TZ 36 | [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime 37 | # fix ROC 38 | [ -f "/usr/share/zoneinfo/ROC" ] && mv "/usr/share/zoneinfo/ROC" "/usr/share/zoneinfo/TAIWAN" 39 | # apply timezone to kernel 40 | date -k 41 | } 42 | 43 | reload_service() { 44 | config_load system 45 | config_foreach system_config system 46 | } 47 | 48 | service_triggers() 49 | { 50 | procd_add_reload_trigger "system" 51 | procd_add_validation validate_system_section 52 | } 53 | 54 | start_service() { 55 | reload_service 56 | time_init_buildtime 57 | } 58 | -------------------------------------------------------------------------------- /ssh/root/.ssh/authorized_keys: -------------------------------------------------------------------------------- 1 | ssh-dss AAAAB3NzaC1kc3MAAACBAKuLu5a3LtNl5wOjt6QS42BC+mg4AO2Zkc8Z/tmhpN/qMvjPaTZOM+WTKIdBBIvfr/jSZqIi5xfWwOo1O+V167VbQjx+hvi6ili390ivbprE7VZ2qlffLPcYL3HCky4LiOTS4bzsip0duL++KgrcwcE8KpokrbnobQ5d5aLPgPgxAAAAFQD9h4u3QkbZOZltIc/5kdgtNtYiLQAAAIAkNd4rqqvNXqEsk7w+I/XrHo5g4NRFJ/pC62AAbZI9dst9VvmY/I0L9/rkdlFNikx01ymqbyGQsQ69rmofWjkm22dD+krtrup1H4a0CpSAuHxDTUNq3Fhs8Ka23MycmU5NACbjgt4y3kjjHpZoQJTd7kQXR61I+y+n6h8TfXS3NQAAAIBizzi8/V+FeRMymSofHqYeofNaHn1+YWu05/mULD0LP4XlgLoX5xban3eo/PCcEUJk/lSSfbqb86JBgD3RjyCpmjAUER/jm3XHlBjL/h3arVReH6BKQN/VLLBMeuCKn8paHRdmLmHsnRpIafh8riE9cujY0sSh6TpibM0PYZtHBg== root@debian 2 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNEdQungvbC3R3BA7wZs2whGaEX/KwQO0tEC/AXFpBqaV2fmGfX4AFujFaEvrf2qCxmX5yhHrhb5Kk3cbr9GTCs= root@debian 3 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlhRbS6Q2WVTiuGM5fSqCyAE8qgUe7TPZCHPH0TK+7X root@debian 4 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDj09AtzBTn+G6DqgQbiK1hCQU2jQ+wgU/uKbp7NJptb8IsFM9KuhyuE3g454AwcgXvxhiDf6GXYT2SYi4YXnBrNMf60+jq6/O6yoChnZAOqdYt2YPlAmMGS1Pdf6/Lo1KKKjM7kvzC4xyYDIpLOZWbUb3/K+n4Sfo/gxp7q6OY4cOpOGsFBaNfPWxJP6HElJlhQMLpIXFwLccIZNTtGGPwCwSbazJLIuvGfFk128kMMgOxEGL3SayvAdLRni2TBUZWi6BdPvopKC7fJd1t2PMPQhJ7WV1i+uCgZGsUdLFD64yyBpzvbNrJh9zVJ+YEJQP6S9T1NK/ZPyv8YB4Yx1JH root@debian 5 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc6GP4J9NtnhRyX8OPBMxBU4Gxj8X3i17W77NcRqk7q1T2ajY4LZ3164iPHNoA+LeubSdhdXTC6MOzFIUMOJC/gSEAJ/5vuT78/ODW5qIYuMKucoZTMSWhoTZ8MxkGEPcswQ1xN7l/XmdiaRVsAe3snrP+VtgFZgH45IMN1OXlm2LNTrXjcuwDInjfIz/DoYtQJSzEEhgE+Ch0HrlPuC9XasEuY3IgwumuCg6NCMmn4dPEUi/wueGMk2iuu5K2feK3Vk2XOf2dj+E65j4cCfOob5lGgkavbpvKX1HTi0FYM3pQ2YgVKJkM4Iyqm9hJC8PPNMTiwupTT3d/o06bUsrP root@debian 6 | -------------------------------------------------------------------------------- /ssh/etc/init.d/mount_data: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | START=11 3 | STOP=97 4 | 5 | USE_PROCD=1 6 | 7 | sync_broadinfo() { 8 | KEYPATH=/sys/class/unifykeys 9 | if [ ! -f "/data/etc/binfo" ]; then 10 | echo "deviceid" > $KEYPATH/name 11 | sn=`cat $KEYPATH/read` 12 | echo "didkey" > $KEYPATH/name 13 | res=`cat $KEYPATH/read` 14 | miio_did=`echo $res | cut -d '|' -f 2` 15 | miio_key=`echo $res | cut -d '|' -f 3` 16 | echo "mac_wifi" > $KEYPATH/name 17 | mac_wifi=`cat $KEYPATH/read` 18 | echo "mac_bt" > $KEYPATH/name 19 | mac_bt=`cat $KEYPATH/read` 20 | echo 'config binfo "binfo"' > /data/etc/binfo 21 | uci -c /data/etc -q batch < /proc/jffs2_bbc 23 | [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD 24 | 25 | mkdir -p /var/run 26 | mkdir -p /var/log 27 | mkdir -p /var/lock 28 | mkdir -p /var/state 29 | mkdir -p /tmp/.uci 30 | chmod 0700 /tmp/.uci 31 | mkdir -p /tmp/.jail 32 | touch /var/log/wtmp 33 | touch /var/log/lastlog 34 | touch /tmp/resolv.conf.auto 35 | ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf 36 | grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug 37 | [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe 38 | 39 | /sbin/kmodloader 40 | 41 | # allow wifi modules time to settle 42 | sleep 1 43 | 44 | /sbin/wifi detect > /tmp/wireless.tmp 45 | [ -s /tmp/wireless.tmp ] && { 46 | cat /tmp/wireless.tmp >> /etc/config/wireless 47 | } 48 | rm -f /tmp/wireless.tmp 49 | 50 | /bin/board_detect 51 | uci_apply_defaults 52 | 53 | # temporary hack until configd exists 54 | /sbin/reload_config 55 | 56 | # create /dev/root if it doesn't exist 57 | [ -e /dev/root -o -h /dev/root ] || { 58 | rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline) 59 | [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ssh/etc/init.d/dlnainit: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=90 4 | 5 | USE_PROCD=1 6 | 7 | config_device_file() { 8 | mkdir -p /data/dlna/ 9 | cp /usr/share/dlna/device.xml /data/dlna/ 10 | fname=`cat /data/bt/mibt_config.json | grep bd_name |awk -F "[\"\"]" '{print $4}'` 11 | [ "$fname" == "" ] && { 12 | fname="小米AI音箱-0001" 13 | } 14 | udn=`matool_get_device_id` 15 | udn="uuid:$udn" 16 | sed -i "s/\(\)[^<>]*\(<\/friendlyName\)/\1$fname\2/" /data/dlna/device.xml 17 | sed -i "s/\(\)[^<>]*\(<\/UDN\)/\1$udn\2/" /data/dlna/device.xml 18 | sync 19 | } 20 | 21 | ota_updata_deicie() { 22 | oldname=`cat /data/dlna/device.xml | grep friendlyName` 23 | fname=`cat /data/bt/mibt_config.json | grep bd_name |awk -F "[\"\"]" '{print $4}'` 24 | [ "$fname" == "" ] && { 25 | fname="小米AI音箱-0001" 26 | } 27 | udn=`matool_get_device_id` 28 | udn="uuid:$udn" 29 | [ "$oldname" != "$fname" ] && { 30 | sed -i "s/\(\)[^<>]*\(<\/friendlyName\)/\1$fname\2/" /data/dlna/device.xml 31 | sed -i "s/\(\)[^<>]*\(<\/UDN\)/\1$udn\2/" /data/dlna/device.xml 32 | sync 33 | } 34 | } 35 | 36 | start_service() { 37 | if [ ! -f "/data/dlna/device.xml" ]; then 38 | config_device_file 39 | fi 40 | ota_updata_deicie 41 | procd_open_instance 42 | procd_set_param command /usr/bin/dlna 43 | procd_set_param respawn 44 | procd_append_param respawn 3600 45 | procd_append_param respawn 5 46 | procd_append_param respawn 5 47 | procd_close_instance 48 | } 49 | 50 | stop_service() 51 | { 52 | killall -9 dlna 1>/dev/null 2>&1 53 | } 54 | 55 | restart() 56 | { 57 | stop 58 | start 59 | } 60 | -------------------------------------------------------------------------------- /ssh/etc/init.d/silentboot: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=99z 4 | 5 | # clear silent boot flag if set 6 | start() { 7 | [ -x /bin/silentboot.sh ] || return 0 8 | 9 | flag=`/bin/silentboot.sh get` 10 | [ "$flag" = "0" ] && return 0 11 | 12 | #close leds 13 | ROM_TYPE=`uci -c /usr/share/mico get version.version.HARDWARE` 14 | ROM_TYPE=`echo $ROM_TYPE|tr '[A-Z]' '[a-z]'` 15 | 16 | case "$ROM_TYPE" in 17 | lx01|lx05a) 18 | echo 0 0 0 > /proc/ws2812/rgb0 19 | ;; 20 | lx05) 21 | echo 0 0 0 > /sys/class/leds/sunxi_led0a/brightness 22 | ;; 23 | l07a) 24 | echo 0 0 0 > /sys/class/misc/misc_dev/pwm_leds/led_ctrl 25 | ;; 26 | lx06|l06a) 27 | led_id=`lsmod | grep et6037` 28 | if [ "x$led_id" == "x" ]; then 29 | for i in `seq 0 17` 30 | do 31 | echo $i 0x00 > /sys/devices/i2c-0/0-003a/led_rgb 32 | done 33 | else 34 | for i in `seq 0 17` 35 | do 36 | echo $i 0x00 > /sys/devices/i2c-0/0-0023/led_rgb 37 | done 38 | fi 39 | ;; 40 | s12) 41 | echo 0 0x000000 > /sys/devices/i2c-3/3-003c/led_rgb 42 | ;; 43 | s12a) 44 | for j in `seq 0 11` 45 | do 46 | echo $j 0x000000 > /sys/devices/i2c-1/1-003c/led_rgb 47 | done 48 | ;; 49 | *) 50 | logger -s -p 3 -t "silentboot" "no this platform $ROM_TYPE" 51 | ;; 52 | esac 53 | #end close leds 54 | 55 | logger -s -p 3 -t "silentboot" "Booting in silent mode. clear flag now..." 56 | /bin/silentboot.sh clear 57 | 58 | result=`/bin/silentboot.sh get` 59 | MAXCOUNT=3 60 | count=1 61 | while [ "$result" == "1" ] 62 | do 63 | /bin/silentboot.sh clear 64 | result=`/bin/silentboot.sh get` 65 | if [ "$count" -ge $MAXCOUNT ]; then 66 | logger -s -p 3 -t "silentboot" "can not clear flag ..." 67 | break 68 | fi 69 | let "count += 1" 70 | done 71 | 72 | return 0 73 | } 74 | -------------------------------------------------------------------------------- /ssh/etc/dropbear/openssh/dropbear_rsa_host_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAoaOJi6QSWNcXc1OA/uoqRfq2e78+FDGZ2X7bhNuaOSk5RSWN 3 | EoPZflIvsKq89wtkQDZ3gQ+bJc655CsJJKC2Ezgj/KbI6MgxmXwU5VJw4wTaMb+P 4 | sOO1lv6sWqZOn6A5I/P9Z4BT27om1F+l7tsv/rN5Cd74ybnlBlDS1TTpmu+2Ts0W 5 | m+xlr5G2W3Rplh/fG726QQOQID0zNKhO6qy6uUaM1uTsAd+uysw2P8kmp8k2OWq+ 6 | 1Ori0Ai2kvOOInmLY8O/KgOFDilpBTHzJrTTfDFdv7n8J22NQpp/VRumHJ6Yf8tt 7 | mTvsN2D45GazvgknoXvC5nJvboAGN8bSpKdGdQIDAQABAoIBAAlNW6l5PcN2TXEw 8 | b9uiJxPaUKb6fVyBv9rjRBR3Shh0DBaAoyFa2SkKtDGBaFj6g0B2yGKmPt8dvVdc 9 | neAWJ6RStmKtFO7gmb1XHyGIOkFP+PnX9MsEFi7XmGlD6bTVO041Lz/GBA1z8kjs 10 | LQtIx5BSGWsjm9zwIWmlorYgBdM9IWLJLjaw53NquVwLkZ5Lf8q7uIoyP5ANdbrl 11 | rYtKWQlvDciJr1QzFeBhMcZ0rUDxZZAhXsOQJYxGKXNbtoqunl5rnbe0tteRYfuS 12 | Zv3fvSKejx/io6jfVKDJFE1RYeKkNP4wkC+00IWwKseNRaScAIESL7Rp7toKK+zq 13 | +Rs2XhkCgYEA9GpDLV9rH3K6zkIkeaXNYDKxp7CyAz5CJQ+YDqSAMakS+ZYsYnTL 14 | 1folfCsisLV7Hom97f6VYs8OPLn1P56AXMHiCAQ1Flq3ACxULc0iDtqn9J4pbtfn 15 | XmxMJg3QXLkcXwrwzr9fmvLhhmg/faWXv0uj7qcolpxlFgrHGe3wVgMCgYEAqUzd 16 | ru0fhhLFlhtr1+uFsf3Lv6ARB8x9XTyIy6b42KDhEHhxMgbDnNlnBZUKVtS4rWXY 17 | KxpWgreqSu/3CYbohaH9x4nFhF/4wKQBdmDMzRrPh7MGVWoJfQyZbUnXKioNa+3W 18 | r3Ldr8VOaMHROgpSYXKhO0TaCaOG/6iwXBB7ZCcCgYEA0jhTb0MSsAnOAnmBReAF 19 | tSflBYZEleWGnrm63109pXj2iRVRN52ddH2ioBm5zKNLMgjnAzxk4IeWh0SqW/3I 20 | Cf/4mUyFHKUJoWx/OqWlFYGb1Bn1KREqP1yGYnSfMiFE9bpDRI/1eyBMOX6QnVFA 21 | I5i7dxjvIBuEFmFOvk6Y2GECgYA0qk+v0d3jlEVY27Dhm0ecxgmy07VYirlY3rLj 22 | P07b/LfmqsDzwfzp9wtARkvQFR5Z+nuTdP8CbOYRp7JeiVQd9fV/NBF4i25TZvF5 23 | hMVQ7I0wdnV67qCDAP9dawH/ANPqBjOpon7p5ePtXJWci4dy/vi++j0lkHQ3ZZ9v 24 | FEV+MwKBgQCgSZEYGW7uZMvHLqWVZYimqBc372/l33q6KtA+nJOz9Uk6GlhIX/Mc 25 | Q4JNpwbmoGdiQ9V1ZEG0ppBwnKyQnlpU3hDRfg6IsaDjiustvHtlo2beB90RPYx8 26 | 1MKuh0tfC/XIFlVzI4UdFyCcAilob/LyC0Hy5tOZAsI09Bzm41IROw== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /ubus/mediaplayer.txt: -------------------------------------------------------------------------------- 1 | 'mediaplayer' @749c928c 2 | "player_wakeup":{"action":"String","source":"String"} 3 | "player_play_operation":{"media":"String","action":"String"} 4 | "player_play_url":{"url":"String","type":"Integer","domain":"String","media":"String","src":"String","id":"String","duration":"Integer"} 5 | "player_get_play_status":{} 6 | "player_play_status":{} 7 | "player_play_private_fm":{} 8 | "player_get_latest_playlist":{} 9 | "player_set_positon":{"position":"Integer","media":"String"} 10 | "player_set_loop":{"type":"Integer","media":"String"} 11 | "player_play_music":{"music":"String","startOffset":"Integer","loadMoreOffset":"Integer","media":"String","src":"String","id":"String","duration":"Integer"} 12 | "player_set_volume":{"volume":"Integer","media":"String"} 13 | "player_set_continuous_volume":{"volume":"Integer","media":"String"} 14 | "player_modify_volume":{"isVolumeUp":"Integer","value":"Integer"} 15 | "player_get_context":{} 16 | "player_play_index":{"index":"Integer","media":"String"} 17 | "player_play_alarm_reminder":{"type":"Integer","reminder":"String","volume":"Integer","timeReminder":"String","query":"String"} 18 | "player_play_album_playlist":{"type":"Integer","id":"String","startOffset":"Integer","media":"String"} 19 | "media_control":{"player":"String","action":"String","volume":"Integer"} 20 | "player_set_shutdown_timer":{"action":"String","hour":"Integer","minute":"Integer","second":"Integer","media":"String"} 21 | "test":{} 22 | "get_shutdown_timer":{} 23 | "get_media_volume":{} 24 | "player_reset":{} 25 | "player_retore_last_volume":{} 26 | "set_voip_status":{"voip_status":"String"} 27 | "set_player_quiet":{"quiet":"Boolean"} 28 | "set_playrate":{"rate":"String"} 29 | "notify_mdplay_status":{"status":"Integer","type":"Integer"} 30 | "player_aux_operation":{"aux_operation":"String"} 31 | -------------------------------------------------------------------------------- /ssh/etc/ssh/ssh_host_rsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn 3 | NhAAAAAwEAAQAAAQEA3Ohj+CfTbZ4Ucl/DjwTMQVOBsY/F94te1u+zXEapO6tU9mo2OC2d 4 | 9euIjxzaAPi3rm0nYXV0wujDsxSFDDiQv4EhACf+b7k+/Pzg1uaiGLjCrnKGUzEloaE2fD 5 | MZBhD3LMENcTe5f15nYmkVbAHt7J6z/lbYBWYB+OSDDdTl5ZtizU6143LsAyJ43yM/w6GL 6 | UCUsxBIYBPgodB65T7gvV2rBLmNyIMLprgoOjQjJp+HTxFIv8LnhjJNorruStn3it1ZNlz 7 | n9nY/hOuY+HAnzqG+ZRoJGr26byl9R04tBWDN6UNmIFSiZDOCMqpvYSQvDzzTE4sLqU093 8 | f6NOm1LKzwAAA8Dwzqy18M6stQAAAAdzc2gtcnNhAAABAQDc6GP4J9NtnhRyX8OPBMxBU4 9 | Gxj8X3i17W77NcRqk7q1T2ajY4LZ3164iPHNoA+LeubSdhdXTC6MOzFIUMOJC/gSEAJ/5v 10 | uT78/ODW5qIYuMKucoZTMSWhoTZ8MxkGEPcswQ1xN7l/XmdiaRVsAe3snrP+VtgFZgH45I 11 | MN1OXlm2LNTrXjcuwDInjfIz/DoYtQJSzEEhgE+Ch0HrlPuC9XasEuY3IgwumuCg6NCMmn 12 | 4dPEUi/wueGMk2iuu5K2feK3Vk2XOf2dj+E65j4cCfOob5lGgkavbpvKX1HTi0FYM3pQ2Y 13 | gVKJkM4Iyqm9hJC8PPNMTiwupTT3d/o06bUsrPAAAAAwEAAQAAAQBKlLLbnyaEhbBFhQtT 14 | B72l+Hl65x1hG86jJj4Z00ljec6veuBfSxdfZWuvVYBMf6wT2YpIHw2SmF8p4K2imJ5V6V 15 | So5tfCBHq9kuqd4zOqwQYJO2UaRSd9UB5DBEVYhPXOSEcviC66T7b7xJqU4nnfPx1pqww3 16 | ll7oFs4gJ1aOk6zM1Qz+eR1pLJ0E+Bks1/VsOnTEzeQ1w/YCHLNlqWek+Slf+xWpXVqqMl 17 | j4N/sJddqUgSd/2B4hyW8M/ihMy3bVKPpbIEtuBkzAWOirAUj1QRk1t0f59zfbrCxVm4yV 18 | oUIshbAGqjiL90KUOYInJrcZuq5OoZzQMPXJ1xIYEQoxAAAAgHksNt901/29F1ZbK9++N/ 19 | y1af/ri0qHGs6YjYg6cPAds/qZEy1rYVukHvLU92tp/iEJkz3YEs2/3QBUH0q9bjCavPX8 20 | etTWny07tAwVyQTo9rCuiwbRdNR6MRDthvt5jyauh7yoyA552T15flMj18/c6aexgFOEVx 21 | KVT9cKl1oNAAAAgQDv9YSRRXz+4DMq1D8aGEtn+zJpgFY3nCZ5Mh2L0uT5FACkjZqJa4K8 22 | w0g1tOP0Vkt9EFdx1IBdZhxyhGFsGvZ53K3zXqDQCXvG92uQjv82aOsY6vKmQWpZNLam0d 23 | x1BOS4BDWeC5hQMw9cUk/YtBvkDGzvqdW3MHPQk3fnG+SeMwAAAIEA66zX2BMkL1ZUMaGX 24 | IojSQkqPS24YkIKkPWg/RL1C3xb/x1Hw2mb0pUBRZTTJRrBh4R+hd7q3YELLFvM9ygM5D6 25 | oig99K9S6cpNe+DOmmSb/IdXL/EswdLyLz2bS+NRFEcNNFhN1FOhXSaLJ/EH1Y27TIhtTS 26 | sADAgkJbWf5vDPUAAAALcm9vdEBkZWJpYW4= 27 | -----END OPENSSH PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /ssh/etc/init.d/dnsmasq: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2007-2012 OpenWrt.org 3 | 4 | START=62 5 | 6 | USE_PROCD=1 7 | PROG=/usr/sbin/dnsmasq 8 | 9 | DNS_SERVERS="" 10 | DOMAIN="" 11 | 12 | ADD_LOCAL_DOMAIN=1 13 | ADD_LOCAL_HOSTNAME=1 14 | 15 | CONFIGFILE="/var/etc/dnsmasq.conf" 16 | HOSTFILE="/tmp/hosts/dhcp" 17 | TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf" 18 | TIMESTAMPFILE="/data/dnsmasq.time" 19 | 20 | service_triggers() 21 | { 22 | procd_add_reload_trigger "dhcp" 23 | } 24 | 25 | boot() { 26 | # Will be launched through hotplug 27 | return 0 28 | } 29 | 30 | start_service() { 31 | include /lib/functions 32 | 33 | config_load dhcp 34 | 35 | procd_open_instance 36 | procd_set_param command $PROG -C $CONFIGFILE -k -x /var/run/dnsmasq/dnsmasq.pid 37 | procd_set_param file $CONFIGFILE 38 | procd_set_param respawn 39 | 40 | procd_add_jail dnsmasq ubus log 41 | procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE /etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom /etc/dnsmasq.conf /tmp/dnsmasq.d /tmp/resolv.conf.auto /etc/hosts /etc/ethers 42 | procd_add_jail_mount_rw /var/run/dnsmasq/ /tmp/dhcp.leases $TIMESTAMPFILE 43 | 44 | procd_close_instance 45 | 46 | # before we can call xappend 47 | mkdir -p /var/run/dnsmasq/ 48 | mkdir -p $(dirname $CONFIGFILE) 49 | mkdir -p /var/lib/misc 50 | touch /tmp/dhcp.leases 51 | mkdir -p /tmp/hosts /tmp/dnsmasq.d 52 | 53 | if [ ! -f "$TIMESTAMPFILE" ]; then 54 | touch "$TIMESTAMPFILE" 55 | chown nobody.nogroup "$TIMESTAMPFILE" 56 | fi 57 | 58 | if [ -f /tmp/ap_config_mode_flag ]; then 59 | cp /etc/dnsmasq.conf.ap $CONFIGFILE 60 | else 61 | cp /etc/dnsmasq.conf.sta $CONFIGFILE 62 | fi 63 | 64 | rm -f /tmp/resolv.conf 65 | [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && { 66 | echo "search $DOMAIN" >> /tmp/resolv.conf 67 | } 68 | DNS_SERVERS="$DNS_SERVERS 127.0.0.1" 69 | for DNS_SERVER in $DNS_SERVERS ; do 70 | echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf 71 | done 72 | } 73 | 74 | reload_service() { 75 | rc_procd start_service "$@" 76 | return 0 77 | } 78 | 79 | stop_service() { 80 | [ -f /tmp/resolv.conf ] && { 81 | rm -f /tmp/resolv.conf 82 | ln -s /tmp/resolv.conf.auto /tmp/resolv.conf 83 | } 84 | rm -f /var/run/dnsmasq.*.dhcp 85 | } 86 | -------------------------------------------------------------------------------- /ubus/mibt.txt: -------------------------------------------------------------------------------- 1 | 'mibt' @da0813b2 2 | "wakeup_tv":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 3 | "connect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 4 | "connect_and_play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 5 | "lock":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 6 | "status":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 7 | "unpair":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 8 | "ble":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 9 | "enable":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 10 | "disconnect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 11 | "volume":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 12 | "volume_action":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 13 | "play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 14 | "switch_role":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 15 | "scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 16 | "get_scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 17 | "display_conn":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 18 | "debug":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 19 | -------------------------------------------------------------------------------- /ssh/etc/init.d/alarm: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=70 4 | 5 | USE_PROCD=1 6 | EXTRA_COMMANDS="micmute_remove sync" 7 | 8 | alarm_log() { 9 | logger -t /etc/init.d/alarm[$$] -p 3 "$*" 10 | echo $* 11 | } 12 | 13 | ubus_to_file() 14 | { 15 | source /usr/share/libubox/jshn.sh 16 | result=$(ubus call workday get_config {\"name\":\"$1\"}) 17 | [ x"$result" == x"" ] && { 18 | alarm_log "config get $1 error, return 1" 19 | return 1; 20 | } 21 | 22 | json_init 23 | json_load "$result" 24 | json_get_var data_string data 25 | json_cleanup 26 | alarm_log "data string: "$data_string 27 | [ x"$data_string" == x"" ] && { 28 | alarm_log "config get $1 empty, return 1" 29 | return 1; 30 | } 31 | 32 | rm -rf $2 33 | for one_day in $data_string 34 | do 35 | echo $one_day >> $2 36 | done 37 | alarm_log "create file $2 success." 38 | } 39 | 40 | ORI_DIR="/etc/workday/" 41 | DEST_DIR="/data/workday/" 42 | FILE_HOLIDAY="unnomal_holiday.cfg" 43 | FILE_WORKDAY="unnomal_workday.cfg" 44 | country=$(uci -c /data/etc/ get binfo.binfo.country) 45 | file_ext="."$country 46 | [ "$country" == "CN" ] && { 47 | alarm_log "country is CN" 48 | file_ext="" 49 | } 50 | 51 | sync_holiday() 52 | { 53 | rm -rf /tmp/$FILE_HOLIDAY 54 | rm -rf /tmp/$FILE_WORKDAY 55 | [ x"$file_ext" != x"" ] && { 56 | alarm_log "try get code $country" 57 | ubus_to_file $FILE_HOLIDAY$file_ext /tmp/$FILE_HOLIDAY 58 | ubus_to_file $FILE_WORKDAY$file_ext /tmp/$FILE_WORKDAY 59 | } 60 | 61 | [ ! -f /tmp/$FILE_HOLIDAY -o ! -f /tmp/$FILE_WORKDAY ] && { 62 | alarm_log "get default config CN" 63 | ubus_to_file $FILE_HOLIDAY /tmp/$FILE_HOLIDAY 64 | ubus_to_file $FILE_WORKDAY /tmp/$FILE_WORKDAY 65 | } 66 | 67 | [ ! -f /tmp/$FILE_HOLIDAY -o ! -f /tmp/$FILE_WORKDAY ] && { 68 | alarm_log "get default config fail, return" 69 | rm -rf /tmp/$FILE_HOLIDAY 70 | rm -rf /tmp/$FILE_WORKDAY 71 | return 1 72 | } 73 | 74 | rm -rf $DEST_DIR/$FILE_HOLIDAY 75 | rm -rf $DEST_DIR/$FILE_WORKDAY 76 | mv /tmp/$FILE_HOLIDAY $DEST_DIR/$FILE_HOLIDAY 77 | mv /tmp/$FILE_WORKDAY $DEST_DIR/$FILE_WORKDAY 78 | 79 | return 0 80 | } 81 | 82 | sync() 83 | { 84 | restart 85 | } 86 | 87 | country_prepare() 88 | { 89 | [ ! -f $ORI_DIR$FILE_HOLIDAY$file_ext -o ! -f $ORI_DIR$FILE_WORKDAY$file_ext ] && { 90 | alarm_log "file not exist, country $country" 91 | file_ext="" 92 | } 93 | 94 | alarm_log "final file ext $file_ext, country $country" 95 | ln -s -f $ORI_DIR/$FILE_HOLIDAY$file_ext $DEST_DIR/$FILE_HOLIDAY 96 | ln -s -f $ORI_DIR/$FILE_WORKDAY$file_ext $DEST_DIR/$FILE_WORKDAY 97 | /bin/sync 98 | } 99 | 100 | start_service() 101 | { 102 | /usr/bin/alarm_translate.sh 103 | rm -rf $DEST_DIR 104 | mkdir -p $DEST_DIR 105 | 106 | country_prepare 107 | 108 | sync_holiday 109 | 110 | /bin/sync 111 | 112 | procd_open_instance 113 | procd_set_param command /usr/bin/alarmd 114 | 115 | procd_set_param respawn 3600 5 0 116 | procd_close_instance 117 | } 118 | 119 | 120 | -------------------------------------------------------------------------------- /server/echo/main.go: -------------------------------------------------------------------------------- 1 | package echo 2 | 3 | import ( 4 | "fmt" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net" 8 | "regexp" 9 | "strings" 10 | "errors" 11 | . "../http1" 12 | ) 13 | 14 | type Echo struct { 15 | Args Args `json:"args"` 16 | Headers Headers `json:"headers"` 17 | Origin string `json:"origin"` 18 | URL string `json:"url"` 19 | } 20 | type Args map[string]interface{} 21 | type Headers struct { 22 | Accept string `json:"Accept"` 23 | Host string `json:"Host"` 24 | UserAgent string `json:"User-Agent"` 25 | XAmznTraceID string `json:"X-Amzn-Trace-Id"` 26 | } 27 | func Unmarshal(data []byte) (Echo, error) { 28 | var r Echo 29 | err := json.Unmarshal(data, &r) 30 | return r, err 31 | } 32 | 33 | func (r *Echo) Marshal() ([]byte, error) { 34 | return json.Marshal(r) 35 | } 36 | 37 | func Whoami() (Echo,error){ 38 | var echo Echo 39 | u:="https://httpbin.org/get" 40 | d:=map[string]interface{}{ 41 | 42 | } 43 | r,_:=Get(u,d) 44 | fmt.Println(r.Status) 45 | if r.StatusCode != 200 { 46 | return echo, errors.New("network error") 47 | } 48 | // defer r.Body.Close() 49 | b, err := ioutil.ReadAll(r.Body) 50 | if err != nil { 51 | fmt.Println("ZZZZZZ") 52 | return echo,err 53 | } 54 | echo, err = Unmarshal(b) 55 | if err != nil { 56 | fmt.Println("ZZZZZZ") 57 | return echo,err 58 | } 59 | //fmt.Println(echo.Origin) 60 | return echo,nil 61 | } 62 | 63 | func GetLocalIP1()(string,error){ 64 | ip:="" 65 | conn, err := net.Dial("udp", "www.google.com.hk:80") 66 | if err != nil { 67 | fmt.Println(err.Error()) 68 | return ip,err 69 | } 70 | defer conn.Close() 71 | ip_port:=conn.LocalAddr().String() 72 | ip=strings.Split(ip_port, ":")[0] 73 | //fmt.Println(ip) 74 | return ip,nil 75 | } 76 | 77 | func GetLocalIP() (map[string]string){ 78 | var result map[string]string 79 | result = make(map[string]string) 80 | ifaces, err := net.Interfaces() 81 | 82 | if err!=nil { 83 | fmt.Println(err) 84 | } 85 | //fmt.Println(ifaces) 86 | //{3 1500 wlp2s0 9a:ab:a3:2b:d5:77 up|broadcast|multicast} 87 | for _, iface := range ifaces { 88 | re,_:=regexp.Compile("docker|hassio|veth") 89 | is_v:=re.MatchString(iface.Name) 90 | 91 | if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 || is_v{ 92 | continue 93 | } 94 | addrs, err := iface.Addrs() 95 | if err!=nil { 96 | fmt.Println(err) 97 | } 98 | //fmt.Println("1111",addrs) 99 | for _,addr :=range addrs{ 100 | addr1:=strings.SplitN(addr.String(), "/", 2)[0] 101 | //fmt.Println(iface.Name,addr1) 102 | result[iface.Name]=addr1 103 | } 104 | } 105 | return result 106 | } 107 | 108 | 109 | func Test(d []byte) { 110 | r, _ := Unmarshal(d) 111 | bytes, _ := r.Marshal() 112 | fmt.Println(bytes) 113 | } 114 | 115 | 116 | func Test1(){ 117 | echo,err:=Whoami() 118 | if err!=nil { 119 | 120 | } 121 | ip:=echo.Origin 122 | fmt.Println(ip) 123 | 124 | } 125 | 126 | func Test2(){ 127 | ip:=GetLocalIP() 128 | fmt.Println(ip) 129 | 130 | ip1,_:=GetLocalIP1() 131 | fmt.Println(ip1) 132 | } 133 | 134 | func Main() { 135 | Test1() 136 | Test2() 137 | } 138 | -------------------------------------------------------------------------------- /ssh/etc/init.d/check_mac: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | START=13 3 | 4 | USE_PROCD=1 5 | 6 | warn_log() 7 | { 8 | echo "check_mac $*" 9 | logger -t check_mac -p 3 "$*" 10 | } 11 | 12 | start_service() { 13 | LAST_CONFIG_FILE=/tmp/mibt_config.json-old 14 | 15 | if [ ! -d /data/wifi ]; then 16 | echo Create /data/wifi folder ... 17 | /bin/mkdir /data/wifi 18 | /bin/chmod 777 /data/wifi 19 | fi 20 | if [ ! -d /data/bt ]; then 21 | echo Create /data/bt folder ... 22 | /bin/mkdir /data/bt 23 | /bin/chmod 777 /data/bt 24 | fi 25 | if [ ! -f /data/wifi/nvram.txt ]; then 26 | cp /etc/wifi/nvram.txt /data/wifi 27 | cp /etc/wifi/config.txt /data/wifi 28 | fi 29 | if [ ! -f /data/bt/bt_config.xml ]; then 30 | cp /etc/bt/bt_config.xml /data/bt 31 | fi 32 | if [ ! -f /data/bt/mibt_config.json ]; then 33 | cp /etc/bt/mibt_config.json /data/bt 34 | else 35 | mv /data/bt/mibt_config.json $LAST_CONFIG_FILE 36 | cp /etc/bt/mibt_config.json /data/bt 37 | fi 38 | if ! grep -Fq macaddr /data/wifi/nvram.txt 39 | then 40 | cp /etc/wifi/nvram.txt /data/wifi/nvram.txt 41 | cp /etc/wifi/config.txt /data/wifi/config.txt 42 | fi 43 | if ! grep -Fq bd_addr /data/bt/bt_config.xml 44 | then 45 | cp /etc/bt/bt_config.xml /data/bt/bt_config.xml 46 | fi 47 | 48 | KEYPATH=/sys/class/unifykeys 49 | echo "mac_wifi" > $KEYPATH/name 50 | mac_wifi=`cat $KEYPATH/read` 51 | str=`cat /data/wifi/nvram.txt |grep macaddr` 52 | old=`echo ${str#*=}` 53 | if [ "$mac_wifi" != "$old" ]; then 54 | /bin/config_update.sh /data/wifi/nvram.txt macaddr=$mac_wifi 55 | else 56 | echo NOT need modify WiFi MAC. 57 | fi 58 | 59 | echo "mac_bt" > $KEYPATH/name 60 | mac_bt=`cat $KEYPATH/read` 61 | str1=`cat /data/bt/bt_config.xml |grep bd_addr` 62 | str2=`echo ${str1#*>}` 63 | oldmac=`echo ${str2%:*}` 64 | if [ "$mac_bt" != "$oldmac" ]; then 65 | sed -i "s|.*|$mac_bt:|" /data/bt/bt_config.xml 66 | else 67 | echo NOT need modify BT MAC. 68 | fi 69 | 70 | CONFIGNAMETMP="mibt_config.json.tmp" 71 | SOUNDBOXNAME="小米AI音箱" 72 | BTCONFIGFILE="/data/bt/mibt_config.json" 73 | 74 | oldmac=`cat $BTCONFIGFILE|grep bd_addr | awk -F "[\"\"]" '{print $4}'` 75 | poststr=`echo ${mac_wifi} | awk -F "[\:]" '{print $5$6}'` 76 | oldname=`cat $BTCONFIGFILE|grep bd_name | awk -F "[\"\"]" '{print $4}'` 77 | sn=`getmac.sh sn` 78 | discoverable=`cat $LAST_CONFIG_FILE | grep discoverable | awk -F "[\"]" '{print $4}'` 79 | connectable=`cat $LAST_CONFIG_FILE | grep connectable | awk -F "[\"]" '{print $4}'` 80 | sn_poststr=${sn:$((${#sn}-4))} 81 | if [ "$sn_poststr" == "" ]; then 82 | sn_poststr="0001" 83 | fi 84 | if [ "${mac_bt}" != "$oldmac" -o "$oldname" != "${SOUNDBOXNAME}-${sn_poststr}" ]; then 85 | cp -f $BTCONFIGFILE /tmp/${CONFIGNAMETMP} 86 | sed -i "s|bd_addr.*|bd_addr\": \"${mac_bt}\",|" /tmp/${CONFIGNAMETMP} 87 | sed -i "s|bd_name.*|bd_name\": \"${SOUNDBOXNAME}-${sn_poststr}\",|" /tmp/${CONFIGNAMETMP} 88 | sed -i "s|discoverable.*|discoverable\": \"${discoverable}\",|" /tmp/${CONFIGNAMETMP} 89 | sed -i "s|connectable.*|connectable\": \"${connectable}\",|" /tmp/${CONFIGNAMETMP} 90 | #修复部分配置出错的设备z 91 | sed -i "s|bt_name.*|bd_name\": \"${SOUNDBOXNAME}-${sn_poststr}\",|" /tmp/${CONFIGNAMETMP} 92 | cp -f /tmp/${CONFIGNAMETMP} $BTCONFIGFILE 93 | rm -rf $LAST_CONFIG_FILE 94 | echo "Modify BT MAC(JSON):${mac_bt}" 95 | echo "Modify BT NAME(JSON):${SOUNDBOXNAME}-${sn_poststr}" 96 | sync 97 | else 98 | echo "NOT need modify BT MAC(JSON)." 99 | fi 100 | 101 | } 102 | -------------------------------------------------------------------------------- /ssh/etc/init.d/network: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=20 4 | STOP=90 5 | 6 | USE_PROCD=1 7 | 8 | init_switch() { 9 | setup_switch() { return 0; } 10 | 11 | include /lib/network 12 | setup_switch 13 | } 14 | 15 | start_service() { 16 | init_switch 17 | 18 | procd_open_instance 19 | procd_set_param command /sbin/netifd 20 | procd_set_param respawn 21 | procd_set_param watch network.interface 22 | [ -e /proc/sys/kernel/core_pattern ] && { 23 | procd_set_param limits core="unlimited" 24 | echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern 25 | } 26 | procd_close_instance 27 | } 28 | 29 | reload_service() { 30 | init_switch 31 | ubus call network reload 32 | /sbin/wifi reload_legacy 33 | } 34 | 35 | stop() { 36 | /sbin/wifi down 37 | procd_kill network '' 38 | } 39 | 40 | service_running() { 41 | ubus -t 30 wait_for network.interface 42 | /sbin/wifi reload_legacy 43 | } 44 | 45 | validate_atm_bridge_section() 46 | { 47 | uci_validate_section network "atm-bridge" "${1}" \ 48 | 'unit:uinteger:0' \ 49 | 'vci:range(32, 65535):35' \ 50 | 'vpi:range(0, 255):8' \ 51 | 'atmdev:uinteger:0' \ 52 | 'encaps:or("llc", "vc"):llc' \ 53 | 'payload:or("bridged", "routed"):bridged' 54 | } 55 | 56 | validate_route_section() 57 | { 58 | uci_validate_section network route "${1}" \ 59 | 'interface:string' \ 60 | 'target:cidr4' \ 61 | 'netmask:netmask4' \ 62 | 'gateway:ip4addr' \ 63 | 'metric:uinteger' \ 64 | 'mtu:uinteger' \ 65 | 'table:or(range(0,65535),string)' 66 | } 67 | 68 | validate_route6_section() 69 | { 70 | uci_validate_section network route6 "${1}" \ 71 | 'interface:string' \ 72 | 'target:cidr6' \ 73 | 'gateway:ip6addr' \ 74 | 'metric:uinteger' \ 75 | 'mtu:uinteger' \ 76 | 'table:or(range(0,65535),string)' 77 | } 78 | 79 | validate_rule_section() 80 | { 81 | uci_validate_section network rule "${1}" \ 82 | 'in:string' \ 83 | 'out:string' \ 84 | 'src:cidr4' \ 85 | 'dest:cidr4' \ 86 | 'tos:range(0,31)' \ 87 | 'mark:string' \ 88 | 'invert:bool' \ 89 | 'lookup:or(range(0,65535),string)' \ 90 | 'goto:range(0,65535)' \ 91 | 'action:or("prohibit", "unreachable", "blackhole", "throw")' 92 | } 93 | 94 | validate_rule6_section() 95 | { 96 | uci_validate_section network rule6 "${1}" \ 97 | 'in:string' \ 98 | 'out:string' \ 99 | 'src:cidr6' \ 100 | 'dest:cidr6' \ 101 | 'tos:range(0,31)' \ 102 | 'mark:string' \ 103 | 'invert:bool' \ 104 | 'lookup:or(range(0,65535),string)' \ 105 | 'goto:range(0,65535)' \ 106 | 'action:or("prohibit", "unreachable", "blackhole", "throw")' 107 | } 108 | 109 | validate_switch_section() 110 | { 111 | uci_validate_section network switch "${1}" \ 112 | 'name:string' \ 113 | 'enable:bool' \ 114 | 'enable_vlan:bool' \ 115 | 'reset:bool' 116 | } 117 | 118 | validate_switch_vlan() 119 | { 120 | uci_validate_section network switch_vlan "${1}" \ 121 | 'device:string' \ 122 | 'vlan:uinteger' \ 123 | 'ports:list(ports)' 124 | } 125 | 126 | service_triggers() 127 | { 128 | procd_add_reload_trigger network wireless 129 | 130 | procd_open_validate 131 | validate_atm_bridge_section 132 | validate_route_section 133 | validate_route6_section 134 | validate_rule_section 135 | validate_rule6_section 136 | validate_switch_section 137 | validate_switch_vlan 138 | procd_close_validate 139 | } 140 | 141 | restart() { 142 | ifdown -a 143 | sleep 1 144 | trap '' TERM 145 | stop "$@" 146 | start "$@" 147 | } 148 | 149 | shutdown() { 150 | ifdown -a 151 | sleep 1 152 | } 153 | -------------------------------------------------------------------------------- /server/http1/main.go: -------------------------------------------------------------------------------- 1 | package http1 2 | 3 | import ( 4 | //"crypto/hmac" 5 | //"crypto/sha1" 6 | //"crypto/sha256" 7 | //"strconv" 8 | //"encoding/base64" 9 | // iconv "github.com/djimenez/iconv-go" 10 | // "golang.org/x/text/encoding" 11 | //"sort" 12 | "math/rand" 13 | "strings" 14 | "time" 15 | //"os" 16 | "encoding/json" 17 | //"log" 18 | "net/url" 19 | "fmt" 20 | //"math" 21 | "bufio" 22 | "io" 23 | //"io/ioutil" 24 | "net/http" 25 | "golang.org/x/net/html/charset" 26 | "golang.org/x/text/encoding/htmlindex" 27 | ) 28 | 29 | var ( 30 | HEADERS=map[string]string{ 31 | "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0", 32 | "Accept": "application/json, text/plain, */*", 33 | "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", 34 | "DNT": "1", 35 | "Pragma": "no-cache", 36 | "Cache-Control": "no-cache", 37 | "Sec-Fetch-Dest":"empty", 38 | "Sec-Fetch-Mode":"cors", 39 | "Sec-Fetch-Site":"same-origin", 40 | //"Host": "api.weibo.com", 41 | // "Referer": "https://api.weibo.com/chat/", 42 | //"Cookie":"", 43 | //"Accept-Encoding": "gzip, deflate, br", 44 | } 45 | ) 46 | 47 | 48 | 49 | func GetHeaders(u string) map[string]string{ 50 | var h=map[string]string{} 51 | for k,v:=range HEADERS{ 52 | h[k]=v 53 | } 54 | h["Referer"]=u 55 | //h["Host"]="" 56 | //h["Cookie"]=config.Cookie 57 | //fmt.Println("zzzzzzzz",h) 58 | return h 59 | } 60 | 61 | 62 | func To_qs(u string,o map[string]string) string{ 63 | Url, _ := url.Parse(u) 64 | p:=url.Values{} 65 | for k, v := range o{ 66 | p.Add(k,v) 67 | } 68 | Url.RawQuery = p.Encode() 69 | return Url.String() 70 | } 71 | 72 | func To_qs1(o map[string]string) string{ 73 | p:=url.Values{} 74 | for k, v := range o{ 75 | p.Add(k,v) 76 | } 77 | return p.Encode() 78 | } 79 | 80 | 81 | func Random() string{ 82 | rand.Seed(time.Now().UnixNano()) 83 | return fmt.Sprintf("%v", rand.Intn(254)) 84 | } 85 | 86 | func Pick(s []string) string{ 87 | rand.Seed(time.Now().UnixNano()) 88 | l:=len(s) 89 | n:=rand.Intn(l) 90 | return s[n] 91 | } 92 | 93 | func Ip() string{ 94 | z:=[]string{} 95 | for i:=0;i<4;i++{ 96 | t:=Random() 97 | z=append(z,t) 98 | } 99 | return strings.Join(z , ".") 100 | } 101 | 102 | 103 | func Now() string{ 104 | return fmt.Sprintf("%v", time.Now().UnixNano()/1e6) 105 | } 106 | 107 | 108 | func To_json(d map[string]string) string{ 109 | m,_:=json.Marshal(d) 110 | return string(m) 111 | } 112 | 113 | 114 | func detectContentCharset(body io.Reader) string { 115 | r := bufio.NewReader(body) 116 | if data, err := r.Peek(1024); err == nil { 117 | if _, name, ok := charset.DetermineEncoding(data, ""); ok { 118 | return name 119 | } 120 | } 121 | return "utf-8" 122 | } 123 | 124 | func DecodeHTMLBody(body io.Reader, charset string) (io.Reader, error) { 125 | if charset == "" { 126 | charset = detectContentCharset(body) 127 | } 128 | e, err := htmlindex.Get(charset) 129 | if err != nil { 130 | return nil, err 131 | } 132 | if name, _ := htmlindex.Name(e); name != "utf-8" { 133 | body = e.NewDecoder().Reader(body) 134 | } 135 | return body, nil 136 | } 137 | 138 | 139 | 140 | 141 | 142 | func Get (u string,d map[string]interface{}) (*http.Response,error){ 143 | client := http.Client{} 144 | p:=url.Values{} 145 | for k, v := range d{ 146 | p.Add(fmt.Sprintf("%v", k), fmt.Sprintf("%v", v)) 147 | } 148 | qs:=p.Encode() 149 | u1:=u+"?"+qs 150 | fmt.Println("get",u1) 151 | req, _ := http.NewRequest("GET", u1,nil) 152 | h:=GetHeaders(u1) 153 | for k,v := range h{ 154 | req.Header.Add(k, v) 155 | } 156 | //fmt.Println("hhhhhhhhh",h) 157 | return client.Do(req) 158 | } 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /ssh/etc/ssh/sshd_config: -------------------------------------------------------------------------------- 1 | # $OpenBSD: sshd_config,v 1.97 2015/08/06 14:53:21 deraadt Exp $ 2 | 3 | # This is the sshd server system-wide configuration file. See 4 | # sshd_config(5) for more information. 5 | 6 | # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin 7 | 8 | # The strategy used for options in the default sshd_config shipped with 9 | # OpenSSH is to specify options with their default value where 10 | # possible, but leave them commented. Uncommented options override the 11 | # default value. 12 | 13 | Port 2222 14 | AddressFamily any 15 | ListenAddress 0.0.0.0 16 | ListenAddress :: 17 | 18 | # The default requires explicit activation of protocol 1 19 | #Protocol 2 20 | 21 | # HostKey for protocol version 1 22 | #HostKey /etc/ssh/ssh_host_key 23 | # HostKeys for protocol version 2 24 | HostKey /etc/ssh/ssh_host_rsa_key 25 | HostKey /etc/ssh/ssh_host_dsa_key 26 | HostKey /etc/ssh/ssh_host_ecdsa_key 27 | HostKey /etc/ssh/ssh_host_ed25519_key 28 | 29 | # Lifetime and size of ephemeral version 1 server key 30 | #KeyRegenerationInterval 1h 31 | #ServerKeyBits 1024 32 | 33 | # Ciphers and keying 34 | #RekeyLimit default none 35 | 36 | # Logging 37 | # obsoletes QuietMode and FascistLogging 38 | #SyslogFacility AUTH 39 | #LogLevel INFO 40 | 41 | # Authentication: 42 | 43 | LoginGraceTime 2m 44 | PermitRootLogin yes #prohibit-password 45 | StrictModes no 46 | MaxAuthTries 6 47 | MaxSessions 10 48 | 49 | #RSAAuthentication yes 50 | #PubkeyAuthentication yes 51 | 52 | # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 53 | # but this is overridden so installations will only check .ssh/authorized_keys 54 | AuthorizedKeysFile .ssh/authorized_keys 55 | 56 | #AuthorizedPrincipalsFile none 57 | 58 | #AuthorizedKeysCommand none 59 | #AuthorizedKeysCommandUser nobody 60 | 61 | # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts 62 | #RhostsRSAAuthentication no 63 | # similar for protocol version 2 64 | #HostbasedAuthentication no 65 | # Change to yes if you don't trust ~/.ssh/known_hosts for 66 | # RhostsRSAAuthentication and HostbasedAuthentication 67 | #IgnoreUserKnownHosts no 68 | # Don't read the user's ~/.rhosts and ~/.shosts files 69 | #IgnoreRhosts yes 70 | 71 | # To disable tunneled clear text passwords, change to no here! 72 | PasswordAuthentication yes 73 | PermitEmptyPasswords yes 74 | 75 | # Change to no to disable s/key passwords 76 | #ChallengeResponseAuthentication yes 77 | 78 | # Kerberos options 79 | #KerberosAuthentication no 80 | #KerberosOrLocalPasswd yes 81 | #KerberosTicketCleanup yes 82 | #KerberosGetAFSToken no 83 | 84 | # GSSAPI options 85 | #GSSAPIAuthentication no 86 | #GSSAPICleanupCredentials yes 87 | 88 | # Set this to 'yes' to enable PAM authentication, account processing, 89 | # and session processing. If this is enabled, PAM authentication will 90 | # be allowed through the ChallengeResponseAuthentication and 91 | # PasswordAuthentication. Depending on your PAM configuration, 92 | # PAM authentication via ChallengeResponseAuthentication may bypass 93 | # the setting of "PermitRootLogin without-password". 94 | # If you just want the PAM account and session checks to run without 95 | # PAM authentication, then enable this but set PasswordAuthentication 96 | # and ChallengeResponseAuthentication to 'no'. 97 | #UsePAM no 98 | 99 | AllowAgentForwarding yes 100 | AllowTcpForwarding yes 101 | GatewayPorts yes 102 | X11Forwarding yes 103 | #X11DisplayOffset 10 104 | #X11UseLocalhost yes 105 | PermitTTY yes 106 | PrintMotd yes 107 | PrintLastLog yes 108 | TCPKeepAlive yes 109 | #UseLogin no 110 | UsePrivilegeSeparation sandbox # Default for new installations. 111 | #PermitUserEnvironment no 112 | #Compression delayed 113 | #ClientAliveInterval 0 114 | #ClientAliveCountMax 3 115 | #UseDNS no 116 | #PidFile /var/run/sshd.pid 117 | #MaxStartups 10:30:100 118 | #PermitTunnel no 119 | #ChrootDirectory none 120 | #VersionAddendum none 121 | 122 | # no default banner path 123 | #Banner none 124 | 125 | # enable DSCP QoS values (per RFC-4594) 126 | #IPQoS AF21 AF11 127 | 128 | # override default of no subsystems 129 | Subsystem sftp /usr/lib/sftp-server 130 | 131 | # Example of overriding settings on a per-user basis 132 | #Match User anoncvs 133 | # X11Forwarding no 134 | # AllowTcpForwarding no 135 | # PermitTTY no 136 | # ForceCommand cvs server 137 | -------------------------------------------------------------------------------- /ssh/readme.md: -------------------------------------------------------------------------------- 1 | ### dropbear 2 | 3 | 4 | ```bash 5 | 6 | dropbear -h 7 | Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html 8 | Usage: dropbear [options] 9 | -b bannerfile Display the contents of bannerfile before user login 10 | (default: none) 11 | -r keyfile Specify hostkeys (repeatable) 12 | defaults: 13 | dss /etc/dropbear/dropbear_dss_host_key 14 | rsa /etc/dropbear/dropbear_rsa_host_key 15 | -R Create hostkeys as required 16 | -F Don't fork into background 17 | -E Log to stderr rather than syslog 18 | -w Disallow root logins 19 | -s Disable password logins 20 | -g Disable password logins for root 21 | -B Allow blank password logins #!!! 22 | -j Disable local port forwarding 23 | -k Disable remote port forwarding 24 | -a Allow connections to forwarded ports from any host 25 | -p [address:]port 26 | Listen on specified tcp port (and optionally address), 27 | up to 10 can be specified 28 | (default port is 22 if none specified) 29 | -P PidFile Create pid file PidFile 30 | (default /var/run/dropbear.pid) 31 | -W (default 24576, larger may be faster, max 1MB) 32 | -K (0 is never, default 0, in seconds) 33 | -I (0 is never, default 0, in seconds) 34 | -V Version 35 | 36 | ``` 37 | 38 | 39 | ```bash 40 | 41 | cd /etc/dropbear 42 | rm * 43 | for i in rsa dss ecdsa ed25519 do 44 | dropbearkey -t ${i} -f dropbear_${i}_host_key 1>>authorized_keys 45 | done 46 | sed -i '/:/d' authorized_keys 47 | chmod 600 * 48 | 49 | mkdir openssh 50 | for i in `ls *key` 51 | do 52 | dropbearconvert dropbear openssh $i openssh/$i 53 | done 54 | 55 | 56 | #dropbear -p 33 -B 57 | #ssh root@192.168.0.106 -i dropbear_rsa_host_key -p 33 58 | #ssh root@192.168.0.106 -p 33 59 | 60 | #/etc/init.d/dropbear enable 61 | #/etc/init.d/dropbear start 62 | 63 | ################################################################################ 64 | #vi /etc/init.d/dropbear1 65 | #!/bin/sh /etc/rc.common 66 | 67 | START=50 68 | STOP=50 69 | USE_PROCD=1 70 | PROG=/usr/sbin/dropbear 71 | NAME=dropbear1 72 | PIDCOUNT=0 73 | 74 | start_service() { 75 | /bin/busybox passwd root -d 76 | procd_open_instance 77 | procd_set_param command $PROG -B -r /etc/dropbear/dropbear_rsa_host_key 78 | procd_close_instance 79 | } 80 | 81 | shutdown() { 82 | stop 83 | /usr/bin/killall dropbear 84 | } 85 | 86 | ################################################################################ 87 | 88 | 89 | 90 | chmod 777 /etc/init.d/dropbear1 91 | /etc/init.d/dropbear1 start 92 | ps |grep drop 93 | 13245 root 2268 S /usr/sbin/dropbear -B -r /etc/dropbear/dropbear_rsa_host_key 94 | 95 | ssh root@192.168.0.106 -i dropbear_rsa_host_key 96 | 97 | ``` 98 | 99 | 100 | ### openssh 101 | 102 | 103 | 104 | ```bash 105 | 106 | wget https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/openssh-keygen_7.1p2-1_arm64.ipk 107 | tar xzvf openssh-keygen_7.1p2-1_arm64.ipk 108 | tar xzvf data.tar.gz -C / 109 | 110 | wget https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/openssh-server_7.1p2-1_arm64.ipk 111 | #opkg install openssh-server_7.1p2-1_arm64.ipk 112 | tar xzvf openssh-server_7.1p2-1_arm64.ipk 113 | ./debian-binary 114 | ./data.tar.gz 115 | ./control.tar.gz 116 | 117 | tar xzvf data.tar.gz -C / 118 | 119 | /usr/sbin/sshd 120 | /etc/ssh/sshd_config 121 | /etc/init.d/sshd 122 | 123 | 124 | /usr/sbin/sshd 125 | Privilege separation user sshd does not exist 126 | 127 | 在/etc/passwd 中加入: 128 | sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin 129 | mkdir -p /var/empty/sshd 130 | 131 | 132 | 133 | cd /etc/ssh/ 134 | for type in rsa dsa ecdsa ed25519 135 | do 136 | key=/etc/ssh/ssh_host_${type}_key 137 | echo $type $key 138 | ssh-keygen -N '' -t $type -f $key 2>&- >&- 139 | done 140 | 141 | chmod 600 /etc/ssh/*_key 142 | /etc/ssh/sshd_config 143 | 144 | 145 | Port 2222 146 | AddressFamily any 147 | ListenAddress 0.0.0.0 148 | ListenAddress :: 149 | 150 | HostKey /etc/ssh/ssh_host_rsa_key 151 | HostKey /etc/ssh/ssh_host_dsa_key 152 | HostKey /etc/ssh/ssh_host_ecdsa_key 153 | HostKey /etc/ssh/ssh_host_ed25519_key 154 | 155 | PasswordAuthentication yes 156 | PermitEmptyPasswords yes 157 | 158 | 159 | mkdir ~/.ssh 160 | cat /etc/ssh/*.pub > ~/.ssh/authorized_keys 161 | /etc/init.d/sshd enable 162 | /etc/init.d/sshd start 163 | #/usr/sbin/sshd 164 | 165 | #copy ssh_host_rsa_key to pc 166 | ssh 192.168.0.106 -i ssh_host_rsa_key -p 2222 167 | ``` 168 | 169 | -------------------------------------------------------------------------------- /ssh/etc/init.d/dropbear: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2010 OpenWrt.org 3 | # Copyright (C) 2006 Carlos Sobrinho 4 | 5 | START=50 6 | STOP=50 7 | 8 | USE_PROCD=1 9 | PROG=/usr/sbin/dropbear 10 | NAME=dropbear 11 | PIDCOUNT=0 12 | EXTRA_COMMANDS="killclients" 13 | EXTRA_HELP=" killclients Kill ${NAME} processes except servers and yourself" 14 | 15 | append_ports() 16 | { 17 | local ipaddrs="$1" 18 | local port="$2" 19 | 20 | [ -z "$ipaddrs" ] && { 21 | procd_append_param command -p "$port" 22 | return 23 | } 24 | 25 | for addr in $ipaddrs; do 26 | procd_append_param command -p "$addr:$port" 27 | done 28 | } 29 | 30 | validate_section_dropbear() 31 | { 32 | uci_validate_section dropbear dropbear "${1}" \ 33 | 'PasswordAuth:bool:0' \ 34 | 'enable:bool:1' \ 35 | 'Interface:string' \ 36 | 'GatewayPorts:bool:0' \ 37 | 'RootPasswordAuth:bool:0' \ 38 | 'RootLogin:bool:1' \ 39 | 'rsakeyfile:file' \ 40 | 'dsskeyfile:file' \ 41 | 'BannerFile:file' \ 42 | 'Port:list(port):22' \ 43 | 'SSHKeepAlive:uinteger:300' \ 44 | 'IdleTimeout:uinteger:0' \ 45 | 'mdns:uinteger:1' 46 | } 47 | 48 | dropbear_instance() 49 | { 50 | local PasswordAuth enable Interface GatewayPorts \ 51 | RootPasswordAuth RootLogin rsakeyfile \ 52 | dsskeyfile BannerFile Port SSHKeepAlive IdleTimeout \ 53 | mdns ipaddrs 54 | 55 | validate_section_dropbear "${1}" || { 56 | echo "validation failed" 57 | return 1 58 | } 59 | 60 | [ -n "${Interface}" ] && { 61 | network_get_ipaddrs_all ipaddrs "${Interface}" || { 62 | echo "interface ${Interface} has no physdev or physdev has no suitable ip" 63 | return 1 64 | } 65 | } 66 | 67 | [ "${enable}" = "0" ] && return 1 68 | PIDCOUNT="$(( ${PIDCOUNT} + 1))" 69 | local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid" 70 | 71 | procd_open_instance 72 | procd_set_param command "$PROG" -F -P "$pid_file" 73 | [ "${PasswordAuth}" -eq 0 ] && procd_append_param command -s 74 | [ "${GatewayPorts}" -eq 1 ] && procd_append_param command -a 75 | [ "${RootPasswordAuth}" -eq 0 ] && procd_append_param command -g 76 | [ "${RootLogin}" -eq 0 ] && procd_append_param command -w 77 | [ -n "${rsakeyfile}" ] && procd_append_param command -r "${rsakeyfile}" 78 | [ -n "${dsskeyfile}" ] && procd_append_param command -d "${dsskeyfile}" 79 | [ -n "${BannerFile}" ] && procd_append_param command -b "${BannerFile}" 80 | append_ports "${ipaddrs}" "${Port}" 81 | [ "${IdleTimeout}" -ne 0 ] && procd_append_param command -I "${IdleTimeout}" 82 | [ "${SSHKeepAlive}" -ne 0 ] && procd_append_param command -K "${SSHKeepAlive}" 83 | [ "${mdns}" -ne 0 ] && procd_add_mdns "ssh" "tcp" "$Port" "daemon=dropbear" 84 | procd_close_instance 85 | } 86 | 87 | keygen() 88 | { 89 | for keytype in rsa dss; do 90 | # check for keys 91 | key=dropbear/dropbear_${keytype}_host_key 92 | [ -f /tmp/$key -o -s /etc/$key ] || { 93 | # generate missing keys 94 | mkdir -p /tmp/dropbear 95 | [ -x /usr/bin/dropbearkey ] && { 96 | /usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start 97 | } & 98 | exit 0 99 | } 100 | done 101 | 102 | lock /tmp/.switch2jffs 103 | mkdir -p /etc/dropbear 104 | mv /tmp/dropbear/dropbear_* /etc/dropbear/ 105 | lock -u /tmp/.switch2jffs 106 | chown root /etc/dropbear 107 | chmod 0700 /etc/dropbear 108 | } 109 | 110 | start_service() 111 | { 112 | ssh_en=`cat /tmp/ssh_en 2>/dev/null` 113 | channel=`/sbin/uci -q get /usr/share/mico/version.version.CHANNEL` 114 | if [ "$ssh_en" != "1" -a "$channel" = "release" ]; then 115 | return 0 116 | fi 117 | [ -s /etc/dropbear/authorized_keys ] && 118 | chmod 600 /etc/dropbear/authorized_keys 119 | 120 | [ -s /etc/dropbear/dropbear_rsa_host_key -a \ 121 | -s /etc/dropbear/dropbear_dss_host_key ] || keygen 122 | 123 | . /lib/functions.sh 124 | . /lib/functions/network.sh 125 | 126 | config_load "${NAME}" 127 | config_foreach dropbear_instance dropbear 128 | } 129 | 130 | service_triggers() 131 | { 132 | procd_add_reload_trigger "dropbear" 133 | procd_add_validation validate_section_dropbear 134 | } 135 | 136 | killclients() 137 | { 138 | local ignore='' 139 | local server 140 | local pid 141 | 142 | # if this script is run from inside a client session, then ignore that session 143 | pid="$$" 144 | while [ "${pid}" -ne 0 ] 145 | do 146 | # get parent process id 147 | pid=`cut -d ' ' -f 4 "/proc/${pid}/stat"` 148 | [ "${pid}" -eq 0 ] && break 149 | 150 | # check if client connection 151 | grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" && { 152 | append ignore "${pid}" 153 | break 154 | } 155 | done 156 | 157 | # get all server pids that should be ignored 158 | for server in `cat /var/run/${NAME}.*.pid` 159 | do 160 | append ignore "${server}" 161 | done 162 | 163 | # get all running pids and kill client connections 164 | local skip 165 | for pid in `pidof "${NAME}"` 166 | do 167 | # check if correct program, otherwise process next pid 168 | grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" || { 169 | continue 170 | } 171 | 172 | # check if pid should be ignored (servers, ourself) 173 | skip=0 174 | for server in ${ignore} 175 | do 176 | if [ "${pid}" = "${server}" ] 177 | then 178 | skip=1 179 | break 180 | fi 181 | done 182 | [ "${skip}" -ne 0 ] && continue 183 | 184 | # kill process 185 | echo "${initscript}: Killing ${pid}..." 186 | kill -KILL ${pid} 187 | done 188 | } 189 | -------------------------------------------------------------------------------- /ubus/all.txt: -------------------------------------------------------------------------------- 1 | #### ai_crontab 2 | 'ai_crontab' @c85e9773 3 | "new":{"personal_skill":"String"} 4 | "notify":{"src":"String","event":"String","id":"String"} 5 | "remove_all":{} 6 | "dump":{"busy":"Integer","free":"Integer"} 7 | #### alarm 8 | 'alarm' @1dedfb7b 9 | "mibrain_operation":{"mibrain":"String"} 10 | "alarm_create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 11 | "alarm_query":{"type":"String"} 12 | "alarm_delete":{"type":"String","id":"String"} 13 | "alarm_close":{"type":"String","id":"String"} 14 | "alarm_open":{"type":"String","id":"String"} 15 | "alarm_modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 16 | "create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 17 | "query":{"type":"String"} 18 | "delete":{"type":"String","id":"String"} 19 | "close":{"type":"String","id":"String"} 20 | "open":{"type":"String","id":"String"} 21 | "modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 22 | "micmute":{"hour":"Integer","minute":"Integer","second":"Integer"} 23 | "micmute_remove":{} 24 | #### dlna 25 | 'dlna' @4ce6e9ae 26 | "demo":{"mac":"String","action":"String"} 27 | "play":{"mac":"String","action":"String"} 28 | "status":{"mac":"String","action":"String"} 29 | #### led 30 | 'led' @78abec6a 31 | "show":{"L":"Integer","pos":"Integer","rgb":"String"} 32 | "shut":{"L":"Integer"} 33 | "status":{} 34 | "shut_all":{} 35 | #### mediaplayer 36 | 'mediaplayer' @749c928c 37 | "player_wakeup":{"action":"String","source":"String"} 38 | "player_play_operation":{"media":"String","action":"String"} 39 | "player_play_url":{"url":"String","type":"Integer","domain":"String","media":"String","src":"String","id":"String","duration":"Integer"} 40 | "player_get_play_status":{} 41 | "player_play_status":{} 42 | "player_play_private_fm":{} 43 | "player_get_latest_playlist":{} 44 | "player_set_positon":{"position":"Integer","media":"String"} 45 | "player_set_loop":{"type":"Integer","media":"String"} 46 | "player_play_music":{"music":"String","startOffset":"Integer","loadMoreOffset":"Integer","media":"String","src":"String","id":"String","duration":"Integer"} 47 | "player_set_volume":{"volume":"Integer","media":"String"} 48 | "player_set_continuous_volume":{"volume":"Integer","media":"String"} 49 | "player_modify_volume":{"isVolumeUp":"Integer","value":"Integer"} 50 | "player_get_context":{} 51 | "player_play_index":{"index":"Integer","media":"String"} 52 | "player_play_alarm_reminder":{"type":"Integer","reminder":"String","volume":"Integer","timeReminder":"String","query":"String"} 53 | "player_play_album_playlist":{"type":"Integer","id":"String","startOffset":"Integer","media":"String"} 54 | "media_control":{"player":"String","action":"String","volume":"Integer"} 55 | "player_set_shutdown_timer":{"action":"String","hour":"Integer","minute":"Integer","second":"Integer","media":"String"} 56 | "test":{} 57 | "get_shutdown_timer":{} 58 | "get_media_volume":{} 59 | "player_reset":{} 60 | "player_retore_last_volume":{} 61 | "set_voip_status":{"voip_status":"String"} 62 | "set_player_quiet":{"quiet":"Boolean"} 63 | "set_playrate":{"rate":"String"} 64 | "notify_mdplay_status":{"status":"Integer","type":"Integer"} 65 | "player_aux_operation":{"aux_operation":"String"} 66 | #### messagingagent 67 | 'messagingagent' @bd5bbd4f 68 | "notify":{"payload":"String"} 69 | "identify_device":{} 70 | "miot_push":{"payload":"String"} 71 | "report_events":{"payload":"String"} 72 | "add_device_log":{"mac":"String","payload":"String"} 73 | "set_kv":{"key":"String","value":"String"} 74 | "close":{} 75 | "get_pid":{} 76 | "fault":{} 77 | "sync_admin":{} 78 | "get_ai_service_token":{} 79 | #### mibrain 80 | 'mibrain' @9d7d7caa 81 | "nlp_result_get":{} 82 | "text_to_speech":{"text":"String","caller":"String","vendor":"String","codec":"String","volume":"Integer","save":"Integer","play":"Integer"} 83 | "vendor_switch":{"vendor_name":"String"} 84 | "vendor_who":{} 85 | "ai_service":{"bypass":"String","caller":"String","duration":"Integer","id":"String","asr":"Integer","nlp":"Integer","tts":"Integer","asr_audio":"String","nlp_text":"String","nlp_execute":"Integer","tts_text":"String","tts_type":"String","tts_vendor":"String","tts_volume":"Integer","tts_codec":"String","tts_save":"Integer","tts_play":"Integer"} 86 | "aivs_miio_token_update":{"token":"String","session_id":"String"} 87 | "aivs_authorization_get":{} 88 | "aivs_event_post":{"namespace":"String","name":"String","payload":"String"} 89 | "aivs_track_post":{"event":"String","dialog_id":"String","extend":"String"} 90 | "aivs_env_switch":{} 91 | "tts_vendor_switch":{"vendor_name":"String"} 92 | "tts_vendor_show":{} 93 | #### mibt 94 | 'mibt' @da0813b2 95 | "wakeup_tv":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 96 | "connect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 97 | "connect_and_play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 98 | "lock":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 99 | "status":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 100 | "unpair":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 101 | "ble":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 102 | "enable":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 103 | "disconnect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 104 | "volume":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 105 | "volume_action":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 106 | "play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 107 | "switch_role":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 108 | "scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 109 | "get_scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 110 | "display_conn":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 111 | "debug":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 112 | #### miio 113 | 'miio' @efe16487 114 | "renew":{} 115 | "register":{"ssid":"String","psk":"String","uid":"String","country":"String"} 116 | "drop":{} 117 | "token_write":{"token":"String","session_id":"String","ttl":"String"} 118 | "miio_restore_status":{} 119 | #### network 120 | 'network' @51d67f39 121 | "restart":{} 122 | "reload":{} 123 | "add_host_route":{"target":"String","v6":"Boolean","interface":"String"} 124 | "get_proto_handlers":{} 125 | "add_dynamic":{"name":"String"} 126 | #### network.device 127 | 'network.device' @6c48ce6a 128 | "status":{"name":"String"} 129 | "set_alias":{"alias":"Array","device":"String"} 130 | "set_state":{"name":"String","defer":"Boolean"} 131 | #### network.interface 132 | 'network.interface' @824adad3 133 | "up":{} 134 | "down":{} 135 | "status":{} 136 | "prepare":{} 137 | "dump":{} 138 | "add_device":{"name":"String","link-ext":"Boolean"} 139 | "remove_device":{"name":"String","link-ext":"Boolean"} 140 | "notify_proto":{} 141 | "remove":{} 142 | "set_data":{} 143 | #### network.interface.lan 144 | 'network.interface.lan' @6e4e9b86 145 | "up":{} 146 | "down":{} 147 | "status":{} 148 | "prepare":{} 149 | "dump":{} 150 | "add_device":{"name":"String","link-ext":"Boolean"} 151 | "remove_device":{"name":"String","link-ext":"Boolean"} 152 | "notify_proto":{} 153 | "remove":{} 154 | "set_data":{} 155 | #### network.interface.loopback 156 | 'network.interface.loopback' @30102251 157 | "up":{} 158 | "down":{} 159 | "status":{} 160 | "prepare":{} 161 | "dump":{} 162 | "add_device":{"name":"String","link-ext":"Boolean"} 163 | "remove_device":{"name":"String","link-ext":"Boolean"} 164 | "notify_proto":{} 165 | "remove":{} 166 | "set_data":{} 167 | #### network.wireless 168 | 'network.wireless' @01c2f7ee 169 | "up":{} 170 | "down":{} 171 | "status":{} 172 | "notify":{} 173 | "get_validate":{} 174 | #### nightmode 175 | 'nightmode' @1cb6eb2d 176 | "set":{"total":"String","light":"String","volume":"String","start":"String","stop":"String"} 177 | "status":{} 178 | "current":{} 179 | #### notify 180 | 'notify' @10d3873e 181 | "create":{"id":"String","level":"Integer","expire":"Integer","volume":"Integer","text":"String"} 182 | "query":{"id":"String"} 183 | "delete":{"id":"String"} 184 | "play":{} 185 | "stop":{} 186 | "clean":{} 187 | "status":{"level":"Integer"} 188 | "set":{"level":"Integer","enable":"Integer","autoplay":"Integer","volume":"Integer"} 189 | #### pnshelper 190 | 'pnshelper' @e56be10e 191 | "event_notify":{"src":"Integer","event":"Integer","detail":"String"} 192 | #### qplayer 193 | 'qplayer' @41f40184 194 | "play":{"play":"String","light":"Integer"} 195 | #### service 196 | 'service' @ee67d7e0 197 | "set":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 198 | "add":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 199 | "list":{"name":"String","verbose":"Boolean"} 200 | "delete":{"name":"String","instance":"String"} 201 | "signal":{"name":"String","instance":"String","signal":"Integer"} 202 | "update_start":{"name":"String"} 203 | "update_complete":{"name":"String"} 204 | "event":{"type":"String","data":"Table"} 205 | "validate":{"package":"String","type":"String","service":"String"} 206 | "get_data":{"name":"String","instance":"String","type":"String"} 207 | "state":{"spawn":"Boolean","name":"String"} 208 | #### system 209 | 'system' @5a550b2d 210 | "board":{} 211 | "info":{} 212 | "reboot":{} 213 | "watchdog":{"frequency":"Integer","timeout":"Integer","magicclose":"Boolean","stop":"Boolean"} 214 | "signal":{"pid":"Integer","signum":"Integer"} 215 | "sysupgrade":{"path":"String","prefix":"String","command":"String"} 216 | #### upnp-disc 217 | 'upnp-disc' @9d4924e5 218 | "demo":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 219 | "lookup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 220 | "select":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 221 | "wakeup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 222 | "list":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 223 | "enable":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 224 | #### voip 225 | 'voip' @bb41b65d 226 | "voip_signal_op":{"op":"Integer","uid":"String"} 227 | "action":{"vender":"String","event":"String","contact_id":"String","number":"String","name":"String","string":"String"} 228 | "cmcc_register":{"msisdn":"String","type":"String","operation":"Integer"} 229 | "cmcc_unregister":{"msisdn":"String","type":"String","operation":"Integer"} 230 | "cmcc_miscellaneous":{"msisdn":"String","type":"String","operation":"Integer"} 231 | #### volctl 232 | 'volctl' @5015c14d 233 | "setvol":{"callername":"String","softnode":"String","vol":"Integer"} 234 | "setvolfine":{"callername":"String","softnode":"String","vol":"Integer"} 235 | "getvol":{"callername":"String","softnode":"String"} 236 | "volup":{"callername":"String","softnode":"String"} 237 | "voldown":{"callername":"String","softnode":"String"} 238 | "volrel":{"callername":"String","softnode":"String","vol":"Integer"} 239 | "vollinerel":{"callername":"String","softnode":"String","vol":"Integer"} 240 | "volline":{"callername":"String","softnode":"String","vol":"Integer"} 241 | "nightmode":{"callername":"String","val":"Integer"} 242 | #### wifitool 243 | 'wifitool' @1ce770e0 244 | "getrssi":{"get_rssi":"String"} 245 | "setswitch":{"set_switch":"String"} 246 | "pushrssi":{"push_rssi":"Integer"} 247 | "getbssid":{"get_bssid":"String"} 248 | #### workday 249 | 'workday' @62cfc3c6 250 | "get_config":{"name":"String"} 251 | "get_version":{} 252 | "get_ts":{} 253 | "sync_config":{"force":"Boolean","check_ts":"Boolean"} 254 | -------------------------------------------------------------------------------- /ubus/readme.md: -------------------------------------------------------------------------------- 1 | ## list 2 | 3 | + ai_crontab 4 | + alarm 5 | + dlna 6 | + led 7 | + mediaplayer 8 | + messagingagent 9 | + mibrain 10 | + mibt 11 | + miio 12 | + network 13 | + network.device 14 | + network.interface 15 | + network.interface.lan 16 | + network.interface.loopback 17 | + network.wireless 18 | + nightmode 19 | + notify 20 | + pnshelper 21 | + qplayer 22 | + service 23 | + system 24 | + upnp-disc 25 | + voip 26 | + volctl 27 | + wifitool 28 | + workday 29 | 30 | 31 | ### args 32 | 33 | 34 | #### ai_crontab 35 | 'ai_crontab' @c85e9773 36 | "new":{"personal_skill":"String"} 37 | "notify":{"src":"String","event":"String","id":"String"} 38 | "remove_all":{} 39 | "dump":{"busy":"Integer","free":"Integer"} 40 | #### alarm 41 | 'alarm' @1dedfb7b 42 | "mibrain_operation":{"mibrain":"String"} 43 | "alarm_create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 44 | "alarm_query":{"type":"String"} 45 | "alarm_delete":{"type":"String","id":"String"} 46 | "alarm_close":{"type":"String","id":"String"} 47 | "alarm_open":{"type":"String","id":"String"} 48 | "alarm_modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 49 | "create":{"type":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 50 | "query":{"type":"String"} 51 | "delete":{"type":"String","id":"String"} 52 | "close":{"type":"String","id":"String"} 53 | "open":{"type":"String","id":"String"} 54 | "modify":{"type":"String","id":"String","timestamp":"Integer","circle":"Integer","volume":"Integer","event":"String","extra":"String","behavior":"String","ringtone_query":"String","ringtone_type":"String","display_txt":"String","time_reminder":"String"} 55 | "micmute":{"hour":"Integer","minute":"Integer","second":"Integer"} 56 | "micmute_remove":{} 57 | #### dlna 58 | 'dlna' @4ce6e9ae 59 | "demo":{"mac":"String","action":"String"} 60 | "play":{"mac":"String","action":"String"} 61 | "status":{"mac":"String","action":"String"} 62 | #### led 63 | 'led' @78abec6a 64 | "show":{"L":"Integer","pos":"Integer","rgb":"String"} 65 | "shut":{"L":"Integer"} 66 | "status":{} 67 | "shut_all":{} 68 | #### mediaplayer 69 | 'mediaplayer' @749c928c 70 | "player_wakeup":{"action":"String","source":"String"} 71 | "player_play_operation":{"media":"String","action":"String"} 72 | "player_play_url":{"url":"String","type":"Integer","domain":"String","media":"String","src":"String","id":"String","duration":"Integer"} 73 | "player_get_play_status":{} 74 | "player_play_status":{} 75 | "player_play_private_fm":{} 76 | "player_get_latest_playlist":{} 77 | "player_set_positon":{"position":"Integer","media":"String"} 78 | "player_set_loop":{"type":"Integer","media":"String"} 79 | "player_play_music":{"music":"String","startOffset":"Integer","loadMoreOffset":"Integer","media":"String","src":"String","id":"String","duration":"Integer"} 80 | "player_set_volume":{"volume":"Integer","media":"String"} 81 | "player_set_continuous_volume":{"volume":"Integer","media":"String"} 82 | "player_modify_volume":{"isVolumeUp":"Integer","value":"Integer"} 83 | "player_get_context":{} 84 | "player_play_index":{"index":"Integer","media":"String"} 85 | "player_play_alarm_reminder":{"type":"Integer","reminder":"String","volume":"Integer","timeReminder":"String","query":"String"} 86 | "player_play_album_playlist":{"type":"Integer","id":"String","startOffset":"Integer","media":"String"} 87 | "media_control":{"player":"String","action":"String","volume":"Integer"} 88 | "player_set_shutdown_timer":{"action":"String","hour":"Integer","minute":"Integer","second":"Integer","media":"String"} 89 | "test":{} 90 | "get_shutdown_timer":{} 91 | "get_media_volume":{} 92 | "player_reset":{} 93 | "player_retore_last_volume":{} 94 | "set_voip_status":{"voip_status":"String"} 95 | "set_player_quiet":{"quiet":"Boolean"} 96 | "set_playrate":{"rate":"String"} 97 | "notify_mdplay_status":{"status":"Integer","type":"Integer"} 98 | "player_aux_operation":{"aux_operation":"String"} 99 | #### messagingagent 100 | 'messagingagent' @bd5bbd4f 101 | "notify":{"payload":"String"} 102 | "identify_device":{} 103 | "miot_push":{"payload":"String"} 104 | "report_events":{"payload":"String"} 105 | "add_device_log":{"mac":"String","payload":"String"} 106 | "set_kv":{"key":"String","value":"String"} 107 | "close":{} 108 | "get_pid":{} 109 | "fault":{} 110 | "sync_admin":{} 111 | "get_ai_service_token":{} 112 | #### mibrain 113 | 'mibrain' @9d7d7caa 114 | "nlp_result_get":{} 115 | "text_to_speech":{"text":"String","caller":"String","vendor":"String","codec":"String","volume":"Integer","save":"Integer","play":"Integer"} 116 | "vendor_switch":{"vendor_name":"String"} 117 | "vendor_who":{} 118 | "ai_service":{"bypass":"String","caller":"String","duration":"Integer","id":"String","asr":"Integer","nlp":"Integer","tts":"Integer","asr_audio":"String","nlp_text":"String","nlp_execute":"Integer","tts_text":"String","tts_type":"String","tts_vendor":"String","tts_volume":"Integer","tts_codec":"String","tts_save":"Integer","tts_play":"Integer"} 119 | "aivs_miio_token_update":{"token":"String","session_id":"String"} 120 | "aivs_authorization_get":{} 121 | "aivs_event_post":{"namespace":"String","name":"String","payload":"String"} 122 | "aivs_track_post":{"event":"String","dialog_id":"String","extend":"String"} 123 | "aivs_env_switch":{} 124 | "tts_vendor_switch":{"vendor_name":"String"} 125 | "tts_vendor_show":{} 126 | #### mibt 127 | 'mibt' @da0813b2 128 | "wakeup_tv":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 129 | "connect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 130 | "connect_and_play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 131 | "lock":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 132 | "status":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 133 | "unpair":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 134 | "ble":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 135 | "enable":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 136 | "disconnect":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 137 | "volume":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 138 | "volume_action":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 139 | "play":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 140 | "switch_role":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 141 | "scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 142 | "get_scan_bt":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 143 | "display_conn":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 144 | "debug":{"mac":"String","name":"String","recent":"String","action":"String","btmode":"String","volume":"Integer","connect":"Integer","discover":"Integer","btrole":"String"} 145 | #### miio 146 | 'miio' @efe16487 147 | "renew":{} 148 | "register":{"ssid":"String","psk":"String","uid":"String","country":"String"} 149 | "drop":{} 150 | "token_write":{"token":"String","session_id":"String","ttl":"String"} 151 | "miio_restore_status":{} 152 | #### network 153 | 'network' @51d67f39 154 | "restart":{} 155 | "reload":{} 156 | "add_host_route":{"target":"String","v6":"Boolean","interface":"String"} 157 | "get_proto_handlers":{} 158 | "add_dynamic":{"name":"String"} 159 | #### network.device 160 | 'network.device' @6c48ce6a 161 | "status":{"name":"String"} 162 | "set_alias":{"alias":"Array","device":"String"} 163 | "set_state":{"name":"String","defer":"Boolean"} 164 | #### network.interface 165 | 'network.interface' @824adad3 166 | "up":{} 167 | "down":{} 168 | "status":{} 169 | "prepare":{} 170 | "dump":{} 171 | "add_device":{"name":"String","link-ext":"Boolean"} 172 | "remove_device":{"name":"String","link-ext":"Boolean"} 173 | "notify_proto":{} 174 | "remove":{} 175 | "set_data":{} 176 | #### network.interface.lan 177 | 'network.interface.lan' @6e4e9b86 178 | "up":{} 179 | "down":{} 180 | "status":{} 181 | "prepare":{} 182 | "dump":{} 183 | "add_device":{"name":"String","link-ext":"Boolean"} 184 | "remove_device":{"name":"String","link-ext":"Boolean"} 185 | "notify_proto":{} 186 | "remove":{} 187 | "set_data":{} 188 | #### network.interface.loopback 189 | 'network.interface.loopback' @30102251 190 | "up":{} 191 | "down":{} 192 | "status":{} 193 | "prepare":{} 194 | "dump":{} 195 | "add_device":{"name":"String","link-ext":"Boolean"} 196 | "remove_device":{"name":"String","link-ext":"Boolean"} 197 | "notify_proto":{} 198 | "remove":{} 199 | "set_data":{} 200 | #### network.wireless 201 | 'network.wireless' @01c2f7ee 202 | "up":{} 203 | "down":{} 204 | "status":{} 205 | "notify":{} 206 | "get_validate":{} 207 | #### nightmode 208 | 'nightmode' @1cb6eb2d 209 | "set":{"total":"String","light":"String","volume":"String","start":"String","stop":"String"} 210 | "status":{} 211 | "current":{} 212 | #### notify 213 | 'notify' @10d3873e 214 | "create":{"id":"String","level":"Integer","expire":"Integer","volume":"Integer","text":"String"} 215 | "query":{"id":"String"} 216 | "delete":{"id":"String"} 217 | "play":{} 218 | "stop":{} 219 | "clean":{} 220 | "status":{"level":"Integer"} 221 | "set":{"level":"Integer","enable":"Integer","autoplay":"Integer","volume":"Integer"} 222 | #### pnshelper 223 | 'pnshelper' @e56be10e 224 | "event_notify":{"src":"Integer","event":"Integer","detail":"String"} 225 | #### qplayer 226 | 'qplayer' @41f40184 227 | "play":{"play":"String","light":"Integer"} 228 | #### service 229 | 'service' @ee67d7e0 230 | "set":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 231 | "add":{"name":"String","script":"String","instances":"Table","triggers":"Array","validate":"Array","autostart":"Boolean"} 232 | "list":{"name":"String","verbose":"Boolean"} 233 | "delete":{"name":"String","instance":"String"} 234 | "signal":{"name":"String","instance":"String","signal":"Integer"} 235 | "update_start":{"name":"String"} 236 | "update_complete":{"name":"String"} 237 | "event":{"type":"String","data":"Table"} 238 | "validate":{"package":"String","type":"String","service":"String"} 239 | "get_data":{"name":"String","instance":"String","type":"String"} 240 | "state":{"spawn":"Boolean","name":"String"} 241 | #### system 242 | 'system' @5a550b2d 243 | "board":{} 244 | "info":{} 245 | "reboot":{} 246 | "watchdog":{"frequency":"Integer","timeout":"Integer","magicclose":"Boolean","stop":"Boolean"} 247 | "signal":{"pid":"Integer","signum":"Integer"} 248 | "sysupgrade":{"path":"String","prefix":"String","command":"String"} 249 | #### upnp-disc 250 | 'upnp-disc' @9d4924e5 251 | "demo":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 252 | "lookup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 253 | "select":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 254 | "wakeup":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 255 | "list":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 256 | "enable":{"mac":"String","udn":"String","select":"Integer","enable":"Integer"} 257 | #### voip 258 | 'voip' @bb41b65d 259 | "voip_signal_op":{"op":"Integer","uid":"String"} 260 | "action":{"vender":"String","event":"String","contact_id":"String","number":"String","name":"String","string":"String"} 261 | "cmcc_register":{"msisdn":"String","type":"String","operation":"Integer"} 262 | "cmcc_unregister":{"msisdn":"String","type":"String","operation":"Integer"} 263 | "cmcc_miscellaneous":{"msisdn":"String","type":"String","operation":"Integer"} 264 | #### volctl 265 | 'volctl' @5015c14d 266 | "setvol":{"callername":"String","softnode":"String","vol":"Integer"} 267 | "setvolfine":{"callername":"String","softnode":"String","vol":"Integer"} 268 | "getvol":{"callername":"String","softnode":"String"} 269 | "volup":{"callername":"String","softnode":"String"} 270 | "voldown":{"callername":"String","softnode":"String"} 271 | "volrel":{"callername":"String","softnode":"String","vol":"Integer"} 272 | "vollinerel":{"callername":"String","softnode":"String","vol":"Integer"} 273 | "volline":{"callername":"String","softnode":"String","vol":"Integer"} 274 | "nightmode":{"callername":"String","val":"Integer"} 275 | #### wifitool 276 | 'wifitool' @1ce770e0 277 | "getrssi":{"get_rssi":"String"} 278 | "setswitch":{"set_switch":"String"} 279 | "pushrssi":{"push_rssi":"Integer"} 280 | "getbssid":{"get_bssid":"String"} 281 | #### workday 282 | 'workday' @62cfc3c6 283 | "get_config":{"name":"String"} 284 | "get_version":{} 285 | "get_ts":{} 286 | "sync_config":{"force":"Boolean","check_ts":"Boolean"} 287 | 288 | 289 | -------------------------------------------------------------------------------- /ssh/etc/init.d/pns: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=85 4 | 5 | USE_PROCD=1 6 | EXTRA_COMMANDS="toggle refresh mitv_on mitv_off mitv_get mic_on mic_off mic_open mic_close mic_get" 7 | SAI_CONFIG_PATH="/usr/share/sai" #default 8 | #SAI_VAD_MODE="cloud" #default 9 | SAI_VAD_MODE="local" 10 | VOIP_STATUS_IDLE="idle" 11 | VOIP_STATUS_BUSY="busy" 12 | export LED_PARENT=pns 13 | VOIP_FLAG=$2 14 | 15 | _start_mipns_nuance() { 16 | local voip_status=$(cat /tmp/mico-voip/status) 17 | mkdir -p /data/pns 18 | procd_open_instance 19 | if [ '2' = $voip_status ]; then 20 | procd_set_param command /usr/lib/nuance/demos/mipns-nuance -V -c /usr/lib/nuance/demos/config.json 21 | else 22 | procd_set_param command /usr/lib/nuance/demos/mipns-nuance -c /usr/lib/nuance/demos/config.json -l 23 | fi 24 | procd_set_param env NUANCE_MIX_1_0_NODELIB_PATH=/usr/lib/nuance/mix-1.0/bundles 25 | procd_append_param env NUANCE_ELVIS_35_2_MODEL_PATH=/usr/lib/nuance/elvis-35.2/data 26 | procd_append_param env NUANCE_VOCON_4_11_MODEL_PATH=/usr/lib/nuance/vocon-4.11/models 27 | procd_set_param nice 28 | procd_append_param nice -10 29 | procd_set_param respawn 3600 5 0 30 | procd_set_param stdout 0 31 | procd_set_param stderr 0 32 | procd_close_instance 33 | } 34 | 35 | _start_mipns_soundai_prepare() { 36 | local model=$(matool_get_hardware) 37 | if [ 'LX01' = $model -o 'LX05A' = $model ]; then 38 | if [ -d /tmp/mipns/soundai/config/ ]; then 39 | rm -rf /tmp/mipns/soundai/config/* 40 | else 41 | mkdir -p /tmp/mipns/soundai/config/ 42 | fi 43 | cp /usr/share/sai/sai_config.txt* /tmp/mipns/soundai/config/ 44 | cp /usr/share/sai/saires_midot.txt /tmp/mipns/soundai/config/ 45 | ln -s /usr/share/sai/saires_midot.q /tmp/mipns/soundai/config/saires_midot.q 46 | ln -s /usr/share/sai/saires_midot2.q /tmp/mipns/soundai/config/saires_midot2.q 47 | ln -s /usr/share/sai/saivad.q /tmp/mipns/soundai/config/saivad.q 48 | ln -s /usr/share/sai/saicfg.q /tmp/mipns/soundai/config/saicfg.q 49 | ln -s /usr/share/sai/wopt_4mic_midot.bin /tmp/mipns/soundai/config/wopt_4mic_midot.bin 50 | SAI_CONFIG_PATH="/tmp/mipns/soundai/config" 51 | fi 52 | } 53 | 54 | _start_mipns_soundai() { 55 | local voip_status=$(/usr/bin/voip_helper -e query) 56 | _start_mipns_soundai_prepare 57 | procd_open_instance 58 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 59 | if [ 'local' = $SAI_VAD_MODE ]; then 60 | procd_set_param command /usr/bin/mipns-sai -c $SAI_CONFIG_PATH -l -v 61 | else 62 | procd_set_param command /usr/bin/mipns-sai -c $SAI_CONFIG_PATH -v 63 | fi 64 | else 65 | if [ 'local' = $SAI_VAD_MODE ]; then 66 | procd_set_param command /usr/bin/mipns-sai -c $SAI_CONFIG_PATH -l 67 | else 68 | procd_set_param command /usr/bin/mipns-sai -c $SAI_CONFIG_PATH 69 | fi 70 | fi 71 | procd_set_param nice 72 | procd_append_param nice -10 73 | procd_set_param respawn 3600 5 0 74 | procd_set_param stdout 0 75 | procd_set_param stderr 0 76 | procd_close_instance 77 | } 78 | 79 | _start_mipns_xiaomi() { 80 | local voip_status=$(/usr/bin/voip_helper -e query) 81 | procd_open_instance 82 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 83 | procd_set_param command /usr/bin/mipns-xiaomi -c /usr/share/xiaomi/xaudio_engine.conf -r opus32 -l -v 84 | else 85 | procd_set_param command /usr/bin/mipns-xiaomi -c /usr/share/xiaomi/xaudio_engine.conf -r opus32 -l 86 | fi 87 | procd_set_param nice 88 | procd_append_param nice -10 89 | procd_set_param respawn 3600 5 0 90 | procd_set_param stdout 0 91 | procd_set_param stderr 0 92 | procd_close_instance 93 | } 94 | 95 | _start_mipns_gmems() { 96 | local voip_status=$(/usr/bin/voip_helper -e query) 97 | procd_open_instance 98 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 99 | procd_set_param command /usr/bin/mipns-gmems -c /usr/share/gmems/ -r opus32 -l -v 100 | else 101 | procd_set_param command /usr/bin/mipns-gmems -c /usr/share/gmems/ -r opus32 -l 102 | fi 103 | procd_set_param nice 104 | procd_append_param nice -10 105 | procd_set_param respawn 3600 5 0 106 | procd_set_param stdout 0 107 | procd_set_param stderr 0 108 | procd_close_instance 109 | } 110 | 111 | _start_mipns_soundiot() { 112 | local voip_status=$(/usr/bin/voip_helper -e query) 113 | procd_open_instance 114 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 115 | procd_set_param command /usr/bin/mipns-siot -c /usr/share/siot/ -r opus32 -l -v 116 | else 117 | procd_set_param command /usr/bin/mipns-siot -c /usr/share/siot/ -r opus32 -l 118 | fi 119 | procd_set_param nice 120 | procd_append_param nice -10 121 | procd_set_param respawn 3600 5 0 122 | procd_set_param stdout 0 123 | procd_set_param stderr 0 124 | procd_close_instance 125 | } 126 | 127 | _start_mipns_aispeech() { 128 | local voip_status=$(/usr/bin/voip_helper -e query) 129 | procd_open_instance 130 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 131 | procd_set_param command /usr/bin/mipns-aispeech -c /usr/share/aispeech/ -r opus32 -l -v 132 | else 133 | procd_set_param command /usr/bin/mipns-aispeech -c /usr/share/aispeech/ -r opus32 -l 134 | fi 135 | procd_set_param nice 136 | procd_append_param nice -10 137 | procd_set_param respawn 3600 5 0 138 | procd_set_param stdout 0 139 | procd_set_param stderr 0 140 | procd_close_instance 141 | } 142 | 143 | _start_mipns_horizon() { 144 | local voip_status=$(/usr/bin/voip_helper -e query) 145 | procd_open_instance 146 | if [ $VOIP_STATUS_IDLE != $voip_status -o "$VOIP_FLAG" == "voip" ]; then 147 | procd_set_param command /usr/bin/mipns-horizon -c /usr/share/horizon/ -r opus32 -l -v 148 | else 149 | procd_set_param command /usr/bin/mipns-horizon -c /usr/share/horizon/ -r opus32 -l 150 | fi 151 | procd_set_param nice 152 | procd_append_param nice -10 153 | procd_set_param respawn 3600 5 0 154 | procd_set_param stdout 0 155 | procd_set_param stderr 0 156 | procd_close_instance 157 | } 158 | 159 | start_service() { 160 | local sn=$(uci -c /data/etc/ get binfo.binfo.sn); 161 | local model=$(matool_get_hardware) 162 | if [ 'S12A' = $model ]; then 163 | if [[ '18090/981107732' = $sn ]] || [[ '18090/981107218' = $sn ]] || [[ '18090/981140781' = $sn ]]; then 164 | amixer sset 'pdm dclk' 'pdm dclk 1.024m, support 8k/16k' 165 | if [ -d /var/mipns/soundai/ ]; then 166 | rm -rf /var/mipns/soundai/* 167 | else 168 | mkdir -p /var/mipns/soundai/ 169 | fi 170 | ln -s /usr/share/sai/sai_config_16k.txt /var/mipns/soundai/sai_config.txt 171 | ln -s /usr/share/sai/sai_info /var/mipns/soundai/sai_info 172 | ln -s /usr/share/sai/sai_mic.q /var/mipns/soundai/sai_mic.q 173 | ln -s /usr/share/sai/saires_xiaomi.q /var/mipns/soundai/saires_xiaomi.q 174 | ln -s /usr/share/sai/saires_xiaomi2.q /var/mipns/soundai/saires_xiaomi2.q 175 | ln -s /usr/share/sai/saivad.q /var/mipns/soundai/saivad.q 176 | ln -s /usr/share/sai/wopt_6mic_xiaomi.bin /var/mipns/soundai/wopt_6mic_xiaomi.bin 177 | SAI_CONFIG_PATH="/var/mipns/soundai" 178 | echo soundai > /data/mipns/vendor 179 | elif [ '18089/880000050' = $sn ]; then 180 | amixer sset 'pdm dclk' 'pdm dclk 1.024m, support 8k/16k' 181 | if [ -d /var/mipns/soundai/ ]; then 182 | rm -rf /var/mipns/soundai/* 183 | else 184 | mkdir -p /var/mipns/soundai/ 185 | fi 186 | ln -s /usr/share/sai/sai_config_16k.txt /var/mipns/soundai/sai_config.txt 187 | ln -s /usr/share/sai/sai_info /var/mipns/soundai/sai_info 188 | ln -s /usr/share/sai/sai_mic.q /var/mipns/soundai/sai_mic.q 189 | ln -s /usr/share/sai/saires_xiaomi.q /var/mipns/soundai/saires_xiaomi.q 190 | ln -s /usr/share/sai/saires_xiaomi2.q /var/mipns/soundai/saires_xiaomi2.q 191 | ln -s /usr/share/sai/saivad.q /var/mipns/soundai/saivad.q 192 | ln -s /usr/share/sai/wopt_6mic_xiaomi.bin /var/mipns/soundai/wopt_6mic_xiaomi.bin 193 | SAI_CONFIG_PATH="/var/mipns/soundai" 194 | echo soundai > /data/mipns/vendor 195 | else 196 | amixer sset 'pdm dclk' 'pdm dclk 3.072m, support 8k/16k/32k/48k' 197 | fi 198 | fi 199 | 200 | local vendor_name=$(/usr/bin/mico_vendor_helper vendor_name_get); 201 | if [ "nuance" = $vendor_name ]; then 202 | _start_mipns_nuance 203 | elif [ "xiaomi" = $vendor_name ]; then 204 | _start_mipns_xiaomi 205 | elif [ "gmems" = $vendor_name ]; then 206 | _start_mipns_gmems 207 | elif [ "soundiot" = $vendor_name ]; then 208 | _start_mipns_soundiot 209 | elif [ "aispeech" = $vendor_name ]; then 210 | _start_mipns_aispeech 211 | elif [ "horizon" = $vendor_name ]; then 212 | _start_mipns_horizon 213 | elif [ "soundai" = $vendor_name ]; then 214 | _start_mipns_soundai 215 | else # exception 216 | return 217 | fi 218 | ubus call pnshelper event_notify '{"src":3, "event":0}' > /dev/null 2>&1 & 219 | } 220 | 221 | stop_service() { 222 | local vendor_name=$(/usr/bin/mico_vendor_helper vendor_name_get); 223 | rm -rf /tmp/mipns/upload 224 | if [ "nuance" = $vendor_name ]; then 225 | rm -rf /tmp/mipns/nuance 226 | elif [ "xiaomi" = $vendor_name ]; then 227 | rm -rf /tmp/mipns/xiaomi 228 | elif [ "gmems" = $vendor_name ]; then 229 | rm -rf /tmp/mipns/gmems 230 | elif [ "soundiot" = $vendor_name ]; then 231 | rm -rf /tmp/mipns/soundiot 232 | elif [ "aispeech" = $vendor_name ]; then 233 | rm -rf /tmp/mipns/aispeech 234 | elif [ "horizon" = $vendor_name ]; then 235 | rm -rf /tmp/mipns/horizon 236 | elif [ "soundai" = $vendor_name ]; then 237 | rm -rf /tmp/mipns/soundai 238 | else # exception 239 | return 240 | fi 241 | ubus call pnshelper event_notify '{"src":3, "event":1}' > /dev/null 2>&1 & 242 | } 243 | 244 | service_running() { 245 | [ $(pidof mipns-nuance) ] || [ $(pidof mipns-sai) ] || [ $(pidof mipns-xiaomi) ] || [ $(pidof mipns-gmems) ] || [ $(pidof mipns-siot) ] || [ $(pidof mipns-aispeech) ] || [ $(pidof mipns-horizon) ] 246 | } 247 | 248 | _set_volume() { 249 | local MVOL="255" # max wakeup notify volume 255 250 | local vol=`ubus -t1 -S call mediaplayer get_media_volume | cut -d':' -f2 |cut -d '}' -f1` 251 | if [ "$vol" -gt "$MVOL" ]; then 252 | # 3. tune vol if it is too loud. 253 | amixer sset notifyvol "$MVOL" > /dev/null 254 | else 255 | amixer sset notifyvol "$vol" > /dev/null 256 | fi 257 | } 258 | 259 | toggle() { 260 | local voip_status 261 | if service_running; then 262 | voip_status=$(/usr/bin/voip_helper -e mute) 263 | if [ $VOIP_STATUS_IDLE != $voip_status ]; then #idle 264 | return 265 | fi 266 | stop 267 | show_led 7 268 | _set_volume 269 | ubus -t 1 call qplayer play {\"play\":\"/usr/share/sound/mic_off.opus\"} 270 | # recover mediaplayer status when mute after wakeup 271 | ubus -t 1 call mediaplayer player_wakeup {\"action\":\"stop\"} 272 | logger stat_points_none micolog_mic_off_count=1 > /dev/null 2>&1 & 273 | else 274 | voip_status=$(/usr/bin/voip_helper -e unmute) 275 | if [ $VOIP_STATUS_IDLE != $voip_status ]; then 276 | return 277 | fi 278 | 279 | start 280 | shut_led 7 281 | _set_volume 282 | ubus -t 1 call qplayer play {\"play\":\"/usr/share/sound/mic_on.opus\"} 283 | logger stat_points_none micolog_mic_on_count=1 > /dev/null 2>&1 & 284 | ubus -t 1 call alarm micmute_remove 285 | fi 286 | } 287 | 288 | mic_on() { 289 | voip_status=$(/usr/bin/voip_helper -e unmute) 290 | if [ $VOIP_STATUS_IDLE != $voip_status ]; then 291 | return; 292 | fi 293 | 294 | if service_running; then 295 | echo "do nothing" 296 | else 297 | start 298 | shut_led 7 299 | _set_volume 300 | ubus -t 1 call qplayer play {\"play\":\"/usr/share/sound/mic_on.opus\"} 301 | logger stat_points_none micolog_mic_on_count=1 > /dev/null 2>&1 & 302 | fi 303 | 304 | ubus -t 1 call alarm micmute_remove 305 | } 306 | 307 | mic_off() { 308 | voip_status=$(/usr/bin/voip_helper -e mute) 309 | if [ $VOIP_STATUS_IDLE != $voip_status ]; then 310 | return; 311 | fi 312 | 313 | if service_running; then 314 | stop 315 | show_led 7 316 | _set_volume 317 | ubus -t 1 call qplayer play {\"play\":\"/usr/share/sound/mic_off.opus\"} 318 | # recover mediaplayer status when mute after wakeup 319 | ubus -t 1 call mediaplayer player_wakeup {\"action\":\"stop\"} 320 | logger stat_points_none micolog_mic_off_count=1 > /dev/null 2>&1 & 321 | else 322 | echo "do nothing" 323 | fi 324 | } 325 | 326 | mic_open() { 327 | local _result=$(ubus call pnshelper event_notify "{\"src\":1,\"event\":0}") 328 | echo $local _result 329 | [ x"$_result" == x"" ] && exit 1 330 | json_init 331 | json_load "$_result" 332 | json_get_var _code code 333 | json_cleanup 334 | echo $_code 335 | [ x"$_code" == x"0" ] &&{ 336 | echo "open" 337 | /bin/show_led 1 338 | return 0 339 | } 340 | return 1 341 | } 342 | 343 | mic_close() { 344 | sleep 6 345 | /bin/shut_led 1 346 | ubus call pnshelper event_notify '{"src":1,"event":1}' 347 | } 348 | 349 | 350 | mic_get() { 351 | if service_running; then 352 | echo "on" 353 | else 354 | echo "off" 355 | fi 356 | } 357 | 358 | refresh() { 359 | if service_running; then 360 | restart 361 | logger -t mipns-refresh -p 3 "Refresh pns service..." 362 | fi 363 | } 364 | 365 | mitv_on() { 366 | # set mitv wakeup on 367 | if [ ! -d "/data/mipns/" ]; then 368 | mkdir "/data/mipns/" 369 | fi 370 | 371 | if [ ! -d "/tmp/mipns/" ]; then 372 | mkdir "/tmp/mipns/" 373 | fi 374 | 375 | echo "on" > /data/mipns/mitv 376 | echo "mitv=on" > /tmp/mipns/config 377 | kill -s SIGHUP $(pidof mipns-sai) 378 | } 379 | 380 | mitv_off() { 381 | # set mitv wakeup off 382 | if [ ! -d "/data/mipns/" ]; then 383 | mkdir "/data/mipns/" 384 | fi 385 | if [ ! -d "/tmp/mipns/" ]; then 386 | mkdir "/tmp/mipns/" 387 | fi 388 | 389 | echo "off" > /data/mipns/mitv 390 | echo "mitv=off" > /tmp/mipns/config 391 | kill -s SIGHUP $(pidof mipns-sai) 392 | } 393 | 394 | mitv_get() { 395 | if [ -f "/data/mipns/mitv" ]; then 396 | cat /data/mipns/mitv 397 | else 398 | echo "off" 399 | fi 400 | } 401 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 小米AI音箱-5402 The Mi AI SoundBox S12 2 | 3 | ### 设备信息 4 | 5 | 6 | /data/dlna/device.xml 7 | 8 | ```xml 9 | 小米AI音箱-5402 10 | Mi, Inc. 11 | The Mi AI SoundBox 12 | S12 13 | S12 14 | QPlay:2 16 | 17 | DMR-1.50 19 | 20 | , 22 | 23 | ``` 24 | 25 | 26 | ### 播放控制 27 | 28 | [ubus](https://openwrt.org/docs/techref/ubus) 29 | 30 | ```bash 31 | ubus 32 | ubus list 33 | ubus list network.interface.* 34 | ubus -v list network.interface.lan 35 | 36 | ubus call network.interface.wan status 37 | ubus call network.device status '{ "name": "eth0" }' 38 | ubus listen & 39 | 40 | ubus call network.interface.wan down 41 | ubus call network.interface.wan up 42 | 43 | ubus listen & 44 | ubus send foo '{ "bar": "baz" }' 45 | 46 | ubus 47 | Usage: ubus [] [arguments...] 48 | Options: 49 | -s : Set the unix domain socket to connect to 50 | -t : Set the timeout (in seconds) for a command to complete 51 | -S: Use simplified output (for scripts) 52 | -v: More verbose output 53 | -m : (for monitor): include a specific message type 54 | (can be used more than once) 55 | -M (for monitor): only capture received or transmitted traffic 56 | 57 | Commands: 58 | - list [] List objects 59 | - call [] Call an object method 60 | - listen [...] Listen for events 61 | - send [] Send an event 62 | - wait_for [...] Wait for multiple objects to appear on ubus 63 | - monitor Monitor ubus traffic 64 | 65 | root@mico:~# ubus list 66 | ai_crontab 67 | alarm 68 | dlna 69 | led 70 | mediaplayer 71 | messagingagent 72 | mibrain 73 | mibt 74 | miio 75 | network 76 | network.device 77 | network.interface 78 | network.interface.lan 79 | network.interface.loopback 80 | network.wireless 81 | nightmode 82 | notify 83 | pnshelper 84 | qplayer 85 | service 86 | system 87 | upnp-disc 88 | voip 89 | volctl 90 | wifitool 91 | workday 92 | 93 | 94 | 95 | 96 | ``` 97 | 98 | 99 | #### uttpd + lua 100 | 101 | + [rpcd](https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/rpcd-mod-lxc_20141012_arm64.ipk) 102 | + [/etc/config/uhttpd](https://openwrt.org/docs/guide-user/services/webserver/uhttpd) 103 | + /etc/config/rpcd 104 | + /etc/config/system 105 | + /usr/share/rpcd/acl.d/superuser.json 106 | + /usr/share/rpcd/acl.d/*.json 107 | + `ubus_cors=1` 108 | 109 | 110 | ```bash 111 | opkg install uhttpd-mod-lua luci-sgi-uhttpd 112 | #edit /etc/config/uhttpd 113 | /etc/init.d/uhttpd restart 114 | 115 | data={ 116 | "ubus_rpc_session": "xxxxx", 117 | "object": "requested-object", 118 | "function": "requested-method" 119 | } 120 | ubus call session access $data 121 | 122 | ``` 123 | 124 | 125 | ```bash 126 | 127 | url="http://localhost/ubus" 128 | data=' 129 | { 130 | "jsonrpc": "2.0", 131 | "id": 1, 132 | "method": "call", 133 | "params": [ 134 | "00000000000000000000000000000000", 135 | "session", 136 | "login", 137 | { 138 | "username": "root", 139 | "password": "secret" 140 | } 141 | ] 142 | } 143 | ' 144 | curl -d $data $url 145 | 146 | ``` 147 | ```json 148 | { 149 | "jsonrpc": "2.0", 150 | "id": 1, 151 | "result": [ 152 | 0, 153 | { 154 | "ubus_rpc_session": "c1ed6c7b025d0caca723a816fa61b668", 155 | "timeout": 300, 156 | "expires": 299, 157 | "acls": { 158 | "access-group": { 159 | "superuser": [ 160 | "read", 161 | "write" 162 | ], 163 | "unauthenticated": [ 164 | "read" 165 | ] 166 | }, 167 | "ubus": { 168 | "*": [ 169 | "*" 170 | ], 171 | "session": [ 172 | "access", 173 | "login" 174 | ] 175 | }, 176 | "uci": { 177 | "*": [ 178 | "read", 179 | "write" 180 | ] 181 | } 182 | }, 183 | "data": { 184 | "username": "root" 185 | } 186 | } 187 | ] 188 | } 189 | 190 | 191 | ``` 192 | 193 | #### 示例 194 | 195 | /sbin/ubusd 196 | 197 | ```lua 198 | 199 | require("ubus") 200 | 201 | function speak(s) 202 | --ubus -t 1000 call mibrain text_to_speech "{\"text\":\"$tts\",\"save\":0}" 203 | local conn = ubus.connect() 204 | 205 | local s2 = conn:call("mibrain", "text_to_speech", {text=s,save=0}) 206 | --local s1 = conn:call("mediaplayer", "player_set_volume", {volume=v }) 207 | --local s2 = conn:call("mediaplayer", "player_set_loop", {type=0,media="common"}) 208 | --local s3 = conn:call("mediaplayer", "player_play_url", { url=url,type=0 }) 209 | 210 | conn:close() 211 | end 212 | ``` 213 | 214 | ```bash 215 | 216 | root@mico:~# ubus list mediaplayer -v 217 | 218 | 'mediaplayer' @4920c7ce 219 | "player_wakeup":{"action":"String","source":"String"} 220 | "player_play_operation":{"media":"String","action":"String"} 221 | "player_play_url":{"url":"String","type":"Integer","domain":"String","media":"String","src":"String","id":"String","duration":"Integer"} 222 | "player_get_play_status":{} 223 | "player_play_status":{} 224 | "player_play_private_fm":{} 225 | "player_get_latest_playlist":{} 226 | "player_set_positon":{"position":"Integer","media":"String"} 227 | "player_set_loop":{"type":"Integer","media":"String"} 228 | "player_play_music":{"music":"String","startOffset":"Integer","loadMoreOffset":"Integer","media":"String","src":"String","id":"String","duration":"Integer"} 229 | "player_set_volume":{"volume":"Integer","media":"String"} 230 | "player_set_continuous_volume":{"volume":"Integer","media":"String"} 231 | "player_modify_volume":{"isVolumeUp":"Integer","value":"Integer"} 232 | "player_get_context":{} 233 | "player_play_index":{"index":"Integer","media":"String"} 234 | "player_play_alarm_reminder":{"type":"Integer","reminder":"String","volume":"Integer","timeReminder":"String","query":"String"} 235 | "player_play_album_playlist":{"type":"Integer","id":"String","startOffset":"Integer","media":"String"} 236 | "media_control":{"player":"String","action":"String","volume":"Integer"} 237 | "player_set_shutdown_timer":{"action":"String","hour":"Integer","minute":"Integer","second":"Integer","media":"String"} 238 | "test":{} 239 | "get_shutdown_timer":{} 240 | "get_media_volume":{} 241 | "player_reset":{} 242 | "player_retore_last_volume":{} 243 | "set_voip_status":{"voip_status":"String"} 244 | "set_player_quiet":{"quiet":"Boolean"} 245 | "set_playrate":{"rate":"String"} 246 | "notify_mdplay_status":{"status":"Integer","type":"Integer"} 247 | "player_aux_operation":{"aux_operation":"String"} 248 | 249 | cd /tmp 250 | mkidr ubus 251 | cd ubus 252 | for i in `ubus list` ; do ubus list $i -v >$i.txt ;done 253 | 254 | 255 | ``` 256 | 257 | 258 | 259 | ```bash 260 | 261 | 262 | 263 | 264 | ubus call mibt ble '{"action":"hidden"}' 265 | ubus call voip cmcc_unregister 266 | ubus -t 1 call ai_crontab remove_all 267 | ubus -t 1 call qplayer play {\"play\":\"$wakeup_wav\"} 268 | 269 | ubus call mibrain text_to_speech "{\"text\":\"呵呵\",\"save\":1}" 270 | ubus call mibrain text_to_speech "{\"text\":\"日志上传成功\",\"save\":0}" 271 | ubus call mibrain text_to_speech "{\"text\":\"日志上传失败\",\"save\":0}" 272 | 273 | #闪烁 274 | OP="8" # 2 6 9 275 | POS="2"# 276 | RGB="" # 277 | ubus -t 1 call led shut 278 | ubus -t 1 call led show "{\"L\":$OP,\"pos\":$POS}" 279 | ubus -t 1 call led show "{\"L\":$OP, \"rgb\":\"$RGB\"}" 280 | ubus -t 1 call led shut "{\"L\":$OP}" 281 | 282 | TIMEOUT=1 283 | MPATH="mediaplayer" 284 | METHOD="player_play_operation" 285 | VOIP_STATUS_IDLE="0x00000000" 286 | volume=70 287 | url="http://cdn.cnbj1.fds.api.mi-img.com/xiaomi0802/xiayu.mp3" 288 | 289 | ubus -t $TIMEOUT call $MPATH player_set_volume {\"volume\":"$volume"} 290 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"play\",\"media\":\"common\"} 291 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"play\",\"media\":\"common\"} 292 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"pause\",\"media\":\"common\"} 293 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"toggle\",\"media\":\"common\"} 294 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"next\",\"media\":\"common\"} 295 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"prev\",\"media\":\"common\"} 296 | ubus -t $TIMEOUT call $MPATH $METHOD {\"action\":\"channel\",\"media\":\"common\"} 297 | 298 | ubus -t 1 call mediaplayer player_play_url {\"url\":\""$url"\",\"type\":1} 299 | ubus -t1 -S call mediaplayer get_media_volume 300 | ubus -t 1 call mediaplayer player_wakeup {\"action\":\"start\"} 301 | ubus -t 1 call mediaplayer player_wakeup {\"action\":\"stop\"} 302 | 303 | ubus -t 10 call mediaplayer test 304 | ubus call mediaplayer player_get_play_status 305 | ubus -t 1 call mediaplayer player_get_context 306 | 307 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/command_timeout.mp3\",\"type\":1} 308 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/wifi_disconnect.mp3\",\"type\":1} 309 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/internet_disconnect.mp3\",\"type\":1} 310 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_connect_timeout.mp3\",\"type\":1} 311 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_service_timeout.mp3\",\"type\":1} 312 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_network_unreachable.mp3\",\"type\":1} 313 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_service_unreachable.mp3\",\"type\":1} 314 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_auth_failed.mp3\",\"type\":1} 315 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/mibrain_start_failed.mp3\",\"type\":1} 316 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/upgrade_now.mp3\",\"type\":1} 317 | ubus -t 1 call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/upgrade_later.mp3\",\"type\":1} 318 | 319 | ubus call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/shutdown.mp3\",\"type\":1} 320 | ubus call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/ble.mp3\",\"type\":1} 321 | ubus call mediaplayer player_play_url {\"url\":\"file:///usr/share/sound/setupdone.mp3\",\"type\":1} 322 | ``` 323 | 324 | ### ssh 325 | 326 | ![拆机连ttl线](img/ttl.png) 327 | 328 | + 小爱 GTR 329 | + pc GRT (黑白绿) 330 | 331 | 小爱同学经常自动升级, 332 | 修改/etc/shadow 或/etc/passwd 没用了,重启以后会自动还原。。 333 | ttl线手动连接需要输入root密码 (账号root) 334 | 335 | #### 密码规则 336 | 337 | ```javascript 338 | 339 | u=require('utility') 340 | 341 | sn="00000/000000000" 342 | //音箱底部贴纸上找,15位 343 | 344 | b="9C78089F-83C7-3CDC-BCC9-93B378868E7F" 345 | password=u.md5(sn+b).slice(0,14) 346 | console.log(password) 347 | 348 | ``` 349 | 350 | 351 | ```bash 352 | minicom 353 | 354 | mico login: root 355 | Password: 356 | 357 | 358 | BusyBox v1.23.2 (2019-11-11 03:44:52 UTC) built-in shell (ash) 359 | 360 | _______ ________ __ 361 | | |.-----.-----.-----.| | | |.----.| |_ 362 | | - || _ | -__| || | | || _|| _| 363 | |_______|| __|_____|__|__||________||__| |____| 364 | |__| W I R E L E S S F R E E D O M 365 | ----------------------------------------------------- 366 | CHAOS CALMER (Chaos Calmer, unknown) 367 | ----------------------------------------------------- 368 | * 1 1/2 oz Gin Shake with a glassful 369 | * 1/4 oz Triple Sec of broken ice and pour 370 | * 3/4 oz Lime Juice unstrained into a goblet. 371 | * 1 1/2 oz Orange Juice 372 | * 1 tsp. Grenadine Syrup 373 | ----------------------------------------------------- 374 | root@mico:~# 375 | 376 | ``` 377 | 小爱同学升级以后有毒, 378 | 379 | 每次拆机连线太麻烦了。。。 380 | 381 | 被升级一次拆机配置一堆,还是做个服务吧。。 382 | 383 | 384 | ```bash 385 | crontab -l 386 | # explain crontab in https://crontab.guru/ 387 | # 388 | # At every 5th minute. 389 | */5 * * * * /usr/sbin/easy_logcut size 390 | # At every minute. 391 | * * * * * /usr/sbin/network_probe.sh 392 | # At 04:32. 393 | 32 4 * * * /usr/sbin/pns refresh 394 | # At every 10th minute. 395 | */10 * * * * /usr/bin/check_mediaplayer_status 396 | # At 03:00. 397 | 0 3 * * * /bin/ota slient # check ota 398 | root@mico:~# 399 | 400 | 401 | ``` 402 | 403 | 404 | ### 安装openwrt插件 405 | 406 | 小爱同学本质为openwrt套壳, 可用opkg安装openwrt的各种插件 407 | 408 | #### 插件版本 409 | 410 | + cpu arm64 (aarch64) 411 | + openwrt 15.05.1 412 | 413 | ```bash 414 | 415 | cat /proc/version 416 | Linux version 3.14.29 (jenkins@3f0613e75445) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 unknown) ) #1 SMP PREEMPT Mon Nov 11 03:59:20 UTC 2019 417 | 418 | 419 | root@mico:~# cat /proc/cpuinfo 420 | Processor : AArch64 Processor rev 4 (aarch64) 421 | processor : 0 422 | processor : 1 423 | processor : 2 424 | processor : 3 425 | Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 426 | CPU implementer : 0x41 427 | CPU architecture: AArch64 428 | CPU variant : 0x0 429 | CPU part : 0xd03 430 | CPU revision : 4 431 | 432 | Hardware : Amlogic 433 | Serial : 210af2004d6194b776700628dc7baded 434 | root@mico:~# 435 | 436 | 437 | 438 | ``` 439 | 查看openwrt版本 440 | 441 | ```bash 442 | cat /etc/openwrt_version 443 | 15.05.1 444 | 445 | cat /etc/openwrt_release 446 | 447 | DISTRIB_ID='OpenWrt' 448 | DISTRIB_RELEASE='Chaos Calmer' 449 | DISTRIB_REVISION='unknown' 450 | DISTRIB_CODENAME='chaos_calmer' #https://archive.openwrt.org/chaos_calmer/ 451 | DISTRIB_TARGET='meson/gxl' ### 452 | DISTRIB_DESCRIPTION='OpenWrt Chaos Calmer 15.05.1' 453 | DISTRIB_TAINTS='no-all glibc busybox' 454 | 455 | ``` 456 | 457 | #### 插件地址 458 | 459 | [15.05 插件](https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/) 460 | 461 | ```json 462 | { 463 | "base": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/base/", 464 | "luci": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/luci/", 465 | "management": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/management/", 466 | "packages": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/", 467 | "routing": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/routing/", 468 | "telephony": "https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/telephony/" 469 | } 470 | 471 | ``` 472 | 473 | [15.05.1 插件 缺arm64](https://archive.openwrt.org/chaos_calmer/15.05.1/) 474 | 475 | 修改/etc/opkg/distfeeds.conf 476 | 477 | ``` 478 | src/gz chaos_calmer_base https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/base 479 | src/gz chaos_calmer_luci https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/luci 480 | src/gz chaos_calmer_management https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/management 481 | src/gz chaos_calmer_packages https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages 482 | src/gz chaos_calmer_routing https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/routing 483 | src/gz chaos_calmer_telephony https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/telephony 484 | # src/gz chaos_calmer_oldpackages http://downloads.openwrt.org/chaos_calmer/15.05.1/meson/gxl/packages/oldpackages 485 | 486 | ``` 487 | 488 | ```bash 489 | opkg update 490 | opkg list 491 | 492 | opkg find python 493 | opkg find zsh 494 | 495 | opkg install zsh 496 | opkg install python 497 | 498 | 499 | ``` 500 | 501 | ### [手动安装插件](https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/) 502 | 503 | 以openssh为例 504 | 505 | ```bash 506 | 507 | wget https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/openssh-keygen_7.1p2-1_arm64.ipk 508 | tar xzvf openssh-keygen_7.1p2-1_arm64.ipk 509 | tar xzvf data.tar.gz -C / 510 | 511 | wget https://archive.openwrt.org/chaos_calmer/15.05/arm64/generic/packages/packages/openssh-server_7.1p2-1_arm64.ipk 512 | #opkg install openssh-server_7.1p2-1_arm64.ipk 513 | tar xzvf openssh-server_7.1p2-1_arm64.ipk 514 | ./debian-binary 515 | ./data.tar.gz 516 | ./control.tar.gz 517 | 518 | tar xzvf data.tar.gz -C / 519 | 520 | ``` 521 | 522 | #### 内置插件 523 | 524 | root@mico:/tmp/z# opkg list-installed 525 | + 6in4 - 21-2 526 | + 6to4 - 12-2 527 | + agora-media - 0.0.1 528 | + alarm - 0.0.1 529 | + alsa-lib - 1.0.28-1 530 | + alsa-plugins - 1.1.1-2 531 | + alsa-utils - 1.0.28-2 532 | + ar - 2.24-3 533 | + base-files - 157.2-unknown 534 | + binutils - 2.24-3 535 | + busybox - 1.23.2-1 536 | + ca-bundle - 20180409-2 537 | + ca-certificates - 20180409-2 538 | + curl - 7.60.0-3 539 | + dlna - 1 540 | + dnsmasq - 2.78-5 541 | + drill - 1.6.17-2 542 | + dropbear - 2015.67-1 543 | + e2fsprogs - 1.42.12-1 544 | + fstools - 2016-01-10-96415afecef35766332067f4205ef3b2c7561d21 545 | + glib2 - 2.43.4-1 546 | + glog - 0.3.5-1 547 | + hostapd - 2017-08-24-3 548 | + hostapd-common - 2017-08-24-3 549 | + htop - 1.0.3-1 550 | + htpdate - 1.0.4-1 551 | + i2c-tools - 2013-12-15-1 552 | + iperf - 2.0.5-1 553 | + iputils-ping - 20101006-1 554 | + iputils-ping6 - 20101006-1 555 | + iputils-tracepath - 20101006-1 556 | + iputils-tracepath6 - 20101006-1 557 | + iputils-traceroute6 - 20101006-1 558 | + iw - 4.3-1 559 | + jshn - 2017-09-29-632688e8-10429bccd0dc5d204635e110a7a8fae7b80d16cb 560 | + jsonfilter - 2014-06-19-cdc760c58077f44fc40adbbe41e1556a67c1b9a9 561 | + kernel - 3.14.29-1-55e86761b221b7a3819a24d8a972fa3f 562 | + kmod-bcm43458 - 3.14.29-1 563 | + kmod-cfg80211 - 3.14.29+2016-01-10-1 564 | + kmod-input-core - 3.14.29-1 565 | + kmod-iptunnel - 3.14.29-1 566 | + kmod-iptunnel4 - 3.14.29-1 567 | + kmod-ipv6 - 3.14.29-1 568 | + kmod-leds-is31fl3236a - 3.14.29-1 569 | + kmod-lib-crc-ccitt - 3.14.29-1 570 | + kmod-lib80211 - 3.14.29+2016-01-10-1 571 | + kmod-sit - 3.14.29-1 572 | + kmod-sound-core - 3.14.29-1 573 | + kmod-xiaomi-cyttsp - 3.14.29-1 574 | + leveldb - 1.20-1 575 | + libattr - 20150220-1 576 | + libbfd - 2.24-3 577 | + libblobmsg-json - 2017-09-29-632688e8-10429bccd0dc5d204635e110a7a8fae7b80d16cb 578 | + libbz2 - 1.0.6-2 579 | + libc - 2.19-1 580 | + libconfig - 1.4.9-2 581 | + libcurl - 7.60.0-3 582 | + libdbi - 0.9.0-4 583 | + libdirac - 2.4-0 584 | + libdw - 0.161-1 585 | + libelf1 - 0.161-1 586 | + libevent2 - 2.0.22-1 587 | + libeventlog - 0.2.9-2 588 | + libext2fs - 1.42.12-1 589 | + libffi - 3.0.13-1 590 | + libflac - 1.3.1-1 591 | + libgcc - 4.8-linaro-1 592 | + libgmp - 6.0.0-1 593 | + libgnutls - 3.4.15-1 594 | + libgssdp - 1.0.2-1 595 | + libgupnp - 1.0.2-1 596 | + libi2c - 2013-12-15-1 597 | + libiconv-full - 1.11.1-1 598 | + libintl-full - 0.19.6-2 599 | + libip4tc - 1.4.21-1 600 | + libip6tc - 1.4.21-1 601 | + libjson-c - 0.12-1 602 | + libjson-script - 2017-09-29-632688e8-10429bccd0dc5d204635e110a7a8fae7b80d16cb 603 | + libldns - 1.6.17-2 604 | + liblua - 5.1.5-1 605 | + liblzo - 2.08-1 606 | + libncurses - 5.9-2 607 | + libnettle - 3.1.1-1 608 | + libnghttp2 - 1.32.0-1 609 | + libnl-tiny - 0.1-4 610 | + libogg - 1.3.2-2 611 | + libopcodes - 2.24-3 612 | + libopenssl - 1.0.2h-1 613 | + libopus - 1.1-1 614 | + libopusfile - 0.11-1 615 | + libpcre - 8.41-2 616 | + libpolarssl - 1.3.14-1 617 | + libprotobuf-c - v1.0.1 618 | + libpthread - 2.19-1 619 | + libreadline - 6.3-1 620 | + librt - 2.19-1 621 | + libsndfile - 1.0.28-1 622 | + libsoup - 2.53.2-1 623 | + libspeexdsp - 1.2rc1-1 624 | + libsqlite3 - 3081101-1 625 | + libstdcpp - 4.8-linaro-1 626 | + libthrift - 0.11.0-1 627 | + libubox - 2017-09-29-632688e8-10429bccd0dc5d204635e110a7a8fae7b80d16cb 628 | + libubus - 2017-02-18-34c6e818-34c6e818 629 | + libuci - 2017-09-29-5ad59ad4.1-1 630 | + libuci-lua - 2017-09-29-5ad59ad4.1-1 631 | + libuuid - 2.25.2-4 632 | + libwrap - 7.6-1 633 | + libxml2 - 2.9.2-3 634 | + libxtables - 1.4.21-1 635 | + lua - 5.1.5-1 636 | + mediaplayer - 0.0.1 637 | + messagingagent - 1-1.1 638 | + mibrain - 1 639 | + mibrain-common-sdk - 0.0.1 640 | + mibrain-service - 0.0.1 641 | + mibt - 0.0.1 642 | + mico-ai-crontab - 0.0.1 643 | + mico-miio - 0.0.1 644 | + mico-misc - 0.1.1-1 645 | + mico-upgrade - 1.0.0-1 646 | + mico-vendor - 0.0.1 647 | + mimc_sdk - 0.0.1 648 | + mipns-general - 1 649 | + mipns-helper - 0.0.1 650 | + mipns-sai - 1 651 | + mipns-xiaomi - 1 652 | + mitv-agent - 0.0.1 653 | + mtd - 21 654 | + nano-httpd - 0.0.1 655 | + netifd - 2015-12-16-245527193e90906451be35c2b8e972b8712ea6ab 656 | + notify - 0.0.1 657 | + objdump - 2.24-3 658 | + opkg - 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-9 659 | + perf - 3.14.29-2 660 | + procd - 2017-09-28-ee582d16-1 661 | + quickplayer - 0.0.1 662 | + rapidjson - 1.1.0-1 663 | + snappy - 1.1.7-1 664 | + sqlite3-cli - 3081101-1 665 | + strace - 4.8-1 666 | + stund - 0.97-1 667 | + syslog-ng - 3.0.5-5 668 | + terminfo - 5.9-2 669 | + traceroute - 2.1.0-1 670 | + ubi-utils - 1.5.1-2 671 | + ubox - 2017-09-01-d73e7d288-c086167a0154745c677f8730a336ea9cf7d71031 672 | + ubus - 2017-02-18-34c6e818-34c6e818 673 | + ubusd - 2017-02-18-34c6e818-34c6e818 674 | + uci - 2017-09-29-5ad59ad4.1-1 675 | + upnp-disc - 1 676 | + usign - 2015-05-08-cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131 677 | + vad-sdk - 1 678 | + voip - 0.0.1 679 | + volctl - 0.0.1 680 | + wget - 1.17.1-1 681 | + wpa-cli - 2017-08-24-3 682 | + wpa-supplicant - 2017-08-24-3 683 | + xiaoqiang-util - 1-1.1 684 | + zlib - 1.2.8-1 685 | + zoneinfo-core - 2015d-1 686 | 687 | #### uci 688 | 689 | ```bash 690 | uci show 691 | dhcp.@dnsmasq[0]=dnsmasq 692 | dhcp.@dnsmasq[0].domainneeded='1' 693 | dhcp.@dnsmasq[0].boguspriv='1' 694 | dhcp.@dnsmasq[0].filterwin2k='0' 695 | dhcp.@dnsmasq[0].localise_queries='1' 696 | dhcp.@dnsmasq[0].local='/lan/' 697 | dhcp.@dnsmasq[0].domain='lan' 698 | dhcp.@dnsmasq[0].expandhosts='1' 699 | dhcp.@dnsmasq[0].nonegcache='0' 700 | dhcp.@dnsmasq[0].authoritative='1' 701 | dhcp.@dnsmasq[0].readethers='0' 702 | dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases' 703 | dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.auto' 704 | dhcp.@dnsmasq[0].localservice='1' 705 | dhcp.lan=dhcp 706 | dhcp.lan.interface='lan' 707 | dhcp.lan.start='100' 708 | dhcp.lan.limit='150' 709 | dhcp.lan.leasetime='12h' 710 | dhcp.lan.ignore='1' 711 | dropbear.@dropbear[0]=dropbear 712 | dropbear.@dropbear[0].PasswordAuth='0' 713 | dropbear.@dropbear[0].RootPasswordAuth='0' 714 | dropbear.@dropbear[0].Port='22' 715 | network.loopback=interface 716 | network.loopback.ifname='lo' 717 | network.loopback.proto='static' 718 | network.loopback.ipaddr='127.0.0.1' 719 | network.loopback.netmask='255.0.0.0' 720 | network.lan=interface 721 | network.lan.ifname='wlan0' 722 | network.lan.proto='static' 723 | network.lan.ipaddr='10.0.0.1' 724 | network.lan.netmask='255.0.0.0' 725 | system.@system[0]=system 726 | system.@system[0].hostname='mico' 727 | system.@system[0].zonename='PRC' 728 | system.ntp=timeserver 729 | system.ntp.server='0.openwrt.pool.ntp.org' '1.openwrt.pool.ntp.org' '2.openwrt.pool.ntp.org' '3.openwrt.pool.ntp.org' 730 | system.ntp.enabled='1' 731 | system.ntp.enable_server='0' 732 | system.pns=pnsservice 733 | system.pns.tts_vendor='AiNiRobot:活泼可爱' 'XiaoMi:温柔知性' 734 | system.pns.vendor='soundai' 735 | system.pns.dummydev='on' 736 | system.pns.distrib_wakeup='on 737 | ``` 738 | 739 | #### process 740 | 741 | 742 | ```bash 743 | 744 | 1 root 2756 S /sbin/procd 745 | 2 root 0 SW [kthreadd] 746 | 3 root 0 SW [ksoftirqd/0] 747 | 5 root 0 SW< [kworker/0:0H] 748 | 6 root 0 SW [kworker/u8:0] 749 | 7 root 0 SW [rcu_preempt] 750 | 8 root 0 SW [rcu_sched] 751 | 9 root 0 SW [rcu_bh] 752 | 10 root 0 SW [migration/0] 753 | 11 root 0 SW [watchdog/0] 754 | 12 root 0 SW [watchdog/1] 755 | 13 root 0 SW [migration/1] 756 | 14 root 0 SW [ksoftirqd/1] 757 | 15 root 0 SW [kworker/1:0] 758 | 16 root 0 SW< [kworker/1:0H] 759 | 17 root 0 SW [watchdog/2] 760 | 18 root 0 SW [migration/2] 761 | 19 root 0 SW [ksoftirqd/2] 762 | 21 root 0 SW< [kworker/2:0H] 763 | 22 root 0 SW [watchdog/3] 764 | 23 root 0 SW [migration/3] 765 | 24 root 0 SW [ksoftirqd/3] 766 | 25 root 0 SW [kworker/3:0] 767 | 26 root 0 SW< [kworker/3:0H] 768 | 27 root 0 SW< [khelper] 769 | 28 root 0 SW [kdevtmpfs] 770 | 29 root 0 SW [kworker/u8:1] 771 | 33 root 0 SW< [suspend] 772 | 266 root 0 SW< [writeback] 773 | 269 root 0 SW< [bioset] 774 | 270 root 0 SW< [crypto] 775 | 272 root 0 SW< [kblockd] 776 | 285 root 0 SW< [devfreq_wq] 777 | 294 root 0 SW [kworker/0:1] 778 | 296 root 0 SW< [cfg80211] 779 | 418 root 0 SW [khungtaskd] 780 | 424 root 0 SW [kswapd0] 781 | 468 root 0 SW [fsnotify_mark] 782 | 522 root 0 SW [cfinteractive] 783 | 523 root 0 SW [NULL_task_for_h] 784 | 524 root 0 SW [cpu_hotplug_gdb] 785 | 525 root 0 RW [cpu_idle_gdbs] 786 | 531 root 0 SW< [binder] 787 | 550 root 0 SW [irq/248-sd_emmc] 788 | 631 root 0 RW [kworker/1:1] 789 | 646 root 0 SW< [ipv6_addrconf] 790 | 653 root 0 SW< [krfcommd] 791 | 659 root 0 SW< [deferwq] 792 | 675 root 0 SW [kworker/3:1] 793 | 680 root 0 SW [ubi_bgt0d] 794 | 683 root 0 SW [ubifs_bgt0_0] 795 | 707 root 0 SW [kworker/2:1] 796 | 868 root 2152 S /sbin/ubusd 797 | 869 root 2016 S /sbin/askfirst /bin/login 798 | 870 root 2016 S /sbin/askfirst /bin/ash --login 799 | 1230 root 0 SW [ubi_bgt1d] 800 | 1233 root 0 SW [ubifs_bgt1_0] 801 | 1323 root 2548 S /sbin/netifd 802 | 1340 root 146m S < /bin/ledserver 803 | 1436 root 3136 S /usr/sbin/crond -f -c /etc/crontabs -L /dev/null 804 | 1460 root 4520 S /usr/sbin/sshd -D 805 | 1465 root 6740 S {syslog-ng} supervising syslog-ng 806 | 1466 root 6992 S /usr/sbin/syslog-ng 807 | 1490 root 200m S /usr/bin/bsa_server -d /dev/ttyS1 -r 13 -lpm -p /etc/bt/bcmdhd_37M.hcd -u /var/run/ --all=0 808 | 1491 root 79692 S /usr/bin/mibt_ble 809 | 1525 root 82072 S /usr/bin/work_day_sync_service 810 | 1534 root 8652 S /usr/bin/xiaomi_dns_server 811 | 1576 root 0 SW [wl_event_handle] 812 | 1578 root 0 SW [dhd_watchdog_th] 813 | 1579 root 0 RW [dhd_dpc] 814 | 1580 root 0 SW [dhd_rxf] 815 | 1596 root 0 SW [kworker/0:2] 816 | 1626 root 3600 S /usr/sbin/wpa_supplicant -Dnl80211 -iwlan0 -c/data/wifi/wpa_supplicant.conf -s 817 | 1629 root 3032 S {wifi_check_ccmp} /bin/sh /bin/wifi_check_ccmp.sh 818 | 1664 root 3032 S udhcpc -f -S -s /bin/simple_dhcp.sh -R -t 0 -i wlan0 -x hostname MiAiSoundbox 819 | 1870 root 360m S /usr/bin/mediaplayer 820 | 1895 root 1056m S /usr/bin/messagingagent --handler_threads 8 821 | 1910 root 2484 S /usr/bin/notifyd 822 | 1940 root 2044 S /bin/wifitool 823 | 1972 root 7392 S /usr/bin/statpoints_daemon 824 | 3400 root 2237m S < /usr/bin/mipns-sai -c /usr/share/sai -l 825 | 3484 root 2052 S /bin/touchpad 826 | 3576 nobody 2032 S /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf -k -x /var/run/dnsmasq/dnsmasq.pid 827 | 3619 root 83680 S /usr/bin/dlna 828 | 3648 root 93476 S /usr/bin/upnp-disc 829 | 3705 root 2336 S /usr/bin/alarmd 830 | 3752 root 7444 S /usr/bin/mibrain_service 831 | 3765 root 76232 S /usr/bin/mico_ai_crontab 832 | 3781 root 2124 S /usr/bin/nano_httpd 833 | 3794 root 5052 S /usr/bin/pns_ubus_helper 834 | 3805 root 10832 S /usr/bin/quickplayer 835 | 3817 root 295m S /usr/bin/voip_service 836 | 3828 root 10272 S /usr/bin/volctl 837 | 3832 root 2164 S /usr/sbin/wpa_cli -a/bin/wpa_action.sh 838 | 3898 root 76220 S /usr/bin/miio_client -L /dev/null 839 | 3899 root 3032 S {miio_client_hel} /bin/sh /usr/bin/miio_client_helper 840 | 4104 root 1492 S /usr/bin/miio_recv_line 841 | 4298 root 2416 S /usr/bin/miio_service 842 | 4541 root 0 SW [kworker/2:2] 843 | 4548 root 7080 R sshd: root@ttyp0 844 | 4550 root 3200 S -ash 845 | 7293 root 3124 S bash 846 | 8941 root 0 SW [kworker/u8:2] 847 | 9783 root 2900 S sleep 5 848 | 9787 root 3200 R ps 849 | 850 | 851 | 852 | ``` 853 | -------------------------------------------------------------------------------- /ssh/etc/init.d/wireless: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | #author AlphaCN@gmail.com 3 | 4 | START=61 5 | 6 | USE_PROCD=1 7 | PROCD_DEBUG=1 8 | IS_SHOW_LED=1 9 | ROM_TYPE=$(uci -c /usr/share/mico get version.version.HARDWARE) 10 | HTPDATE_SYNC=1 11 | #BOARD_TYPE==4 : s12c 12 | BOARD_TYPE=`fw_env -g board_id` 1>/dev/null 2>/dev/null 13 | [ "$BOARD_TYPE" == "4" ] && { 14 | ROM_TYPE=s12c_marvell 15 | } 16 | #BOARD_TYPE==8 : s12c 17 | [ x"$BOARD_TYPE" == x"8" ] && { 18 | ROM_TYPE=s12c_marvell 19 | } 20 | ROM_TYPE=$(echo $ROM_TYPE|tr '[A-Z]' '[a-z]') 21 | logger -t wireless[$$] -p 3 "ROM TYPE $ROM_TYPE IS_SHOW_LED $IS_SHOW_LED" 22 | 23 | EXTRA_COMMANDS="ble_oauth miio_register andlink_register internet wifi post_miio post_ble boot_done boot_start config_mode scan trylock unlock trylock_wait reset conf_create" 24 | EXTRA_HELP="\ 25 | wifi connect wifi 26 | format: wifi timeout ssid password identity 27 | internet connect wifi and check internet 28 | ble_oauth ble register by oauth issue 29 | format: ble_oauth country uid ssid password identity 30 | miio_register miio register issue 31 | format: miio_register ssid password identity 32 | andlink_register andlink register issue 33 | format: miio_register configfile 34 | post_ble after ble register issue 35 | post_miio after miio register issue 36 | boot_done after boot complete 37 | config_mode set device config mode. 38 | scan ssid scan issue 1:not found 2:locked 0:found 39 | reset wifi reset for s12c marvell 40 | conf_create andlink register issue 41 | format: conf_create configfile ssid password identity" 42 | 43 | WIRELESS_CONF="/data/wifi/wpa_supplicant.conf" 44 | LOG_TITLE="/etc/init.d/wireless" 45 | ANDLINK_DIR="/data/andlink/" 46 | wireless_log() { 47 | logger -t wireless[$$] -p 3 "$*" 48 | #echo $* 49 | } 50 | 51 | file2log() 52 | { 53 | [ ! -f $1 ] && { 54 | wireless_log "file $1 not exist." 55 | return; 56 | } 57 | 58 | wireless_log "file $1 content:" 59 | 60 | while read oneline;do 61 | wireless_log "# "$oneline 62 | done < $1 63 | } 64 | 65 | show_led() 66 | { 67 | wireless_log "show_led IS_SHOW_LED $IS_SHOW_LED" 68 | [ $IS_SHOW_LED -eq 1 ] && { 69 | export LED_PARENT=$LOG_TITLE; 70 | /bin/show_led $1 1>/dev/null 2>/dev/null 71 | } 72 | } 73 | 74 | shut_led() 75 | { 76 | wireless_log "shut_led IS_SHOW_LED $IS_SHOW_LED" 77 | [ $IS_SHOW_LED -eq 1 ] && { 78 | export LED_PARENT=$LOG_TITLE; 79 | /bin/shut_led $1 1>/dev/null 2>/dev/null 80 | } 81 | } 82 | 83 | qplay() 84 | { 85 | ubus call qplayer play "{\"play\":\"$1\",\"light\":3}" 86 | } 87 | 88 | miplay() 89 | { 90 | show_led 3 1>/dev/null 2>/dev/null 91 | miplayer -f $1 1>/dev/null 2>/dev/null 92 | shut_led 3 1>/dev/null 2>/dev/null 93 | } 94 | 95 | #/tmp/ap_config_mode_flag 96 | file_create() 97 | { 98 | wireless_log "create file $1" 99 | touch $1 > /dev/null 2>&1 100 | sync 101 | } 102 | 103 | file_delete() 104 | { 105 | wireless_log "delete file $1" 106 | rm -f $1 > /dev/null 2>&1 107 | sync 108 | } 109 | 110 | file_trycp() 111 | { 112 | wireless_log "cp file $1 to $2" 113 | [ ! -f "$2" ] && { 114 | cp $1 $2 115 | sync 116 | } 117 | } 118 | 119 | ################################################################################################# 120 | #platform related functions 121 | ################################################################################################# 122 | SUPPORT_5G=0 123 | VOL_VALUE=100 124 | case $ROM_TYPE in 125 | s12|s12a|s12c_marvell) 126 | VOL_VALUE=100 127 | SUPPORT_5G=1 128 | ;; 129 | lx01) 130 | VOL_VALUE=200 131 | SUPPORT_5G=0 132 | ;; 133 | lx05a) 134 | VOL_VALUE=225 135 | SUPPORT_5G=0 136 | ;; 137 | l07a) 138 | VOL_VALUE=175 139 | SUPPORT_5G=0 140 | ;; 141 | lx05) 142 | VOL_VALUE=165 143 | SUPPORT_5G=0 144 | ;; 145 | lx06|l06a) 146 | VOL_VALUE=175 147 | SUPPORT_5G=1 148 | ;; 149 | esac 150 | 151 | try_insmod() 152 | { 153 | local has_mod="" 154 | has_mod=`lsmod | grep $1` 155 | [ "$has_mod" == "" ] && { 156 | insmod $1.ko $2 157 | } 158 | } 159 | 160 | lx05_update_map() 161 | { 162 | MAPFILE="/data/wifi/wifi_efuse_8723ds.map" 163 | country=$(uci -c /data/etc get binfo.binfo.country) 164 | country=${country:-CN} 165 | #CN /TW set B8 bit 20H 166 | [ "$country" == "CN" -o "$country" == "TW" ] && { 167 | wireless_log "update $MAPFILE" 168 | awk '{if(NR==11) $8=20; print $0}' $MAPFILE >$MAPFILE.tmp 169 | mv $MAPFILE.tmp $MAPFILE 170 | } 171 | } 172 | 173 | data_prepare() 174 | { 175 | [ ! -d "/data/wifi" ] && mkdir -p "/data/wifi" 176 | 177 | case $ROM_TYPE in 178 | s12|s12a) 179 | file_trycp /etc/wifi/nvram.txt /data/wifi/nvram.txt 180 | try_insmod dhd "firmware_path=/etc/wifi/fw_bcm43455c0_ag.bin nvram_path=/data/wifi/nvram.txt config_path=/data/wifi/config.txt" 181 | #wireless_log "prepare ap for $ROM_TYPE" 182 | 183 | echo -n 2 >/sys/module/dhd/parameters/op_mode 184 | break 185 | ;; 186 | lx01|lx05a) 187 | file_trycp /lib/firmware/nv_43436p.txt /data/wifi/nv_43436p.txt 188 | file_trycp /lib/firmware/nv_43438a1.txt /data/wifi/nv_43438a1.txt 189 | file_trycp /lib/firmware/config.txt /data/wifi/config.txt 190 | try_insmod bcmdhd 191 | 192 | echo -n /lib/firmware/fw_bcm4343_ag.bin > /sys/module/bcmdhd/parameters/firmware_path 193 | echo -n /data/wifi/ > /sys/module/bcmdhd/parameters/nvram_path 194 | echo -n 2 > /sys/module/bcmdhd/parameters/op_mode 195 | break; 196 | ;; 197 | s12c_marvell|lx06|l06a) 198 | mac_wifi=$(uci -c /data/etc get binfo.binfo.mac_wifi) 199 | country_code=`cat /data/wifi/config.txt | grep ccode | awk -F '=' '{print $2}'` 200 | wireless_log "Read country code is $country_code" 201 | country=${country:-CN} 202 | try_insmod mlan 203 | try_insmod sd8xxx "drv_mode=3 cfg80211_wext=0xf cal_data_cfg=mrvl/WlanCalData_ext.conf fw_name=mrvl/sdsd8977_combo_v2.bin 204 | sta_name=wlan mac_addr=$mac_wifi reg_alpha2=$country_code drvdbg=0x80007 ps_mode=2 auto_ds=2" 205 | #wireless_log "prepare data for $ROM_TYPE" 206 | ;; 207 | lx05|l07a) 208 | lx05_update_map 209 | try_insmod 8723ds "rtw_channel_plan=0x21" 210 | ;; 211 | esac 212 | } 213 | 214 | firmware_prepare_ap() 215 | { 216 | [ ! -d "/data/wifi" ] && mkdir -p "/data/wifi" 217 | case $ROM_TYPE in 218 | s12|s12a) 219 | file_trycp /etc/wifi/nvram.txt /data/wifi/nvram.txt 220 | try_insmod dhd "firmware_path=/etc/wifi/fw_bcm43455c0_ag.bin nvram_path=/data/wifi/nvram.txt config_path=/data/wifi/config.txt" 221 | echo -n 2 >/sys/module/dhd/parameters/op_mode 222 | break 223 | ;; 224 | lx01|lx05a) 225 | file_trycp /lib/firmware/nv_43436p.txt /data/wifi/nv_43436p.txt 226 | file_trycp /lib/firmware/nv_43438a1.txt /data/wifi/nv_43438a1.txt 227 | file_trycp /lib/firmware/config.txt /data/wifi/config.txt 228 | try_insmod bcmdhd 229 | echo -n /lib/firmware/fw_bcm4343_ag.bin > /sys/module/bcmdhd/parameters/firmware_path 230 | echo -n /data/wifi/ > /sys/module/bcmdhd/parameters/nvram_path 231 | echo -n 2 > /sys/module/bcmdhd/parameters/op_mode 232 | break; 233 | ;; 234 | s12c_marvell|lx06|l06a) 235 | mac_wifi=`uci -c /data/etc get binfo.binfo.mac_wifi` 236 | country_code=`cat /data/wifi/config.txt | grep ccode | awk -F '=' '{print $2}'` 237 | wireless_log "Read country code is $country_code" 238 | country=${country:-CN} 239 | 240 | try_insmod mlan 241 | try_insmod sd8xxx "drv_mode=3 cfg80211_wext=0xf cal_data_cfg=mrvl/WlanCalData_ext.conf fw_name=mrvl/sdsd8977_combo_v2.bin 242 | sta_name=wlan mac_addr=$mac_wifi reg_alpha2=$country_code drvdbg=0x80007 ps_mode=2 auto_ds=2" 243 | ;; 244 | lx05|l07a) 245 | lx05_update_map 246 | try_insmod 8723ds "rtw_channel_plan=0x21" 247 | ;; 248 | esac 249 | } 250 | 251 | firmware_prepare_sta() 252 | { 253 | [ ! -d "/data/wifi" ] && mkdir -p "/data/wifi" 254 | case $ROM_TYPE in 255 | s12|s12a) 256 | file_trycp /etc/wifi/nvram.txt /data/wifi/nvram.txt 257 | try_insmod dhd "firmware_path=/etc/wifi/fw_bcm43455c0_ag.bin nvram_path=/data/wifi/nvram.txt config_path=/data/wifi/config.txt" 258 | 259 | echo -n 0 >/sys/module/dhd/parameters/op_mode 260 | break; 261 | ;; 262 | lx01|lx05a) 263 | file_trycp /lib/firmware/nv_43436p.txt /data/wifi/nv_43436p.txt 264 | file_trycp /lib/firmware/nv_43438a1.txt /data/wifi/nv_43438a1.txt 265 | file_trycp /lib/firmware/config.txt /data/wifi/config.txt 266 | try_insmod bcmdhd 267 | 268 | echo -n /lib/firmware/fw_bcm4343_ag.bin > /sys/module/bcmdhd/parameters/firmware_path 269 | echo -n /data/wifi/ > /sys/module/bcmdhd/parameters/nvram_path 270 | echo -n 0 > /sys/module/bcmdhd/parameters/op_mode 271 | break; 272 | ;; 273 | s12c_marvell|lx06|l06a) 274 | mac_wifi=`uci -c /data/etc get binfo.binfo.mac_wifi` 275 | country_code=`cat /data/wifi/config.txt | grep ccode | awk -F '=' '{print $2}'` 276 | wireless_log "Read country code is $country_code" 277 | country=${country:-CN} 278 | 279 | try_insmod mlan 280 | try_insmod sd8xxx "drv_mode=3 cfg80211_wext=0xf cal_data_cfg=mrvl/WlanCalData_ext.conf fw_name=mrvl/sdsd8977_combo_v2.bin 281 | sta_name=wlan mac_addr=$mac_wifi reg_alpha2=$country_code drvdbg=0x80007 ps_mode=2 auto_ds=2" 282 | 283 | #wireless_log "prepare data for $ROM_TYPE" 284 | uap0_exist=`ifconfig | grep uap0` 285 | [ "x$uap0_exist" != "x" ] && { 286 | ifconfig uap0 down 287 | } 288 | ;; 289 | lx05|l07a) 290 | lx05_update_map 291 | try_insmod 8723ds "rtw_channel_plan=0x21" 292 | ;; 293 | esac 294 | } 295 | 296 | firmware_stop() 297 | { 298 | case $ROM_TYPE in 299 | s12|s12a) 300 | sleep 2 301 | rmmod dhd 302 | sleep 2 303 | break; 304 | ;; 305 | lx01|lx05a) 306 | sleep 2 307 | rmmod bcmdhd 308 | sleep 2 309 | break; 310 | ;; 311 | s12c_marvell|lx06|l06a) 312 | echo "do nothing for $ROM_TYPE" 313 | ;; 314 | lx05|l07a) 315 | echo "do nothing for $ROM_TYPE" 316 | ;; 317 | esac 318 | } 319 | 320 | firmware_reset() 321 | { 322 | #not called at this time 20180830 323 | return; 324 | 325 | [ "$ROM_TYPE" == "s12c_marvell" || "$ROM_TYPE" == "lx06" || "$ROM_TYPE" == "l06a" ] && { 326 | ifconfig wlan0 down 327 | #/etc/init.d/bluetooth call 328 | #rmmod bt8xxx.ko 329 | rmmod mlan.ko 330 | #rmmod sd8xxx.ko 331 | echo 0 > /sys/class/gpio/gpio78/value 332 | sleep 1 333 | echo 1 > /sys/class/gpio/gpio78/value 334 | sleep 1 335 | } 336 | } 337 | 338 | ap_model_get() 339 | { 340 | AP_MODEL="s12" 341 | case $ROM_TYPE in 342 | s12|s12a|s12c_marvell) 343 | AP_MODEL="s12" 344 | break; 345 | ;; 346 | lx05a) 347 | AP_MODEL="lx5a" 348 | break; 349 | ;; 350 | l07a) 351 | AP_MODEL="l7a" 352 | break; 353 | ;; 354 | *) 355 | AP_MODEL=$(echo $ROM_TYPE|tr '[A-Z]' '[a-z]') 356 | break; 357 | ;; 358 | esac 359 | 360 | wireless_log "ap model get $AP_MODEL" 361 | } 362 | 363 | wifi_signal_check_wl() 364 | { 365 | SIGNAL_CHECK_LOG="/tmp/signal_check.log" 366 | WHICH_SSID="$1" 367 | 368 | wireless_log "waiting for signal check scan done" 369 | wl scan --ssid=$WHICH_SSID 370 | sleep 3 371 | wl scanresults > $SIGNAL_CHECK_LOG 372 | wl scanabort 373 | file2log $SIGNAL_CHECK_LOG 374 | wireless_log "signal check scan complete" 375 | local scan_results=$(cat $SIGNAL_CHECK_LOG| grep "RSSI:" |awk -F" " '{print $4}') 376 | [ -z $scan_results ] && { 377 | wireless_log "ssid $1 scan fail" 378 | return 2; 379 | } 380 | 381 | [ $scan_results -lt -70 ] && { 382 | cp $SIGNAL_CHECK_LOG $SIGNAL_CHECK_LOG.backup 383 | wireless_log "ssid $1 signal weak" 384 | return 1; 385 | } 386 | 387 | return 0; 388 | } 389 | 390 | wifi_signal_check_rtl() 391 | { 392 | SIGNAL_CHECK_LOG="/tmp/signal_check.log" 393 | WHICH_SSID="$1" 394 | 395 | wireless_log "waiting for $WHICH_SSID signal check scan done" 396 | iw dev wlan0 scan ssid $WHICH_SSID >$SCAN_LOG 397 | local scan_results=$(cat $SCAN_LOG |grep signal |awk -F " " '{print $2}'|sed s/[[:space:]]//g) 398 | [ -z $scan_results ] && { 399 | wireless_log "ssid $1 scan fail" 400 | return 2; 401 | } 402 | 403 | [ $scan_results -lt -70 ] && { 404 | cp $SIGNAL_CHECK_LOG $SIGNAL_CHECK_LOG.backup 405 | wireless_log "ssid $1 signal weak" 406 | return 1; 407 | } 408 | 409 | return 0; 410 | } 411 | 412 | wifi_signal_check_marvell() 413 | { 414 | SIGNAL_CHECK_LOG="/tmp/signal_check.log" 415 | WHICH_SSID="$1" 416 | 417 | wireless_log "waiting for signal check scan done" 418 | mlanutl wlan0 setuserscan ssid=$WHICH_SSID >$SCAN_LOG 419 | local scan_results=$(cat $SCAN_LOG |grep $WHICH_SSID |awk -F "|" '{print $3}'|sed s/[[:space:]]//g) 420 | [ -z $scan_results ] && { 421 | wireless_log "ssid $1 scan fail" 422 | return 2; 423 | } 424 | 425 | [ $scan_results -lt -70 ] && { 426 | cp $SIGNAL_CHECK_LOG $SIGNAL_CHECK_LOG.backup 427 | wireless_log "ssid $1 signal weak" 428 | return 1; 429 | } 430 | 431 | return 0; 432 | } 433 | 434 | wifi_signal_check() 435 | { 436 | WHICH_SSID="$1" 437 | wireless_log "waiting for signal check ROM_TYPE $ROM_TYPE" 438 | case $ROM_TYPE in 439 | s12|s12a|lx01|lx05a) 440 | wifi_signal_check_wl $WHICH_SSID 441 | return $? 442 | ;; 443 | s12c_marvell|lx06|l06a) 444 | #wifi_signal_check_marvell 445 | return 0 446 | #do nothing for future use 447 | ;; 448 | lx05|l07a) 449 | wireless_log "waiting for signal check lx05" 450 | wifi_signal_check_rtl $WHICH_SSID 451 | return $? 452 | ;; 453 | *) 454 | wifi_signal_check_wl $WHICH_SSID 455 | return $? 456 | ;; 457 | esac 458 | 459 | return 0; 460 | } 461 | 462 | ################################################################################################# 463 | player_pause() 464 | { 465 | /usr/bin/mphelper pause 1>/dev/null 2>/dev/null 466 | } 467 | 468 | REGISTER_FLAG="/tmp/mico_reigister_is_working" 469 | unlock() 470 | { 471 | wireless_log "#LOCK# unlock `cat $REGISTER_FLAG`" 472 | rm -f $REGISTER_FLAG 473 | sync 474 | } 475 | 476 | trylock() 477 | { 478 | [ -f $REGISTER_FLAG ] && { 479 | wireless_log "#LOCK# already locked by $(cat $REGISTER_FLAG)." 480 | return 1; 481 | } 482 | 483 | echo "$1" > $REGISTER_FLAG 484 | sync 485 | wireless_log "#LOCK# $1 lock success." 486 | return 0; 487 | } 488 | 489 | #if locked by $WHICH_LOCK, wait 490 | #if not locked by $WHICH_LOCK, fail 491 | #if not locked, trylock, success 492 | #if timeout, fail. 493 | trylock_wait() 494 | { 495 | TIMEOUT=$3 496 | WHICH_LOCK=$1 497 | MY_LOCK=$2 498 | wireless_log "#LOCK# wait lock $WHICH_LOCK, timeout $TIMEOUT" 499 | local wait_times=0 500 | while true; 501 | do 502 | [ $((${wait_times})) -ge $TIMEOUT ] && { 503 | wireless_log "#LOCK# wait lock $WHICH_LOCK timeout. fail." 504 | return 1 505 | }; 506 | 507 | 508 | [ ! -f $REGISTER_FLAG ] && { 509 | echo "$MY_LOCK" > $REGISTER_FLAG 510 | sync 511 | wireless_log "#LOCK# $MY_LOCK lock success." 512 | return 0; 513 | } 514 | 515 | CURRENT_LOCK=$(cat $REGISTER_FLAG) 516 | [ "$CURRENT_LOCK" != "$WHICH_LOCK" ] && { 517 | wireless_log "#LOCK# current locked by $CURRENT_LOCK, not by lock $WHICH_LOCK, fail." 518 | return 1; 519 | }; 520 | wireless_log "#LOCK# wait lock $WHICH_LOCK, $wait_times times" 521 | wait_times=$((${wait_times}+1)); 522 | sleep 1; 523 | done 524 | 525 | return 1 526 | } 527 | 528 | hostapd_start() 529 | { 530 | wireless_log "host apd start." 531 | HOSTAPD_CONFIG="/tmp/hostapd.conf" 532 | ap_model_get 533 | 534 | sn=$(getmac.sh sn) 535 | sn_poststr=${sn:$((${#sn}-4))} 536 | ssid=xiaomi-wifispeaker-${AP_MODEL}_miap${sn_poststr:-0001} 537 | 538 | #random chanel 539 | channel=$(($(date +%s)%11+1)) 540 | wireless_log "ap mode channel=$channel $newssid ssid:$ssid" 541 | 542 | #format see /etc/wifi/hostapd.conf 543 | echo "ssid=${ssid} 544 | channel=${channel} 545 | interface=wlan0 546 | driver=nl80211 547 | wpa=0 548 | rsn_pairwise=CCMP" > $HOSTAPD_CONFIG 549 | sync 550 | 551 | [ "$ROM_TYPE" == "s12c_marvell" || "$ROM_TYPE" == "lx06" || "$ROM_TYPE" == "l06a" ] && { 552 | echo " 553 | hw_mode=g 554 | ieee80211n=1 555 | ht_capab=[SHORT-GI-20]" >> $HOSTAPD_CONFIG 556 | } 557 | 558 | hostapd -d -P /tmp/hostapd.pid $HOSTAPD_CONFIG >/tmp/hostapd.log & 559 | } 560 | 561 | #配网成功后脚本会自己退出 562 | aptimer_start() { 563 | #for ccmp error 564 | [ -f $WIRELESS_CONF ] && { 565 | wireless_log "ap timer will not start." 566 | return 0 567 | } 568 | 569 | [ -f "/data/status/config_done" ] && { 570 | wireless_log "ap timer will not start." 571 | return 0 572 | } 573 | 574 | wireless_log "ap timer start." 575 | killall -9 ap_timer.sh >/dev/null 2>&1 576 | /usr/bin/ap_timer.sh & >/dev/null 2>&1 577 | } 578 | 579 | 580 | wait_dhcp_done() 581 | { 582 | local wpa_result="/tmp/wpa_supplicant_auth_result" 583 | local wait_times=0 584 | echo "waiting dhcp done $wait_times" 585 | while true; 586 | do 587 | [ -f "$wpa_result" ] && { 588 | dhcp_done=0; 589 | break 590 | } 591 | 592 | [ -f "/data/status/dhcp_done" ] && { 593 | dhcp_done=1; 594 | break; 595 | } 596 | 597 | [ $((${wait_times})) -ge $1 ] && { 598 | dhcp_done=0; 599 | break 600 | }; 601 | 602 | wireless_log "waiting dhcp done $wait_times" 603 | echo "waiting dhcp done $wait_times" 604 | wait_times=$((${wait_times}+1)); 605 | sleep 1; 606 | done 607 | } 608 | 609 | conf_delete() 610 | { 611 | rm -f $WIRELESS_CONF 1>/dev/null 2>/dev/null 612 | sync 613 | } 614 | 615 | conf_create() 616 | { 617 | local _ssid=$2 618 | local _password=$3 619 | local _identity=$4 620 | local countryconf="" 621 | local wireless_conf=$1 622 | local _country=$(uci -c /data/etc get binfo.binfo.country) 623 | _country=${_country:-CN} 624 | 625 | mkdir -p /data/wifi/ 626 | 627 | wireless_log "Create wifi config file: $_config_file" 628 | [ "${wireless_conf}" == "" ] && wireless_conf=$WIRELESS_CONF 629 | 630 | [ "$ROM_TYPE" == "s12c_marvell" || "$ROM_TYPE" == "lx06" || "$ROM_TYPE" == "l06a" ] && { 631 | countryconf="country=$_country" 632 | } 633 | 634 | #MIBT_CONFIG_WIFI_WPAEAP 635 | [ "$_identity" != "" -a "$_password" != "" ] && { 636 | echo -e "ctrl_interface=/var/run/wpa_supplicant 637 | ap_scan=1 638 | $countryconf 639 | 640 | network={ 641 | ssid=\"$_ssid\" 642 | scan_ssid=1 643 | key_mgmt=WPA-EAP IEEE8021X 644 | eap=PEAP 645 | identity=\"$_identity\" 646 | password=\"$_password\" 647 | phase2=\"\" 648 | }" > ${wireless_conf} 649 | sync 650 | return; 651 | } 652 | 653 | #MIBT_CONFIG_WIFI_WPA 654 | [ "$_password" != "" ] && { 655 | [ ${#_password} -eq 64 ] && { 656 | #len == 64 means HEX 657 | echo -e "ctrl_interface=/var/run/wpa_supplicant 658 | ap_scan=1 659 | $countryconf 660 | 661 | network={ 662 | ssid=\"$_ssid\" 663 | psk=$_password 664 | scan_ssid=1 665 | key_mgmt=WPA-PSK 666 | }\n" > ${wireless_conf} 667 | sync 668 | return; 669 | } 670 | 671 | echo -e "ctrl_interface=/var/run/wpa_supplicant 672 | ap_scan=1 673 | $countryconf 674 | 675 | network={ 676 | ssid=\"$_ssid\" 677 | psk=\"$_password\" 678 | scan_ssid=1 679 | key_mgmt=WPA-PSK 680 | }\n" > ${wireless_conf} 681 | sync 682 | return; 683 | } 684 | 685 | #MIBT_CONFIG_WIFI_OPEN 686 | echo -e "ctrl_interface=/var/run/wpa_supplicant 687 | ap_scan=1 688 | $countryconf 689 | 690 | network={ 691 | ssid=\"$_ssid\" 692 | scan_ssid=1 693 | key_mgmt=NONE 694 | }\n" > ${wireless_conf} 695 | sync 696 | return; 697 | } 698 | 699 | app_restart_check() 700 | { 701 | /etc/init.d/messagingagent restart >/dev/null 2>&1 702 | /etc/init.d/mediaplayer restart >/dev/null 2>&1 703 | /etc/init.d/alarm restart >/dev/null 2>&1 704 | /etc/init.d/pns restart >/dev/null 2>&1 705 | sleep 1 706 | } 707 | 708 | country_change_check() 709 | { 710 | [ ! -f "/data/status/config_done" ] && { 711 | wireless_log "conifg not done, will not check country" 712 | return 0 713 | } 714 | 715 | local _ccode=$1 716 | local _old=$(uci -c /data/etc get binfo.binfo.country) 717 | _ccode=$(echo $_ccode|tr '[a-z]' '[A-Z]') 718 | _old=$(echo $_old|tr '[a-z]' '[A-Z]') 719 | _ccode=${_ccode:-CN} 720 | _ccode=${_ccode//NULL/CN} 721 | _old=${_old:-CN} 722 | 723 | wireless_log "country old $_old new $_ccode" 724 | [ "$_ccode" != "$_old" ] && { 725 | wireless_log "config mode country changed, not allow" 726 | return 1 727 | } 728 | 729 | return 0 730 | } 731 | 732 | register_user_write() 733 | { 734 | wireless_log "write register time and uid." 735 | echo $(date +"%Y-%m-%d %H:%M:%S") >/data/status/register_date 736 | echo "$1" >/data/status/register_user 737 | 738 | fsync /data/status/register_date 739 | fsync /data/status/register_user 740 | } 741 | 742 | register_info_write() 743 | { 744 | wireless_log "write register country ssid" 745 | echo CCODE:$1 >/data/status/register_info 746 | echo SSID:$2 >>/data/status/register_info 747 | echo PASSWORD:$3 >>/data/status/register_info 748 | echo IDENTIFY:$4 >>/data/status/register_info 749 | fsync /data/status/register_info 750 | } 751 | 752 | register_type_write() 753 | { 754 | echo $1 >/data/status/register_type 755 | fsync /data/status/register_type 756 | } 757 | 758 | country_code_delete() 759 | { 760 | [ -f "/data/status/config_done" ] && { 761 | wireless_log "conifg already done, will not clean country" 762 | return 0 763 | } 764 | 765 | uci -c /data/etc/ delete binfo.binfo.country 1>/dev/null 2>/dev/null 766 | uci -c /data/etc/ commit 1>/dev/null 2>/dev/null 767 | } 768 | 769 | country_code_update() 770 | { 771 | local _ccode=$1 772 | local _regrev 773 | local _config_file="/data/wifi/config.txt" 774 | local _old=$(uci -c /data/etc get binfo.binfo.country) 775 | _ccode=$(echo $_ccode|tr '[a-z]' '[A-Z]') 776 | _old=$(echo $_old|tr '[a-z]' '[A-Z]') 777 | _ccode=${_ccode:-CN} 778 | _ccode=${_ccode//NULL/CN} 779 | _old=${_old:-CN} 780 | 781 | wireless_log "Update wifi config file: $_config_file" 782 | 783 | _ccode_write=$_ccode 784 | if [ "$_ccode" == "CN" ]; then 785 | _regrev=38 786 | elif [ "$_ccode" == "TW" ]; then 787 | _regrev=0 788 | [ "$ROM_TYPE" == "s12a" ] && { 789 | _regrev=38 790 | _ccode_write="CN" 791 | } 792 | 793 | [ "$ROM_TYPE" == "s12c_marvell" || "$ROM_TYPE" == "lx06" || "$ROM_TYPE" == "l06a" ] && { 794 | _ccode_write="TW/2" 795 | } 796 | else 797 | wireless_log "The country code is invalid" 798 | return 799 | fi 800 | 801 | wireless_log "The country code $_ccode write $_ccode_write" 802 | uci -c /data/etc/ set binfo.binfo.country=$_ccode 803 | uci -c /data/etc/ commit 804 | 805 | /bin/config_update.sh $_config_file ccode=$_ccode_write 1>/dev/null 2>/dev/null 806 | /bin/config_update.sh $_config_file regrev=$_regrev 1>/dev/null 2>/dev/null 807 | 808 | sync 809 | [ "$_ccode" != "$_old" ] && { 810 | wireless_log "country code $_ccode old $_old, restart app and firmware." 811 | app_restart_check 812 | firmware_reset 813 | } 814 | } 815 | 816 | config_start_sound() 817 | { 818 | miplayer -f /usr/share/sound/init_wifi_config.mp3 >/dev/null 2>/dev/null & 819 | } 820 | 821 | internet_check() 822 | { 823 | [ $HTPDATE_SYNC -eq 1 ] && { 824 | wireless_log "checking internet, time sync...." 825 | htpdate -d -l -t -s www.mi.com 826 | } 827 | wireless_log "checking internet...." 828 | 829 | local check_url="https://api2.mina.mi.com/ping" 830 | [ "$country" == "TW" ] && { 831 | check_url="https://tw.api2.mina.mi.com/ping" 832 | } 833 | 834 | SLEEP_TIME=8 835 | MAX_TIME=25 836 | MAX_WAIT_TIMES=8 837 | time_start=$(date +%s) 838 | time_expire=$((time_start + MAX_TIME)) 839 | local wait_times=0 840 | 841 | wireless_log "start:$time_start expire:$time_expire waittimes $wait_times url $check_url" 842 | sleep 1 843 | while true; 844 | do 845 | connect_result=$(curl --connect-timeout 3 $check_url) 846 | [ "$connect_result" == "good" ] && { 847 | wireless_log "checking internet curl return \"$connect_result\", return" 848 | network_ready=1; 849 | return 0; 850 | } 851 | 852 | wireless_log "checking internet curl return \"$connect_result\", retry" 853 | time_now=$(date +%s) 854 | [ $time_now -gt $time_expire -a $wait_times -gt $MAX_WAIT_TIMES ] && { 855 | wireless_log "checking internet expire \"$connect_result\", exit" 856 | network_ready=0; 857 | return 858 | } 859 | 860 | wireless_log "waiting internet check done $wait_times" 861 | echo "waiting internet check done $wait_times" 862 | wait_times=$((${wait_times}+1)); 863 | 864 | sleep 1; 865 | done 866 | 867 | echo "fail" 868 | return 1; 869 | } 870 | 871 | 872 | scan_stop() 873 | { 874 | [ "$ROM_TYPE" != "s12c_marvell" ] && { 875 | wl scanabort 876 | } 877 | } 878 | 879 | SCAN_LOCK="scan" 880 | scan() 881 | { 882 | SCAN_LOG="/tmp/wireless_scan.log" 883 | WHICH_SSID=$1 884 | 885 | trylock $SCAN_LOCK 886 | [ $? != 0 ] && { 887 | wireless_log "already proessing a regiser issue, stop scan" 888 | exit 2; 889 | } 890 | case $ROM_TYPE in 891 | s12|s12a|lx01|lx05a) 892 | wl scan --ssid=$WHICH_SSID 893 | sleep 3 894 | wl scanresults > $SCAN_LOG 895 | wl scanabort 896 | cat $SCAN_LOG |grep "^SSID:"|grep "\"$WHICH_SSID\"" 897 | local scan_results=$(cat $SCAN_LOG |grep "^SSID:"|grep "\"$WHICH_SSID\""|wc -l) 898 | #CURRENT_BSSID=$(cat $SCAN_LOG |grep BSSID|awk '{print $2}') 899 | ;; 900 | s12c_marvell|lx06|l06a) 901 | #mlanutl wlan0 setuserscan ssid=$WHICH_SSID >$SCAN_LOG 902 | #local scan_results=$(cat $SCAN_LOG |grep "\"$WHICH_SSID\""|wc -l) 903 | ;; 904 | lx05|l07a) 905 | echo "do nothing for $ROM_TYPE" 906 | ;; 907 | esac 908 | 909 | #mico_log "waiting for scan done $wait_times" 910 | [ $scan_results -eq 1 ] && { 911 | cp $SCAN_LOG $SCAN_LOG.backup 912 | unlock 913 | exit 1; 914 | } 915 | unlock 916 | exit 0; 917 | } 918 | 919 | wireless_stop() 920 | { 921 | /etc/init.d/dnsmasq stop >/dev/null 2>&1 922 | /etc/init.d/dhcpc stop >/dev/null 2>&1 923 | /etc/init.d/odhcp6c stop >/dev/null 2>&1 924 | case $ROM_TYPE in 925 | s12|s12a|lx01|lx05a) 926 | wl disassoc 927 | ;; 928 | esac 929 | 930 | killall -9 wireless_point.sh >/dev/null 2>&1 931 | killall -9 miio_service >/dev/null 2>&1 932 | killall -9 wifi_check_ccmp.sh >/dev/null 2>&1 933 | killall -9 hostapd >/dev/null 2>&1 934 | . /lib/functions/procd.sh 935 | 936 | #urgly fix for destroy useless socket files 937 | rm -f /tmp/wpa_ctrl_* 938 | procd_kill "wireless" 939 | #for ccmp error 940 | ifconfig wlan0 down 941 | 942 | firmware_stop 943 | } 944 | 945 | ap_start() 946 | { 947 | show_led 6 948 | wireless_log "miio enter ap config mode" 949 | ubus call mibt ble '{"action":"display"}' 950 | file_create "/tmp/ap_config_mode_flag" 951 | if [ ! -f "/data/status/config_done" ] 952 | then 953 | wireless_log "set ap config mode start" 954 | firmware_prepare_ap 955 | 956 | ifconfig wlan0 up 957 | sleep 2s 958 | ifconfig wlan0 10.0.0.1 959 | 960 | case $ROM_TYPE in 961 | s12|s12a|lx01|lx05a) 962 | bssid=`matool_get_mac` 963 | wl down 964 | wl cur_etheraddr $bssid 965 | wl up 966 | ;; 967 | esac 968 | 969 | hostapd_start 970 | 971 | /etc/init.d/miio restart 972 | /etc/init.d/dnsmasq restart 973 | wireless_log "set ap config mode finish" 974 | ifconfig wlan0 10.0.0.1 975 | else 976 | data_prepare 977 | fi 978 | 979 | } 980 | 981 | sta_start() 982 | { 983 | local wireless_conf=$1 984 | 985 | [ "${wireless_conf}" == "" ] && wireless_conf=$WIRELESS_CONF 986 | firmware_prepare_sta 987 | ifconfig wlan0 up 988 | # A workaround to improve network performance under low SNR wifi link on LX01 989 | case "$ROM_TYPE" in LX01|lx01*) ifconfig wlan0 mtu 900;; esac 990 | #/usr/sbin/wpa_supplicant -Dnl80211 -iwlan0 -c${wireless_conf} & >/dev/null 2>&1 991 | #/usr/sbin/wpa_cli -a/bin/wpa_action.sh & >/dev/null 2>&1 992 | scan_stop 993 | . /lib/functions/procd.sh 994 | 995 | procd_kill "wireless" 996 | procd_open_service "wireless" 997 | procd_open_instance 998 | procd_set_param command /usr/sbin/wpa_supplicant -Dnl80211 -iwlan0 -c${wireless_conf} -s 999 | #procd_set_param command /usr/sbin/wpa_supplicant -Dnl80211 -iwlan0 -c${wireless_conf} -s -dd 1000 | procd_set_param respawn 3600 5 0 1001 | procd_close_instance 1002 | 1003 | procd_open_instance 1004 | procd_set_param command /usr/sbin/wpa_cli -a/bin/wpa_action.sh 1005 | procd_set_param respawn 3600 5 0 1006 | procd_close_instance 1007 | procd_close_service 1008 | 1009 | case $ROM_TYPE in 1010 | s12|s12a|lx01|lx05a) 1011 | /bin/wifi_check_ccmp.sh & 1012 | ;; 1013 | esac 1014 | 1015 | wireless_log "wpa config file:${wireless_conf}" 1016 | /etc/init.d/dhcpc restart >/dev/null 2>&1 1017 | /etc/init.d/odhcp6c restart >/dev/null 2>&1 1018 | } 1019 | 1020 | config_clean() 1021 | { 1022 | shut_led 10 1023 | show_led 6 1024 | wireless_stop > /dev/null 2>&1; 1025 | conf_delete > /dev/null 2>&1; 1026 | country_code_delete 1027 | rm -rf $ANDLINK_DIR 1028 | miplay /usr/share/sound/setup_failure.opus & 1029 | ap_start >/dev/null 2>&1 1030 | } 1031 | 1032 | user_data_clean() 1033 | { 1034 | rm /data/alarm -r -f > /dev/null 2>&1; 1035 | rm /data/timer -r -f > /dev/null 2>&1; 1036 | # rm /data/status -r -f > /dev/null 2>&1; 1037 | rm /data/messagingagent -r -f > /dev/null 2>&1; 1038 | rm /data/.mediaplayerconfig -r -f> /dev/null 2>&1; 1039 | rm /data/miio -r -f > /dev/null 2>&1; 1040 | rm /data/mibrain/mibrain_asr_nlp.rcd > /dev/null 2>&1; 1041 | rm /data/bt/bt_devices.xml > /dev/null 2>&1; 1042 | rm /data/bt/bt_av_devices.xml > /dev/null 2>&1; 1043 | rm /data/upnp-disc -r -f > /dev/null 2>&1; 1044 | rm /data/dts_conf -r -f > /dev/null 2>&1; 1045 | rm /data/voip -r -f > /dev/null 2>&1; 1046 | rm /data/player/volume.cfg 1047 | sync 1048 | /etc/init.d/alarm restart; 1049 | /etc/init.d/voip restart; 1050 | /etc/init.d/mediaplayer restart; 1051 | /etc/init.d/messagingagent restart; 1052 | /etc/init.d/miio restart; 1053 | /etc/init.d/pns restart 1054 | /etc/init.d/mibrain_service restart 1055 | /etc/init.d/sound_effect restart 1056 | } 1057 | 1058 | wifi() 1059 | { 1060 | show_led 10 1061 | wireless_log "try connect wifi ssid:$2 password:$3 identity:$4 timeout:$1" 1062 | wireless_stop >/dev/null 2>&1 1063 | 1064 | SSID=$(echo "$2" |sed s#'\\'#'\\\\'#g) 1065 | PASSWORD=$(echo "$3" |sed s#'\\'#'\\\\'#g) 1066 | 1067 | conf_create /tmp/wpa_supplicant.conf "$SSID" "$PASSWORD" "$4" >/dev/null 2>&1 1068 | 1069 | sta_start /tmp/wpa_supplicant.conf >/dev/null 2>&1 1070 | 1071 | show_led 10 1072 | 1073 | wireless_log "waiting for dhcp done" 1074 | wait_dhcp_done "$1" >/dev/null 2>&1 1075 | [ "$dhcp_done" == "0" ] && { 1076 | wireless_log "wifi connect fail." 1077 | config_clean 1078 | echo "dhcpfail" 1079 | return 1 1080 | }; 1081 | 1082 | #export LED_PARENT=$0; 1083 | #/bin/shut_led 10 1>/dev/null 2>/dev/null 1084 | echo "success" 1085 | return 0; 1086 | } 1087 | 1088 | internet() 1089 | { 1090 | wpa_result="/tmp/wpa_supplicant_auth_result" 1091 | wireless_stop 1>/dev/null 2>/dev/null 1092 | wireless_log "try connect internet ssid:$2 password:$3 identity:$4 timeout:$1" 1093 | 1094 | SSID=$(echo "$2" |sed s#'\\'#'\\\\'#g) 1095 | PASSWORD=$(echo "$3" |sed s#'\\'#'\\\\'#g) 1096 | 1097 | conf_create $WIRELESS_CONF "$SSID" "$PASSWORD" "$4" >/dev/null 2>&1 1098 | 1099 | file_delete $wpa_result >/dev/null 2>&1 1100 | sta_start $WIRELESS_CONF >/dev/null 2>&1 1101 | 1102 | wireless_log "waiting for dhcp done" 1103 | 1104 | wait_dhcp_done "$1" 1>/dev/null 2>/dev/null 1105 | [ "$dhcp_done" == "0" ] && { 1106 | wireless_log "wifi connect fail." 1107 | 1108 | 1109 | [ -f "$wpa_result" ] && { 1110 | [ $(cat $wpa_result) == "key_mgmt_mismatch" ] && { 1111 | echo "key_mgmt_mismatch" 1112 | } || { 1113 | echo "authfail" 1114 | } 1115 | 1116 | config_clean 1117 | file_delete $wpa_result >/dev/null 2>&1 1118 | return 5; 1119 | } 1120 | 1121 | config_clean 1122 | wifi_signal_check $SSID 1123 | local check_result=$? 1124 | wireless_log "wifi connect fail signal check result $check_result." 1125 | [ $check_result -eq 2 ] && { 1126 | #ssidnotfound --> 1127 | echo "ssidnotfound" 1128 | return 4; 1129 | } 1130 | 1131 | [ $check_result -eq 1 ] && { 1132 | echo "signalweak" 1133 | return 3; 1134 | } 1135 | 1136 | echo "dhcpfail" 1137 | return 1 1138 | }; 1139 | wireless_log "waiting for dhcp done fininsh" 1140 | 1141 | internet_check 1>/dev/null 2>/dev/null 1142 | [ "$network_ready" -eq "0" ] && { 1143 | config_clean 1144 | echo "networkfail" 1145 | return 2; 1146 | } 1147 | 1148 | echo "success" 1149 | return 0; 1150 | } 1151 | 1152 | #################################### BOOT DONE ##################################################### 1153 | # -->/etc/init.d/done 1154 | boot_start() 1155 | { 1156 | MEDIA_CONF_FILE="/data/player/volume.cfg" 1157 | if [ -f $MEDIA_CONF_FILE ]; then 1158 | config_volume=$(grep "volume" $MEDIA_CONF_FILE | cut -f2 -d'"') 1159 | wireless_log "config_volume:"$config_volume 1160 | if [ -n "$config_volume" ] && [ "$config_volume" -ge "0" ] && [ "$config_volume" -le "255" ]; then 1161 | VOL_VALUE=$config_volume 1162 | else 1163 | wireless_log "wrong config_volume:"$config_volume 1164 | fi 1165 | fi 1166 | 1167 | wireless_log "boot start volume $VOL_VALUE" 1168 | amixer sset mysoftvol $VOL_VALUE 1169 | [ -x /bin/silentboot.sh ] && si_flag=`/bin/silentboot.sh get` 1170 | if [ "$si_flag" = "1" ]; then 1171 | wireless_log "Silent boot mode... skip bootup start sound." 1172 | else 1173 | miplay /usr/share/sound/bootup.mp3 & 1174 | fi 1175 | } 1176 | 1177 | boot_done() 1178 | { 1179 | MEDIA_CONF_FILE="/data/player/volume.cfg" 1180 | if [ -f $MEDIA_CONF_FILE ]; then 1181 | config_volume=$(grep "volume" $MEDIA_CONF_FILE | cut -f2 -d'"') 1182 | wireless_log "config_volume:"$config_volume 1183 | if [ -n "$config_volume" ] && [ "$config_volume" -ge "0" ] && [ "$config_volume" -le "255" ]; then 1184 | VOL_VALUE=$config_volume 1185 | else 1186 | wireless_log "wrong config_volume:"$config_volume 1187 | fi 1188 | fi 1189 | 1190 | wireless_log "boot done volume $VOL_VALUE" 1191 | amixer sset mysoftvol $VOL_VALUE 1192 | if [ ! -f "/data/status/config_done" ]; then 1193 | ubus -t 10 wait_for mediaplayer 1194 | /etc/init.d/pns stop 1195 | 1196 | mphelper tone /usr/share/sound/welcome.opus 1197 | /etc/init.d/pns start 1198 | else 1199 | [ -x /bin/silentboot.sh ] && si_flag=`/bin/silentboot.sh get` 1200 | if [ "$si_flag" = "1" ]; then 1201 | wireless_log "Silent boot mode... skip bootup done sound." 1202 | else 1203 | miplay /usr/share/sound/bootup.mp3 & 1204 | fi 1205 | fi 1206 | 1207 | aptimer_start 1208 | } 1209 | 1210 | #################################### POST MIIO ISSUE ############################################## 1211 | # -->config_mode ->touchpad 1212 | config_mode() 1213 | { 1214 | #force unlock 1215 | [ ! -f "/data/status/config_done" ] && { 1216 | wireless_log "not config done, dismiss config mode." 1217 | wireless_log " config mode will not exit for temp" 1218 | #exit 1 1219 | } 1220 | 1221 | unlock 1222 | 1223 | wireless_log "config mode volume $VOL_VALUE." 1224 | wireless_log "config mode remove config file." 1225 | rm -f /data/status/mico_try_register_times 1226 | conf_delete 1227 | sync 1228 | file2log $WIRELESS_CONF 1229 | #equipment binding information exists, 1230 | #disconnect wireless to ensure that the device is in a stop service state 1231 | player_pause 1232 | show_led 6 1233 | amixer sset mysoftvol $VOL_VALUE 1234 | 1235 | sleep 1 1236 | 1237 | case $ROM_TYPE in 1238 | l07a) 1239 | ubus -t 1 call qplayer play {\"play\":\"/usr/share/sound/enter_config_mode_l07a.opus\"} 1240 | break; 1241 | ;; 1242 | *) 1243 | miplay /usr/share/sound/enter_config_mode.wav 1244 | break; 1245 | ;; 1246 | esac 1247 | 1248 | wireless_log "config mode try restart miio." 1249 | [ -f $WIRELESS_CONF ] && { 1250 | mv $WIRELESS_CONF /tmp/wpa_supplicant.conf.useless 1251 | wireless_log "config mode wait 3 seconds, retry delete conf." 1252 | } 1253 | /etc/init.d/mibt_mesh_proxy stop 1254 | /etc/init.d/bluetooth restart 1255 | /etc/init.d/mibt_mesh_proxy restart 1256 | /etc/init.d/wireless restart 1257 | /etc/init.d/voip restart 1258 | 1259 | file2log $WIRELESS_CONF 1260 | wireless_log "config mode restart miio." 1261 | /etc/init.d/miio restart 1262 | #ubus call mibt enable '{"btmode":"ble", "action":"close"}' 1263 | } 1264 | 1265 | andlink_enable() 1266 | { 1267 | custom_type=$(uci -c /data/etc/ get binfo.binfo.custom) 1268 | wireless_log "test andlink enable, type $custom_type" 1269 | [ x"$custom_type" == x"CMCC" ] && { 1270 | wireless_log "try andlink enabled" 1271 | /etc/init.d/cmcc_andlink enable >/dev/null 2>&1 1272 | } 1273 | } 1274 | 1275 | #################################### POST MIIO ISSUE ############################################## 1276 | # -->miio_client_helper 1277 | post_miio() 1278 | { 1279 | wireless_log "miio exit ap config mode" 1280 | file_delete "/tmp/ap_config_mode_flag" 1281 | file_create /data/status/config_done 1282 | /etc/init.d/dnsmasq restart 1283 | ubus call mibt enable '{"btmode":"ble", "action":"close"}' 1284 | ubus call mibt enable '{"btmode":"classic", "action":"close"}' 1285 | /bin/shut_led 10 1286 | 1287 | andlink_enable >/dev/null 2>&1 1288 | /etc/init.d/cmcc_ims restart >/dev/null 2>&1 1289 | nice -n -10 miplayer -f /usr/share/sound/network_done_miio.mp3 & 1290 | } 1291 | 1292 | 1293 | 1294 | #################################### MIIO ######################################################### 1295 | # -->miio_client_helper 1296 | miio_register() 1297 | { 1298 | uid=$1 1299 | country=$2 1300 | ssid=$3 1301 | password=$4 1302 | identity=$5 1303 | 1304 | config_start_sound 1305 | show_led 10 1306 | #trylock "miio" 1307 | 1308 | trylock_wait $SCAN_LOCK "miio" 10 1309 | [ $? != 0 ] && { 1310 | shut_led 10 1311 | wireless_log "already proessing a regiser issue, stop miio" 1312 | echo "already_in_register" 1313 | exit 1; 1314 | } 1315 | 1316 | 1317 | #remove for cmcc-ims 1318 | #connect_times_update 1319 | player_pause 1320 | country_code_update $country 1321 | internet 16 "$ssid" "$password" 1322 | [ "$?" != "0" ] && { 1323 | wireless_log "dhcp faild!" 1324 | unlock 1325 | exit 1; 1326 | } 1327 | 1328 | unlock 1329 | 1330 | register_user_write "$uid" 1>/dev/null 2>/dev/null 1331 | register_info_write "$country" "$ssid" "$password" "$identity" 1>/dev/null 2>/dev/null 1332 | register_type_write miio 1>/dev/null 2>/dev/null 1333 | exit 0; 1334 | } 1335 | 1336 | miio_stop() 1337 | { 1338 | /etc/init.d/miio stop 1339 | } 1340 | 1341 | miio_start() 1342 | { 1343 | file_delete /data/miio/miio_sessionid 1344 | file_delete /data/miio/miio_token 1345 | /etc/init.d/miio restart 1>/dev/null 2>/dev/null 1346 | } 1347 | 1348 | #################################### ANLINK REGISTER ######################################################### 1349 | andlink_success() 1350 | { 1351 | mkdir -p /data/status; 1352 | register_type_write andlink 1353 | file_create /data/status/config_done 1354 | file_delete "/tmp/ap_config_mode_flag" 1355 | /etc/init.d/dnsmasq restart 1 1356 | miio_start 1357 | andlink_enable >/dev/null 2>&1 1358 | /etc/init.d/cmcc_ims stop >/dev/null 2>&1 1359 | miplay /usr/share/sound/network_done_miio.mp3 1360 | /etc/init.d/cmcc_ims start >/dev/null 2>&1 1361 | sync 1362 | } 1363 | 1364 | andlink_env_prepare() 1365 | { 1366 | DEVICE_TYPE=$(uci get cmcc.andlink.device_type) 1367 | PRODUCT_TOKEN=$(uci get cmcc.andlink.product_token) 1368 | ANDLINK_TOKEN=$(uci get cmcc.andlink.andlink_token) 1369 | wireless_log "DEVICE_TYPE:$DEVICE_TYPE" 1370 | wireless_log "PRODUCT_TOKEN:$PRODUCT_TOKEN" 1371 | wireless_log "ANDLINK_TOKEN:$ANDLINK_TOKEN" 1372 | 1373 | QLINK_BROADCAST_IP=$(ifconfig wlan0 |grep "Bcast:" |awk '{print $3}'|awk -F':' '{print $2}') 1374 | mico_log "QLINK_BROADCAST_IP:$QLINK_BROADCAST_IP" 1375 | } 1376 | 1377 | andlink_coap_online() 1378 | { 1379 | andlink_env_prepare 1380 | local DEVICE_MAC=$(matool_get_mac) 1381 | wireless_log "andlink coap broadcast online" 1382 | 1383 | coap-client -B 10 -N -m post -e '{"deviceMac":"'$DEVICE_MAC'","deviceType":"'$DEVICE_TYPE'"}' coap://$QLINK_BROADCAST_IP:5683/qlink/success & 1384 | wireless_log "coap-client -B 10 -N -m post -e '{\"deviceMac\":\"'$DEVICE_MAC'\",\"deviceType\":\"'$DEVICE_TYPE'\"}' coap://$QLINK_BROADCAST_IP:5683/qlink/success" 1385 | } 1386 | 1387 | 1388 | # --> mibt_ble 1389 | #{ 1390 | # "SSID":"shaohuihua", 1391 | # "password":"12345678", 1392 | # "channel":"0", 1393 | # "encrypt":"", 1394 | # "CGW":{ 1395 | # "gwAddress":"112.13.96.199:5683", 1396 | # "gwAddress2":"https://112.13.96.199:20443", 1397 | # "user_key":"TYuYNdvxcZjILBe9xTwTsYmrPhCN0bD8FevrJ-QEXMaT2SFHCkHakyyvhfxkganu" 1398 | # } 1399 | # "extra":{ 1400 | # "method":"****" // 参见表格"method值" 1401 | # "data":"****"// data值使用JSON格式,具体内容由设备端与APP端协商,不在本规范中体现 1402 | # } 1403 | #} 1404 | andlink_register() 1405 | { 1406 | 1407 | rm -rf $ANDLINK_DIR 1408 | mkdir -p $ANDLINK_DIR; 1409 | local conf_file=$1 1410 | local country= 1411 | local uid= 1412 | local ssid= 1413 | local password= 1414 | local encrypt= 1415 | local CGW= 1416 | local gwAddress2= 1417 | local user_key= 1418 | local method= 1419 | local data= 1420 | local country=cn 1421 | local oauth_token="" 1422 | local oauth_uid="" 1423 | local oauth_appid="" 1424 | 1425 | config_start_sound 1426 | show_led 10 1427 | 1428 | json_init 1>/dev/null 2>/dev/null 1429 | json_load "$(cat $conf_file)" 1>/dev/null 2>/dev/null 1430 | json_get_var ssid "SSID" 1>/dev/null 2>/dev/null 1431 | json_get_var password "password" 1>/dev/null 2>/dev/null 1432 | json_get_var encrypt "encrypt" 1>/dev/null 2>/dev/null 1433 | json_select extra 1>/dev/null 2>/dev/null 1434 | json_get_var oauth_token "miotoken" 1>/dev/null 2>/dev/null 1435 | json_get_var oauth_appid "miAppid" 1>/dev/null 2>/dev/null 1436 | json_get_var oauth_uid "userId" 1>/dev/null 2>/dev/null 1437 | json_select .. 1>/dev/null 2>/dev/null 1438 | json_select CGW 1>/dev/null 2>/dev/null 1439 | json_get_var gwAddress2 "gwAddress2" 1>/dev/null 2>/dev/null 1440 | json_get_var user_key "user_key" 1>/dev/null 2>/dev/null 1441 | json_select .. 1>/dev/null 2>/dev/null 1442 | json_cleanup 1443 | 1444 | wireless_log "andlink connect start." 1445 | wireless_log "ssid $ssid" 1446 | wireless_log "password $password" 1447 | #OPEN WEP, WPAPSK, WPAPSK2, MIXED-WPAPSK2 1448 | wireless_log "encrypt $encrypt" 1449 | wireless_log "gwAddress2 $gwAddress2" 1450 | wireless_log "user_key $user_key" 1451 | wireless_log "miotoken $oauth_token" 1452 | wireless_log "miAppid $oauth_appid" 1453 | wireless_log "userId $oauth_uid" 1454 | wireless_log "method $method" 1455 | wireless_log "data $data" 1456 | 1457 | [ "$ssid" == "" -o "$gwAddress2" == "" -o "$user_key" == "" -o "$oauth_token" == "" -o "$oauth_appid" == "" -o "$oauth_uid" == "" ] && { 1458 | unlock 1459 | wireless_log "lackof arg" 1460 | echo "lackof arg" 1461 | shut_led 10 1462 | unlock 1463 | config_clean 1464 | miio_start 1465 | rm $conf_file 1>/dev/null 2>/dev/null 1466 | exit 5 1467 | } 1468 | 1469 | 1470 | 1471 | echo $gwAddress2 >$ANDLINK_DIR/gwAddress2 1472 | echo $user_key >$ANDLINK_DIR/user_key 1473 | echo $method >$ANDLINK_DIR/method 1474 | echo $data >$ANDLINK_DIR/data 1475 | 1476 | #trylock "ble" 1477 | trylock_wait $SCAN_LOCK "andlink" 10 1478 | [ $? != 0 ] && { 1479 | wireless_log "already proessing a regiser issue, stop ble." 1480 | shut_led 10 1481 | config_clean 1482 | miio_start 1483 | rm $conf_file 1>/dev/null 2>/dev/null 1484 | echo "already_in_register" 1485 | exit 1; 1486 | } 1487 | 1488 | connect_times_update 1489 | player_pause 1490 | 1491 | register_user_write "$uid" 1>/dev/null 2>/dev/null 1492 | register_info_write "$country" "$ssid" "$password" "$identity" 1>/dev/null 2>/dev/null 1493 | country_code_update $country 1>/dev/null 2>/dev/null 1494 | 1495 | miio_stop 1496 | connect_result=$(internet 16 "$ssid" "$password" "$identity"); 1497 | [ "$connect_result" != "success" ] && { 1498 | wireless_log "wifi connnect fail ret $connect_result" 1499 | shut_led 10 1500 | unlock 1501 | config_clean 1502 | miio_start 1503 | rm $conf_file 1>/dev/null 2>/dev/null 1504 | echo "$connect_result" 1505 | exit 2; 1506 | } 1507 | 1508 | andlink_coap_online 1>/dev/null 2>/dev/null 1509 | sleep 3 1510 | 1511 | wireless_log "TRY GET UID" 1512 | local new_uid=$(matool_get_uid_by_oauth $oauth_appid $oauth_token) 1513 | [ -z $new_uid ] && { 1514 | wireless_log "result new uid $new_uid" 1515 | rm $conf_file 1>/dev/null 2>/dev/null 1516 | echo "oauth_not_get_uid" 1517 | shut_led 10 1518 | unlock 1519 | config_clean 1520 | miio_start 1521 | exit 4; 1522 | } 1523 | 1524 | wireless_log "TRY BIND" 1525 | local bind_result=$(matool_identify_and_bind_device $new_uid) 1526 | [ "$bind_result" != "success" ] && { 1527 | wireless_log "uid bind result:" 1528 | wireless_log "$connect_result" 1529 | wireless_log "uid bind result end" 1530 | rm $conf_file 1>/dev/null 2>/dev/null 1531 | echo "oauth not get uid" 1532 | shut_led 10 1533 | unlock 1534 | config_clean 1535 | miio_start 1536 | exit 4; 1537 | } 1538 | 1539 | 1540 | shut_led 10 1541 | miio_start 1542 | unlock 1543 | rm $conf_file 1>/dev/null 2>/dev/null 1544 | wireless_log "andlink register success." 1545 | andlink_success 1>/dev/null 2>/dev/null & 1546 | echo "success" 1547 | 1548 | exit 0 1549 | } 1550 | 1551 | 1552 | #################################### POST BLE ISSUE ############################################### 1553 | # -->mibt_ble 1554 | post_ble() 1555 | { 1556 | device_count=$1 1557 | wireless_log "a bind sound count $device_count" 1558 | wireless_log "ble exit ap config mode" 1559 | 1560 | mphelper tone /usr/share/sound/init_wifi_success.mp3 & 1561 | 1562 | andlink_enable >/dev/null 2>&1 1563 | /etc/init.d/cmcc_ims restart >/dev/null 2>&1 1564 | } 1565 | 1566 | #################################### BLE ########################################################## 1567 | #/tmp/ble_connect_times is used in simple_dhcp.sh 1568 | connect_times_update() 1569 | { 1570 | mkdir -p /data/status/ 1571 | local connect_times=0; 1572 | local CONNECT_TIMES_FILE="/data/status/mico_try_register_times" 1573 | [ -f $CONNECT_TIMES_FILE ] && { 1574 | connect_times=$(cat $CONNECT_TIMES_FILE) 1575 | } 1576 | 1577 | connect_times=$(($connect_times+1)) 1578 | echo $connect_times > $CONNECT_TIMES_FILE 1579 | sync 1580 | return 0; 1581 | } 1582 | 1583 | ble_success() 1584 | { 1585 | mkdir -p /data/status; 1586 | register_type_write ble 1587 | file_create /data/status/config_done 1588 | file_delete "/tmp/ap_config_mode_flag" 1589 | /etc/init.d/dnsmasq restart 1 1590 | miio_start 1591 | /etc/init.d/voip restart 1592 | sync 1593 | } 1594 | 1595 | ble_oauth() 1596 | { 1597 | country=$1 1598 | uid=$2 1599 | ssid=$3 1600 | password=$4 1601 | identity=$5 1602 | 1603 | wireless_log "wifi connect start." 1604 | wireless_log "country $country" 1605 | wireless_log "uid $uid" 1606 | wireless_log "ssid $ssid" 1607 | wireless_log "password $password" 1608 | wireless_log "identity $identity" 1609 | 1610 | config_start_sound 1611 | show_led 10 1612 | 1613 | #trylock "ble" 1614 | trylock_wait $SCAN_LOCK "ble" 10 1615 | [ $? != 0 ] && { 1616 | wireless_log "already proessing a regiser issue, stop ble." 1617 | shut_led 10 1618 | config_clean 1619 | miio_start 1620 | echo "already_in_register" 1621 | exit 1; 1622 | } 1623 | 1624 | connect_times_update 1625 | player_pause 1626 | 1627 | register_user_write "$uid" 1>/dev/null 2>/dev/null 1628 | register_info_write "$country" "$ssid" "$password" "$identity" 1>/dev/null 2>/dev/null 1629 | country_code_update $country 1>/dev/null 2>/dev/null 1630 | 1631 | miio_stop 1632 | #DEFAULT use htpdate date sync, but ble use phone time. 1633 | HTPDATE_SYNC=0 1634 | connect_result=$(internet 16 "$ssid" "$password" "$identity"); 1635 | [ "$connect_result" != "success" ] && { 1636 | wireless_log "wifi connnect fail ret $connect_result" 1637 | shut_led 10 1638 | unlock 1639 | #config_clean 1640 | miio_start 1641 | echo "$connect_result" 1642 | exit 2; 1643 | } 1644 | 1645 | wireless_log "uid try sync." 1646 | set_new_uid=0 1647 | [ "$uid" != "0" ] && { 1648 | wireless_log "uid sync" 1649 | /usr/bin/matool_get_super_admin sync > /tmp/matool_get_super_admin.log 1650 | [ $? -eq 0 ] && { 1651 | ori_uid=$(cat /tmp/matool_get_super_admin.log) 1652 | wireless_log "uid sync uid=$ori_uid newuid=$uid" 1653 | file2log "/tmp/matool_get_super_admin.log" 1654 | if [ "$ori_uid" == "$uid" ] 1655 | then 1656 | #set wifi only 1657 | wireless_log "wifi only." 1658 | ble_success 1>/dev/null 2>/dev/null 1659 | mphelper tone /usr/share/sound/init_wifi_success.mp3 & 1660 | echo "wifi_only_success" 1661 | shut_led 10 1662 | 1663 | unlock 1664 | wireless_log "success" 1665 | exit 0 1666 | elif [ "$ori_uid" == "-1" -o "$ori_uid" == "" ] 1667 | then 1668 | wireless_log "uid -1, do nothing." 1669 | #do nothing 1670 | else 1671 | wireless_log "new uid got, clean user data." 1672 | user_data_clean > /dev/null 2>&1 1673 | sleep 4 1674 | set_new_uid=1; 1675 | fi 1676 | } 1677 | wireless_log "checking uid finish." 1678 | } 1679 | 1680 | sleep 3 1681 | 1682 | wireless_log "TRY BIND" 1683 | local bind_result=$(matool_identify_and_bind_device $uid) 1684 | [ "$bind_result" != "success" ] && { 1685 | wireless_log "uid bind result:" 1686 | wireless_log "$bind_result" 1687 | wireless_log "uid bind result end" 1688 | echo "matoolsfail" 1689 | shut_led 10 1690 | unlock 1691 | config_clean 1692 | miio_start 1693 | exit 4; 1694 | } 1695 | 1696 | 1697 | shut_led 10 >/dev/null 2>&1 1698 | 1699 | unlock 1700 | wireless_log "ble_oauth register success." 1701 | ble_success >/dev/null 2>&1 1702 | 1703 | wireless_log "a bind sound count $device_count" 1704 | wireless_log "ble exit ap config mode" 1705 | 1706 | mphelper tone /usr/share/sound/init_wifi_success.mp3 >/dev/null & 1707 | 1708 | andlink_enable >/dev/null 2>&1 1709 | /etc/init.d/cmcc_ims restart >/dev/null 2>&1 1710 | device_id=$(matool_get_device_id) 1711 | 1712 | echo "success:$device_id" 1713 | 1714 | exit 0 1715 | } 1716 | 1717 | ################################################################################################# 1718 | reset() 1719 | { 1720 | firmware_reset 1721 | } 1722 | 1723 | start_service() { 1724 | wireless_log "start" 1725 | #wireless_stop >/dev/null 2>&1 1726 | #for ccmp error 1727 | [ ! -f $WIRELESS_CONF ] && { 1728 | ap_start 1729 | return 0 1730 | } 1731 | 1732 | sta_start $WIRELESS_CONF #>/dev/null 2>&1 1733 | /usr/bin/wireless_point.sh >/dev/null & 1734 | return 0 1735 | } 1736 | 1737 | stop_service() { 1738 | wireless_log "stop" 1739 | wireless_stop 1740 | } 1741 | 1742 | restart() { 1743 | wireless_log "restart $1" 1744 | [ "$1" == "wificheck" ] && { 1745 | IS_SHOW_LED=0 1746 | wireless_log "wificheck restart change IS_SHOW_LED to $IS_SHOW_LED" 1747 | } 1748 | stop 1749 | start 1750 | } 1751 | 1752 | 1753 | --------------------------------------------------------------------------------