2017年11月7日 星期二

arduino email solution

想使用arduino在需要時發email通知。一開始找ethernet library,結果要使用的話必須要有public ip,後來找到的方法是利用arduino sdk寫code再利用外部網站API達到目的,不過那個需要付費並且掌握在別人手上。後來找到直接install apk在arduino linux上即可達到目的,為了這個還發現arduino出廠時是使用factory image,必須要自己upgrade才能獲取全部的arduino society support。看到download.linino.org就代表你是連到factory自己建的repository,不但常常掛資源也少,正確的應該是downloads.arduino.cc

參考資料

ethernet lib
https://forum.arduino.cc/index.php?topic=126829.0

arduino sdk
http://tronixstuff.com/2013/11/23/tutorial-send-email-with-the-arduino-yun/

arduino linux
http://www.binarypower.com/2014/07/use-arduino-yun-to-send-emails-simple.html

download.linino.org
https://forum.arduino.cc/index.php?topic=286191.0

2017年8月31日 星期四

pfsense openvpn TCP_size_error

之前就有發生過類似的情形,後來試了一下發現是碰不到openvpn server(log沒有反應,區網測試可以)。trouble shoot老半天結果居然是Dlink router DMZ不會轉送 port 443,我還找到MTU那邊去。之前因為都是直接用pfsense pppoe,最近換到dlink減輕server負擔沒想到會這樣,暈倒....

附上解決方法,除了DMZ外再做一次port forwarding....

參考資料
自己
https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwji842Uv4HWAhUFJ5QKHU4sBlIQFggoMAA&url=https%3A%2F%2Fwww.mobile01.com%2Ftopicdetail.php%3Ff%3D110%26t%3D5888&usg=AFQjCNF3Tx6urZ1LXe0L-3gCuDcaNebGuA

2017年8月14日 星期一

pfsense DNS forwardar

必須要將DHCP server的DNS server設為pfsense IP才會生效

參考資料
https://forum.pfsense.org/index.php?topic=31327.0

Arduino smart home ac remote

想要玩arduino很久了,總算有時間來試一下。參考了網路上的資訊,從完全沒摸過到寫程式燒錄到arduino,還有網頁http request的研究,總算最後是完成了。花了三天的時間,很有成就感也很累,在炎炎夏日還蠻實用的。

幾個過程中的重點:

arduino:

  • 匯入程式庫後compile才成功,不能自己用貼上.h的方式
  • Could not connect to YunServer 146 Connection refused的問題在我去除while (!Serial);後有顯著的改善
  • 目前紅外線LED的遙控距離還是太短,考慮增加電阻
  • 使用readuntil到?時會中斷(應該是timeout),所以目前是拿掉,之後再看有沒有辦法解決
  • 網頁資料是使用serial,我改用rest的方式,所以在資料取得方式上有些不同


web:


  • header必須要用Status: 200而非HTTP/1.1 200 OK,後者會導致content type無法變成text/html
  • arduino rest api protection要關閉,是為了讓網頁執行時不會hit到CORS(cross-origin resource sharing)的問題。狀況是這樣,因為使用了authrization所以會變成非簡單要求,發出OPTION request後因為我們建置的並非正式webserver所以response為空沒辦法加入header(arduino寫的程式必須要先能夠碰到REST)因此被擋(無法回傳access-allow-origin: *),使用datatype: jasonp並沒有辦法解決問題。沒使用authrization前是401,使用後是400。



參考資料
自己
smart home ac
http://cc.beingo.net/archives/2234
https://m.mobile01.com/topicdetail.php?f=731&t=4135366&p=1
http://cms.35g.tw/coding/arduino-remote-daikin-3/
http://cms.35g.tw/coding/arduino-remote-daikin-2/
http://cms.35g.tw/coding/arduino-remote-daikin/

arduino yun
https://forum.arduino.cc/index.php?topic=191895.0
https://forum.arduino.cc/index.php?topic=227213.0
http://yehnan.blogspot.tw/2014/04/arduino-yunbridgeconsoleprocess.html
https://www.arduino.cc/en/Tutorial/Bridge
https://arduino.stackexchange.com/questions/10257/sending-values-to-an-arduino-yun-across-different-networks
http://yehnan.blogspot.tw/2014/04/arduino-yunbridgeyunserveryunclient.html
http://yehnan.blogspot.tw/2013/01/arduinods18b20.html
http://yehnan.blogspot.tw/2013/05/arduino.html
http://yehnan.blogspot.tw/2016/04/arduino-yunwi-fi.html
https://forum.arduino.cc/index.php?topic=192936.0

CORS
http://www.ruanyifeng.com/blog/2016/04/cors.html
https://blog.m157q.tw/posts/2016/09/07/cross-origin-resource-sharing/
https://developer.mozilla.org/zh-TW/docs/Web/HTTP/Access_control_CORS

ajax
http://blog.techbridge.cc/2017/05/20/api-ajax-cors-and-jsonp/
https://babaawesam.com/2014/11/06/control-input-output-of-arduino-yun-with-ajax/
http://www.cnblogs.com/Mainz/p/3506956.html
http://shiyousan.com/post/635433082130309661

phpmyadmin create sql
http://www.complete-concrete-concise.com/web-tools/creating-a-mysql-database-using-ampps

HTML
http://www.w3school.com.cn/tags/tag_doctype.asp

字元與字串
http://dhcp.tcgs.tc.edu.tw/c/p009.htm

Basic Auth
https://stackoverflow.com/questions/5507234/how-to-use-basic-auth-with-jquery-and-ajax
https://stackoverflow.com/questions/3571090/basic-authentication-with-jquery-ajax-request-and-jsonp
https://stackoverflow.com/questions/27904082/using-http-basic-authentication-with-ajax-call

php windows工作排程
http://mrbignose.blogspot.tw/2010/05/php-windows-php.html

2017年4月13日 星期四

pfsense pppoe 失效問題

最近伺服器只要重開PPPOE就會撥接不上,本來還以為是switch topology有誤,後來總算是發現原來是wan interface沒有正確assign到em0,重新assign後問題解決。

參考資料:
自己

2016年12月21日 星期三

virtualbox guest windows OS network issue

遇到一個問題是guest OS windows會不定期網路沒有網際網路,後來發現host有裝vmplayer,將vmware network adapter停用後目前問題解除,待觀察

經過一陣子觀察之後沒有再出現異常,應該是這個問題沒錯,有遇到相同問題的人可以一試

20170201更新
還是有問題發生,暫停guest os再取消暫停之後可以回復網路狀態

參考資料
自己

2016年4月19日 星期二

Windows 10 磁碟空間 storage space經驗分享

最近想組raid保護資料,研究了一下發現硬體raid可能有風險,如果controller壞掉的話必須要找到相同晶片資料才可以救援,而且同樣容量的硬碟外接硬碟比裸碟便宜不少。所以後來看了資料後決定使用windows自身的軟體raid機制。

先是發現windows7不支援外接硬碟布建軟體raid,本來看到有人說可以更改分割表的bit把硬碟顯示為fix,後來看了一下發現是發文者弄錯了。後來看到windows8以上可以使用新功能-磁碟空間(storage space)可以使用外接硬碟,就決定將系統升級到windows10。

本來想要架raid5,買了兩顆3TB的硬碟加上原有的一顆三組,後來接上去之後發現windows磁碟空間的架構與硬體不同,不需用到整顆硬碟容量做設定可以切割。於是先分割小空間做測試,傳輸檔案時發現速度非常慢,usb 3.0速度僅有10MB/s,實在是不可思議,本來想說沒救了,後來看到有人分享加速的方法,原來是windows考量到power failure的可能將寫入快取取消限制效能。

開啟加速方法如下:

  1. 使用系統管理員權限開啟powershell
  2. 輸入Get-StoragePool,找到FriendlyName
  3. 輸入Set-StoragePool -FriendlyName <Storage Pool Name> -IsPowerProtected $True
開啟加速之後速度可以達到50MB/s,不過還是達不到usb 3.0的速度,後來查了資料知道同位(raid5)寫入速度比較慢,最後改成mirror(raid1)後問題解決。

最後是virtualbox在升級到windows10後發生網卡找不到問題,同樣搜尋後找到必須解除安裝後重新安裝virtualbox問題解決。

參考資料
storage space加速
https://social.technet.microsoft.com/Forums/windowsserver/en-US/64aff15f-2e34-40c6-a873-2e0da5a355d2/parity-storage-space-so-slow-that-its-unusable?forum=winserver8gen
同位(raid5)寫入速度慢
http://blogs.technet.com/b/mspfe/archive/2013/02/25/why-windows-server-2012-parity-storage-spaces-might-perform-slowly.aspx
virtualbox找不到網卡問題
http://ftcforum.usfirst.org/showthread.php?4898-Error-relaunching-the-VirtualBox