2017年6月20日 星期二

video stream2 on rpi

Ref : https://github.com/Tomtomgo/raspberry_livestream


Ref : http://engineer2you.blogspot.tw/2016/10/rasbperry-pi-ffmpeg-install-and-stream.html

Ref : https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=133871&p=1011437

ffmpeg youtube rtmp

ffmpeg -thread_queue_size 512 -f v4l2 -i /dev/video0  -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec aac -ab 128k -strict experimental -aspect 16:9 -vcodec h264 -preset veryfast -crf 25 -pix_fmt yuv420p -g 60 -vb 820k -maxrate 820k -bufsize 820k -profile:v baseline -r 30 -f flv rtmp://a.rtmp.youtube.com/live2/"your api key"

2017年6月16日 星期五

check server port on centos

Ref : https://support.rackspace.com/how-to/checking-listening-ports-with-netstat/


sudo netstat -plnt

install mqtt on centos

Ref : https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-centos-7


把   home-oojah-mqtt.repo copy到   /etc/yum.repos.d/

然後執行

sudo yum install mosquitto
 sudo yum install mosquitto-clients


CentOS

Download the repository config file for your CentOS version from below and copy it to /etc/yum.repos.d/ You’ll now be able to install and keep mosquitto up to date using the normal package management tools.
The available packages are: mosquitto, mosquitto-clients, libmosquitto1, libmosquitto-devel, libmosquittopp1, libmosquittopp-devel, python-mosquitto.

sudo yum -y install epel-release

 sudo yum install mosquitto
 sudo yum install mosquitto-clients




mosquitto_pub -h 192.168.0.103 -t test -m "forward"

2017年6月12日 星期一

mqtt on rpi


Ref : https://learn.adafruit.com/diy-esp8266-home-security-with-lua-and-mqtt/configuring-mqtt-on-the-raspberry-pi

Ref : http://www.instructables.com/id/Installing-MQTT-BrokerMosquitto-on-Raspberry-Pi/


用 stretch 的 iso

This is what I did as per your instructions:
To use the new repository you should first import the repository package signing key:

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
Then make the repository available to apt:

cd /etc/apt/sources.list.d/
Then one of the following, depending on which version of debian you are using:

sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list


Then update apt information:

sudo apt-get update


 sudo apt-get install python-pip

sudo pip install paho-mqtt

  1. sudo apt-get install mosquitto mosquitto-clients python-mosquitto

sudo systemctl restart mosquitto


--------------------------------------------------------------


import os
import string
import paho.mqtt.client as mqtt
import time


localBroker = "192.168.1.120"           # Local MQTT broker
localPort = 1883                        # Local MQTT port
localUser = "mosquitto"                 # Local MQTT user
localPass = "mosquitto"                 # Local MQTT password
localTopic = "test"             # Local MQTT topic to monitor
localTimeOut = 120                      # Local MQTT session timeout


if "__main__" == __name__:

   # The callback for when the client receives a CONNACK response from the server.
   def on_connect(client, userdata, flags, rc):
                print("Connected with result code "+str(rc))

                # Subscribing in on_connect() means that if we lose the connection and
                # reconnect then subscriptions will be renewed.
                client.subscribe(localTopic)

   # The callback for when a PUBLISH message is received from the server.
   def on_message(client, userdata, msg):
                #(sensorID, sensorVoltage) = string.split(msg.payload)
                 print(msg.payload)

   client = mqtt.Client()
   client.on_connect = on_connect
   client.on_message = on_message
   client.connect(localBroker, localPort, localTimeOut)

   client.loop_forever()
   quit()


----------------------------------------------------------------------------------------------------------

mosquitto_pub -h 192.168.1.120 -t test -m "hello world"




install centos

Ref : https://blog.gtwang.org/linux/centos-7-installation-tutorial/


pppoe on centos

Ref : http://shaocian.blogspot.tw/2012/07/centos-pppoe-rp-pppoe.html

2017年6月3日 星期六

資料學習

Ref : https://www.gitbook.com/book/mcknote/brohrer/details

git 指令大全


基礎設定
  1. 查詢版本
  2. git version
  3.  
  4. 查詢設定列表
  5. git config --list
  6.  
  7. 輸入姓名
  8. git config --global user.name "你的名字"
  9.  
  10. 輸入email
  11. git config --global user.email "你的email"
新增本地/遠端數據庫
  1. 在本地資料夾新增數據庫
  2. git init
  3.  
  4. 複製遠端數據庫
  5. git clone 遠端數據庫網址
增加/刪除檔案
  1. 增加檔案進入索引
  2. git add 檔案名稱
  3.  
  4. 增加全部檔案進入索引
  5. git add .
  6.  
  7. 查詢狀態
  8. git status
  9.  
  10. 顯示歷史紀錄
  11. git log
  12.  
  13. 將索引提交到數據庫
  14. git commit -m '更新訊息'
還原指令
  1. 還原工作目錄與索引,會跟最後一次 commit 保持一樣
  2. git reset --hard
  3.  
  4. 全部檔案取消索引
  5. git reset HEAD
  6.  
  7. 單一檔案取消索引
  8. git reset HEAD 檔案名稱
  9.  
  10. 恢復單一檔案到最新 commit 狀態
  11. git checkout 檔案名稱
  12.  
  13. 刪除最近一次 commit
  14. git reset --hard "HEAD^"
  15.  
  16. 上面語法如果刪除錯了可以再用此語法還原
  17. git reset --hard ORIG_HEAD
  18.  
  19. 刪除最近一次 commit,但保留異動內容
  20. git reset --soft "HEAD^"
  21.  
  22. commit 後發現有幾個檔案忘了加入進去,想要補內容進去時
  23. git commit --amend
分支
  1. 顯示所有本地分支
  2. git branch
  3.  
  4. 新增分支
  5. git bracnch 分支名稱
  6.  
  7. 切換分支
  8. git checkout 分支名稱
  9.  
  10. 合併指定分支到目前的分支
  11. git merge 分支名稱
  12.  
  13. 刪除分支
  14. git branch -d 分支名稱
遠端數據庫操作
  1. 複製遠端數據庫
  2. git clone 遠端數據庫網址
  3.  
  4. 查詢遠端數據庫
  5. git remote
  6.  
  7. 將本地分支推送到遠端分支
  8. git push 遠端數據庫名稱 遠端分支名稱
  9.  
  10. 將遠端分支拉下來與本地分支進行合併
  11. git pull
標籤
  1. 查詢標籤
  2. git tag
  3.  
  4. 查詢詳細標籤
  5. git tag n
  6.  
  7. 刪除標籤
  8. git tag -d 標籤名稱
  9.  
  10. 新增輕量標籤
  11. git tag 標籤名稱
  12.  
  13. 新增標示標籤
  14. git tag -am "備註內容" 標籤名稱
暫存
  1. 暫時儲存當前目錄
  2. git stash
  3.  
  4. 瀏覽 stash 列表
  5. git stash list
  6.  
  7. 還原暫存
  8. git stash pop
  9.  
  10. 清除最新暫存
  11. git stash drop
  12.  
  13. 清除全部暫存
  14. git stash clear