qmi_set_nas_get_serving_system_request(msg);
return QMI_CMD_REQUEST;
}
+
+static void
+cmd_nas_network_scan_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+ static struct qmi_nas_network_scan_response res;
+ const char *network_status[] = {
+ "current_serving",
+ "available",
+ "home",
+ "roaming",
+ "forbidden",
+ "not_forbidden",
+ "preferred",
+ "not_preferred",
+ };
+ const char *radio[] = {
+ [QMI_NAS_RADIO_INTERFACE_NONE] = "none",
+ [QMI_NAS_RADIO_INTERFACE_CDMA_1X] = "cdma-1x",
+ [QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO] = "cdma-1x_evdo",
+ [QMI_NAS_RADIO_INTERFACE_AMPS] = "amps",
+ [QMI_NAS_RADIO_INTERFACE_GSM] = "gsm",
+ [QMI_NAS_RADIO_INTERFACE_UMTS] = "umts",
+ [QMI_NAS_RADIO_INTERFACE_LTE] = "lte",
+ [QMI_NAS_RADIO_INTERFACE_TD_SCDMA] = "td-scdma",
+ };
+ void *t, *c, *info, *stat;
+ int i, j;
+
+ qmi_parse_nas_network_scan_response(msg, &res);
+
+ t = blobmsg_open_table(&status, NULL);
+
+ c = blobmsg_open_array(&status, "network_info");
+ for (i = 0; i < res.data.network_information_n; i++) {
+ info = blobmsg_open_table(&status, NULL);
+ blobmsg_add_u32(&status, "mcc", res.data.network_information[i].mcc);
+ blobmsg_add_u32(&status, "mnc", res.data.network_information[i].mnc);
+ if (res.data.network_information[i].description)
+ blobmsg_add_string(&status, "description", res.data.network_information[i].description);
+ stat = blobmsg_open_array(&status, "status");
+ for (j = 0; j < ARRAY_SIZE(network_status); j++) {
+ if (!(res.data.network_information[i].network_status & (1 << j)))
+ continue;
+
+ blobmsg_add_string(&status, NULL, network_status[j]);
+ }
+ blobmsg_close_array(&status, stat);
+ blobmsg_close_table(&status, info);
+ }
+ blobmsg_close_array(&status, c);
+
+ c = blobmsg_open_array(&status, "radio_access_technology");
+ for (i = 0; i < res.data.radio_access_technology_n; i++) {
+ const char *r = "unknown";
+ int r_i = res.data.radio_access_technology[i].radio_interface;
+
+ info = blobmsg_open_table(&status, NULL);
+ blobmsg_add_u32(&status, "mcc", res.data.radio_access_technology[i].mcc);
+ blobmsg_add_u32(&status, "mnc", res.data.radio_access_technology[i].mnc);
+ if (r_i >= 0 && r_i < ARRAY_SIZE(radio))
+ r = radio[r_i];
+
+ blobmsg_add_string(&status, "radio", r);
+ blobmsg_close_table(&status, info);
+ }
+ blobmsg_close_array(&status, c);
+
+ blobmsg_close_table(&status, t);
+}
+
+static enum qmi_cmd_result
+cmd_nas_network_scan_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ struct qmi_nas_network_scan_request sreq = {};
+
+ qmi_set_nas_network_scan_request(msg, &sreq);
+ return QMI_CMD_REQUEST;
+}
#define __uqmi_nas_commands \
__uqmi_command(nas_set_network_modes, set-network-modes, required, QMI_SERVICE_NAS), \
__uqmi_command(nas_initiate_network_register, network-register, no, QMI_SERVICE_NAS), \
+ __uqmi_command(nas_network_scan, network-scan, no, QMI_SERVICE_NAS), \
__uqmi_command(nas_get_signal_info, get-signal-info, no, QMI_SERVICE_NAS), \
__uqmi_command(nas_get_serving_system, get-serving-system, no, QMI_SERVICE_NAS), \
__uqmi_command(nas_set_network_preference, set-network-preference, required, QMI_SERVICE_NAS) \
" Available modes: all, lte, umts, gsm, cdma, td-scdma\n" \
" --set-network-preference <mode> Set preferred network mode to <mode>\n" \
" Available modes: auto, gsm, wcdma\n" \
+ " --network-scan: Initiate network scan\n" \
" --network-register: Initiate network register\n" \
" --get-signal-info: Get signal strength info\n" \
" --get-serving-system: Get serving system info\n" \