zabuton library
Dependencies: CushionSock EthernetNetIf MbedJSONValue mbed
main.cpp
00001 #include "mbed.h" 00002 #include "CushionSock.h" 00003 00004 int main() { 00005 Timer timer; 00006 CushionSock *cs; 00007 00008 cs=new CushionSock(); 00009 cs->init("ws://www2.minelab.jp:12020/test"); 00010 printf("connect start\n"); 00011 cs->connect(); 00012 printf("connect"); 00013 00014 char msg[64]; 00015 int counter=0; 00016 timer.start(); 00017 while(1) { 00018 Net::poll(); 00019 if (timer.read_ms() >= 2000) { 00020 cs->mess_send(cs->MESS_TEST, "down"); 00021 timer.reset(); 00022 counter++; 00023 } 00024 int type = cs->mess_recv(msg); 00025 if (type >= 0) { 00026 printf("messtype:%d rcv: %s\r\n",type, msg); 00027 } 00028 00029 Net::poll(); 00030 00031 if(!cs->is_connected()||counter>10) 00032 break; 00033 } 00034 cs->close(); 00035 }
Generated on Thu Jul 14 2022 08:11:09 by 1.7.2