ssssss

Committer:
3116redtrain
Date:
Sat Dec 17 11:03:10 2016 +0000
Revision:
1:e6addce35f93
Parent:
0:01a2e92d2924
first comp;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
3116redtrain 0:01a2e92d2924 1 #ifndef CUSHION_SOCK_H
3116redtrain 0:01a2e92d2924 2 #define CUSHION_SOCK_H
3116redtrain 0:01a2e92d2924 3
3116redtrain 0:01a2e92d2924 4 #include "mbed.h"
3116redtrain 0:01a2e92d2924 5 #include "Websocket.h"
3116redtrain 0:01a2e92d2924 6 #include "EthernetNetIf.h"
3116redtrain 0:01a2e92d2924 7 #include "MbedJSONValue.h"
3116redtrain 0:01a2e92d2924 8
3116redtrain 0:01a2e92d2924 9
3116redtrain 0:01a2e92d2924 10 class CushionSock
3116redtrain 0:01a2e92d2924 11 {
3116redtrain 0:01a2e92d2924 12 public:
3116redtrain 0:01a2e92d2924 13 int MESS_STOP;
3116redtrain 0:01a2e92d2924 14 int MESS_START;
3116redtrain 0:01a2e92d2924 15 int MESS_SIT;
3116redtrain 0:01a2e92d2924 16 int MESS_FRUST;
3116redtrain 0:01a2e92d2924 17 int MESS_TEST;
3116redtrain 1:e6addce35f93 18 int MESS_TWEET;
3116redtrain 0:01a2e92d2924 19
3116redtrain 0:01a2e92d2924 20 /*
3116redtrain 0:01a2e92d2924 21 Constructor
3116redtrain 0:01a2e92d2924 22 @param hostAndport format : "hostname:port"
3116redtrain 0:01a2e92d2924 23 */
3116redtrain 1:e6addce35f93 24 CushionSock();
3116redtrain 0:01a2e92d2924 25
3116redtrain 1:e6addce35f93 26 void init(char * hostAndPort);
3116redtrain 0:01a2e92d2924 27 /*
3116redtrain 0:01a2e92d2924 28 connect to server
3116redtrain 0:01a2e92d2924 29 @return true if the connection is established, false otherwise
3116redtrain 0:01a2e92d2924 30 */
3116redtrain 0:01a2e92d2924 31 bool connect();
3116redtrain 0:01a2e92d2924 32
3116redtrain 0:01a2e92d2924 33 /*
3116redtrain 0:01a2e92d2924 34 send message to server
3116redtrain 0:01a2e92d2924 35 @return the number of bytes sent
3116redtrain 0:01a2e92d2924 36 @param type Message type(prease show and choose from line 14 to 17 in souece code)
3116redtrain 0:01a2e92d2924 37 @param msg message payload
3116redtrain 0:01a2e92d2924 38 */
3116redtrain 0:01a2e92d2924 39 int mess_send(int type, char * msg);
3116redtrain 0:01a2e92d2924 40
3116redtrain 0:01a2e92d2924 41 /*
3116redtrain 0:01a2e92d2924 42 Recieve message from server
3116redtrain 0:01a2e92d2924 43 @return if recieved succsessful, Message type(prease show and choose from line 14 to 17 in souece code), otherwise returns -1.
3116redtrain 0:01a2e92d2924 44 @param msg pointer to the message to be read.
3116redtrain 0:01a2e92d2924 45 */
3116redtrain 0:01a2e92d2924 46 int mess_recv(char * msg);
3116redtrain 0:01a2e92d2924 47
3116redtrain 0:01a2e92d2924 48 /*
3116redtrain 0:01a2e92d2924 49 To see if there is a SocketIO connection active
3116redtrain 0:01a2e92d2924 50 @return true if there is a connection active
3116redtrain 0:01a2e92d2924 51 */
3116redtrain 0:01a2e92d2924 52 bool is_connected();
3116redtrain 0:01a2e92d2924 53
3116redtrain 0:01a2e92d2924 54 bool close();
3116redtrain 0:01a2e92d2924 55
3116redtrain 0:01a2e92d2924 56 private:
3116redtrain 0:01a2e92d2924 57 EthernetNetIf *eth;
3116redtrain 0:01a2e92d2924 58 Websocket *ws;
3116redtrain 0:01a2e92d2924 59 };
3116redtrain 0:01a2e92d2924 60 #endif