Raspberry Piã¨SORACOM Airã¨Google Cloud Vision APIã§ä¸æ£é§è»ãç£è¦ãã
ãã®è¨äºã¯ãã½ã©ã³ã ã®Software Designèªå·»é ç¹éè¨å¿µãªã¬ã¼ããã° 5æ1æ¥åã§ãã
ãã®è¨äºã§ã¯ãã¹ãã¼ã¯ã«ã©ãã§PoCãè¡ã£ããRaspberry Pi, SORACOM Air, Google Cloud Vision APIã使ã£ãç°¡æãªä¸æ£é§è»ãç£è¦ããã·ã¹ãã ãç´¹ä»ãã¾ãã
ä¸æ£é§è»ç£è¦ã·ã¹ãã ã®åä½æ¦è¦
ãã®ã·ã¹ãã ã¯ãæ®æ®µã¯èªåè»ãåã¾ã£ã¦ããªãå ´æãç£è¦ã«ã¡ã©ã§ç£è¦ãã¾ãã
ã» ãã®ã·ã¹ãã ã¯ãé§è»å ´ã®åºå
¥ãå£ãªã©ãæ®æ®µã¯èªåè»ãåã¾ã£ã¦ããªãå ´æãç£è¦ã«ã¡ã©ã§ç£è¦ãã¾ãã
ã» Raspberry Piã¨Webã«ã¡ã©ãç£è¦ã«ã¡ã©ã¨ãã¦ä½¿ãã¾ãã
ã» ãã®è¨äºã§ã¯ä¸æ£é§è»ãããã®ç£è¦ã«ã¡ã©ã§æ®å½±ãã¦ããå ´æã«èªåè»ãåã¾ã£ã¦ããäºã¨å®ç¾©ãã¾ãã
Raspberry Piã§è¡ãå¦çã¯ããã®å³ã®ããã«ãªãã¾ãã
ãã®ã·ã¹ãã ã¯ãä¸æ£é§è»ã®æ¤åºã¨ã¦ã¼ã¶ã¼éç¥ãWebãµã¼ãã¼ã§è¡ãã¾ãã
- Raspberry Piã§ä¸å®æéæ¯ã«åçãåãããã®ç»åãWebãµã¼ãã¼ã«ã¢ãããã¼ããã¾ãã
- ç»åã®ã¢ãããã¼ãã¯ãSORACOM Airã«ããã¤ã³ã¿ã¼ããããçµç±ãã¦è¡ãã¾ããSORACOM Airã¯ãIoT åãã®ãã¼ã¿éä¿¡SIM âAir SIMâ ãæä¾ãããµã¼ãã¹ã§ãã
- ä¸æ£é§è»ã®æç¡ã¯ãã¢ãããã¼ããããç»åã«èªåè»ãåã£ã¦ãããã©ããã§å¤å®ãã¾ãã
- èªåè»ãåã£ã¦ãããã©ããã¯ãGoogle Cloud Vision APIã使ã£ã¦å¤å®ãã¾ããGoogle Cloud Vision APIã¯Googleã®ç»åèªèAPIã§ãç»åå ã®ãã¾ãã¾ãªç©ä½ãç°¡åã«æ¤ç¥åºæ¥ã¾ãã
- ä¸æ£é§è»ãæ¤åºããããã¦ã¼ã¶ã¼ã«ã¡ã¼ã«ã§éç¥ãã¾ãã
Webãµã¼ãã¼ã¯AWS API Gatewayã¨AWS Lambdaã§ä½æãã¾ãã
ã¢ãããã¼ããããç»åã«å¯¾ããWebãµã¼ãã¼ã§ã®å¦çã¯ããã®å³ã®ç¢å°ã«æ²¿ã£ã¦è¡ãã¾ãã
ä¸æ£é§è»ç£è¦ã·ã¹ãã ã®ä½ãæ¹
以éã¯ä¸æ£é§è»ãç£è¦ããã·ã¹ãã ãä½ãæé ã説æãã¾ãã
ç®æ¬¡
1. ãã¼ãã¦ã§ã¢ã®æºå
1.1. Webã«ã¡ã©ã«ã¤ãã¦
1.2. ãã¼ã¿é信端æ«ã¨SIMã«ã¤ãã¦
1.3. ãã®ä»
2. Raspberry Piã®è¨å®
2.1. Raspbianã®ã¤ã³ã¹ãã¼ã«
2.2. SORACOM Airã®è¨å®
2.2.1. SORACOM Airã®èªåæ¥ç¶è¨å®
2.3. Webã«ã¡ã©ç£è¦ãµã¼ãã¹ã®è¨å®
2.3.1. å¿
è¦ãªããã±ã¼ã¸ã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«
2.3.2. Webã«ã¡ã©ç£è¦ãµã¼ãã¹ã®ç»é²
3. Webãµã¼ãã¼ã®è¨å®
3.1. Google Cloud Vision APIã®APIãã¼ã®åå¾
3.2. AWS SNSã«éç¥ç¨ã¡ã¼ã«ã¢ãã¬ã¹ãç»é²ãã
3.3. AWS S3ã«ç»åä¿åç¨ãã±ãããä½æãã
3.4. AWS DynamoDBã«ä¸æ£é§è»æ¤åºç¨ã®ãã¼ãã«ãä½æãã
3.5. AWS IAMã§ä¸æ£é§è»æ¤åºç¨ã®ãã¼ã«ãä½æãã
3.6. AWS Lambdaã«ä¸æ£é§è»æ¤åºå¦çãç»é²ãã
3.7. AWS API Gatewayã«ããWebãµã¼ãã¼ã®å
Ž
- ãã¼ãã¦ã§ã¢ã®æºå
以ä¸ã®ãã¼ãã¦ã§ã¢ãå¿ è¦ã§ãã
- Raspberry Pi 3
- SDã«ã¼ã: 8GB以ä¸
- USBã®Webã«ã¡ã©
- USBãã¼ã¿é信端æ«
- SORACOM Air SIM
1.1. Webã«ã¡ã©ã«ã¤ãã¦
ä»åã®è¨äºã®åä½ç¢ºèªã§ã¯ãWebã«ã¡ã©ã«ELECOM UCAM-DLV300ã使ãã¾ããããä»ã®Webã«ã¡ã©ã§ãåä½ããã¨æãã¾ãã
1.2. ãã¼ã¿é信端æ«ã¨SIMã«ã¤ãã¦
ãã®è¨äºã§ã¯ãå¯å£«ã½ããFS01BUã¨Software-Design-2016å¹´5æå·ä»é²ã®SIMã使ãã¾ããã
代ããã«docomoãã¼ã¿é信端æ«L-05Aã使ãã¾ããããã¡ãã®æ¹ãä¸å¤ã§å®ãã£ããã§ãã
ä»ã®ãã¼ã¿é信端æ«ã§ãåä½ããã¨æãã¾ãã
è¨äºã®å
容ã¯é©å®èªã¿æ¿ãã¦ä¸ããã
1.3. ãã®ä»
ãã®ä»ã以ä¸ã®ãããªç©ãããã°å±å¤ã§ä½¿ç¨ããéã«ä¾¿å©ã§ãã
- ããããªã¼: cheero Canvas
- Raspberry Piã±ã¼ã¹
ãããã®ãã¼ãã¦ã§ã¢ãæ¥ç¶ããã¨ãRaspberry Piã¯ä»¥ä¸ã®ãããªç¶æ ã«ãªãã¾ãã
2. Raspberry Piã®è¨å®
2.1. Raspbianã®ã¤ã³ã¹ãã¼ã«
raspberrypi.orgã®ã¤ã³ã¹ãã¼ã«ã¬ã¤ãã«å¾ã£ã¦Raspbianãã¤ã³ã¹ãã¼ã«ãã¦ä¸ããã
2.2. SORACOM Airã®è¨å®
å¯å£«ã½ããFS01BUã¨Software-Design-2016å¹´5æå·ä»é²ã®SIMãã使ãã®æ¹ã¯ã
Software-Design-2016å¹´5æå·çãåèã«ãã¦SORACOM Airã®è¨å®ããã¦ä¸ããã
ãã®2.2é
ã§ã¯L-05Aã使ã£ãå ´åã«ã¤ãã¦èª¬æãã¾ãã
ä»ã®é信端æ«ãã使ãã®å ´åã«ã¯ãé©å®èªã¿æ¿ãã¦è¨å®ãã¦ä¸ããã
2.2.1. SORACOM Airã®èªåæ¥ç¶è¨å®
Raspberry Pièµ·åæã«èªåçã«SORACOM Airã§ã¤ã³ã¿ã¼ãããã¨æ¥ç¶åºæ¥ãããã«ãã¾ãã
ä»å使ç¨ããL-05Aã§ã¯ãRaspberry Pi B+ 㨠L-05A 㧠SORACOM Airï¼nano SIMï¼ã試ãã¦ã¿ããåèã«ããã¦é ããè¨å®ãã¾ããã
ã¾ãRaspberry Pi B+ 㨠L-05A 㧠SORACOM Airï¼nano SIMï¼ã試ãã¦ã¿ããåèã«ãSORACOM Airã§ã¤ã³ã¿ã¼ãããã¨æ¥ç¶ãã¦ä¸ããã
次ã«ã以ä¸ã®2ã¤ã®ãã¡ã¤ã«ãpiã¦ã¼ã¶ã¼ã®ãã¼ã ãã£ã¬ã¯ããªã«ã³ãã¼ãã¦ä¸ããã
- soracom.sh
#!/bin/sheject /dev/sr0
pon soracom
while [ ! -e /sys/class/net/ppp0 ]
do
sleep 1
done
pidof pppd > /var/run/soracom.pid
- soracom.service
[Unit]
Description=ppp daemon with soracom air.
Requires=network.target
After=network.target[Service]
User=root
ExecStart=/usr/local/bin/soracom.sh
ExecStop=/usr/bin/poff soracom
Restart=always
Type=forking
PIDFile=/var/run/soracom.pid[Install]
WantedBy=multi-user.target
次ã«piã¦ã¼ã¶ã¼ã§ã以ä¸ã®ã³ãã³ãå®è¡ãã¦ä¸ããã
cd
sudo cp soracom.sh /usr/local/bin
sudo chmod +x /usr/local/bin/soracom.sh
sudo cp soracom.service /etc/systemd/system
sudo systemctl enable soracom
以ä¸ã§ãraspbianèµ·åå¾èªåçã«SORACOM Airã§ã®éä¿¡ãåºæ¥ãããã«ãªãã¾ãã
2.3. Webã«ã¡ã©ç£è¦ãµã¼ãã¹ã®è¨å®
Webã«ã¡ã©ã§å®æçã«ç»åãåå¾ããç»åãã¢ãããã¼ãããå¦çããµã¼ãã¹ã¨ãã¦systemdã«ç»é²ãã¾ãã
Raspbianã¯ããã¹ããã°ã¤ã³ã«ãªãããè¨å®ãã¦ããã¦ä¸ããã
2.3.1. å¿ è¦ãªããã±ã¼ã¸ã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«
以ä¸ã®ã³ãã³ããå®è¡ãã¦ãwebã«ã¡ã©ãæä½ããã³ãã³ããã¤ã³ã¹ãã¼ã«ãã¦ä¸ããã
sudo apt-get update
sudo apt-get install fswebcam
2.3.2. Webã«ã¡ã©ç£è¦ãµã¼ãã¹ã®ç»é²
ç»åã®åå¾ã¨ã¢ãããã¼ãã®å®æçãªå®è¡ã¯systemdã§è¡ãã¾ãã
ãã®é
ã§ã¯ãWebã«ã¡ã©ç£è¦ãµã¼ãã¹ãä½æãç»é²ãããµã¼ãã¹ãå®æçã«å®è¡ãããæé ã«ã¤ãã¦èª¬æãã¾ãã
以ä¸ã®3ã¤ã®ãã¡ã¤ã«ãpiã¦ã¼ã¶ã¼ã®ãã¼ã ãã£ã¬ã¯ããªã«ã³ãã¼ãã¦ä¸ããã
- capture_and_upload.sh
ç»åã®åå¾ã¨ã¢ãããã¼ããè¡ãã¹ã¯ãªããã§ãã
#!/bin/shURL=âhttps://***********'IMSI=â1234567890'
IMG=â/tmp/image.jpgâ# Webã«ã¡ã©ã§ç»åãåã
fswebcam -r 640x480 â jpeg 30 -D 1 -S 35 â no-banner ${IMG}# ç»åã${URL}ã«POSTãã
echo â{âb64strâ: ââ`base64 ${IMG}`ââ}â | \
curl -X POST -H âContent-Type: application/jsonâ -H âX-SORACOM-IMSI:${IMSI}â -H âX-SORACOM-TIMESTAMP:1234â -d @- ${URL}
- webcam-monitoring.service
capture_and_upload.shã1åå®è¡ããã ãã®ã¦ãããã§ãã
[Unit]
Description=take a pic by web cam and upload it
After=soracom.service
Requires=soracom.service[Service]
ExecStart=/usr/local/bin/capture_and_upload.sh
Type=simple
- webcam-monitoring.timer
webcam-monitoring.serviceã10ç§æ¯ã«å¼ã³åºãã¦ãããã§ãã
[Unit]
Description=web cam monitoring service
After=soracom.service
Requires=soracom.service[Timer]
OnUnitActiveSec=10sec[Install]
WantedBy=timers.target
次ã«piã¦ã¼ã¶ã¼ã§ã以ä¸ã®ã³ãã³ãå®è¡ãã¦ä¸ããã
cd
sudo cp capture_and_upload.sh /usr/local/bin
sudo chmod +x /usr/local/bin/capture_and_upload.sh
sudo cp webcam-monitoring.service /etc/systemd/system
sudo cp webcam-monitoring.timer /etc/systemd/system
sudo systemctl enable webcam-monitoring
ããã§ãwebcam-monitoring.serviceã¨webcam-monitoring.timerãsystemdã«ç»é²ããã¾ããã
2.2.1.é
ã§è¨å®ããsoracom.serviceãå®è¡ä¸ã§ããã°ãWebã«ã¡ã©ã«ããç£è¦ãµã¼ãã¹ãå®è¡ãããããã«ãªãã¾ãã
3. Webãµã¼ãã¼ã®è¨å®
3.1. Google Cloud Vision APIã®APIãã¼ã®åå¾
Google Cloud Vision APIã使ãããã«ã¯ãAPIãã¼ãå¿ è¦ã§ããAuthenticating to a Cloud API Serviceãåèã«ãã¦ãbrowser API keyãåå¾ãã¦ä¸ããã
3.2. AWS SNSã«éç¥ç¨ã¡ã¼ã«ã¢ãã¬ã¹ãç»é²ãã
(1) AWS SNSã®ã³ã³ã½ã¼ã«ãéãã¦ä¸ããã
(2) âCreate actionsâã®âCreate Topicâãªã³ã¯ãæ¼ä¸ãã¦ãâCreate new topicâã¦ã£ã³ãã¦ã表示ãããäºã確èªãã¦ä¸ããã
(3) Topic name, Diplay nameã«âsoracom_demoâã¨å ¥åããâCreate new topicâã¦ã£ã³ãã¦å³ä¸ã®Create topicãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(4) âTopics Detailsâç»é¢ã«é·ç§»ããäºã確èªãã¦ä¸ããã
(5) âCreate Subscriptionâãã¿ã³ãæ¼ä¸ãã¦ãâCreate Subscriptionâã¦ã£ã³ãã¦ã表示ãããäºã確èªãã¦ä¸ããã
(6) Protocolã«Emailãé¸æãã¦ä¸ããã
(7) Endpointã«ä¸æ£é§è»æ¤åºã®éç¥ãåããçºã®ã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãã¦ä¸ããã
(8) âCreate Subscriptionâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(9) âTopics Detailsâç»é¢ã«é·ç§»ããäºã確èªãã¦ä¸ããã
以ä¸ã§ã¡ã¼ã«ã¢ãã¬ã¹ã®ç»é²ã¯å®äºã§ãã
表示ããã¦ããTopic ARNãæ§ãã¦ããã¦ä¸ãããAWS Lambdaã§ãã®Topic ARNã使ãã¾ãã
3.3. AWS S3ã«ç»åä¿åç¨ãã±ãããä½æãã
(1) AWS S3ã®ã³ã³ã½ã¼ã«ãéãã¦ãã ããã
(2) ç»é¢å·¦ä¸ã®âãã±ãããä½æâãã¿ã³ãæ¼ä¸ããâãã±ããã®ä½æâã¦ã£ã³ãã¦ã表示ãããäºã確èªãã¦ä¸ããã
(3) ãã±ããåã«ä»»æã®ååãå ¥åãã¦ä¸ããã
(4) ãªã¼ã¸ã§ã³ã«Tokyoãæå®ãã¦ä¸ããã
(5) ã¦ã£ã³ãã¦å³ä¸ã®âä½æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
以ä¸ã§ãã±ããã®ä½æã¯å®äºã§ãã
ä½æãããã±ããåã¯æ§ãã¦ããã¦ä¸ãããAWS Lambdaã§ãã®ãã±ããåã使ãã¾ãã
3.4. AWS DynamoDBã«ä¸æ£é§è»æ¤åºç¨ã®ãã¼ãã«ãä½æãã
(1) AWS DynamoDBã®ã³ã³ã½ã¼ã«ãéãã¦ä¸ããã
(2) DynamoDBã®ã³ã³ã½ã¼ã«ã§ãâãã¼ãã«ã®ä½æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(3) âDynamoDB ãã¼ãã«ã®ä½æâç»é¢ã«é·ç§»ããäºã確èªãã¦ä¸ããã
(4) âDynamoDB ãã¼ãã«ã®ä½æâç»é¢ã§ããã¼ãã«åã«âsoracom_demoâãå ¥åãã¦ä¸ããã
(5) âDynamoDB ãã¼ãã«ã®ä½æâç»é¢ã§ããã©ã¤ããªãã¼ã«âimsiâãå ¥åããæååãé¸æãã¦ä¸ããã
(6) ç»é¢å³ä¸ã®âä½æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
以ä¸ã§ãã¼ãã«ã®ä½æã¯å®äºã§ãã
ä½æãããã¼ãã«åã¯æ§ãã¦ããã¦ä¸ãããAWS Lambdaã§ãã®ãã¼ãã«åã使ãã¾ãã
3.5. AWS IAMã§ä¸æ£é§è»æ¤åºç¨ã®ãã¼ã«ãä½æãã
(1) AWS IAMã®ã³ã³ã½ã¼ã«ãéãã¦ä¸ããã
(2) ç»é¢å·¦ä¸å¤®ä»è¿ã®âãã¼ã«âãæ¼ä¸ãã¦ä¸ããã
(3) ç»é¢å³ãé·ç§»ããã®ã確èªããâæ°ãããã¼ã«ã®ä½æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(4) âæé 1: ãã¼ã«åã®è¨å®âç»é¢ã«é·ç§»ããã®ã確èªãããã¼ã«åã«soracom_demoãå ¥åãã¦ãç»é¢å³ä¸ã®â次ã®ã¹ãããâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(5) âæé 2: ãã¼ã«ã¿ã¤ãã®é¸æâç»é¢ã«é·ç§»ããã®ã確èªããâAWSãµã¼ãã¹ãã¼ã«âã§ãAWS Lambdaã®å³ã«ããâé¸æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(6) âæé 4: ããªã·ã¼ã®ã¢ã¿ããâç»é¢ã«é·ç§»ããã®ã確èªãã以ä¸ã®4ã¤ã®ããªã·ã¼ã«å¯¾ãã¦ãåè¡ã®1åç®ã«ãããã§ãã¯ãã¿ã³ãæ¼ä¸ãããã§ãã¯ãå ¥ãã¦ä¸ããã
- AmazonS3FullAccess
- AmazonDynamoDBFullAccess
- AWSLambdaBasicExecutionRole
- AmazonSNSFullAccess
(7) âæé 4: ããªã·ã¼ã®ã¢ã¿ããâç»é¢å³ä¸ã«ããâ次ã®ã¹ãããâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(8) âæé 5: 確èªâç»é¢ã«é·ç§»ããäºã確èªããç»é¢å³ä¸ã®âãã¼ã«ã®ä½æâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
以ä¸ã§ãã¼ã«ã®ä½æã¯å®äºã§ãã
AWS Lambdaã§ãã®ãã¼ã«ã使ãã¾ãã
3.6. AWS Lambdaã«ä¸æ£é§è»æ¤åºå¦çãç»é²ãã
(1) AWS Lambdaã®ã³ã³ã½ã¼ã«ãéãã¦ä¸ããã
(2) âCreate a Lambda functionâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(3) âStep 1: Select blueprintâç»é¢ã«é·ç§»ããäºã確èªããç»é¢å³ä¸ã®âSkipâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(4) âStep 2: Configure functionâç»é¢ã«é·ç§»ããäºã確èªããç»é¢ä¸ã®3ã¤ã®é ç®ã«ä»¥ä¸ã®å 容ãå ¥åãã¦ä¸ããã
- Name: âsoracom_demoâ
- Description: âsoracom demoâ
- Runtime: python2.7
(5) âStep 2: Configure functionâç»é¢ã®âLambda function codeâã§ãCode entry typeã©ã¸ãªãã¿ã³ãâEdit code inlineâãé¸æãã¦ããäºã確èªãã¦ä¸ããã
(6) âStep 2: Configure functionâç»é¢ã®âLambda function codeâã§ã大ããªããã¹ãããã¯ã¹ã«æ¬¡ã®ã³ã¼ããå ¥åãã¦ä¸ããã
(7) âStep 2: Configure functionâç»é¢âLambda function codeâã®å¤§ããªããã¹ãããã¯ã¹ã«å ¥åããã³ã¼ãä¸ã®GCV_KEYå¤æ°ã®å 容ãã3.1.é ã§åå¾ããbrowser APIãã¼ã«å¤æ´ãã¦ä¸ããã
(8) âStep 2: Configure functionâç»é¢âLambda function codeâã®å¤§ããªããã¹ãããã¯ã¹ã«å ¥åããã³ã¼ãä¸ã®TOPIC_ARNå¤æ°ã®å 容ãã3.2.é ã§åå¾ããTopic ARNã«å¤æ´ãã¦ä¸ããã
(9) âStep 2: Configure functionâç»é¢âLambda function codeâã®å¤§ããªããã¹ãããã¯ã¹ã«å ¥åããã³ã¼ãä¸ã®BUCKET_NAMEå¤æ°ã®å 容ãã3.3.é ã§åå¾ãããã±ããåã«å¤æ´ãã¦ä¸ããã
(10) âStep 2: Configure functionâç»é¢âLambda function codeâã®å¤§ããªããã¹ãããã¯ã¹ã«å ¥åããã³ã¼ãä¸ã®DYNAMO_TABLEå¤æ°ã®å 容ãã3.4.é ã§åå¾ããDynamoDBã®ãã¼ãã«åã«å¤æ´ãã¦ä¸ããã
(11) âStep 2: Configure functionâç»é¢âLambda function handler and roleâã§ãHandlerããã¹ãããã¯ã¹ã«âlambda_function.lambda_handlerâã¨å ¥åãã¦ä¸ããã
(12) âStep 2: Configure functionâç»é¢âLambda function handler and roleâã§ãRoleã«3.5.é ã§ä½æããsoracom_demoãæå®ãã¦ä¸ããã
(13) âStep 2: Configure functionâç»é¢å³ä¸ã®âNextâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(14) âStep 3: Reviewâç»é¢ã«é·ç§»ããäºã確èªããç»é¢å³ä¸ã®âCreate functionâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
以ä¸ã§AWS Lambdaã¸ã®ä¸æ£é§è»æ¤åºå¦çã®ç»é²ãå®äºãã¾ããã
3.7. AWS API Gatewayã«ããWebãµã¼ãã¼ã®å ¬é
(1) AWS API Gatewayã®ã³ã³ã½ã¼ã«ãéãã¦ä¸ããã
(2) âAPIã®ä½æâãã¿ã³ãæ¼ä¸ããç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(3) ç»é¢ã®âNew APIâã©ã¸ãªãã¿ã³ãé¸æããã¦ããäºã確èªãã¦ä¸ããã
(4) âAPIåâããã¹ãããã¯ã¹ã«âsoracom_demoâã¨å ¥åããç»é¢å³ã®âAPIã®ä½æâãã¿ã³ãæ¼ä¸ãã¦ãç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(5) âActionsâã»ã¬ã¯ãããã¯ã¹ãæ¼ä¸ãã¦ä¸è¦§ã表示ãããâCreate Methodâãæ¼ä¸ãã¦ä¸ããã
(6) æ°ãã表示ãããã»ã¬ã¯ãããã¯ã¹ãæ¼ä¸ãã¦ä¸è¦§ã表示ãããâPOSTâãæ¼ä¸ãããã®ã»ã¬ã¯ãããã¯ã¹ã®å³å´ã«ãã§ãã¯ãã¼ã¯ã¢ã¤ã³ã³ã表示ãããäºã確èªãã¦ä¸ããã
(7) (6)ã§è¡¨ç¤ºããããã§ãã¯ãã¼ã¯ã¢ã¤ã³ã³ãæ¼ä¸ããç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(8) âLambdaé¢æ°âã©ã¸ãªãã¿ã³ãæ¼ä¸ããâLambdaé¢æ°âãé¸æãã¦ä¸ããã
(9) âLambdaãªã¼ã¸ã§ã³âã»ã¬ã¯ãããã¯ã¹ãããâap-northeast-1"ãé¸æãã¦ä¸ããã
(10) âLambdaé¢æ°âããã¹ãããã¯ã¹ã«âsoracom_demoâã¨å ¥åããç»é¢å³ã®âä¿åâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(11) âLambdaçµ±åâã¦ã£ã³ãã¦ããããã¢ãããããäºã確èªããâOKâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(12) âLambda é¢æ°ã«æ¨©éã追å ããâã¦ã£ã³ãã¦ããããã¢ãããããäºã確èªããâOKâãã¿ã³ãæ¼ä¸ãã¦ç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(13) âã¡ã½ãããªã¯ã¨ã¹ãâã®ãªã³ã¯ãæ¼ä¸ããç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(14) âHTTPãªã¯ã¨ã¹ããããã¼âæååã®å·¦ã«ããä¸è§å½¢ã®ãã¿ã³ãæ¼ä¸ããââ ãããã¼ã®è¿½å âãç¾ããäºã確èªãã¦ä¸ããã
(15) ââ ãããã¼ã®è¿½å âãªã³ã¯ãæ¼ä¸ããã¨ç¾ããããã¹ãããã¯ã¹ã«âX-SORACOM-IMSIâã¨å ¥åãããã®ããã¹ãããã¯ã¹ã®ããè¡ã®å³ã«ãããã§ãã¯ãã¼ã¯ã¢ã¤ã³ã³ãæ¼ä¸ãã¦ä¸ããã
(16) ââ ãããã¼ã®è¿½å âãªã³ã¯ãæ¼ä¸ããã¨ç¾ããããã¹ãããã¯ã¹ã«âX-SORACOM-TIMESTAMPâã¨å ¥åãããã®ããã¹ãããã¯ã¹ã®ããè¡ã®å³ã«ãããã§ãã¯ãã¼ã¯ã¢ã¤ã³ã³ãæ¼ä¸ãã¦ä¸ããã
(17) âã¡ã½ããã®å®è¡âãªã³ã¯ãæ¼ä¸ãã¦ãç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(18) âçµ±åãªã¯ã¨ã¹ãâãªã³ã¯ãæ¼ä¸ãã¦ãç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(19) â ãããã³ã°ãã³ãã¬ã¼ãâæååã®å·¦ã«ããä¸è§å½¢ã®ãã¿ã³ãæ¼ä¸ããââ ãããã³ã°ãã³ãã¬ã¼ãã®è¿½å âãªã³ã¯ãç¾ããäºã確èªãã¦ä¸ããã
(20) ââ ãããã³ã°ãã³ãã¬ã¼ãã®è¿½å âãªã³ã¯ãæ¼ä¸ããâContent-Typeâãã¼ãã«ã«ããããã¹ãããã¯ã¹ã«âapplication/jsonâã¨å ¥åããããã¹ãããã¯ã¹ã®å³ã«ãããã§ãã¯ãã¼ã¯ã¢ã¤ã³ã³ãæ¼ä¸ãã¦ä¸ããã
(21) ââ ãããã³ã°ãã³ãã¬ã¼ãã®è¿½å âãªã³ã¯ã®å³ã«å¤§ããããã¹ãããã¯ã¹ãç¾ããäºã確èªãã以ä¸ã®æååãå ¥åãã¦ãããç»é¢å³ä¸ã®âSaveâãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
{
âimsiâ:â$input.params(âX-SORACOM-IMSIâ)â,
âtimestampâ:$input.params(âX-SORACOM-TIMESTAMPâ),
âb64strâ:$input.json(â$.b64strâ)
}
(22) âã¡ã½ããã®å®è¡âãªã³ã¯ãæ¼ä¸ãã¦ãç»é¢ãé·ç§»ããäºã確èªãã¦ä¸ããã
(23) âActionsâã»ã¬ã¯ãããã¯ã¹ãæ¼ä¸ãã¦ä¸è¦§ã表示ãããâAPIã®ãããã¤âãæ¼ä¸ãã¦ä¸ããã
(24) âAPIã®ãããã¤âã¦ã£ã³ãã¦ã表示ãããäºã確èªããâãããã¤ãããã¹ãã¼ã¸âã»ã¬ã¯ãããã¯ã¹ããâ[New Stage]âãé¸æãã¦ä¸ããã
(25) âã¹ãã¼ã¸åâããã¹ãããã¯ã¹ã«âprodâã¨å ¥åãã¦ãããã¦ã£ã³ãã¦ã®å³ä¸ã«ããâãããã¤âãã¿ã³ãæ¼ä¸ãã¦ä¸ããã
(26) ç»é¢ãé·ç§»ãã¦ãâURLã®å¼ã³åºãâæååã®å³ã«URLã表示ããã¦ããäºã確èªãããããã®URLãæ§ãã¦ä¸ããã
(27) 2.3.2.é ã§ä½æããcapture_and_upload.shã®URLå¤æ°ã«(26)ã§æ§ããURLãå ¥åãã¦ä¸ããã
以ä¸ã§Webãµã¼ãã¼ã®å ¬éãå®äºãã¾ããã
Raspberry Piã«é»æºãå
¥ããä¸æ£é§è»ã®ç£è¦ãå®è¡ãã¦ä¸ããã
ä¸æ£é§è»ããã£ãå ´åã«ãç»é²æ¸ã¿ã®ã¡ã¼ã«ã¢ãã¬ã¹ã«ä¸æ£é§è»æ¤åºã®ã¡ã¼ã«ãå±ãäºã確èªãã¦ä¸ããã