[ ardunio ] tm time reference

struct tm {
int tm_sec; /* วินาที, range 0 to 59 */
int tm_min; /* นาที, range 0 to 59 */
int tm_hour; /* ชั่วโมง, range 0 to 23 */
int tm_mday; /* วันที่, range 1 to 31 */
int tm_mon; /* เดือน, range 0 to 11 */
int tm_year; /* ปีคริสศักราช ตั้งแต่ 1900 */
int tm_wday; /* วัน, range 0 to 6 */
int tm_yday; /* วันใน 1 ปี, range 0 to 365 */
int tm_isdst; /* daylight saving time */
};

ref : http://montienfocus.blogspot.com/2016/06/internet-esp8266.html

[ bash ] check contentType

contentType=$(curl -X HEAD -I ${url} | grep -Fi content-type | tr -d "\r")

if [ "${expectedContentType}" == "$contentType" ];
then
  echo "Success"
  exit 0
else
  echo "Content-type is not the same as expected"
  exit -1
fi

<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>

[ bash ] compare 2 files and check if it is changed

date=`date '+%Y-%m-%d %H:%M:%S'`
latest_ads='ads.txt'
snapshot_ads="ads-$date.txt"
diff_ads='ads.diff.txt'

# download ads.txt page from $url
curl -L "$url" > "$snapshot_ads"

# get the diff into $diff_ads file
rm -f $diff_ads
diff -c $latest_ads "$snapshot_ads" > $diff_ads && echo 'same!' || echo 'differences!'
cat $diff_ads

# create latest_ads
rm -f $latest_ads
ln -s "$snapshot_ads" $latest_ads

# check if the diff is acceptable
line_diff_count=`wc -l < $diff_ads`
if [ $line_diff_count -ne 0 ]; then
echo 'The ads.txt page is changed'
exit 1
fi

[ ardunio ] create CACert for client.setCACert_P()

On firefox,

Click on the ‘>’ icon.

Click on “More Information” button at the bottom of the window.

In the new window titled “Page Info – https://api.github.com&#8221;, click on the “View Certificate” button.

In the “Certificate Viewer” window, click on the “Details” tab.

In the “Certificate Hierarchy” top window pane click on “DigiCert High Assurance EV Root CA” so it is highlighted.

Click on the “Export…” button at the bottom of the page.

At the bottom of the page select “X.509 Certificate (DER)” format then click on Save.

Use your favorite program to convert the binary DER format to ASCII. Here is what I do.

$ xxd -i DigiCertHighAssuranceEVRootCA.crt.der >cacert.h

ref : https://www.esp8266.com/viewtopic.php?p=74154

, https://github.com/esp8266/Arduino/tree/d5bb4a99f64a843e28b119d174b90c910516458f/libraries/ESP8266WiFi/examples/HTTPSRequestCACert