Skip to content

Commit f895f9e

Browse files
committed
samples: modem: hello_hl78xx: remove POSIX API dependency
The sample no longer requires the POSIX API layer, so the CONFIG_POSIX_API option is removed from prj.conf. The code is updated to use the native zsock_* APIs instead of the POSIX getaddrinfo(), inet_ntop(), and freeaddrinfo() variants. This aligns the sample with Zephyr’s preferred socket API and avoids pulling in unnecessary POSIX compatibility layers. No functional behavior is changed. Signed-off-by: Zafer SEN <zafersn93@gmail.com>
1 parent 5a2c29f commit f895f9e

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

samples/drivers/modem/hello_hl78xx/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
CONFIG_HEAP_MEM_POOL_SIZE=4096
1212
CONFIG_MAIN_STACK_SIZE=4096
1313
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
14-
CONFIG_POSIX_API=y
1514

1615
# ============================================================================
1716
# Power Management (Optional)

samples/drivers/modem/hello_hl78xx/src/main.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#include <zephyr/net/conn_mgr_monitor.h>
1717
#include <zephyr/net/socket.h>
1818

19-
#include <zephyr/posix/sys/socket.h>
20-
#include <zephyr/posix/arpa/inet.h>
21-
#include <zephyr/posix/netdb.h>
22-
2319
/* Macros used to subscribe to specific Zephyr NET management events. */
2420
#if defined(CONFIG_NET_SAMPLE_COMMON_WAIT_DNS_SERVER_ADDITION)
2521
#define L4_EVENT_MASK (NET_EVENT_DNS_SERVER_ADD | NET_EVENT_L4_DISCONNECTED)
@@ -186,29 +182,29 @@ static void hl78xx_on_ok(struct modem_chat *chat, char **argv, uint16_t argc, vo
186182
static int resolve_broker_addr(struct sockaddr_in *broker)
187183
{
188184
int ret;
189-
struct addrinfo *ai = NULL;
185+
struct zsock_addrinfo *ai = NULL;
190186

191-
const struct addrinfo hints = {
187+
const struct zsock_addrinfo hints = {
192188
.ai_family = AF_INET,
193189
.ai_socktype = SOCK_STREAM,
194190
.ai_protocol = 0,
195191
};
196192
char port_string[6] = {0};
197193

198194
snprintf(port_string, sizeof(port_string), "%d", TEST_SERVER_PORT);
199-
ret = getaddrinfo(TEST_SERVER_ENDPOINT, port_string, &hints, &ai);
195+
ret = zsock_getaddrinfo(TEST_SERVER_ENDPOINT, port_string, &hints, &ai);
200196
if (ret == 0) {
201197
char addr_str[INET_ADDRSTRLEN];
202198

203199
memcpy(broker, ai->ai_addr, MIN(ai->ai_addrlen, sizeof(struct sockaddr_storage)));
204200

205-
inet_ntop(AF_INET, &broker->sin_addr, addr_str, sizeof(addr_str));
201+
zsock_inet_ntop(AF_INET, &broker->sin_addr, addr_str, sizeof(addr_str));
206202
LOG_INF("Resolved: %s:%u", addr_str, htons(broker->sin_port));
207203
} else {
208204
LOG_ERR("failed to resolve hostname err = %d (errno = %d)", ret, errno);
209205
}
210206

211-
freeaddrinfo(ai);
207+
zsock_freeaddrinfo(ai);
212208

213209
return ret;
214210
}

0 commit comments

Comments
 (0)