コード例 #1
0
ファイル: ril_intel.c プロジェクト: endocode/ofono
static void set_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ril_thermal_management *tm = user_data;
	struct ril_data *rd = ofono_modem_get_data(tm->modem);
	const char *path = ofono_modem_get_path(tm->modem);

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s RILD reply failure: %s",
			g_ril_request_id_to_string(rd->ril, message->req),
			ril_error_to_string(message->error));

		__ofono_dbus_pending_reply(&tm->pending,
					__ofono_error_failed(tm->pending));
		return;
	}

	/* Change the throttling state */
	tm->throttling = tm->throttling ? false : true;

	__ofono_dbus_pending_reply(&tm->pending,
				dbus_message_new_method_return(tm->pending));

	ofono_dbus_signal_property_changed(conn, path,
					THERMAL_MANAGEMENT_INTERFACE,
					"TransmitPowerThrottling",
					DBUS_TYPE_BOOLEAN,
					&tm->throttling);
}
コード例 #2
0
ファイル: radio-settings.c プロジェクト: morphis/ofono
static void mtk_query_available_rats_cb(struct ril_msg *message,
					gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_radio_settings *rs = cbd->user;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);
	ofono_radio_settings_available_rats_query_cb_t cb = cbd->cb;
	unsigned int available_rats = OFONO_RADIO_ACCESS_MODE_GSM;
	int slot_3g, is_3g;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
		return;
	}

	slot_3g = g_mtk_reply_parse_get_3g_capability(rd->ril, message);
	if (slot_3g < 0) {
		ofono_error("%s: parse error", __func__);
		CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
		return;
	}

	is_3g = (g_ril_get_slot(rd->ril) == slot_3g);

	if (is_3g) {
		available_rats |= OFONO_RADIO_ACCESS_MODE_UMTS;

		if (ofono_modem_get_boolean(rd->modem, MODEM_PROP_LTE_CAPABLE))
			available_rats |= OFONO_RADIO_ACCESS_MODE_LTE;
	}

	CALLBACK_WITH_SUCCESS(cb, available_rats, cbd->data);
}
コード例 #3
0
static void ril_query_call_fwd_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct forw_data *fd = ofono_call_forwarding_get_data(cbd->user);
	ofono_call_forwarding_query_cb_t cb = cbd->cb;
	struct ofono_call_forwarding_condition *list;
	unsigned int list_size = -1;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: rild error: %s", __func__,
				ril_error_to_string(message->error));
		goto error;
	}

	list = g_ril_reply_parse_query_call_fwd(fd->ril, message, &list_size);
	/*
	 * From atmodem:
	 *
	 * Specification is really unclear about this
	 * generate status=0 for all classes just in case
	 */
	if (list_size == 0) {
		list = g_new0(struct ofono_call_forwarding_condition, 1);
		list_size = 1;

		list->status = 0;
		list->cls = fd->last_cls;
	} else if (list == NULL) {
コード例 #4
0
ファイル: gprs.c プロジェクト: ClementFan/ofono
static void ril_gprs_set_pref_network_cb(struct ril_msg *message,
						gpointer user_data)
{
	if (message->error != RIL_E_SUCCESS) {
		ofono_error("SET_PREF_NETWORK reply failure: %s", ril_error_to_string(message->error));
	}
}
コード例 #5
0
ファイル: sim.c プロジェクト: impegoraro/ofono
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_imsi_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct ofono_error error;
	struct parcel rilp;
	gchar *imsi;

	if (message->error == RIL_E_SUCCESS) {
		DBG("GET IMSI reply - OK");
		decode_ril_error(&error, "OK");
	} else {
		ofono_error("Reply failure: %s",
			    ril_error_to_string(message->error));
		decode_ril_error(&error, "FAIL");
		cb(&error, NULL, cbd->data);
		return;
	}

	ril_util_init_parcel(message, &rilp);

	/* 15 is the max length of IMSI
	 * add 4 bytes for string length */
	/* FIXME: g_assert(message->buf_len <= 19); */
	imsi = parcel_r_string(&rilp);

	g_ril_append_print_buf(sd->ril, "{%s}", imsi);
	g_ril_print_response(sd->ril, message);

	cb(&error, imsi, cbd->data);
	g_free(imsi);
}
コード例 #6
0
ファイル: radio-settings.c プロジェクト: jkangas/ofono-1
static void mtk_query_modem_rats_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_radio_settings *rs = cbd->user;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);
	ofono_radio_settings_modem_rats_query_cb_t cb = cbd->cb;
	ofono_bool_t modem_rats[OFONO_RADIO_ACCESS_MODE_LAST] = { FALSE };
	int is_3g;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
		return;
	}

	is_3g = g_mtk_reply_parse_get_3g_capability(rd->ril, message);
	if (is_3g < 0) {
		ofono_error("%s: parse error", __func__);
		CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
		return;
	}

	modem_rats[OFONO_RADIO_ACCESS_MODE_GSM] = TRUE;

	if (is_3g) {
		modem_rats[OFONO_RADIO_ACCESS_MODE_UMTS] = TRUE;

		if (getenv("OFONO_RIL_RAT_LTE"))
			modem_rats[OFONO_RADIO_ACCESS_MODE_LTE] = TRUE;
	}

	CALLBACK_WITH_SUCCESS(cb, modem_rats, cbd->data);
}
コード例 #7
0
ファイル: gprs-context.c プロジェクト: marttipiirainen/ofono
static void ril_deactivate_data_call_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_gprs_context_cb_t cb = cbd->cb;
	struct ofono_gprs_context *gc = cbd->user;
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
	gint id = gcd->active_ctx_cid;

	ofono_info("deactivating data call");

	/* Reply has no data... */
	if (message->error == RIL_E_SUCCESS) {

		g_ril_print_response_no_args(gcd->ril, message);

		set_context_disconnected(gcd);

		/* If the deactivate was a result of a shutdown,
		 * there won't be call back, so _deactivated()
		 * needs to be called directly.
		 */
		if (cb)
			CALLBACK_WITH_SUCCESS(cb, cbd->data);
		else
			ofono_gprs_context_deactivated(gc, id);

	} else {
		ofono_error("%s: replay failure: %s",
				__func__,
				ril_error_to_string(message->error));

		if (cb)
			CALLBACK_WITH_FAILURE(cb, cbd->data);
	}
}
コード例 #8
0
ファイル: sim.c プロジェクト: endocode/ofono
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_imsi_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct parcel rilp;
	gchar *imsi;

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("Reply failure: %s",
				ril_error_to_string(message->error));
		goto error;
	}

	g_ril_init_parcel(message, &rilp);
	imsi = parcel_r_string(&rilp);

	g_ril_append_print_buf(sd->ril, "{%s}", imsi ? imsi : "NULL");
	g_ril_print_response(sd->ril, message);

	if (imsi == NULL)
		goto error;

	CALLBACK_WITH_SUCCESS(cb, imsi, cbd->data);
	g_free(imsi);
	return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
コード例 #9
0
ファイル: gprs.c プロジェクト: alfonsosanchezbeato/ofono
static void gprs_allow_data_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_gprs_cb_t cb = cbd->cb;
	struct gprs_attach_data *attach_data = cbd->user;
	struct ril_gprs_data *gd = attach_data->gd;

	g_ril_print_response_no_args(attach_data->ril, message);

	/*
	 * We do not care if detaching the other slot fails. This happens in
	 * turbo when the other slot is empty, for instance.
	 */
	if (attach_data->detaching_other_slot) {
		attach_data->ril = gd->ril;
		attach_data->detaching_other_slot = FALSE;

		send_allow_data(cbd, gd->ril, attach_data->set_attached);
		return;
	}

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, cbd->data);
		free_attach_cbd(cbd);
		return;
	}

	gd->ofono_attached = attach_data->set_attached;

	CALLBACK_WITH_SUCCESS(cb, cbd->data);

	free_attach_cbd(cbd);
}
コード例 #10
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_modem_online_cb_t cb = cbd->cb;
	struct ofono_modem *modem = cbd->user;
	struct mtk_data *md = ofono_modem_get_data(modem);

	if (message->error == RIL_E_SUCCESS) {
		g_ril_print_response_no_args(md->ril, message);
		/*
		 * Although the request was successful, radio state might not
		 * have changed yet. So we wait for the upcoming radio event,
		 * otherwise RIL requests that depend on radio state will fail.
		 * If we are switching the 3G slot, we cannot really trust this
		 * behaviour, so we add a failsafe timer.
		 */
		md->online_cb = cb;
		md->online_data = cbd->data;

		g_timeout_add(T_SIM_SWITCH_FAILSAFE_MS,
						sim_switch_failsafe, md);
	} else {
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, cbd->data);
		exec_pending_online(md);
	}
}
コード例 #11
0
ファイル: sim.c プロジェクト: morphis/ofono
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_imsi_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct ofono_error error;
	gchar *imsi;

	if (message->error == RIL_E_SUCCESS) {
		DBG("GET IMSI reply - OK");
		decode_ril_error(&error, "OK");
	} else {
		ofono_error("Reply failure: %s",
				ril_error_to_string(message->error));
		goto error;
	}

	imsi = g_ril_reply_parse_imsi(sd->ril, message);
	if (imsi == NULL) {
		ofono_error("Error empty IMSI");
		goto error;
	}

	cb(&error, imsi, cbd->data);
	g_free(imsi);

	return;

error:
	decode_ril_error(&error, "FAIL");
	cb(&error, NULL, cbd->data);
}
コード例 #12
0
static void ril_clir_query_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_call_settings *cs = cbd->user;
	struct settings_data *sd = ofono_call_settings_get_data(cs);
	ofono_call_settings_clir_cb_t cb = cbd->cb;
	struct reply_clir *rclir;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: Reply failure: %s", __func__,
				ril_error_to_string(message->error));
		goto error;
	}

	rclir = g_ril_reply_parse_get_clir(sd->ril, message);
	if (rclir == NULL) {
		ofono_error("%s: parse error", __func__);
		goto error;
	}

	CALLBACK_WITH_SUCCESS(cb, rclir->status, rclir->provisioned, cbd->data);

	g_ril_reply_free_get_clir(rclir);

	return;

error:
	CALLBACK_WITH_FAILURE(cb, -1, -1, cbd->data);
}
コード例 #13
0
ファイル: gprs.c プロジェクト: mkuukkane/ofono
static void ril_data_probe_reg_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_gprs *gprs = cbd->user;
	struct gprs_data *gd = ofono_gprs_get_data(gprs);
	struct ofono_error error;
	int status, lac, ci, tech;
	int max_cids = 1;
	int id = RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED;

	DBG("");

	if (!(gd && message->error == RIL_E_SUCCESS)) {
		ofono_error("ril_data_reg_cb: reply failure: %s",
				ril_error_to_string(message->error));
		decode_ril_error(&error, "FAIL");
		error.error = message->error;
		status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
		goto out;
	}

	decode_ril_error(&error, "OK");
	status = -1;

	if (ril_util_parse_reg(gd->ril, message, &status,
				&lac, &ci, &tech, &max_cids) == FALSE) {
		ofono_error("Failure parsing data registration response.");
		decode_ril_error(&error, "FAIL");

		if (status == -1)
			status = NETWORK_REGISTRATION_STATUS_UNKNOWN;

		goto out;
	}

	ofono_gprs_register(gprs);

	registered = TRUE;

	if (max_cids > gd->max_cids) {
		DBG("Setting max cids to %d", max_cids);
		gd->max_cids = max_cids;
		ofono_gprs_set_cid_range(gprs, 1, max_cids);
	}

	if (status == NETWORK_REGISTRATION_STATUS_ROAMING)
		status = check_if_really_roaming(status);

out:
	ofono_info("data registration status is %d", status);

	DBG("Starting to listen network status");
	gd->registerid = g_ril_register(gd->ril,
			id, ril_gprs_state_change, gprs);

	gd->rild_status = status;

}
コード例 #14
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void detach_received_cb(struct ril_msg *message, gpointer user_data)
{
	struct mtk_data *md = user_data;

	if (message->error == RIL_E_SUCCESS)
		g_ril_print_response_no_args(md->ril, message);
	else
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
}
コード例 #15
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void poweron_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_modem *modem = cbd->user;
	struct mtk_data *md = ofono_modem_get_data(modem);
	ofono_modem_online_cb_t cb = cbd->cb;

	DBG("");

	/*
	 * MTK's rild behavior when a POWERON is sent to it is different
	 * depending on whether a previous POWEROFF had been sent. When
	 * the modem is initialized during device startup, POWERON is
	 * sent without a prior POWEROFF, rild responds with an OK reply,
	 * and the modem is brought up. Any subsequent POWERON requests
	 * are sent whenever both modems have been offlined before ( meaning a
	 * POWEROFF has been sent prior ). rild may respond to the POWERON
	 * request, but will usually ( always? ) trigger a socket disconnect in
	 * this case.
	 *
	 * This means there's a race condition between the POWERON reply
	 * callback and the socket disconnect function ( which triggers a
	 * SIM_MODE_SWITCH request ). In some cases rild is slower than
	 * usual closing the socket, so we add a timeout to avoid following
	 * the code path used when there is not a disconnection. Otherwise,
	 * there would be a race and some requests would return errors due to
	 * having been sent through the about-to-be-disconnected socket, leaving
	 * ofono in an inconsistent state. So, we delay sending the
	 * SIM_MODE_SWITCH for 1s, to allow the disconnect to happen when we
	 * know that we have sent previously a POWEROFF.
	 *
	 * Also, I saw once that sending SIM_MODE while the
	 * socket was being disconnected provoked a crash due to SIGPIPE being
	 * issued. The timeout should also fix this.
	 */

	if (message->error == RIL_E_SUCCESS) {
		g_ril_print_response_no_args(md->ril, message);

		if (disconnect_expected) {
			if (not_disconn_cb_id != 0)
				g_source_remove(not_disconn_cb_id);

			not_disconn_cb_id = g_timeout_add(T_WAIT_DISCONN_MS,
						no_disconnect_case, cbd);
		} else {
			mtk_send_sim_mode(mtk_sim_mode_cb, cbd);
		}
	} else {
		ofono_error("%s RADIO_POWERON error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, cbd->data);
		g_free(cbd);
	}
}
コード例 #16
0
ファイル: gprs.c プロジェクト: ClementFan/ofono
static void ril_data_reg_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_gprs_status_cb_t cb = cbd->cb;
	struct ofono_gprs *gprs = cbd->user;
	struct gprs_data *gd = ofono_gprs_get_data(gprs);
	struct ofono_error error;
	int status, lac, ci, tech;
	int max_cids = 1;

	if (message->error == RIL_E_SUCCESS) {
		decode_ril_error(&error, "OK");
	} else {
		ofono_error("ril_data_reg_cb: reply failure: %s",
				ril_error_to_string(message->error));
		decode_ril_error(&error, "FAIL");
		error.error = message->error;
		status = -1;
		goto error;
	}

	if (ril_util_parse_reg(message, &status,
				&lac, &ci, &tech, &max_cids) == FALSE) {
		ofono_error("Failure parsing data registration response.");
		decode_ril_error(&error, "FAIL");
		status = -1;
		goto error;
	}

	if (gd->status == -1) {
		DBG("calling ofono_gprs_register...");
		ofono_gprs_register(gprs);

		g_ril_register(gd->ril, RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED,
				ril_gprs_state_change, gprs);
	}

	if (max_cids > gd->max_cids) {
		DBG("Setting max cids to %d", max_cids);
		gd->max_cids = max_cids;
		ofono_gprs_set_cid_range(gprs, 1, max_cids);
	}

	if (gd->status != status) {
		DBG("gd->status: %d status: %d", gd->status, status);
		ofono_gprs_status_notify(gprs, status);
	}

	gd->status = status;
	gd->tech = tech;

error:
	if (cb)
		cb(&error, status, cbd->data);
}
コード例 #17
0
ファイル: sim.c プロジェクト: endocode/ofono
static void inf_pin_retries_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_pin_retries_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct parcel rilp;
	int32_t *data;
	int len;
	char *hex_dump;
	int expected;

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("Reply failure: %s",
				ril_error_to_string(message->error));
		goto error;
	}

	g_ril_init_parcel(message, &rilp);

	data = parcel_r_raw(&rilp, &len);
	if (data == NULL) {
		ofono_error("%s: malformed parcel", __func__);
		goto error;
	}

	hex_dump = encode_hex((unsigned char *) data, len, '\0');
	g_ril_append_print_buf(sd->ril, "{%d,%s}", len, hex_dump);
	g_ril_print_response(sd->ril, message);
	g_free(hex_dump);

	expected = sizeof(int32_t) * 5;
	if (len < expected) {
		ofono_error("%s: reply too small", __func__);
		g_free(data);
		goto error;
	}

	/* First integer is INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS */
	sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = data[1];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = data[2];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = data[3];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = data[4];

	g_free(data);
	CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data);
	return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
コード例 #18
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void set_trm_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct mtk_data *md = ofono_modem_get_data(modem);

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
		return;
	}

	g_ril_print_response_no_args(md->ril, message);
}
コード例 #19
0
ファイル: radio-settings.c プロジェクト: ubports/ofono
static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_radio_settings *rs = user_data;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: reply failure: %s", __func__,
				ril_error_to_string(message->error));
		return;
	}

	g_ril_print_response_no_args(rd->ril, message);
}
コード例 #20
0
ファイル: gprs.c プロジェクト: alfonsosanchezbeato/ofono
static void drop_data_call_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_gprs *gprs = user_data;
	struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);

	if (message->error == RIL_E_SUCCESS)
		g_ril_print_response_no_args(gd->ril, message);
	else
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));

	if (--(gd->pending_deact_req) == 0)
		ril_gprs_registration_status(gprs, NULL, NULL);
}
コード例 #21
0
ファイル: sim.c プロジェクト: endocode/ofono
static void mtk_pin_retries_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_pin_retries_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct parcel rilp;
	char **strv;
	char *debug_str;
	int pin[MTK_EPINC_NUM_PASSWD];
	int num_pin;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("Reply failure: %s",
				ril_error_to_string(message->error));
		goto error;
	}

	g_ril_init_parcel(message, &rilp);

	strv = parcel_r_strv(&rilp);
	if (strv == NULL) {
		ofono_error("%s: parse error", __func__);
		goto error;
	}

	debug_str = g_strjoinv(",", strv);
	g_ril_append_print_buf(sd->ril, "{%d,%s}",
					g_strv_length(strv), debug_str);
	g_free(debug_str);
	g_ril_print_response(sd->ril, message);

	num_pin = sscanf(strv[0], "+EPINC:%d,%d,%d,%d",
					&pin[0], &pin[1], &pin[2], &pin[3]);
	g_strfreev(strv);

	if (num_pin != MTK_EPINC_NUM_PASSWD)
		goto error;

	sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = pin[0];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = pin[1];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = pin[2];
	sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = pin[3];

	CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data);
	return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
コード例 #22
0
ファイル: ril.c プロジェクト: jpakkane/ofono
static void sim_status_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct ril_data *ril = ofono_modem_get_data(modem);
	struct reply_sim_status *status;

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ril->sim_status_retries++;

		ofono_error("GET_SIM_STATUS request failed: %s; retries: %d",
				ril_error_to_string(message->error),
				ril->sim_status_retries);

		if (ril->sim_status_retries < MAX_SIM_STATUS_RETRIES)
			g_timeout_add_seconds(2, sim_status_retry, modem);
		else
			ofono_error("Max retries for GET_SIM_STATUS exceeded!");
	} else {

		if ((status = g_ril_reply_parse_sim_status(ril->modem, message))
				!= NULL) {

			if (status->card_state == RIL_CARDSTATE_PRESENT) {
				DBG("Card PRESENT; num_apps: %d",
					status->num_apps);

				if (!ril->have_sim) {
					DBG("notify SIM inserted");
					ril->have_sim = TRUE;

					ofono_sim_inserted_notify(ril->sim, TRUE);
				}

			} else {
				ofono_warn("Card NOT_PRESENT.");

				if (ril->have_sim) {
					DBG("notify SIM removed");
					ril->have_sim = FALSE;

					ofono_sim_inserted_notify(ril->sim, FALSE);
				}
			}
			g_ril_reply_free_sim_status(status);
		}
	}
}
コード例 #23
0
ファイル: radio-settings.c プロジェクト: ubports/ofono
static void switch_finish_cb(struct ril_msg *message, gpointer user_data)
{
	struct radio_data *rd = user_data;
	struct switch_data *sd = rd->switch_d;
	struct radio_data *rd1 = sd->rd_1;
	struct radio_data *rd2 = sd->rd_2;
	struct reply_radio_capability *caps;

	sd->pending_msgs--;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		return;
	}

	caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
	if (caps == NULL) {
		ofono_error("%s: parse error", __func__);
		return;
	}

	if (sd->pending_msgs != 0)
		return;

	ofono_info("Switching radio caps between slots - FINISH");

	set_preferred_network(rd1, sd->cbd, sd->mode_to_switch);

	/*
	 * If the complementary slot does not support anymore its current
	 * technology, we change it to the best possible among available ones.
	 */
	if ((rd2->rat_mode & rd2->available_rats) == 0) {

		struct cb_data *cbd =
			cb_data_new(set_preferred_cb, rd2, rd2->radio_settings);

		set_preferred_network(rd2, cbd,
				get_best_available_tech(rd2->available_rats));
	}

	rd1->switch_d = NULL;
	rd2->switch_d = NULL;
	g_free(sd);
	g_free(caps);
}
コード例 #24
0
ファイル: sim.c プロジェクト: morphis/ofono
static void ril_file_write_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_sim_write_cb_t cb = cbd->cb;
	struct sim_data *sd = cbd->user;
	struct reply_sim_io *reply;
	int sw1, sw2;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: RILD reply failure: %s",
				__func__, ril_error_to_string(message->error));
		goto error;
	}

	if ((reply = g_ril_reply_parse_sim_io(sd->ril, message))
			== NULL) {
		ofono_error("%s: Can't parse SIM IO response", __func__);
		goto error;
	}

	sw1 = reply->sw1;
	sw2 = reply->sw2;

	g_ril_reply_free_sim_io(reply);

	if ((sw1 != 0x90 && sw1 != 0x91 && sw1 != 0x92 && sw1 != 0x9f) ||
			(sw1 == 0x90 && sw2 != 0x00)) {
		struct ofono_error error;

		ofono_error("%s: error sw1 %02x sw2 %02x", __func__, sw1, sw2);

		error.type = OFONO_ERROR_TYPE_SIM;
		error.error = (sw1 << 8) | sw2;

		cb(&error, cbd->data);

		return;
	}

	CALLBACK_WITH_SUCCESS(cb, cbd->data);

	return;

error:
	CALLBACK_WITH_FAILURE(cb, cbd->data);
}
コード例 #25
0
ファイル: radio-settings.c プロジェクト: ubports/ofono
/*
 * This function is just for completeness, as we actually need to wait for the
 * unsolocited events to continue the capabilities switch.
 */
static void switch_apply_cb(struct ril_msg *message, gpointer user_data)
{
	struct radio_data *rd = user_data;
	struct reply_radio_capability *caps;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		return;
	}

	caps = g_ril_reply_parse_get_radio_capability(rd->ril, message);
	if (caps == NULL)
		ofono_error("%s: parse error", __func__);

	g_free(caps);
}
コード例 #26
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void query_3g_caps_cb(struct ril_msg *message, gpointer user_data)
{
	struct socket_data *sock = user_data;
	struct socket_data *sock_for_md_0, *sock_for_md_1;
	int slot_3g;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		return;
	}

	slot_3g = g_mtk_reply_parse_get_3g_capability(sock->ril, message);

	/*
	 * The socket at sock_slot_0 always connects to the slot with 3G
	 * capabilities, while sock_slot_1 connects to the slot that is just 2G.
	 * However, the physical slot that owns the 3G capabilities can be
	 * changed dynamically using a RILd request, so the sockets can connect
	 * to different physical slots depending on the current configuration.
	 * We want to keep the relationship between the physical slots and
	 * the modem names in DBus (so /ril_0 and /ril_1 always refer to the
	 * same physical slots), so here we assign the sockets needed by
	 * mtk_data_0 and mtk_data_1 structures to make sure that happens.
	 */
	if (slot_3g == MULTISIM_SLOT_0) {
		sock_for_md_0 = sock_0;
		sock_for_md_1 = sock_1;
		mtk_data_0->has_3g = TRUE;
		mtk_data_1->has_3g = FALSE;
	} else {
		sock_for_md_0 = sock_1;
		sock_for_md_1 = sock_0;
		mtk_data_0->has_3g = FALSE;
		mtk_data_1->has_3g = TRUE;
	}

	start_slot(mtk_data_0, sock_for_md_0, hex_slot_0);
	start_slot(mtk_data_1, sock_for_md_1, hex_slot_1);

	g_free(sock_0);
	sock_0 = NULL;
	g_free(sock_1);
	sock_1 = NULL;
}
コード例 #27
0
ファイル: stk.c プロジェクト: CODeRUS/ofono
static void ril_envelope_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_stk_envelope_cb_t cb = cbd->cb;
	struct ofono_error error;

	DBG("");

	if (message->error == RIL_E_SUCCESS) {
		decode_ril_error(&error, "OK");
	} else {
		DBG("Envelope reply failure: %s",
				ril_error_to_string(message->error));
		decode_ril_error(&error, "FAIL");
	}

	cb(&error, NULL, 0, cbd->data);
}
コード例 #28
0
ファイル: gprs.c プロジェクト: morphis/ofono
static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_gprs_cb_t cb = cbd->cb;
	struct ofono_gprs *gprs = cbd->user;
	struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: reply failure: %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, cbd->data);
		return;
	}

	g_ril_print_response_no_args(gd->ril, message);

	CALLBACK_WITH_SUCCESS(cb, cbd->data);
}
コード例 #29
0
ファイル: sim.c プロジェクト: morphis/ofono
static void sim_send_set_uicc_subscription_cb(struct ril_msg *message,
						gpointer user_data)
{
	struct ofono_sim *sim = user_data;
	struct sim_data *sd = ofono_sim_get_data(sim);

	if (message->error == RIL_E_SUCCESS) {
		g_ril_print_response_no_args(sd->ril, message);
	} else {
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
		/*
		 * Send RIL_REQUEST_GET_SIM_STATUS again. The reply will run
		 * the app selection algorithm again, causing the request to
		 * be re-sent.
		 */
		 send_get_sim_status(sim);
	}
}
コード例 #30
0
ファイル: mtk.c プロジェクト: semafor/ofono
static void store_type_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct mtk_data *md = ofono_modem_get_data(modem);
	struct parcel rilp;
	int trm = 0;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: RIL error %s", __func__,
				ril_error_to_string(message->error));
		md->trm_pending = FALSE;
		return;
	}

	g_ril_print_response_no_args(md->ril, message);

	/*
	 * Send SET_TRM, which reloads the FW. We do not know the meaning of the
	 * magic TRM numbers (no source code for muxreport daemon).
	 */
	if (md->fw_type == MTK_MD_TYPE_LWG) {
		trm = 11;
	} else if (md->fw_type == MTK_MD_TYPE_LTG) {
		trm = 12;
	} else {
		ofono_error("%s: wrong modem type %d", __func__, md->fw_type);
		g_assert(FALSE);
	}

	g_mtk_request_set_trm(md->ril, trm, &rilp);

	if (g_ril_send(md->ril, MTK_RIL_REQUEST_SET_TRM, &rilp,
			set_trm_cb, modem, NULL) == 0)
		ofono_error("%s: failure sending request", __func__);

	/*
	 * rild will close now the socket, and the response to SET_TRM might be
	 * received before that or not.
	 * Measurements showed that rild takes around 5 seconds to re-start, but
	 * we use an 8 seconds timeout as times can vary and that value is also
	 * compatible with krillin modem.
	 */
}