Lines Matching +full:debounce +full:- +full:up +full:- +full:ms

4  * SPDX-License-Identifier: Apache-2.0
211 #define MDM_INVALID_SOCKET_ID -1
217 #define SIZE_WITHOUT_NUL(v) (sizeof(v) - SIZE_OF_NUL)
221 .cmd = cmd_, .cmd_len = (uint16_t)sizeof(cmd_) - 1, \
250 #define RSSI_UNKNOWN -999
294 /* The ? can be a + or - */
301 #define TIME_STRING_TO_TM_STRUCT_YEAR_OFFSET (2000 - 1900)
373 static const char EOF_PATTERN[] = "--EOF--Pattern--";
598 sock->allocated = true; in alloc_stale_socket()
609 sock->allocated = false; in free_stale_socket()
621 sock->type = type; in queue_stale_socket()
622 sock->id = id; in queue_stale_socket()
626 ret = -ENOMEM; in queue_stale_socket()
647 int state = gpio_pin_get_raw(spec->port, spec->pin); in read_pin()
651 spec->port->name, spec->pin, state); in read_pin()
692 * then the device may send +KSUP when waking up. in check_hl7800_awake()
824 sock->context = NULL; in socket_put()
825 sock->socket_id = MDM_INVALID_SOCKET_ID; in socket_put()
826 sock->created = false; in socket_put()
827 sock->reconfig = false; in socket_put()
828 sock->error = 0; in socket_put()
829 sock->rx_size = 0; in socket_put()
830 sock->state = SOCK_IDLE; in socket_put()
831 (void)memset(&sock->src, 0, sizeof(struct sockaddr)); in socket_put()
832 (void)memset(&sock->dst, 0, sizeof(struct sockaddr)); in socket_put()
840 if (addr->sa_family == AF_INET6) { in hl7800_sprint_ip_addr()
841 return net_addr_ntop(AF_INET6, &net_sin6(addr)->sin6_addr, buf, in hl7800_sprint_ip_addr()
846 if (addr->sa_family == AF_INET) { in hl7800_sprint_ip_addr()
847 return net_addr_ntop(AF_INET, &net_sin(addr)->sin_addr, buf, in hl7800_sprint_ip_addr()
852 LOG_ERR("Unknown IP address family:%d", addr->sa_family); in hl7800_sprint_ip_addr()
875 HL7800_IO_DBG_LOG("MDM_RESET -> ASSERTED"); in modem_assert_reset()
878 HL7800_IO_DBG_LOG("MDM_RESET -> NOT_ASSERTED"); in modem_assert_reset()
888 HL7800_IO_DBG_LOG("MDM_WAKE_PIN -> ASSERTED"); in modem_assert_wake()
891 HL7800_IO_DBG_LOG("MDM_WAKE_PIN -> NOT_ASSERTED"); in modem_assert_wake()
905 HL7800_IO_DBG_LOG("MDM_PWR_ON -> ASSERTED"); in modem_assert_pwr_on()
908 HL7800_IO_DBG_LOG("MDM_PWR_ON -> NOT_ASSERTED"); in modem_assert_pwr_on()
916 HL7800_IO_DBG_LOG("MDM_FAST_SHUTD -> ASSERTED"); in modem_assert_fast_shutd()
919 HL7800_IO_DBG_LOG("MDM_FAST_SHUTD -> NOT_ASSERTED"); in modem_assert_fast_shutd()
968 if (agent->event_callback != NULL) { in event_handler()
969 agent->event_callback(event, event_data); in event_handler()
1005 sock->error = 0; in send_at_cmd()
1007 k_sem_reset(&sock->sock_send_sem); in send_at_cmd()
1008 iface_ctx.last_socket_id = sock->socket_id; in send_at_cmd()
1012 sizeof(iface_ctx.no_id_resp_cmd) - 1); in send_at_cmd()
1027 ret = k_sem_take(&sock->sock_send_sem, timeout); in send_at_cmd()
1032 ret = sock->error; in send_at_cmd()
1036 } else if (ret == -EAGAIN) { in send_at_cmd()
1037 ret = -ETIMEDOUT; in send_at_cmd()
1040 retries--; in send_at_cmd()
1059 * then it can respond in ~10 ms. in wakeup_hl7800()
1081 return -EINVAL; in mdm_hl7800_send_at_cmd()
1095 * non-volatile memory.
1099 int ret = -EINVAL; in mdm_hl7800_update_apn()
1110 /* After a reset the APN will be re-read from the modem in mdm_hl7800_update_apn()
1129 int ret = -EINVAL; in mdm_hl7800_update_rat()
1191 ret = -EIO; in mdm_hl7800_get_local_time()
1256 int ret = -1; in mdm_hl7800_set_gps_rate()
1262 /* Stopping first allows changing the rate between two non-zero values. in mdm_hl7800_set_gps_rate()
1303 int ret = -1; in mdm_hl7800_polte_register()
1322 int ret = -1; in mdm_hl7800_polte_enable()
1346 int ret = -1; in mdm_hl7800_polte_locate()
1422 return -EINVAL; in send_data()
1425 sock->error = 0; in send_data()
1426 sock->state = SOCK_TX; in send_data()
1428 frag = pkt->frags; in send_data()
1431 k_sem_reset(&sock->sock_send_sem); in send_data()
1432 if (sock->type == SOCK_STREAM) { in send_data()
1433 snprintk(buf, sizeof(buf), "AT+KTCPSND=%d,%zu", sock->socket_id, in send_data()
1436 if (!net_addr_ntop(sock->family, &net_sin(&sock->dst)->sin_addr, in send_data()
1439 return -EINVAL; in send_data()
1442 sock->socket_id, dst_addr, in send_data()
1443 net_sin(&sock->dst)->sin_port, send_len); in send_data()
1448 ret = k_sem_take(&sock->sock_send_sem, MDM_IP_SEND_RX_TIMEOUT); in send_data()
1454 if (sock->error != 0) { in send_data()
1455 ret = sock->error; in send_data()
1462 actual_send_len += frag->len; in send_data()
1463 mdm_receiver_send(&iface_ctx.mdm_ctx, frag->data, frag->len); in send_data()
1464 frag = frag->frags; in send_data()
1473 k_sem_reset(&sock->sock_send_sem); in send_data()
1475 ret = k_sem_take(&sock->sock_send_sem, MDM_IP_SEND_RX_TIMEOUT); in send_data()
1477 ret = sock->error; in send_data()
1478 } else if (ret == -EAGAIN) { in send_data()
1479 ret = -ETIMEDOUT; in send_data()
1482 if (sock->type == SOCK_STREAM) { in send_data()
1483 if (sock->error == 0) { in send_data()
1484 sock->state = SOCK_CONNECTED; in send_data()
1487 sock->state = SOCK_IDLE; in send_data()
1507 while (*buf && is_crlf(*(*buf)->data)) { in net_buf_skipcrlf()
1509 if (!(*buf)->len) { in net_buf_skipcrlf()
1519 while (buf && !is_crlf(*(buf->data + pos))) { in net_buf_findcrlf()
1520 if (pos + 1 >= buf->len) { in net_buf_findcrlf()
1521 len += buf->len; in net_buf_findcrlf()
1522 buf = buf->frags; in net_buf_findcrlf()
1529 if (buf && is_crlf(*(buf->data + pos))) { in net_buf_findcrlf()
1542 if (!(*buf)->len) { in net_buf_get_u8()
1554 to_remove = (*buf)->len; in net_buf_remove()
1560 len -= to_remove; in net_buf_remove()
1561 if (!(*buf)->len) { in net_buf_remove()
1587 &((struct sockaddr_in6 *)&sock->dst)->sin6_addr, in pkt_setup_ip_data()
1588 &((struct sockaddr_in6 *)&sock->src)->sin6_addr)) { in pkt_setup_ip_data()
1589 return -1; in pkt_setup_ip_data()
1591 net_pkt_set_remote_address(pkt, &sock->dst, sizeof(struct sockaddr_in6)); in pkt_setup_ip_data()
1592 pkt->remote.sa_family = AF_INET6; in pkt_setup_ip_data()
1593 src_port = ntohs(net_sin6(&sock->src)->sin6_port); in pkt_setup_ip_data()
1594 dst_port = ntohs(net_sin6(&sock->dst)->sin6_port); in pkt_setup_ip_data()
1602 pkt, &((struct sockaddr_in *)&sock->dst)->sin_addr, in pkt_setup_ip_data()
1603 &((struct sockaddr_in *)&sock->src)->sin_addr)) { in pkt_setup_ip_data()
1604 return -1; in pkt_setup_ip_data()
1606 net_pkt_set_remote_address(pkt, &sock->dst, sizeof(struct sockaddr_in)); in pkt_setup_ip_data()
1607 pkt->remote.sa_family = AF_INET; in pkt_setup_ip_data()
1608 src_port = ntohs(net_sin(&sock->src)->sin_port); in pkt_setup_ip_data()
1609 dst_port = ntohs(net_sin(&sock->dst)->sin_port); in pkt_setup_ip_data()
1616 if (sock->ip_proto == IPPROTO_UDP) { in pkt_setup_ip_data()
1618 return -1; in pkt_setup_ip_data()
1625 if (sock->ip_proto == IPPROTO_TCP) { in pkt_setup_ip_data()
1630 return -1; in pkt_setup_ip_data()
1636 tcp->src_port = dst_port; in pkt_setup_ip_data()
1637 tcp->dst_port = src_port; in pkt_setup_ip_data()
1640 return -1; in pkt_setup_ip_data()
1681 int len_no_null = MDM_MANUFACTURER_LENGTH - 1; in on_cmd_atcmdinfo_manufacturer()
1703 sizeof(iface_ctx.mdm_manufacturer) - 1, *buf, 0, in on_cmd_atcmdinfo_manufacturer()
1716 int len_no_null = MDM_MODEL_LENGTH - 1; in on_cmd_atcmdinfo_model()
1737 out_len = net_buf_linearize(iface_ctx.mdm_model, sizeof(iface_ctx.mdm_model) - 1, in on_cmd_atcmdinfo_model()
1771 iface_ctx.mdm_revision, sizeof(iface_ctx.mdm_revision) - 1, *buf, 0, len); in on_cmd_atcmdinfo_revision()
1804 out_len = net_buf_linearize(iface_ctx.mdm_imei, sizeof(iface_ctx.mdm_imei) - 1, in on_cmd_atcmdinfo_imei()
1841 len = MIN(iccid_len, sizeof(iface_ctx.mdm_iccid) - 1); in on_cmd_atcmdinfo_iccid()
1913 sizeof(iface_ctx.dns_v6_string) - 1); in dns_work_cb()
1929 if (dnsCtx->state == DNS_RESOLVE_CONTEXT_INACTIVE) { in dns_work_cb()
1994 return -EINVAL; in hl7800_net_addr6_pton()
2000 return -EINVAL; in hl7800_net_addr6_pton()
2006 return -EINVAL; in hl7800_net_addr6_pton()
2010 return -EINVAL; in hl7800_net_addr6_pton()
2013 UNALIGNED_PUT(htons(ipv6_section), &dst->s6_addr16[i]); in hl7800_net_addr6_pton()
2019 if (i < num_sections - 1) { in hl7800_net_addr6_pton()
2020 return -EINVAL; in hl7800_net_addr6_pton()
2067 addr_len = delims[3] - delims[2]; in on_cmd_atcmdinfo_ipaddr()
2093 addr_len = sm_start - addr_start; in on_cmd_atcmdinfo_ipaddr()
2111 addr_len = delims[3] - sm_start; in on_cmd_atcmdinfo_ipaddr()
2122 addr_len = delims[4] - addr_start; in on_cmd_atcmdinfo_ipaddr()
2134 addr_len = delims[5] - addr_start; in on_cmd_atcmdinfo_ipaddr()
2201 * stack is still starting up in on_cmd_atcmdinfo_ipaddr()
2302 sn_len = len - (val_start - value); in on_cmd_atcmdinfo_serial_number()
2399 /* clang-format off */ in get_startup_state_string()
2411 /* clang-format on */ in get_startup_state_string()
2432 int r = -EPERM; in mdm_hl7800_set_desired_sleep_level()
2444 r = -EINVAL; in mdm_hl7800_set_desired_sleep_level()
2512 /* clang-format off */ in get_sleep_state_string()
2522 /* clang-format on */ in get_sleep_state_string()
2547 /* clang-format off */ in get_fota_state_string()
2561 /* clang-format on */ in get_fota_state_string()
2566 LOG_INF("FOTA state: %s->%s", in set_fota_state()
2632 int echo_state = -1; in profile_handler()
2849 * when going from network down->up in hl7800_start_rssi_work()
2879 /* re-start RSSI query work */ in hl7800_rssi_query_work()
2896 int8_t event = -1; in on_cmd_gps_event()
2897 int8_t status = -1; in on_cmd_gps_event()
2947 * Altitude: "-1 m"
2968 size_t gps_len = sizeof(gps_str) - 1; in gps_handler()
3052 size_t rsp_len = sizeof(rsp) - 1; in on_cmd_polte_registration()
3082 /* Command handler looks for string up to the user field */ in on_cmd_polte_registration()
3130 data.status = -1; in on_cmd_polte_registration()
3143 size_t rsp_len = sizeof(rsp) - 1; in on_cmd_polte_locate_cmd_rsp()
3152 data.status = -1; in on_cmd_polte_locate_cmd_rsp()
3183 size_t rsp_len = sizeof(rsp) - 1; in on_cmd_polte_location()
3214 data.status = -1; in on_cmd_polte_location()
3236 memcpy(data.latitude, start, MIN(end - start, sizeof(data.latitude) - 1)); in on_cmd_polte_location()
3244 memcpy(data.longitude, start, MIN(end - start, sizeof(data.longitude) - 1)); in on_cmd_polte_location()
3261 MIN(end - start, sizeof(data.confidence_in_meters) - 1)); in on_cmd_polte_location()
3288 if ((sock->context != NULL) && (sock->type == SOCK_STREAM)) { in notify_all_tcp_sockets_closed()
3289 LOG_DBG("Sock %d closed", sock->socket_id); in notify_all_tcp_sockets_closed()
3291 if (sock->recv_cb) { in notify_all_tcp_sockets_closed()
3292 sock->recv_cb(sock->context, sock->recv_pkt, in notify_all_tcp_sockets_closed()
3294 sock->recv_user_data); in notify_all_tcp_sockets_closed()
3326 /* give up waiting for KSUP */ in iface_status_work_cb()
3327 LOG_DBG("Give up waiting for"); in iface_status_work_cb()
3337 /* Ensure we bring the network interface down and then re-check the current state */ in iface_status_work_cb()
3351 /* bring iface up/down */ in iface_status_work_cb()
3356 LOG_DBG("HL7800 iface UP"); in iface_status_work_cb()
3422 * [,[<cause_type>],[<reject_cause>] [,[<Active-Time>],[<Periodic-TAU>]]]]
3435 l = (value + out_len) - pos; in on_cmd_network_report_query()
3502 * %MEAS: EARFCN=5826, CellID=420, RSRP=-99, RSRQ=-15
3503 * %MEAS: EARFCN=6400, CellID=201, RSRP=-93, RSRQ=-21
3508 char response[sizeof("EARFCN=XXXXXXXXXXX, CellID=XXXXXXXXXXX, RSRP=-XXX, RSRQ=-XXX")]; in on_cmd_survey_status()
3573 size_t str_len = sizeof(TIME_STRING_FORMAT) - 1; in on_cmd_rtc_query()
3616 if ((time_string[i] == '+' || time_string[i] == '-') && in valid_time_string()
3653 tm->tm_year = TIME_STRING_TO_TM_STRUCT_YEAR_OFFSET + in convert_time_string_to_struct()
3655 tm->tm_mon = in convert_time_string_to_struct()
3656 get_next_time_string_digit(&fc, &ptr, TM_MONTH_RANGE_PLUS_1) - in convert_time_string_to_struct()
3658 tm->tm_mday = get_next_time_string_digit(&fc, &ptr, TM_DAY_RANGE); in convert_time_string_to_struct()
3659 tm->tm_hour = get_next_time_string_digit(&fc, &ptr, TM_HOUR_RANGE); in convert_time_string_to_struct()
3660 tm->tm_min = get_next_time_string_digit(&fc, &ptr, TM_MIN_RANGE); in convert_time_string_to_struct()
3661 tm->tm_sec = get_next_time_string_digit(&fc, &ptr, TM_SEC_RANGE); in convert_time_string_to_struct()
3662 tm->tm_isdst = 0; in convert_time_string_to_struct()
3666 if (time_string[TIME_STRING_PLUS_MINUS_INDEX] == '-') { in convert_time_string_to_struct()
3667 *offset *= -1; in convert_time_string_to_struct()
3673 * [,[<cause_type>],[<reject_cause>] [,[<Active-Time>],[<Periodic-TAU>]]]]
3683 sizeof(iface_ctx.mdm_network_status) - 1, *buf, in on_cmd_network_report()
3689 l = pos - iface_ctx.mdm_network_status; in on_cmd_network_report()
3739 if ((delims[1] - delims[0]) == 1) { in on_cmd_atcmdinfo_rssi()
3764 sock->error = 0; in on_cmd_sockok()
3765 k_sem_give(&sock->sock_send_sem); in on_cmd_sockok()
3795 sock->error = 0; in on_cmd_sock_ind()
3796 k_sem_give(&sock->sock_send_sem); in on_cmd_sock_ind()
3828 iface_ctx.last_error = -EIO; in on_cmd_sockerror()
3831 sock->error = -EIO; in on_cmd_sockerror()
3832 k_sem_give(&sock->sock_send_sem); in on_cmd_sockerror()
3852 iface_ctx.last_error = -EIO; in on_cmd_sock_error_code()
3855 sock->error = -EIO; in on_cmd_sock_error_code()
3856 k_sem_give(&sock->sock_send_sem); in on_cmd_sock_error_code()
3872 if (sock->recv_pkt != NULL) { in sock_notif_cb_work()
3876 k_work_reschedule_for_queue(&hl7800_workq, &sock->notif_work, in sock_notif_cb_work()
3879 if (sock->type == SOCK_STREAM) { in sock_notif_cb_work()
3880 LOG_DBG("Sock %d trigger NULL packet", sock->socket_id); in sock_notif_cb_work()
3881 k_work_submit_to_queue(&hl7800_workq, &sock->recv_cb_work); in sock_notif_cb_work()
3924 sock->error = 0; in on_cmd_sock_notif()
3929 sock->error = -ENOTCONN; in on_cmd_sock_notif()
3934 sock->error = -EIO; in on_cmd_sock_notif()
3945 k_work_reschedule_for_queue(&hl7800_workq, &sock->notif_work, MDM_SOCK_NOTIF_DELAY); in on_cmd_sock_notif()
3947 k_sem_give(&sock->sock_send_sem); in on_cmd_sock_notif()
3981 LOG_DBG("Delete untracked socket [%d]", sock->id); in delete_untracked_socket_work_cb()
3982 delete_socket(NULL, sock->type, sock->id); in delete_untracked_socket_work_cb()
4010 LOG_DBG("look up new socket by creation id"); in on_cmd_sockcreate()
4012 if (!sock || sock->type != type) { in on_cmd_sockcreate()
4025 sock->socket_id = iface_ctx.last_socket_id; in on_cmd_sockcreate()
4026 sock->created = true; in on_cmd_sockcreate()
4027 sock->reconfig = false; in on_cmd_sockcreate()
4028 /* don't give back semaphore -- OK to follow */ in on_cmd_sockcreate()
4052 LOG_DBG("Sock %d RX CB (size: %zd)", sock->socket_id, in sockreadrecv_cb_work()
4053 (sock->recv_pkt != NULL) ? net_pkt_get_len(sock->recv_pkt) : 0); in sockreadrecv_cb_work()
4055 pkt = sock->recv_pkt; in sockreadrecv_cb_work()
4056 sock->recv_pkt = NULL; in sockreadrecv_cb_work()
4057 if (sock->recv_cb) { in sockreadrecv_cb_work()
4058 sock->recv_cb(sock->context, pkt, NULL, NULL, 0, in sockreadrecv_cb_work()
4059 sock->recv_user_data); in sockreadrecv_cb_work()
4081 if (sock->error != 0) { in sock_read()
4083 k_work_reschedule_for_queue(&hl7800_workq, &sock->notif_work, in sock_read()
4087 LOG_DBG("Socket %d RX %u bytes", sock->socket_id, sock->rx_size); in sock_read()
4097 wait_for_modem_data(buf, 0, sock->rx_size); in sock_read()
4103 sock->recv_pkt = net_pkt_rx_alloc_with_buffer( in sock_read()
4104 net_context_get_iface(sock->context), sock->rx_size, in sock_read()
4105 sock->family, sock->ip_proto, BUF_ALLOC_TIMEOUT); in sock_read()
4106 if (!sock->recv_pkt) { in sock_read()
4112 net_pkt_set_context(sock->recv_pkt, sock->context); in sock_read()
4115 hdr_len = pkt_setup_ip_data(sock->recv_pkt, sock); in sock_read()
4118 for (i = 0; i < sock->rx_size; i++) { in sock_read()
4122 if (net_pkt_write_u8(sock->recv_pkt, c)) { in sock_read()
4128 if (!*buf && i < sock->rx_size) { in sock_read()
4192 net_pkt_cursor_init(sock->recv_pkt); in sock_read()
4193 net_pkt_set_overwrite(sock->recv_pkt, true); in sock_read()
4196 net_pkt_skip(sock->recv_pkt, hdr_len); in sock_read()
4202 k_work_submit_to_queue(&hl7800_workq, &sock->recv_cb_work); in sock_read()
4203 LOG_DBG("Sock %d RX done", sock->socket_id); in sock_read()
4206 net_pkt_unref(sock->recv_pkt); in sock_read()
4207 sock->recv_pkt = NULL; in sock_read()
4209 if (sock->type == SOCK_STREAM) { in sock_read()
4210 if (sock->error == 0) { in sock_read()
4211 sock->state = SOCK_CONNECTED; in sock_read()
4214 sock->state = SOCK_IDLE; in sock_read()
4233 if (sock->state == SOCK_RX) { in on_cmd_connect()
4237 k_sem_give(&sock->sock_send_sem); in on_cmd_connect()
4248 if ((sock->socket_id <= 0) || (sock->rx_size <= 0)) { in start_socket_rx()
4250 sock->socket_id, sock->rx_size); in start_socket_rx()
4251 return -1; in start_socket_rx()
4254 LOG_DBG("Start socket RX ID:%d size:%d", sock->socket_id, rx_size); in start_socket_rx()
4255 sock->state = SOCK_RX; in start_socket_rx()
4256 if (sock->type == SOCK_DGRAM) { in start_socket_rx()
4258 if (rx_size > (net_if_get_mtu(iface_ctx.iface) - NET_IPV4UDPH_LEN)) { in start_socket_rx()
4259 sock->rx_size = in start_socket_rx()
4260 net_if_get_mtu(iface_ctx.iface) - NET_IPV4UDPH_LEN; in start_socket_rx()
4264 if (rx_size > (net_if_get_mtu(iface_ctx.iface) - NET_IPV6UDPH_LEN)) { in start_socket_rx()
4265 sock->rx_size = in start_socket_rx()
4266 net_if_get_mtu(iface_ctx.iface) - NET_IPV6UDPH_LEN; in start_socket_rx()
4270 sock->socket_id, rx_size); in start_socket_rx()
4273 if (rx_size > (net_if_get_mtu(iface_ctx.iface) - NET_IPV4TCPH_LEN)) { in start_socket_rx()
4274 sock->rx_size = in start_socket_rx()
4275 net_if_get_mtu(iface_ctx.iface) - NET_IPV4TCPH_LEN; in start_socket_rx()
4279 if (rx_size > (net_if_get_mtu(iface_ctx.iface) - NET_IPV6TCPH_LEN)) { in start_socket_rx()
4280 sock->rx_size = in start_socket_rx()
4281 net_if_get_mtu(iface_ctx.iface) - NET_IPV6TCPH_LEN; in start_socket_rx()
4285 sock->socket_id, sock->rx_size); in start_socket_rx()
4309 rc = start_socket_rx(sock, sock->rx_size); in sock_rx_data_cb_work()
4339 out_len = net_buf_linearize(value, sizeof(value) - 1, *buf, 0, len); in on_cmd_sockdataind()
4362 sock->rx_size = left_bytes; in on_cmd_sockdataind()
4364 LOG_DBG("Defer socket RX -> ID: %d bytes: %u", socket_id, in on_cmd_sockdataind()
4366 k_work_submit_to_queue(&hl7800_workq, &sock->rx_data_work); in on_cmd_sockdataind()
4490 LOG_DBG("Send FW update packet %d,%d", pkt->id, iface_ctx.fw_packet_count); in send_fw_update_packet()
4500 iface_ctx.fw_packet.id_complement = 0xFF - iface_ctx.fw_packet.id; in prepare_and_send_fw_packet()
4716 i = -1; in hl7800_rx()
4792 /* give up time if we have a solid stream of data */ in hl7800_rx()
4930 if ((sock->context != NULL) && (sock->created)) { in mark_sockets_for_reconfig()
4931 /* mark socket as possibly needing re-configuration */ in mark_sockets_for_reconfig()
4932 sock->reconfig = true; in mark_sockets_for_reconfig()
4988 /* Debounce the CTS signal */ in mdm_uart_cts_callback_isr()
4990 elapsed = now - iface_ctx.last_cts_time; in mdm_uart_cts_callback_isr()
5028 /* Wake up the modem to see if it has anything to send to us. */ in mdm_uart_cts_callback_isr()
5149 result = -1; in compare_versions()
5161 result = -1; in compare_versions()
5179 int cmd_max_len = sizeof(cmd_string) - 1; in setup_gprs_connection()
5222 return -EINVAL; in mdm_hl7800_set_bands()
5226 num_leading_zeros = MDM_BAND_BITMAP_STR_LENGTH_MAX - strlen(bands); in mdm_hl7800_set_bands()
5229 if (i == (num_leading_zeros - 1)) { in mdm_hl7800_set_bands()
5230 strncpy(temp_bands + (i + 1), bands, sizeof(temp_bands) - (i + 1)); in mdm_hl7800_set_bands()
5287 /* Turn on mobile start-up reporting for next reset. in modem_reset_and_configure()
5289 * Its value is saved in non-volatile memory on the HL7800. in modem_reset_and_configure()
5521 * Temporary Workaround - Ignore error in modem_reset_and_configure()
5596 /* Kernel will fault with non-zero return value. in modem_reset_and_configure()
5709 if (!agent->event_callback) { in mdm_hl7800_register_event_callback()
5712 sys_slist_append(&hl7800_event_callback_list, &agent->node); in mdm_hl7800_register_event_callback()
5726 ret = (int)sys_slist_find_and_remove(&hl7800_event_callback_list, &agent->node); in mdm_hl7800_unregister_event_callback()
5730 ret = -ENOENT; in mdm_hl7800_unregister_event_callback()
5744 snprintk(cmd_con, sizeof(cmd_con), "AT+KTCPCNX=%d", sock->socket_id); in connect_TCP_socket()
5748 ret = -EIO; in connect_TCP_socket()
5754 ret = k_sem_take(&sock->sock_send_sem, MDM_CMD_CONN_TIMEOUT); in connect_TCP_socket()
5756 ret = sock->error; in connect_TCP_socket()
5757 } else if (ret == -EAGAIN) { in connect_TCP_socket()
5758 ret = -ETIMEDOUT; in connect_TCP_socket()
5764 sock->state = SOCK_CONNECTED; in connect_TCP_socket()
5765 net_context_set_state(sock->context, NET_CONTEXT_CONNECTED); in connect_TCP_socket()
5775 int dst_port = -1; in configure_TCP_socket()
5783 if (sock->dst.sa_family == AF_INET6) { in configure_TCP_socket()
5785 dst_port = net_sin6(&sock->dst)->sin6_port; in configure_TCP_socket()
5786 } else if (sock->dst.sa_family == AF_INET) { in configure_TCP_socket()
5788 dst_port = net_sin(&sock->dst)->sin_port; in configure_TCP_socket()
5790 return -EINVAL; in configure_TCP_socket()
5793 sock->socket_id = MDM_CREATE_SOCKET_ID; in configure_TCP_socket()
5796 hl7800_sprint_ip_addr(&sock->dst), dst_port, af, restore_on_boot); in configure_TCP_socket()
5800 ret = -EIO; in configure_TCP_socket()
5819 sock->socket_id = MDM_CREATE_SOCKET_ID; in configure_UDP_socket()
5821 if (sock->family == AF_INET) { in configure_UDP_socket()
5823 } else if (sock->family == AF_INET6) { in configure_UDP_socket()
5826 return -EINVAL; in configure_UDP_socket()
5839 ret = k_sem_take(&sock->sock_send_sem, MDM_CMD_CONN_TIMEOUT); in configure_UDP_socket()
5841 ret = sock->error; in configure_UDP_socket()
5842 } else if (ret == -EAGAIN) { in configure_UDP_socket()
5843 ret = -ETIMEDOUT; in configure_UDP_socket()
5894 ret = -ENOMEM; in offload_get()
5898 (*context)->offload_context = sock; in offload_get()
5900 (*context)->iface = net_if_get_by_iface(iface_ctx.iface); in offload_get()
5901 sock->family = family; in offload_get()
5902 sock->type = type; in offload_get()
5903 sock->ip_proto = ip_proto; in offload_get()
5904 sock->context = *context; in offload_get()
5905 sock->reconfig = false; in offload_get()
5906 sock->created = false; in offload_get()
5907 sock->socket_id = MDM_CREATE_SOCKET_ID; in offload_get()
5919 if (!sock->created) { in offload_get()
5940 return -EINVAL; in offload_bind()
5943 sock = (struct hl7800_socket *)context->offload_context; in offload_bind()
5946 return -EINVAL; in offload_bind()
5950 sock->src.sa_family = addr->sa_family; in offload_bind()
5952 if (addr->sa_family == AF_INET6) { in offload_bind()
5953 net_ipaddr_copy(&net_sin6(&sock->src)->sin6_addr, in offload_bind()
5954 &net_sin6(addr)->sin6_addr); in offload_bind()
5955 net_sin6(&sock->src)->sin6_port = net_sin6(addr)->sin6_port; in offload_bind()
5959 if (addr->sa_family == AF_INET) { in offload_bind()
5960 net_ipaddr_copy(&net_sin(&sock->src)->sin_addr, in offload_bind()
5961 &net_sin(addr)->sin_addr); in offload_bind()
5962 net_sin(&sock->src)->sin_port = net_sin(addr)->sin_port; in offload_bind()
5966 return -EPFNOSUPPORT; in offload_bind()
5975 return -ENOTSUP; in offload_listen()
5984 int dst_port = -1; in offload_connect()
5988 return -EINVAL; in offload_connect()
5991 sock = (struct hl7800_socket *)context->offload_context; in offload_connect()
5994 return -EINVAL; in offload_connect()
5997 if (sock->socket_id < 1) { in offload_connect()
5999 sock->socket_id, context); in offload_connect()
6000 return -EINVAL; in offload_connect()
6003 sock->dst.sa_family = addr->sa_family; in offload_connect()
6006 if (addr->sa_family == AF_INET6) { in offload_connect()
6007 net_ipaddr_copy(&net_sin6(&sock->dst)->sin6_addr, in offload_connect()
6008 &net_sin6(addr)->sin6_addr); in offload_connect()
6009 dst_port = ntohs(net_sin6(addr)->sin6_port); in offload_connect()
6010 net_sin6(&sock->dst)->sin6_port = dst_port; in offload_connect()
6014 if (addr->sa_family == AF_INET) { in offload_connect()
6015 net_ipaddr_copy(&net_sin(&sock->dst)->sin_addr, in offload_connect()
6016 &net_sin(addr)->sin_addr); in offload_connect()
6017 dst_port = ntohs(net_sin(addr)->sin_port); in offload_connect()
6018 net_sin(&sock->dst)->sin_port = dst_port; in offload_connect()
6022 return -EINVAL; in offload_connect()
6027 return -EINVAL; in offload_connect()
6032 if (sock->type == SOCK_STREAM) { in offload_connect()
6038 if (!sock->created) { in offload_connect()
6068 return -ENOTSUP; in offload_accept()
6080 return -EINVAL; in offload_sendto()
6083 sock = (struct hl7800_socket *)context->offload_context; in offload_sendto()
6086 return -EINVAL; in offload_sendto()
6090 if (dst_addr->sa_family == AF_INET6) { in offload_sendto()
6091 net_ipaddr_copy(&net_sin6(&sock->dst)->sin6_addr, in offload_sendto()
6092 &net_sin6(dst_addr)->sin6_addr); in offload_sendto()
6093 dst_port = ntohs(net_sin6(dst_addr)->sin6_port); in offload_sendto()
6094 net_sin6(&sock->dst)->sin6_port = dst_port; in offload_sendto()
6098 if (dst_addr->sa_family == AF_INET) { in offload_sendto()
6099 net_ipaddr_copy(&net_sin(&sock->dst)->sin_addr, in offload_sendto()
6100 &net_sin(dst_addr)->sin_addr); in offload_sendto()
6101 dst_port = ntohs(net_sin(dst_addr)->sin_port); in offload_sendto()
6102 net_sin(&sock->dst)->sin_port = dst_port; in offload_sendto()
6106 return -EINVAL; in offload_sendto()
6150 return -EPFNOSUPPORT; in offload_send()
6153 return offload_sendto(pkt, &context->remote, addr_len, cb, timeout, in offload_send()
6163 return -EINVAL; in offload_recv()
6166 sock = (struct hl7800_socket *)context->offload_context; in offload_recv()
6169 return -EINVAL; in offload_recv()
6172 sock->recv_cb = cb; in offload_recv()
6173 sock->recv_user_data = user_data; in offload_recv()
6184 return -EINVAL; in offload_put()
6187 sock = (struct hl7800_socket *)context->offload_context; in offload_put()
6194 k_work_cancel_delayable(&sock->notif_work); in offload_put()
6199 if (sock->type == SOCK_STREAM) { in offload_put()
6201 sock->socket_id); in offload_put()
6204 sock->socket_id); in offload_put()
6209 if ((sock->type == SOCK_DGRAM) || (sock->error != -ENOTCONN)) { in offload_put()
6213 if (sock->type == SOCK_STREAM) { in offload_put()
6215 delete_socket(sock, sock->type, sock->socket_id); in offload_put()
6222 if (sock->type == SOCK_STREAM) { in offload_put()
6251 ictx->mac_addr[0] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 6]; in hl7800_build_mac()
6252 ictx->mac_addr[1] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 5]; in hl7800_build_mac()
6253 ictx->mac_addr[2] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 4]; in hl7800_build_mac()
6254 ictx->mac_addr[3] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 3]; in hl7800_build_mac()
6255 ictx->mac_addr[4] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 2]; in hl7800_build_mac()
6256 ictx->mac_addr[5] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 1]; in hl7800_build_mac()
6334 return -EIO; in hl7800_init()
6385 hl7800_cfg.gpio[i].port->name); in hl7800_init()
6386 return -ENODEV; in hl7800_init()
6555 struct hl7800_iface_ctx *ctx = dev->data; in offload_iface_init()
6557 iface->if_dev->offload = &offload_funcs; in offload_iface_init()
6558 ctx->iface = iface; in offload_iface_init()