Lines Matching +full:max +full:- +full:read +full:- +full:sz
4 * SPDX-License-Identifier: Apache-2.0
30 return -EPFNOSUPPORT; in eswifi_socket_type_from_zephyr()
42 LOG_DBG("Stopping socket %d", socket->index); in __stop_socket()
43 if (socket->state != ESWIFI_SOCKET_STATE_CONNECTED) { in __stop_socket()
47 socket->state = ESWIFI_SOCKET_STATE_NONE; in __stop_socket()
48 return eswifi_at_cmd(eswifi, socket->is_server ? cmd_srv : cmd_cli); in __stop_socket()
58 /* Set max read size */ in __read_data()
62 LOG_ERR("Unable to set read size"); in __read_data()
63 return -EIO; in __read_data()
71 return -EIO; in __read_data()
82 if (addr->sa_family != AF_INET) { in __eswifi_bind()
84 return -EPFNOSUPPORT; in __eswifi_bind()
87 __select_socket(eswifi, socket->index); in __eswifi_bind()
88 socket->port = sys_be16_to_cpu(net_sin(addr)->sin_port); in __eswifi_bind()
91 snprintk(eswifi->buf, sizeof(eswifi->buf), "P2=%d\r", socket->port); in __eswifi_bind()
92 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_bind()
95 return -EIO; in __eswifi_bind()
98 if (socket->type == ESWIFI_TRANSPORT_UDP) { in __eswifi_bind()
100 snprintk(eswifi->buf, sizeof(eswifi->buf), "P5=1\r"); in __eswifi_bind()
101 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_bind()
104 return -EIO; in __eswifi_bind()
128 if ((socket->type == ESWIFI_TRANSPORT_TCP || in eswifi_off_read_work()
129 socket->type == ESWIFI_TRANSPORT_TCP_SSL) && in eswifi_off_read_work()
130 socket->state != ESWIFI_SOCKET_STATE_CONNECTED) { in eswifi_off_read_work()
134 __select_socket(eswifi, socket->index); in eswifi_off_read_work()
137 pkt = net_pkt_rx_alloc_with_buffer(eswifi->iface, 1460, in eswifi_off_read_work()
144 len = __read_data(eswifi, 1460, &data); /* 1460 is max size */ in eswifi_off_read_work()
148 if (socket->recv_cb) { in eswifi_off_read_work()
156 if (!len || !socket->recv_cb) { in eswifi_off_read_work()
161 LOG_DBG("payload sz = %d", len); in eswifi_off_read_work()
173 socket->recv_cb(socket->context, pkt, in eswifi_off_read_work()
174 NULL, NULL, 0, socket->recv_data); in eswifi_off_read_work()
176 if (!socket->context) { in eswifi_off_read_work()
182 k_sem_give(&socket->read_sem); in eswifi_off_read_work()
186 err = k_work_reschedule_for_queue(&eswifi->work_q, &socket->read_work, in eswifi_off_read_work()
189 LOG_ERR("Rescheduling socket read error"); in eswifi_off_read_work()
198 struct sockaddr *addr = &socket->peer_addr; in __eswifi_off_start_client()
199 struct in_addr *sin_addr = &net_sin(addr)->sin_addr; in __eswifi_off_start_client()
204 __select_socket(eswifi, socket->index); in __eswifi_off_start_client()
207 snprintk(eswifi->buf, sizeof(eswifi->buf), "P6=0\r"); in __eswifi_off_start_client()
208 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
211 return -EIO; in __eswifi_off_start_client()
215 snprintk(eswifi->buf, sizeof(eswifi->buf), "P5=0\r"); in __eswifi_off_start_client()
216 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
219 return -EIO; in __eswifi_off_start_client()
223 snprintk(eswifi->buf, sizeof(eswifi->buf), "P2=0\r"); in __eswifi_off_start_client()
224 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
227 return -EIO; in __eswifi_off_start_client()
231 snprintk(eswifi->buf, sizeof(eswifi->buf), "P3=%u.%u.%u.%u\r", in __eswifi_off_start_client()
232 sin_addr->s4_addr[0], sin_addr->s4_addr[1], in __eswifi_off_start_client()
233 sin_addr->s4_addr[2], sin_addr->s4_addr[3]); in __eswifi_off_start_client()
235 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
238 return -EIO; in __eswifi_off_start_client()
242 snprintk(eswifi->buf, sizeof(eswifi->buf), "P4=%d\r", in __eswifi_off_start_client()
243 (uint16_t)sys_be16_to_cpu(net_sin(addr)->sin_port)); in __eswifi_off_start_client()
244 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
247 return -EIO; in __eswifi_off_start_client()
251 snprintk(eswifi->buf, sizeof(eswifi->buf), "P6=1\r"); in __eswifi_off_start_client()
252 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_off_start_client()
255 return -EIO; in __eswifi_off_start_client()
259 net_context_set_state(socket->context, NET_CONTEXT_CONNECTED); in __eswifi_off_start_client()
269 __select_socket(eswifi, socket->index); in __eswifi_listen()
272 snprintk(eswifi->buf, sizeof(eswifi->buf), "P8=%d\r", backlog); in __eswifi_listen()
273 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_listen()
276 err = -EIO; in __eswifi_listen()
279 socket->is_server = true; in __eswifi_listen()
288 if (socket->state != ESWIFI_SOCKET_STATE_NONE) { in __eswifi_accept()
290 return -EBUSY; in __eswifi_accept()
293 __select_socket(eswifi, socket->index); in __eswifi_accept()
298 return -EIO; in __eswifi_accept()
302 socket->state = ESWIFI_SOCKET_STATE_ACCEPTING; in __eswifi_accept()
310 __select_socket(eswifi, socket->index); in __eswifi_socket_free()
311 k_work_cancel_delayable(&socket->read_work); in __eswifi_socket_free()
313 __select_socket(eswifi, socket->index); in __eswifi_socket_free()
329 return -EPFNOSUPPORT; in __eswifi_socket_new()
334 if (!eswifi->socket[i].context) { in __eswifi_socket_new()
335 socket = &eswifi->socket[i]; in __eswifi_socket_new()
336 socket->index = i; in __eswifi_socket_new()
337 socket->context = context; in __eswifi_socket_new()
344 return -ENOMEM; in __eswifi_socket_new()
347 err = eswifi_socket_type_from_zephyr(proto, &socket->type); in __eswifi_socket_new()
353 err = __select_socket(eswifi, socket->index); in __eswifi_socket_new()
355 LOG_ERR("Unable to select socket %u", socket->index); in __eswifi_socket_new()
356 return -EIO; in __eswifi_socket_new()
359 snprintk(eswifi->buf, sizeof(eswifi->buf), "P1=%d\r", socket->type); in __eswifi_socket_new()
360 err = eswifi_at_cmd(eswifi, eswifi->buf); in __eswifi_socket_new()
363 return -EIO; in __eswifi_socket_new()
366 k_work_init_delayable(&socket->read_work, eswifi_off_read_work); in __eswifi_socket_new()
367 socket->usage = 1; in __eswifi_socket_new()
368 LOG_DBG("Socket index %d", socket->index); in __eswifi_socket_new()
370 return socket->index; in __eswifi_socket_new()