Rev | Line | |
---|
[136] | 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 |
|
---|
| 22 | String USER="user@domain";
|
---|
| 23 | String 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 |
|
---|
| 25 | void setup() {
|
---|
| 26 | Ciao.begin();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | void 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.