Beispiel #1
0
static enum qmi_cmd_result
cmd_get_client_id_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
{
	FILE *fp;
	int qmi_client_id;
	QmiService svc = qmi_service_get_by_name(arg);

	if (svc < 0) {
		fprintf(stderr, "Invalid service name '%s'\n", arg);
		return QMI_CMD_EXIT;
	}

	if (qmi_service_connect(qmi, svc, -1)) {
		fprintf(stderr, "Failed to connect to service\n");
		return QMI_CMD_EXIT;
	}

	qmi_client_id = qmi_service_get_client_id(qmi, svc);

	fp = fopen("/tmp/qmi-client-id", "w+");
	if (fp) {
		fprintf(fp, "%d", qmi_client_id);
		fclose(fp);
	}

	printf("%d\n", qmi_client_id);

	return QMI_CMD_DONE;
}
Beispiel #2
0
static void keep_client_id(struct qmi_dev *qmi, const char *optarg)
{
	QmiService svc = qmi_service_get_by_name(optarg);
	if (svc < 0) {
		fprintf(stderr, "Invalid service %s\n", optarg);
		exit(1);
	}
	qmi_service_get_client_id(qmi, svc);
}