net: mqtt: fix sample to use zsock_ functions
Use zsock_ variants of socket functions in mqtt sample application. Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
This commit is contained in:
parent
fff28ad8ae
commit
c737cca7be
2 changed files with 14 additions and 14 deletions
|
@ -34,7 +34,7 @@ static struct sockaddr socks5_proxy;
|
|||
#endif
|
||||
|
||||
/* Socket Poll */
|
||||
static struct pollfd fds[1];
|
||||
static struct zsock_pollfd fds[1];
|
||||
static int nfds;
|
||||
|
||||
static bool mqtt_connected;
|
||||
|
@ -50,8 +50,8 @@ static struct net_mgmt_event_callback l4_mgmt_cb;
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_DNS_RESOLVER)
|
||||
static struct addrinfo hints;
|
||||
static struct addrinfo *haddr;
|
||||
static struct zsock_addrinfo hints;
|
||||
static struct zsock_addrinfo *haddr;
|
||||
#endif
|
||||
|
||||
static K_SEM_DEFINE(mqtt_start, 0, 1);
|
||||
|
@ -108,7 +108,7 @@ static int wait(int timeout)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = poll(fds, nfds, timeout);
|
||||
rc = zsock_poll(fds, nfds, timeout);
|
||||
if (rc < 0) {
|
||||
LOG_ERR("poll error: %d", errno);
|
||||
return -errno;
|
||||
|
@ -128,7 +128,7 @@ static void broker_init(void)
|
|||
net_ipaddr_copy(&broker4->sin_addr,
|
||||
&net_sin(haddr->ai_addr)->sin_addr);
|
||||
#else
|
||||
inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
|
||||
zsock_inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOCKS)
|
||||
|
@ -136,7 +136,7 @@ static void broker_init(void)
|
|||
|
||||
proxy4->sin_family = AF_INET;
|
||||
proxy4->sin_port = htons(SOCKS5_PROXY_PORT);
|
||||
inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
|
||||
zsock_inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -398,8 +398,8 @@ static int get_mqtt_broker_addrinfo(void)
|
|||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = 0;
|
||||
|
||||
rc = getaddrinfo(CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME, "8883",
|
||||
&hints, &haddr);
|
||||
rc = zsock_getaddrinfo(CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME, "8883",
|
||||
&hints, &haddr);
|
||||
if (rc == 0) {
|
||||
LOG_INF("DNS resolved for %s:%d",
|
||||
CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME,
|
||||
|
|
|
@ -50,7 +50,7 @@ static APP_BMEM struct sockaddr_storage broker;
|
|||
static APP_BMEM struct sockaddr socks5_proxy;
|
||||
#endif
|
||||
|
||||
static APP_BMEM struct pollfd fds[1];
|
||||
static APP_BMEM struct zsock_pollfd fds[1];
|
||||
static APP_BMEM int nfds;
|
||||
|
||||
static APP_BMEM bool connected;
|
||||
|
@ -130,7 +130,7 @@ static int wait(int timeout)
|
|||
int ret = 0;
|
||||
|
||||
if (nfds > 0) {
|
||||
ret = poll(fds, nfds, timeout);
|
||||
ret = zsock_poll(fds, nfds, timeout);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("poll error: %d", errno);
|
||||
}
|
||||
|
@ -269,27 +269,27 @@ static void broker_init(void)
|
|||
|
||||
broker6->sin6_family = AF_INET6;
|
||||
broker6->sin6_port = htons(SERVER_PORT);
|
||||
inet_pton(AF_INET6, SERVER_ADDR, &broker6->sin6_addr);
|
||||
zsock_inet_pton(AF_INET6, SERVER_ADDR, &broker6->sin6_addr);
|
||||
|
||||
#if defined(CONFIG_SOCKS)
|
||||
struct sockaddr_in6 *proxy6 = (struct sockaddr_in6 *)&socks5_proxy;
|
||||
|
||||
proxy6->sin6_family = AF_INET6;
|
||||
proxy6->sin6_port = htons(SOCKS5_PROXY_PORT);
|
||||
inet_pton(AF_INET6, SOCKS5_PROXY_ADDR, &proxy6->sin6_addr);
|
||||
zsock_inet_pton(AF_INET6, SOCKS5_PROXY_ADDR, &proxy6->sin6_addr);
|
||||
#endif
|
||||
#else
|
||||
struct sockaddr_in *broker4 = (struct sockaddr_in *)&broker;
|
||||
|
||||
broker4->sin_family = AF_INET;
|
||||
broker4->sin_port = htons(SERVER_PORT);
|
||||
inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
|
||||
zsock_inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
|
||||
#if defined(CONFIG_SOCKS)
|
||||
struct sockaddr_in *proxy4 = (struct sockaddr_in *)&socks5_proxy;
|
||||
|
||||
proxy4->sin_family = AF_INET;
|
||||
proxy4->sin_port = htons(SOCKS5_PROXY_PORT);
|
||||
inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
|
||||
zsock_inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue