source: rtos_arduino/trunk/arduino_lib/libraries/Ciao/examples/CiaoArduinoXMPP/CiaoArduinoXMPP.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.1 KB
Line 
1/*
2 Arduino Ciao example
3
4 This sketch uses ciao xmpp connector. It sends back “hello world” message to the xmpp client when receives “ciao” from it.
5
6 Be sure to set the xmpp client in the "USER" field used to receive the response by MCU.
7
8 Possible commands to send from the xmpp client:
9 * "ciao" -> random answers in 5 different languages
10
11 created September 2015
12 by andrea[at]arduino[dot]org
13
14
15 NOTE: be sure to activate and configure xmpp connector on Linino OS
16 http://labs.arduino.org/Ciao
17
18 */
19
20#include <Ciao.h>
21
22String USER="user@domain";
23String mess[5]={"Hi, I am MCU :-P","hallo , ik ben MCU :-P","bonjour, je suis MCU :-P","Ciao, io sono MCU :-P","Kon'nichiwa, watashi wa MCU yo :-P" };
24
25void setup() {
26 Ciao.begin();
27}
28
29void loop() {
30
31 CiaoData data = Ciao.read("xmpp");
32
33 if(!data.isEmpty()){
34 String id = data.get(0);
35 String sender = data.get(1);
36 String message = data.get(2);
37
38 message.toLowerCase();
39 if(message == "ciao" )
40 Ciao.write("xmpp", USER,mess[random(0,5)]);
41 }
42}
43
Note: See TracBrowser for help on using the repository browser.