Lines Matching refs:mdata

20 static struct sim7080_data mdata;  variable
62 hash_value = hash32(mdata.mdm_imei, strlen(mdata.mdm_imei)); in modem_get_mac()
94 mdata.state = state; in change_state()
104 return mdata.state; in get_state()
125 k_sem_give(&mdata.sem_tx_ready); in MODEM_CMD_DIRECT_DEFINE()
147 if (modem_socket_is_allocated(&mdata.socket_config, sock) == false) { in offload_connect()
185 &mdata.sem_response, MDM_CONNECT_TIMEOUT); in offload_connect()
192 ret = modem_cmd_handler_get_error(&mdata.cmd_handler_data); in offload_connect()
256 k_sem_take(&mdata.cmd_handler_data.sem_tx_lock, K_FOREVER); in offload_sendto()
257 k_sem_reset(&mdata.sem_tx_ready); in offload_sendto()
260 mdata.current_sock_written = len; in offload_sendto()
269 ret = k_sem_take(&mdata.sem_tx_ready, K_SECONDS(2)); in offload_sendto()
280 k_sem_reset(&mdata.sem_response); in offload_sendto()
281 ret = k_sem_take(&mdata.sem_response, MDM_CMD_TIMEOUT); in offload_sendto()
287 k_sem_give(&mdata.cmd_handler_data.sem_tx_lock); in offload_sendto()
296 return mdata.current_sock_written; in offload_sendto()
331 sock = modem_socket_from_fd(&mdata.socket_config, sockfd); in sockread_common()
359 packet_size = modem_socket_next_packet_size(&mdata.socket_config, sock); in sockread_common()
360 modem_socket_packet_size_update(&mdata.socket_config, sock, -packet_size); in sockread_common()
369 return sockread_common(mdata.current_sock_fd, data, atoi(argv[0]), len); in MODEM_CMD_DEFINE()
401 packet_size = modem_socket_next_packet_size(&mdata.socket_config, sock); in offload_recvfrom()
408 modem_socket_wait_data(&mdata.socket_config, sock); in offload_recvfrom()
409 packet_size = modem_socket_next_packet_size(&mdata.socket_config, sock); in offload_recvfrom()
420 mdata.current_sock_fd = sock->sock_fd; in offload_recvfrom()
423 sendbuf, &mdata.sem_response, MDM_CMD_TIMEOUT); in offload_recvfrom()
441 mdata.current_sock_fd = -1; in offload_recvfrom()
507 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buf, &mdata.sem_response, in socket_close()
513 modem_socket_put(&mdata.socket_config, sock->sock_fd); in socket_close()
546 if (modem_socket_is_allocated(&mdata.socket_config, sock) == false) { in offload_close()
587 return modem_socket_poll(&mdata.socket_config, fds, nfds, msecs); in offload_poll()
678 k_sem_give(&mdata.sem_dns); in MODEM_CMD_DEFINE()
738 &mdata.sem_dns, MDM_DNS_TIMEOUT); in offload_getaddrinfo()
792 ret = modem_socket_get(&mdata.socket_config, family, type, proto); in offload_socket()
822 k_sem_give(&mdata.sem_response); in MODEM_CMD_DEFINE()
829 k_sem_give(&mdata.sem_response); in MODEM_CMD_DEFINE()
836 k_sem_give(&mdata.sem_response); in MODEM_CMD_DEFINE()
849 mdata.pdp_active = strcmp(argv[1], "ACTIVE") == 0; in MODEM_CMD_DEFINE()
850 LOG_INF("PDP context: %u", mdata.pdp_active); in MODEM_CMD_DEFINE()
851 k_sem_give(&mdata.sem_response); in MODEM_CMD_DEFINE()
874 sock = modem_socket_from_fd(&mdata.socket_config, sock_fd); in MODEM_CMD_DEFINE()
880 modem_socket_packet_size_update(&mdata.socket_config, sock, 1); in MODEM_CMD_DEFINE()
883 modem_socket_data_ready(&mdata.socket_config, sock); in MODEM_CMD_DEFINE()
907 sock = modem_socket_from_fd(&mdata.socket_config, sockfd); in MODEM_CMD_DEFINE()
948 mdata.ftp.state = SIM7080_FTP_CONNECTION_STATE_FINISHED; in MODEM_CMD_DEFINE()
950 mdata.ftp.state = SIM7080_FTP_CONNECTION_STATE_CONNECTED; in MODEM_CMD_DEFINE()
952 mdata.ftp.state = SIM7080_FTP_CONNECTION_STATE_ERROR; in MODEM_CMD_DEFINE()
955 k_sem_give(&mdata.sem_ftp); in MODEM_CMD_DEFINE()
966 mdata.mdm_manufacturer, sizeof(mdata.mdm_manufacturer) - 1, data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
967 mdata.mdm_manufacturer[out_len] = '\0'; in MODEM_CMD_DEFINE()
968 LOG_INF("Manufacturer: %s", mdata.mdm_manufacturer); in MODEM_CMD_DEFINE()
977 size_t out_len = net_buf_linearize(mdata.mdm_model, sizeof(mdata.mdm_model) - 1, in MODEM_CMD_DEFINE()
979 mdata.mdm_model[out_len] = '\0'; in MODEM_CMD_DEFINE()
980 LOG_INF("Model: %s", mdata.mdm_model); in MODEM_CMD_DEFINE()
994 out_len = net_buf_linearize(mdata.mdm_revision, sizeof(mdata.mdm_revision) - 1, in MODEM_CMD_DEFINE()
996 mdata.mdm_revision[out_len] = '\0'; in MODEM_CMD_DEFINE()
999 p = strchr(mdata.mdm_revision, ':'); in MODEM_CMD_DEFINE()
1002 memmove(mdata.mdm_revision, p + 1, out_len + 1); in MODEM_CMD_DEFINE()
1005 LOG_INF("Revision: %s", mdata.mdm_revision); in MODEM_CMD_DEFINE()
1015 net_buf_linearize(mdata.mdm_imei, sizeof(mdata.mdm_imei) - 1, data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
1016 mdata.mdm_imei[out_len] = '\0'; in MODEM_CMD_DEFINE()
1017 LOG_INF("IMEI: %s", mdata.mdm_imei); in MODEM_CMD_DEFINE()
1028 net_buf_linearize(mdata.mdm_imsi, sizeof(mdata.mdm_imsi) - 1, data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
1029 mdata.mdm_imsi[out_len] = '\0'; in MODEM_CMD_DEFINE()
1032 LOG_INF("IMSI: %s", mdata.mdm_imsi); in MODEM_CMD_DEFINE()
1041 size_t out_len = net_buf_linearize(mdata.mdm_iccid, sizeof(mdata.mdm_iccid) - 1, in MODEM_CMD_DEFINE()
1043 mdata.mdm_iccid[out_len] = '\0'; in MODEM_CMD_DEFINE()
1046 LOG_INF("ICCID: %s", mdata.mdm_iccid); in MODEM_CMD_DEFINE()
1056 mdata.mdm_registration = atoi(argv[1]); in MODEM_CMD_DEFINE()
1057 LOG_INF("CREG: %u", mdata.mdm_registration); in MODEM_CMD_DEFINE()
1063 mdata.cpin_ready = strcmp(argv[0], "READY") == 0; in MODEM_CMD_DEFINE()
1064 LOG_INF("CPIN: %d", mdata.cpin_ready); in MODEM_CMD_DEFINE()
1070 mdata.mdm_cgatt = atoi(argv[0]); in MODEM_CMD_DEFINE()
1071 LOG_INF("CGATT: %d", mdata.mdm_cgatt); in MODEM_CMD_DEFINE()
1088 mdata.mdm_rssi = -115; in MODEM_CMD_DEFINE()
1090 mdata.mdm_rssi = -111; in MODEM_CMD_DEFINE()
1092 mdata.mdm_rssi = -114 + 2 * rssi; in MODEM_CMD_DEFINE()
1094 mdata.mdm_rssi = -52; in MODEM_CMD_DEFINE()
1096 mdata.mdm_rssi = -1000; in MODEM_CMD_DEFINE()
1099 LOG_INF("RSSI: %d", mdata.mdm_rssi); in MODEM_CMD_DEFINE()
1116 &mdata.sem_response, MDM_CMD_TIMEOUT); in modem_rssi_query_work()
1122 k_work_reschedule_for_queue(&modem_workq, &mdata.rssi_query_work, in modem_rssi_query_work()
1166 while (counter++ < MDM_MAX_CGATT_WAITS && mdata.mdm_cgatt != 1) { in modem_pdp_activate()
1168 ARRAY_SIZE(cgatt_cmd), "AT+CGATT?", &mdata.sem_response, in modem_pdp_activate()
1183 if (!mdata.cpin_ready || mdata.mdm_cgatt != 1) { in modem_pdp_activate()
1194 while (counter++ < MDM_MAX_CEREG_WAITS && mdata.mdm_registration != 1 && in modem_pdp_activate()
1195 mdata.mdm_registration != 5) { in modem_pdp_activate()
1197 &mdata.sem_response, MDM_CMD_TIMEOUT); in modem_pdp_activate()
1214 &mdata.sem_response, MDM_CMD_TIMEOUT); in modem_pdp_activate()
1224 &mdata.sem_response, MDM_CMD_TIMEOUT); in modem_pdp_activate()
1230 ret = k_sem_take(&mdata.sem_response, MDM_PDP_TIMEOUT); in modem_pdp_activate()
1231 if (ret < 0 || mdata.pdp_active == false) { in modem_pdp_activate()
1306 &mdata.sem_response, K_MSEC(500)); in modem_autobaud()
1312 "ATE0", &mdata.sem_response, K_SECONDS(2)); in modem_autobaud()
1558 &mdata.sem_response, K_SECONDS(2)); in mdm_sim7080_query_gnss()
1581 k_work_cancel_delayable(&mdata.rssi_query_work); in mdm_sim7080_start_gnss()
1590 &mdata.sem_response, K_SECONDS(2)); in mdm_sim7080_start_gnss()
1615 mdata.ftp.nread = 0; in MODEM_CMD_DEFINE()
1629 out_len = net_buf_linearize(mdata.ftp.read_buffer, mdata.ftp.nread, data->rx_buf, in MODEM_CMD_DEFINE()
1636 mdata.ftp.nread = nbytes; in MODEM_CMD_DEFINE()
1648 if (mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_ERROR || in mdm_sim7080_ftp_get_read()
1649 mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_INITIAL) { in mdm_sim7080_ftp_get_read()
1654 mdata.ftp.read_buffer = dst; in mdm_sim7080_ftp_get_read()
1655 mdata.ftp.nread = *size; in mdm_sim7080_ftp_get_read()
1665 k_sem_take(&mdata.sem_ftp, K_MSEC(200)); in mdm_sim7080_ftp_get_read()
1667 if (mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_FINISHED) { in mdm_sim7080_ftp_get_read()
1670 } else if (mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_ERROR) { in mdm_sim7080_ftp_get_read()
1676 &mdata.sem_response, MDM_CMD_TIMEOUT); in mdm_sim7080_ftp_get_read()
1683 *size = mdata.ftp.nread; in mdm_sim7080_ftp_get_read()
1703 &mdata.sem_response, MDM_CMD_TIMEOUT); in mdm_sim7080_ftp_get_start()
1716 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1730 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1744 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1758 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1772 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1786 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response, in mdm_sim7080_ftp_get_start()
1794 mdata.ftp.read_buffer = NULL; in mdm_sim7080_ftp_get_start()
1795 mdata.ftp.nread = 0; in mdm_sim7080_ftp_get_start()
1796 mdata.ftp.state = SIM7080_FTP_CONNECTION_STATE_INITIAL; in mdm_sim7080_ftp_get_start()
1800 &mdata.sem_ftp, MDM_CMD_TIMEOUT); in mdm_sim7080_ftp_get_start()
1806 if (mdata.ftp.state != SIM7080_FTP_CONNECTION_STATE_CONNECTED) { in mdm_sim7080_ftp_get_start()
2130 if (!mdata.sms_buffer) { in MODEM_CMD_DEFINE()
2135 if (mdata.sms_buffer_pos >= mdata.sms_buffer->nsms) { in MODEM_CMD_DEFINE()
2139 sms = &mdata.sms_buffer->sms[mdata.sms_buffer_pos]; in MODEM_CMD_DEFINE()
2150 mdata.sms_buffer_pos++; in MODEM_CMD_DEFINE()
2160 mdata.sms_buffer = buffer; in mdm_sim7080_read_sms()
2161 mdata.sms_buffer_pos = 0; in mdm_sim7080_read_sms()
2164 &mdata.sem_response, K_SECONDS(20)); in mdm_sim7080_read_sms()
2169 return mdata.sms_buffer_pos; in mdm_sim7080_read_sms()
2182 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0, buf, &mdata.sem_response, in mdm_sim7080_delete_sms()
2200 k_work_cancel_delayable(&mdata.rssi_query_work); in modem_setup()
2209 ARRAY_SIZE(setup_cmds), &mdata.sem_response, in modem_setup()
2224 (mdata.mdm_rssi >= 0 || mdata.mdm_rssi <= -1000)) { in modem_setup()
2229 if (mdata.mdm_rssi >= 0 || mdata.mdm_rssi <= -1000) { in modem_setup()
2240 k_work_reschedule_for_queue(&modem_workq, &mdata.rssi_query_work, in modem_setup()
2266 k_work_cancel_delayable(&mdata.rssi_query_work); in mdm_sim7080_power_off()
2269 ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT", &mdata.sem_response, in mdm_sim7080_power_off()
2283 &mdata.sem_response, K_MSEC(500)); in mdm_sim7080_power_off()
2300 return mdata.mdm_manufacturer; in mdm_sim7080_get_manufacturer()
2305 return mdata.mdm_model; in mdm_sim7080_get_model()
2310 return mdata.mdm_revision; in mdm_sim7080_get_revision()
2315 return mdata.mdm_imei; in mdm_sim7080_get_imei()
2329 k_sem_init(&mdata.sem_response, 0, 1); in modem_init()
2330 k_sem_init(&mdata.sem_tx_ready, 0, 1); in modem_init()
2331 k_sem_init(&mdata.sem_dns, 0, 1); in modem_init()
2332 k_sem_init(&mdata.sem_ftp, 0, 1); in modem_init()
2337 mdata.mdm_registration = 0; in modem_init()
2338 mdata.cpin_ready = false; in modem_init()
2339 mdata.pdp_active = false; in modem_init()
2341 mdata.sms_buffer = NULL; in modem_init()
2342 mdata.sms_buffer_pos = 0; in modem_init()
2345 ret = modem_socket_init(&mdata.socket_config, &mdata.sockets[0], ARRAY_SIZE(mdata.sockets), in modem_init()
2355 .match_buf = &mdata.cmd_match_buf[0], in modem_init()
2356 .match_buf_len = sizeof(mdata.cmd_match_buf), in modem_init()
2367 ret = modem_cmd_handler_init(&mctx.cmd_handler, &mdata.cmd_handler_data, in modem_init()
2375 .rx_rb_buf = &mdata.iface_rb_buf[0], in modem_init()
2376 .rx_rb_buf_len = sizeof(mdata.iface_rb_buf), in modem_init()
2381 ret = modem_iface_uart_init(&mctx.iface, &mdata.iface_data, &uart_config); in modem_init()
2386 mdata.current_sock_fd = -1; in modem_init()
2387 mdata.current_sock_written = 0; in modem_init()
2389 mdata.ftp.read_buffer = NULL; in modem_init()
2390 mdata.ftp.nread = 0; in modem_init()
2391 mdata.ftp.state = SIM7080_FTP_CONNECTION_STATE_INITIAL; in modem_init()
2394 mctx.data_manufacturer = mdata.mdm_manufacturer; in modem_init()
2395 mctx.data_model = mdata.mdm_model; in modem_init()
2396 mctx.data_revision = mdata.mdm_revision; in modem_init()
2397 mctx.data_imei = mdata.mdm_imei; in modem_init()
2399 mctx.data_imsi = mdata.mdm_imsi; in modem_init()
2400 mctx.data_iccid = mdata.mdm_iccid; in modem_init()
2402 mctx.data_rssi = &mdata.mdm_rssi; in modem_init()
2410 mctx.driver_data = &mdata; in modem_init()
2424 k_work_init_delayable(&mdata.rssi_query_work, modem_rssi_query_work); in modem_init()
2432 NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, modem_init, NULL, &mdata, NULL,