Let me share a short video demo and tutorial about How to setup (a minimal) IOT System using Linux TIzen, iotivity and mraa.

So to make short I tried to make the puzzle’s pieces fit together, note adaptations are about to be integrated into tizen as community contributions and forwarded upstream too.

I know I have to improve the video, but I have a better offer for you, ask me to explain this during FOSDEM in a couple of days (among other surprises), track us at :

https://wiki.tizen.org/wiki/FOSDEM

 

http://www.slideshare.net/rzrfreefr/iotivity-tizenfosdem2015

Feel free to ask any support if instructions are unclear I’ll update this article later.

Hope this will help the community to make a good use of it.

 

 

https://www.youtube.com/watch?v=GnxmLA1j1Bo&list=PLzQ3SYrvd0O2eHEs_kgShUSpL33Ezqm4k&index=31

Setup Hardware

Minnowboard Max is providing GPIO headers so you can easily check yourself with a single LED.

First let’s plug a LED (safer if protected with a 10K resistor) between pin 18 and pin 1 (shortest leg to ground) like this :

                                                                 +---|<|---+

                                                                 |      !

|                                                                |      L |

  +-------------------------------------------------------------|----+  E |

   | MinnowMax                +---------------------------------|--+ |  D |

   |                          |  o  o  o  o    o  (....)  o (1) | |    |

   |                          | (26) o  o  o  (18) (....)  o  o  | |    |

   |                          +------------------|-----------------+ |    |

   |                                              |                  |    |

   |                                              +-----[/\/\]-------------+

   |                                                  Resistor      |

   +------+                                                          |

   | USB2 |                                                          |

   +------+        +--------+                                  +----+

   | USB3 |        | CPU    |                                  |Eth |

   +------+        |  E32xx |                                  |    |

   |                +--------+                                  +----+

   |                                                                  |

   |                                                                  |

   |                                                                  |

   +------+                                                      +----+

   | u SD |                                                      | HD |

   | card |                                                      | MI |

   +------+    +------+    +------+        +------+  +----+    +----+

   |            | FTDI |    | SATA |        |  JP  |  | SW |        |

   +------------+------+----+------+---------+------+--+----+---------+

Pin18 (GPIO_I2S_DO Data Out / GPIO)  is just a random GPIO from Minnowboard reference documentation :

http://www.elinux.org/Minnowboard:MinnowMax#Low_Speed_Expansion_.28Top.29

See Tizen reference how to install common image to sdcard, I used tizen-common_20150128.1_common-wayland-efi-x86_64-sda.raw.bz2 from  http://download.tizen.org/snapshots/tizen/common/latest/images/x86_64-wayland/common-wayland-efi-x86_64/ )

The important thing is that the GPIO mapping differing between kernel version, so GPIO218 will be used for pin20

So far Tizen:Common uses Linux 3.14 (LTSI version) :


bash-4.3# uname -a
Linux common_box 3.14.25-16.10-common-x86_64-default #1 SMP PREEMPT Tue Jan 13 13:36:58 UTC 2015 x86_64 GNU/Linux

Let’s do some direct check, led show switch on and off this way :


n=219 # for pin=18
echo $n | sudo tee /sys/class/gpio/export
echo out | sudo tee /sys/class/gpio/gpio$n/direction
echo 1 | sudo tee /sys/class/gpio/gpio$n/value
sleep 5
echo 0 | sudo tee /sys/class/gpio/gpio$n/value

It will validate your hardware setup.

Setup Software

Edit: Tizen is now providing the built packages :

  zypper ar http://download.tizen.org/live/Contrib:/Common/x86_64-wayland/Contrib:Common.repo

  zypper in iotivity-devel

So you can skip this next session :

The new stuff is here, but until rpm packages are published on Tizen infra, you can rebuild sources from my repos (ask for files if needed) :


git clone https://github.com/rzr/mraa.git
cd mraa
git checkout sandbox/pcoval/tizen
gbs build

git clone https://github.com/rzr/iotivity.git
cd iotivity
git checkout sandbox/pcoval/tizen
gbs build

Last action you need to also rebuild this sample code inspired from upstream  :


git clone https://gitorious.org/tizen/iotivity-example.git
cd iotivity-example
gbs build

And install it all on target :

zypper in iotivity-example iotivity mraa

Note, I shared demo’s code as a minimal standalone project to be used on any hardware.

Running sesssion

To make it simpler client and server will run on the same host and we will switch between them using GNU screen :

Starting server :

ssh root@host # passwd=tizen
zypper in iotivity-example screen

screen

bash-4.3# /usr/lib64/iotivity-example/server
Server:
Press Ctrl-C to quit....
Running IoTServer constructor
Successfully created Platform.Led resource

Starting client in an other shell (hit “ctrl+a c” create new screen)


bash-4.3# /usr/lib64/iotivity-example/client
Running IoTClient constructor
Performing Discovery...

Found Resource
Resource Types:
        Platform.Led
Resource Interfaces:
        iotivity.example.resources
Resource uri: /led
host: coap://192.168.21.213:51270

Enter:
0) Display this menu
1) Turn LED ON
2) Turn LED OFF
9) Quit
1
Set LED switch to: 1

The server is found and communication with coap protocol is ready for orders.

So we switched LED on and see server side  (Ctrl+a a) :


bash-4.3# /usr/lib64/iotivity-example/server
Server:
Press Ctrl-C to quit....
Running IoTServer constructor
Successfully created Platform.Led resource
0:
In entity handler wrapper:

PUT request for platform LED
Turned on LED

Thanks but we knew LED was on :)

Now Stop client and server move the led to the next pin 20 or anyone your board support and restart server :


/usr/lib64/iotivity-example/server 20
Server:
Press Ctrl-C to quit....
Running IoTServer constructor
Successfully created Platform.Led resource
0:
In entity handler wrapper:

PUT request for platform LED
Turned on LED

You can create several clients and run them on different host they will work same.

Let me thank Arron Wang for his initial tizen work and those who merged my patches to get iotivity working on Tizen:Common.

Resources

Source: https://dockr.eurogiciel.fr/blogs/embedded/iotivity//

Copyleft: CC-BY-SA ~pcl

Iotivity on tizen