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.
Diff: TcpClient.cpp
- Revision:
- 13:95c00132cd98
- Parent:
- 12:1dd995402b99
- Child:
- 19:58e840279555
--- a/TcpClient.cpp Fri Aug 30 19:15:42 2019 +0000
+++ b/TcpClient.cpp Sat Aug 31 20:34:52 2019 +0000
@@ -40,7 +40,8 @@
* @retval
*/
TcpClient::TcpClient() :
- data(NULL)
+ data(NULL),
+ _instance(NULL)
{ }
/**
@@ -50,7 +51,8 @@
* @retval
*/
TcpClient::TcpClient(uip_userdata_t* conn_data) :
- data(conn_data)
+ data(conn_data),
+ _instance(NULL)
{ }
/**
@@ -59,6 +61,20 @@
* @param
* @retval
*/
+int TcpClient::open(UipEthernet* ethernet)
+{
+ if (UipEthernet::ethernet != ethernet)
+ UipEthernet::ethernet = ethernet;
+
+ return 0;
+}
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
int TcpClient::connect(IpAddress ip, uint16_t port)
{
stop();
@@ -79,7 +95,7 @@
#ifdef UIPETHERNET_DEBUG_CLIENT
printf("connected, state: %d, first packet in: %d\r\n", data->state, data->packets_in[0]);
#endif
- return 1;
+ return 0;
}
#if UIP_CONNECT_TIMEOUT > 0
@@ -91,7 +107,7 @@
}
}
- return 0;
+ return 1;
}
/**
@@ -171,6 +187,17 @@
* @param
* @retval
*/
+void TcpClient::setInstance(TcpClient *client)
+{
+ _instance = client;
+}
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
bool TcpClient::operator==(const TcpClient& rhs)
{
return data && rhs.data && (data == rhs.data);
@@ -439,7 +466,8 @@
void TcpClient::close()
{
stop();
- delete this;
+ if (_instance)
+ delete this;
}
/**