Updated directories

Dependencies:   EthernetInterface LM75B MMA7660 WebSocketClient mbed-rtos mbed

Fork of app-board-Ethernet-Websocket by jim hamblen

Uses updated libraries, working as of 28/4/14.

Committer:
samux
Date:
Fri Feb 08 12:46:02 2013 +0000
Revision:
2:1fae595547d5
Parent:
1:1ca9c7ae7e0b
Child:
3:26f41c921c2d
demo using acc and tmp sensors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 2:1fae595547d5 1 #include "mbed.h"
samux 2:1fae595547d5 2 #include "EthernetInterface.h"
samux 2:1fae595547d5 3 #include "Websocket.h"
samux 2:1fae595547d5 4 #include "MMA7660.h"
samux 2:1fae595547d5 5 #include "LM75B.h"
samux 2:1fae595547d5 6
samux 2:1fae595547d5 7 // accelerometer
samux 2:1fae595547d5 8 MMA7660 acc(p28, p27);
samux 2:1fae595547d5 9
samux 2:1fae595547d5 10 // temperature sensor
samux 2:1fae595547d5 11 LM75B tmp(p28,p27);
samux 2:1fae595547d5 12
samux 2:1fae595547d5 13 DigitalOut l1(LED1);
samux 2:1fae595547d5 14
samux 2:1fae595547d5 15 int main() {
samux 2:1fae595547d5 16 char json_str[100];
samux 2:1fae595547d5 17
samux 2:1fae595547d5 18 if (acc.testConnection())
samux 2:1fae595547d5 19 l1 = 1;
samux 2:1fae595547d5 20
samux 2:1fae595547d5 21 EthernetInterface eth;
samux 2:1fae595547d5 22 eth.init(); //Use DHCP
samux 2:1fae595547d5 23 eth.connect();
samux 2:1fae595547d5 24 printf("IP Address is %s\n\r", eth.getIPAddress());
samux 2:1fae595547d5 25
samux 2:1fae595547d5 26 // See the output on http://sockets.mbed.org/app-board/viewer
samux 2:1fae595547d5 27 Websocket ws("ws://sockets.mbed.org:443/ws/app-board/wo");
samux 2:1fae595547d5 28 ws.connect();
samux 2:1fae595547d5 29
samux 2:1fae595547d5 30 while (1) {
samux 2:1fae595547d5 31 // create json string with acc/tmp data
samux 2:1fae595547d5 32 sprintf(json_str, "{\"id\":\"app_board_eth_EW2013\",\"ax\":%d,\"ay\":%d,\"az\":%d, \"tmp\":%d}", (int)(acc.x()*360), (int)(acc.y()*360), (int)(acc.z()*360), (int)tmp.read());
samux 2:1fae595547d5 33
samux 2:1fae595547d5 34 // send str
samux 2:1fae595547d5 35 ws.send(json_str);
samux 2:1fae595547d5 36
samux 2:1fae595547d5 37 wait(0.1);
samux 2:1fae595547d5 38 }
samux 0:11bb5faeb547 39 }