Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iot:labs:11 [2015/07/20 12:15]
avner.solomon [2) Newsfeed]
iot:labs:11 [2020/01/07 18:55] (current)
jan.vaduva [Lab 11: IoT usecase for Yocto Project]
Line 1: Line 1:
-===== Lab 11 Web Services ​=====+======Lab 11: IoT usecase for Yocto Project======
  
-===== 1) Chat ===== +Open the AGL getting ​started ​guide located ​at: [[https://docs.automotivelinux.org/docs/en/​guppy/​getting_started/​reference/​getting-started/​image-workflow-intro.html|Developing an AGL Image]]
-Using the what you learned in course 11 continue the chat app you started ​in laboratory 10. +
-For this you have an api at +
-http://api.my-sandbox.co/chat/chat.php +
-When you call get on it you will receive all the messages +
-When you send via post the variables username and msg to it, it will add a message to the chat. +
-For visibility show only last 5-10 messagesEach message is separated by "​\n"​+
  
-In order to fetch the messages you need to use the ajax get method from jquery ​and +Set up your Linux system with the right packages (instruction are provided for Ubuntu, Fedora, CentOS ​and openSUSE)
-replace the \n with <br> in order to display them+
  
-  $.get('http://api.my-sandbox.co/chat/chat.php',​ function(msgs){ +  ​- Install prerequisites:​ <​code>​sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ 
-    ​msgs ​msgs.split("​\n"​).slice(-5).join("<br>"); +     ​build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 
-    //display msgs in some container +     ​xz-utils debianutils iputils-ping libsdl1.2-dev xterm xsltproc docbook-utils \ 
-  ​})+     fop dblatex xmlto make python-git curl</​code>​ 
 +  - Define the work directory<​code>​$ export AGL_TOP=$HOME/workspace_agl 
 +$ mkdir -p $AGL_TOP 
 +</code> 
 +  ​Setup //repo// tool: <​code>​$ mkdir -p ~/bin 
 +$ export PATH=~/​bin:​$PATH 
 +$ curl https://​storage.googleapis.com/git-repo-downloads/​repo > ~/​bin/​repo 
 +$ chmod a+x ~/​bin/​repo 
 +</​code>​ 
 +  - Download latest stable AGL release: <​code>​$ cd $AGL_TOP 
 +$ repo init -b guppy -u https://​gerrit.automotivelinux.org/​gerrit/​AGL/​AGL-repo 
 +$ repo sync 
 +</code
 +  - Source ​//aglsetup.sh//​ script, to create the build directory: <​code>​$ source meta-agl/​scripts/​aglsetup.sh -f -m qemux86-64 agl-demo agl-devel</​code>​ 
 +  ​- Build the OS image: <​code>​$ bitbake agl-demo-platform</​code>​ 
 +  - Build the OS SDK image: <​code>​$ bitbake agl-demo-platform-crosssdk</​code>​  
 +  - Decompress the OS image that resulted after the build: <​code>​$ cd tmp/​deploy/​images/​qemux86-64 
 +$ xz -d agl-demo-platform-qemux86-64.vmdk.xz</​code>​ 
 +  - Boot the image with QEMU: <​code>​$ sudo apt-get install qemu-system-x86 
 +$ qemu-system-x86_64 -enable-kvm -m 2048 \ 
 +    -hda agl-demo-platform-qemux86-64.vmdk \ 
 +    -cpu kvm64 -cpu qemu64,​+ssse3,​+sse4.1,​+sse4.2,​+popcnt \ 
 +    -vga virtio -show-cursor \ 
 +    -device virtio-rng-pci \ 
 +    -serial mon:stdio -serial null \ 
 +    -soundhw hda \ 
 +    -net nic,vlan=0 \ 
 +    -net user,​hostfwd=tcp::​2222-:​22 
 +</​code>​
  
-The split method applied on a string splits the string into an array of strings using the given separator. +===== Exercises===== 
-The slice method is used to select certain elements of an array , here the last 5. +  - Replicate a successful AGL setup
-The join method applied on an array returns of string generated by concatenating the elements of the array +  - Get the list of packages the newly defined image has 
-of delimiting them by the given separator. +  - Check if packages such as openssh ​and screen are included in the image
- +  Deploy ​the AGL image onto VirtualBox 5.2.0 or laterYou could also try using the latest snapshot available: [[https://download.automotivelinux.org/AGL/snapshots/master/latest/qemux86-64/deploy/images/qemux86-64/|AGL Snapshot]]
-In order to send a message you will need to use the post ajax call: +
- +
-  $.post('​http://​api.my-sandbox.co/​chat/​chat.php',​{username:"​some user name|, msg:"​the contents of the msg"}, function(result){ +
-    //code to run when msg sent successfully  +
-  }) +
-===== 2) Newsfeed ​===== +
- +
-Continue the newsfeed you started in laboratory 10+
-Implement support for reading ​the whole article bu showing it on a new page +
-and support for liking articles and display ​the number of likes+
- +
-For this you will have an api at: +
- +
-http://​api.my-sandbox.co/​news/​get.php +
-used to fetch latest news and +
-http://​api.my-sandbox.co/​news/​get.php?​id=PRIMARY_KEY_OF_ARTICLE +
-to fetch the full article +
- +
-and for likes +
- +
-GET http://api.my-sandbox.co/​news/​like.php with +
-with id set in order to get the number of likes for an article +
- +
-GET http://api.my-sandbox.co/news/like.php with +
-with id and uuid set in order to get if you liked or not an article +
- +
-POST http://api.my-sandbox.co/news/​like.php with a JSON +
-  { +
-    method:"​like",​ +
-    uuid:"​phone-uuid",​ +
-    pk:"​article-pk"​ +
-  } +
-in order to like an article +
- +
-POST http://api.my-sandbox.co/news/​like.php with a JSON +
-  { +
-    method:"​unlike",​ +
-    uuid:"​phone-uuid",​ +
-    pk:"​article-pk"​ +
-  } +
-in order to dislike an article. +
- +
-To get the uuid of the phone just access +
-device.uuid +
-The device plugin must be installed (it should be installed in your apps by default but you will have to move the config.xml from the root folder in the www folder) +
- +
-Fetching of news is identical to fetching the text in exercise one. This is also true for fetching the +
-like count with or without id. +
- +
-I order to set JSON encoded messages though you will need to use JSON.stringify method like in the following example: +
-  var json_object = { method:"​like",​ uuid:​device.uuid,​ pk:1 } +
-  $.post(URL,​JSON.stringify(json_object),​ function(response){ ​//post respone action }); +
-===== 3) Comunicate with webservers from your boards ===== +
- +
-Depending on what you made your boards try to make the phone communicate with the webserver from the boards.+
iot/labs/11.1437383705.txt.gz · Last modified: 2015/07/20 12:15 by avner.solomon
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0