Skip to content

Commit

Permalink
Fix wrong netconn function names
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Feb 9, 2020
1 parent 6e9b81f commit b1169e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
26 changes: 13 additions & 13 deletions esp_at_lib/src/api/esp_netconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ typedef struct esp_netconn {
data exchange in time. Set to `0` when timeout feature is disabled. */

#if ESP_CFG_NETCONN_RECEIVE_TIMEOUT || __DOXYGEN__
#define _RCV_NO_WAIT UINT32_MAX
uint32_t rcv_timeout; /*!< Receive timeout in unit of milliseconds */
#endif
} esp_netconn_t;
Expand Down Expand Up @@ -713,16 +712,15 @@ esp_netconn_receive(esp_netconn_p nc, esp_pbuf_p* pbuf) {

*pbuf = NULL;
#if ESP_CFG_NETCONN_RECEIVE_TIMEOUT
if (nc->rcv_timeout == _RCV_NO_WAIT) {
if (!esp_sys_mbox_getnow(&nc->mbox_receive, (void **)pbuf)) {
return espTIMEOUT;
}
} else
/*
* Wait for new received data for up to specific timeout
* or throw error for timeout notification
*/
if (esp_sys_mbox_get(&nc->mbox_receive, (void **)pbuf, nc->rcv_timeout) == ESP_SYS_TIMEOUT) {
if (nc->rcv_timeout == ESP_NETCONN_RECEIVE_NO_WAIT) {
if (!esp_sys_mbox_getnow(&nc->mbox_receive, (void **)pbuf)) {
return espTIMEOUT;
}
} else if (esp_sys_mbox_get(&nc->mbox_receive, (void **)pbuf, nc->rcv_timeout) == ESP_SYS_TIMEOUT) {
return espTIMEOUT;
}
#else /* ESP_CFG_NETCONN_RECEIVE_TIMEOUT */
Expand Down Expand Up @@ -798,7 +796,9 @@ esp_netconn_getconnnum(esp_netconn_p nc) {
*
* \param[in] nc: Netconn handle
* \param[in] timeout: Timeout in units of milliseconds.
* Set to `0` to disable timeout for \ref esp_netconn_receive function
* Set to `0` to disable timeout feature
* Set to `> 0` to set maximum milliseconds to wait before timeout
* Set to \ref ESP_NETCONN_RECEIVE_NO_WAIT to enable non-blocking receive
*/
void
esp_netconn_set_receive_timeout(esp_netconn_p nc, uint32_t timeout) {
Expand All @@ -813,19 +813,19 @@ esp_netconn_set_receive_timeout(esp_netconn_p nc, uint32_t timeout) {
*/
uint32_t
esp_netconn_get_receive_timeout(esp_netconn_p nc) {
return nc->rcv_timeout; /* Return receive timeout */
return nc->rcv_timeout;
}

#endif /* ESP_CFG_NETCONN_RECEIVE_TIMEOUT || __DOXYGEN__ */

/**
* \brief Get netconn's conn handle
* \brief Get netconn connection handle
* \param[in] nc: Netconn handle
* \return esp conn handle.
* \return ESP connection handle
*/
esp_conn_p
esp_netconn_get_conn(esp_netconn_p nc) {
return nc->conn;
}

#endif /* ESP_CFG_NETCONN_RECEIVE_TIMEOUT || __DOXYGEN__ */

#endif /* ESP_CFG_NETCONN || __DOXYGEN__ */
11 changes: 8 additions & 3 deletions esp_at_lib/src/include/esp/esp_netconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ struct esp_netconn;
*/
typedef struct esp_netconn* esp_netconn_p;

/**
* \brief Receive data with no timeout
* \note Used with \ref esp_netconn_set_receive_timeout function
*/
#define ESP_NETCONN_RECEIVE_NO_WAIT 0xFFFFFFFF

/**
* \brief Netconn connection type
*/
Expand All @@ -63,15 +69,14 @@ typedef enum {
ESP_NETCONN_TYPE_UDP = ESP_CONN_TYPE_UDP, /*!< UDP connection */
} esp_netconn_type_t;

esp_conn_p esp_netconn_get_conn(esp_netconn_p nc);

esp_netconn_p esp_netconn_new(esp_netconn_type_t type);
espr_t esp_netconn_delete(esp_netconn_p nc);
espr_t esp_netconn_bind(esp_netconn_p nc, esp_port_t port);
espr_t esp_netconn_connect(esp_netconn_p nc, const char* host, esp_port_t port);
espr_t esp_netconn_receive(esp_netconn_p nc, esp_pbuf_p* pbuf);
espr_t esp_netconn_close(esp_netconn_p nc);
int8_t esp_netconn_getconnnum(esp_netconn_p nc);
int8_t esp_netconn_get_connnum(esp_netconn_p nc);
esp_conn_p esp_netconn_get_conn(esp_netconn_p nc);
void esp_netconn_set_receive_timeout(esp_netconn_p nc, uint32_t timeout);
uint32_t esp_netconn_get_receive_timeout(esp_netconn_p nc);

Expand Down

0 comments on commit b1169e1

Please sign in to comment.