Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed
Fork of CubicHand by
Diff: GloveWifi.cpp
- Revision:
- 19:e751d075e2e6
- Parent:
- 15:b48ac00af0b8
- Child:
- 28:42ae7eed0b68
--- a/GloveWifi.cpp Mon Dec 08 18:56:42 2014 +0000
+++ b/GloveWifi.cpp Mon Dec 08 23:54:33 2014 +0000
@@ -12,7 +12,8 @@
#define ECHO_SERVER_PORT 2000
#define MMA8451_I2C_ADDRESS (0x1d<<1)
-GloveWifi::GloveWifi()
+GloveWifi::GloveWifi():
+DropCount(0)
{
}
@@ -60,8 +61,8 @@
printf("Unable to connect to (%s) on port (%d) \r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
wait(1);
}
- socket->set_blocking(true);
printf("Connected!\r\n");
+ socket->set_blocking(false, 10);
}
@@ -82,14 +83,29 @@
printf("Unable to connect to (%s) on port (%d) \r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
wait(1);
}
- socket->set_blocking(true);
+ socket->set_blocking(false, 10);
printf("Reconnected!\r\n");
}
-uint8_t GloveWifi::GetDataFromBuffer(uint8_t * buf, uint16_t size)
+int GloveWifi::GetDataFromBuffer(char * buf, int size)
{
//printf("Buffer Size: %d\r\n", wifi->_simple_link.get_transmit_error());
- return socket->receive((char *)buf, size);
+ int numR = 0;
+ numR = socket->receive((char *)buf, size);
+ if(numR == -1)
+ {
+ DropCount++;
+ }else
+ {
+ DropCount = 0;
+ }
+ if(DropCount > 200)
+ {
+ printf("!\r\n");
+ Reconnect();
+ DropCount = 0;
+ }
+ return numR;
}
uint8_t GloveWifi::SendDataToGlove(uint8_t * buf, uint16_t size)
