1919 *
2020 * */
2121
22- #include " wic_client.hpp "
23- #include " wic_nsapi.hpp "
22+ #include " wic_client.h "
23+ #include " wic_nsapi.h "
2424#include " EthernetInterface.h"
2525#include < cinttypes>
2626
@@ -56,20 +56,16 @@ int main()
5656 int n;
5757
5858 static EthernetInterface eth;
59- static WIC::Client<sizeof (buffer), 1012 > client (eth);
59+ static WIC::Client<sizeof (buffer)> client (eth);
6060
6161 eth.connect ();
6262
6363 retval = client.connect (" ws://192.168.1.108:9001/getCaseCount?agent=mbed" );
6464
6565 if (retval == NSAPI_ERROR_OK){
6666
67- time_since ();
68-
6967 retval = client.recv (encoding, fin, buffer, sizeof (buffer));
7068
71- PUTS (" recv() in %" PRIu32 " us" , time_since ());
72-
7369 if (retval < 0 ){
7470
7571 PUTS (" failed to read number of test cases (%s)" , WIC::nsapi_error_to_s (retval));
@@ -91,41 +87,27 @@ int main()
9187
9288 PUTS (" BEGIN TC%d" , tc);
9389
94- time_since ();
95-
9690 retval = client.connect (url);
9791
98- PUTS (" tc%d: open() in %" PRIu32 " us" , tc, time_since ());
99-
10092 if (retval == NSAPI_ERROR_OK){
10193
10294 for (;;){
10395
104- time_since ();
105-
10696 retval = client.recv (encoding, fin, buffer, sizeof (buffer));
10797
108- PUTS (" tc%d: recv() in %" PRIu32 " us" , tc, time_since ());
109-
11098 if (retval >= 0 ){
11199
112100 bytes = retval;
113101
114- PUTS (" tc%d: preparing to echo %d bytes of %s" , tc, bytes, (encoding == WIC_ENCODING_UTF8) ? " text" : " binary" );
115-
116- #if 1
117102 time_since ();
118103
119104 retval = client.send (buffer, bytes, encoding, fin);
120105
121- PUTS (" tc%d: send() in %" PRIu32 " us" , tc, time_since ());
122-
123106 if (retval != bytes){
124107
125108 PUTS (" tc%d: breaking loop after send() returned %s" , tc, WIC::nsapi_error_to_s (retval));
126109 break ;
127110 }
128- #endif
129111 }
130112 else {
131113
@@ -137,12 +119,10 @@ int main()
137119 time_since ();
138120
139121 client.close ();
140-
141- PUTS (" tc%d: close() in %" PRIu32 " us" , tc, time_since ());
142122 }
143123 else {
144124
145- PUTS (" tc%d: open () failed with retval %s" , tc, WIC::nsapi_error_to_s (retval));
125+ PUTS (" tc%d: connect () failed with retval %s" , tc, WIC::nsapi_error_to_s (retval));
146126 }
147127
148128 PUTS (" END TC%d" , tc);
@@ -156,7 +136,7 @@ int main()
156136 }
157137 else {
158138
159- PUTS (" failed to connect " );
139+ PUTS (" connect() failed with retval %s " , WIC::nsapi_error_to_s (retval) );
160140 }
161141
162142 PUTS (" all done" );
0 commit comments