Send Yo from mbed! http://www.justyo.co/

Dependencies:   EthernetInterface HTTPClient YoApi mbed-rtos mbed

Committer:
hsgw
Date:
Wed Jun 25 13:16:28 2014 +0000
Revision:
1:b0396f5cb9eb
Parent:
0:4d758dace8b9
go public

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hsgw 0:4d758dace8b9 1 /** YoApi Example
hsgw 0:4d758dace8b9 2 * Copyright (c) 2014, Takuya Urakawa
hsgw 0:4d758dace8b9 3 *
hsgw 0:4d758dace8b9 4 * Send Yo from mbed.
hsgw 0:4d758dace8b9 5 * You can get your Yo API token from https://medium.com/@YoAppStatus/yo-developers-api-e7f2f0ec5c3c
hsgw 0:4d758dace8b9 6 */
hsgw 0:4d758dace8b9 7
hsgw 0:4d758dace8b9 8 #include "mbed.h"
hsgw 0:4d758dace8b9 9 #include "EthernetInterface.h"
hsgw 0:4d758dace8b9 10 #include "HTTPClient.h"
hsgw 0:4d758dace8b9 11 #include "YoApi.h"
hsgw 0:4d758dace8b9 12
hsgw 0:4d758dace8b9 13 const char* apiToken = "YOUR_API_TOKEN";
hsgw 0:4d758dace8b9 14
hsgw 0:4d758dace8b9 15 EthernetInterface eth;
hsgw 0:4d758dace8b9 16 HTTPClient http;
hsgw 0:4d758dace8b9 17 YoApi yo(http,apiToken);
hsgw 0:4d758dace8b9 18
hsgw 0:4d758dace8b9 19 int main() {
hsgw 0:4d758dace8b9 20 printf("Yo from mbed\n");
hsgw 0:4d758dace8b9 21 printf("Ethernet initializing\n");
hsgw 0:4d758dace8b9 22 eth.init();
hsgw 0:4d758dace8b9 23 eth.connect();
hsgw 0:4d758dace8b9 24
hsgw 0:4d758dace8b9 25 //Yo!
hsgw 0:4d758dace8b9 26 int ret = yo.send();
hsgw 0:4d758dace8b9 27 if(!ret) {
hsgw 0:4d758dace8b9 28 printf("YO!\n");
hsgw 0:4d758dace8b9 29 }else{
hsgw 0:4d758dace8b9 30 printf("Error - ret = %d\n", ret);
hsgw 0:4d758dace8b9 31 }
hsgw 0:4d758dace8b9 32
hsgw 0:4d758dace8b9 33 printf("Disconnect Ethernet\n");
hsgw 0:4d758dace8b9 34 eth.disconnect();
hsgw 0:4d758dace8b9 35
hsgw 0:4d758dace8b9 36 return 0;
hsgw 0:4d758dace8b9 37 }