Lines Matching +full:cs +full:- +full:setup +full:- +full:time
4 * SPDX-License-Identifier: Apache-2.0
80 .cmd_len = (uint16_t)sizeof(cmd_)-1, \
191 while (length--) { in hexdump()
223 for (i = 0; i < (16 - (n % 16)); i++) { in hexdump()
278 sock->context = NULL; in socket_put()
279 sock->socket_id = 0; in socket_put()
280 (void)memset(&sock->src, 0, sizeof(struct sockaddr)); in socket_put()
281 (void)memset(&sock->dst, 0, sizeof(struct sockaddr)); in socket_put()
289 if (addr->sa_family == AF_INET6) { in wncm14a2a_sprint_ip_addr()
290 return net_addr_ntop(AF_INET6, &net_sin6(addr)->sin6_addr, in wncm14a2a_sprint_ip_addr()
295 if (addr->sa_family == AF_INET) { in wncm14a2a_sprint_ip_addr()
296 return net_addr_ntop(AF_INET, &net_sin(addr)->sin_addr, in wncm14a2a_sprint_ip_addr()
301 LOG_ERR("Unknown IP address family:%d", addr->sa_family); in wncm14a2a_sprint_ip_addr()
326 k_sem_reset(&sock->sock_send_sem); in send_at_cmd()
327 ret = k_sem_take(&sock->sock_send_sem, K_MSEC(timeout)); in send_at_cmd()
332 } else if (ret == -EAGAIN) { in send_at_cmd()
333 ret = -ETIMEDOUT; in send_at_cmd()
346 return -EINVAL; in send_data()
351 frag = pkt->frags; in send_data()
354 sock->socket_id, net_buf_frags_len(frag)); in send_data()
360 frag->data, frag->len); in send_data()
361 frag = frag->frags; in send_data()
365 k_sem_reset(&sock->sock_send_sem); in send_data()
366 ret = k_sem_take(&sock->sock_send_sem, K_MSEC(MDM_CMD_SEND_TIMEOUT)); in send_data()
369 } else if (ret == -EAGAIN) { in send_data()
370 ret = -ETIMEDOUT; in send_data()
390 while (*buf && is_crlf(*(*buf)->data)) { in net_buf_skipcrlf()
392 if (!(*buf)->len) { in net_buf_skipcrlf()
403 while (buf && !is_crlf(*(buf->data + pos))) { in net_buf_findcrlf()
404 if (pos + 1 >= buf->len) { in net_buf_findcrlf()
405 len += buf->len; in net_buf_findcrlf()
406 buf = buf->frags; in net_buf_findcrlf()
413 if (buf && is_crlf(*(buf->data + pos))) { in net_buf_findcrlf()
425 /* Setup IP header data to be used by some network applications.
440 &((struct sockaddr_in6 *)&sock->dst)->sin6_addr, in pkt_setup_ip_data()
441 &((struct sockaddr_in6 *)&sock->src)->sin6_addr)) { in pkt_setup_ip_data()
442 return -1; in pkt_setup_ip_data()
444 src_port = ntohs(net_sin6(&sock->src)->sin6_port); in pkt_setup_ip_data()
445 dst_port = ntohs(net_sin6(&sock->dst)->sin6_port); in pkt_setup_ip_data()
454 &((struct sockaddr_in *)&sock->dst)->sin_addr, in pkt_setup_ip_data()
455 &((struct sockaddr_in *)&sock->src)->sin_addr)) { in pkt_setup_ip_data()
456 return -1; in pkt_setup_ip_data()
458 src_port = ntohs(net_sin(&sock->src)->sin_port); in pkt_setup_ip_data()
459 dst_port = ntohs(net_sin(&sock->dst)->sin_port); in pkt_setup_ip_data()
469 if (sock->ip_proto == IPPROTO_UDP) { in pkt_setup_ip_data()
471 return -1; in pkt_setup_ip_data()
478 if (sock->ip_proto == IPPROTO_TCP) { in pkt_setup_ip_data()
484 return -1; in pkt_setup_ip_data()
489 /* Setup TCP header */ in pkt_setup_ip_data()
490 tcp->src_port = dst_port; in pkt_setup_ip_data()
491 tcp->dst_port = src_port; in pkt_setup_ip_data()
494 return -1; in pkt_setup_ip_data()
530 sizeof(ictx.mdm_manufacturer) - 1, in on_cmd_atcmdinfo_manufacturer()
541 sizeof(ictx.mdm_model) - 1, in on_cmd_atcmdinfo_model()
552 sizeof(ictx.mdm_revision) - 1, in on_cmd_atcmdinfo_revision()
585 out_len = net_buf_linearize(ictx.mdm_imei, sizeof(ictx.mdm_imei) - 1, in on_cmd_atcmdecho_nosock_imei()
592 /* Handler: %MEAS: RSSI:Reported= -68, Ant0= -63, Ant1= -251 */
603 if (!(*buf)->len) { in on_cmd_atcmdinfo_rssi()
643 k_sem_give(&sock->sock_send_sem); in on_cmd_sockok()
652 ictx.last_error = -EIO; in on_cmd_sockerror()
657 k_sem_give(&sock->sock_send_sem); in on_cmd_sockerror()
669 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_sockexterror()
671 ictx.last_error = -atoi(value); in on_cmd_sockexterror()
677 k_sem_give(&sock->sock_send_sem); in on_cmd_sockexterror()
687 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_sockdial()
704 sock->socket_id = atoi(value); in on_cmd_sockcreat()
706 /* don't give back semaphore -- OK to follow */ in on_cmd_sockcreat()
718 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_sockwrite()
727 k_sem_give(&sock->sock_send_sem); in on_cmd_sockwrite()
739 pkt = sock->recv_pkt; in sockreadrecv_cb_work()
740 sock->recv_pkt = NULL; in sockreadrecv_cb_work()
741 if (sock->recv_cb) { in sockreadrecv_cb_work()
742 sock->recv_cb(sock->context, pkt, NULL, NULL, in sockreadrecv_cb_work()
743 0, sock->recv_user_data); in sockreadrecv_cb_work()
762 while (*buf && i < value_size - 1) { in on_cmd_sockread()
764 len--; in on_cmd_sockread()
765 if (!(*buf)->len) { in on_cmd_sockread()
769 if (value[i-1] == ',') { in on_cmd_sockread()
770 i--; in on_cmd_sockread()
778 if (!*buf || value[i] != ',' || *(*buf)->data != '\"') { in on_cmd_sockread()
788 len--; in on_cmd_sockread()
790 if (!(*buf)->len) { in on_cmd_sockread()
807 sock->recv_pkt = net_pkt_rx_alloc_with_buffer( in on_cmd_sockread()
808 net_context_get_iface(sock->context), in on_cmd_sockread()
809 actual_length, sock->family, sock->ip_proto, in on_cmd_sockread()
811 if (!sock->recv_pkt) { in on_cmd_sockread()
817 net_pkt_set_context(sock->recv_pkt, sock->context); in on_cmd_sockread()
820 hdr_len = pkt_setup_ip_data(sock->recv_pkt, sock); in on_cmd_sockread()
824 char c2 = *(*buf)->data; in on_cmd_sockread()
827 c += c2 - '0'; in on_cmd_sockread()
829 c += c2 - (isupper((int)c2) != 0 ? 'A' - 10 : 'a' - 10); in on_cmd_sockread()
835 if (net_pkt_write_u8(sock->recv_pkt, c)) { in on_cmd_sockread()
837 net_pkt_unref(sock->recv_pkt); in on_cmd_sockread()
838 sock->recv_pkt = NULL; in on_cmd_sockread()
849 if (!(*buf)->len) { in on_cmd_sockread()
854 net_pkt_cursor_init(sock->recv_pkt); in on_cmd_sockread()
855 net_pkt_set_overwrite(sock->recv_pkt, true); in on_cmd_sockread()
858 net_pkt_skip(sock->recv_pkt, hdr_len); in on_cmd_sockread()
862 * case the app takes a long time. in on_cmd_sockread()
864 k_work_submit_to_queue(&wncm14a2a_workq, &sock->recv_cb_work); in on_cmd_sockread()
874 char sendbuf[sizeof("AT@SOCKREAD=-#####,-#####\r")]; in on_cmd_sockdataind()
877 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_sockdataind()
915 sock->socket_id, left_bytes); in on_cmd_sockdataind()
935 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_socknotifyev()
968 /* CSPS: 0: Moved to PS mode, 1: Moved to CS/PS mode */ in on_cmd_socknotifyev()
979 /* local time from network */ in on_cmd_socknotifyev()
994 while ((n > 0) && (*(frag->data + offset) == *s2) && (*s2 != '\0')) { in net_buf_ncmp()
995 if (offset == frag->len) { in net_buf_ncmp()
996 if (!frag->frags) { in net_buf_ncmp()
999 frag = frag->frags; in net_buf_ncmp()
1006 n--; in net_buf_ncmp()
1009 return (n == 0) ? 0 : (*(frag->data + offset) - *s2); in net_buf_ncmp()
1068 /* NON-SOCKET COMMAND ECHOES to clear last_socket_id */ in wncm14a2a_rx()
1124 i = -1; in wncm14a2a_rx()
1180 /* give up time if we have a solid stream of data */ in wncm14a2a_rx()
1192 LOG_DBG("MDM_RESET_PIN -> ASSERTED"); in modem_pin_init()
1195 LOG_DBG("MDM_RESET_PIN -> NOT_ASSERTED"); in modem_pin_init()
1201 * and have internal pull-up/down in the module. While in modem_pin_init()
1205 LOG_DBG("SIG_TRANS_ENA_PIN -> DISABLED"); in modem_pin_init()
1213 LOG_DBG("MDM_BOOT_MODE_SEL_PIN -> NORMAL"); in modem_pin_init()
1215 LOG_DBG("MDM_POWER_PIN -> ENABLE"); in modem_pin_init()
1217 LOG_DBG("MDM_KEEP_AWAKE_PIN -> ENABLED"); in modem_pin_init()
1220 LOG_DBG("MDM_SEND_OK_PIN -> ENABLED"); in modem_pin_init()
1232 LOG_DBG("SIG_TRANS_ENA_PIN -> ENABLED"); in modem_pin_init()
1247 LOG_DBG("MDM_KEEP_AWAKE_PIN -> DISABLED"); in modem_wakeup_pin_fix()
1250 LOG_DBG("MDM_KEEP_AWAKE_PIN -> ENABLED"); in modem_wakeup_pin_fix()
1265 /* re-start RSSI query work */ in wncm14a2a_rssi_query_work()
1288 ret = -1; in wncm14a2a_modem_reset()
1292 if (ret < 0 && ret != -ETIMEDOUT) { in wncm14a2a_modem_reset()
1340 /* wait for RSSI > -1000 and != 0 */ in wncm14a2a_modem_reset()
1342 (ictx.mdm_rssi <= -1000 || in wncm14a2a_modem_reset()
1350 if (ictx.mdm_rssi <= -1000 || ictx.mdm_rssi == 0) { in wncm14a2a_modem_reset()
1403 /* setup port devices and pin directions */ in wncm14a2a_init()
1407 wncm14a2a_cfg.gpio[i].port->name); in wncm14a2a_init()
1408 return -ENODEV; in wncm14a2a_init()
1459 return -ENOMEM; in offload_get()
1462 (*context)->offload_context = sock; in offload_get()
1463 sock->family = family; in offload_get()
1464 sock->type = type; in offload_get()
1465 sock->ip_proto = ip_proto; in offload_get()
1466 sock->context = *context; in offload_get()
1467 sock->socket_id = MDM_MAX_SOCKETS + 1; /* socket # needs assigning */ in offload_get()
1487 return -EINVAL; in offload_bind()
1490 sock = (struct wncm14a2a_socket *)context->offload_context; in offload_bind()
1493 return -EINVAL; in offload_bind()
1497 sock->src.sa_family = addr->sa_family; in offload_bind()
1499 if (addr->sa_family == AF_INET6) { in offload_bind()
1500 net_ipaddr_copy(&net_sin6(&sock->src)->sin6_addr, in offload_bind()
1501 &net_sin6(addr)->sin6_addr); in offload_bind()
1502 net_sin6(&sock->src)->sin6_port = net_sin6(addr)->sin6_port; in offload_bind()
1506 if (addr->sa_family == AF_INET) { in offload_bind()
1507 net_ipaddr_copy(&net_sin(&sock->src)->sin_addr, in offload_bind()
1508 &net_sin(addr)->sin_addr); in offload_bind()
1509 net_sin(&sock->src)->sin_port = net_sin(addr)->sin_port; in offload_bind()
1513 return -EPFNOSUPPORT; in offload_bind()
1522 return -ENOTSUP; in offload_listen()
1532 int ret, dst_port = -1; in offload_connect()
1533 int32_t timeout_sec = -1; /* if not changed, this will be min timeout */ in offload_connect()
1542 return -EINVAL; in offload_connect()
1545 sock = (struct wncm14a2a_socket *)context->offload_context; in offload_connect()
1548 return -EINVAL; in offload_connect()
1551 if (sock->socket_id < 1) { in offload_connect()
1553 sock->socket_id, context); in offload_connect()
1554 return -EINVAL; in offload_connect()
1557 sock->dst.sa_family = addr->sa_family; in offload_connect()
1560 if (addr->sa_family == AF_INET6) { in offload_connect()
1561 net_ipaddr_copy(&net_sin6(&sock->dst)->sin6_addr, in offload_connect()
1562 &net_sin6(addr)->sin6_addr); in offload_connect()
1563 dst_port = ntohs(net_sin6(addr)->sin6_port); in offload_connect()
1564 net_sin6(&sock->dst)->sin6_port = dst_port; in offload_connect()
1568 if (addr->sa_family == AF_INET) { in offload_connect()
1569 net_ipaddr_copy(&net_sin(&sock->dst)->sin_addr, in offload_connect()
1570 &net_sin(addr)->sin_addr); in offload_connect()
1571 dst_port = ntohs(net_sin(addr)->sin_port); in offload_connect()
1572 net_sin(&sock->dst)->sin_port = dst_port; in offload_connect()
1576 return -EINVAL; in offload_connect()
1581 return -EINVAL; in offload_connect()
1591 sock->socket_id, wncm14a2a_sprint_ip_addr(addr), in offload_connect()
1595 net_context_set_state(sock->context, NET_CONTEXT_CONNECTED); in offload_connect()
1613 return -ENOTSUP; in offload_accept()
1628 return -EINVAL; in offload_sendto()
1631 sock = (struct wncm14a2a_socket *)context->offload_context; in offload_sendto()
1634 return -EINVAL; in offload_sendto()
1670 return -EPFNOSUPPORT; in offload_send()
1673 return offload_sendto(pkt, &context->remote, addrlen, cb, in offload_send()
1685 return -EINVAL; in offload_recv()
1688 sock = (struct wncm14a2a_socket *)context->offload_context; in offload_recv()
1691 return -EINVAL; in offload_recv()
1694 sock->recv_cb = cb; in offload_recv()
1695 sock->recv_user_data = user_data; in offload_recv()
1707 return -EINVAL; in offload_put()
1710 sock = (struct wncm14a2a_socket *)context->offload_context; in offload_put()
1716 snprintk(buf, sizeof(buf), "AT@SOCKCLOSE=%d", sock->socket_id); in offload_put()
1728 if (sock->type == SOCK_STREAM) { in offload_put()
1732 * unref a second time. in offload_put()
1754 struct wncm14a2a_iface_ctx *ctx = dev->data; in wncm14a2a_get_mac()
1756 ctx->mac_addr[0] = 0x00; in wncm14a2a_get_mac()
1757 ctx->mac_addr[1] = 0x10; in wncm14a2a_get_mac()
1760 (uint32_t *)(ctx->mac_addr + 2)); in wncm14a2a_get_mac()
1762 return ctx->mac_addr; in wncm14a2a_get_mac()
1768 struct wncm14a2a_iface_ctx *ctx = dev->data; in offload_iface_init()
1770 iface->if_dev->offload = &offload_funcs; in offload_iface_init()
1772 sizeof(ctx->mac_addr), in offload_iface_init()
1774 ctx->iface = iface; in offload_iface_init()