示例#1
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;

}
示例#2
0
static void ril_creg_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_netreg_status_cb_t cb = cbd->cb;
	struct netreg_data *nd = cbd->user;
	struct ofono_error error;
	int status, lac, ci, tech;

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		decode_ril_error(&error, "FAIL");
		ofono_error("Failed to pull registration state");
		cb(&error, -1, -1, -1, -1, cbd->data);
		return;
	}

	decode_ril_error(&error, "OK");

	if (ril_util_parse_reg(nd->ril, message, &status,
				&lac, &ci, &tech, NULL) == FALSE) {
		CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data);
		return;
	}

	DBG("voice registration status is %d", status);

	if (status > 10)
		status = status - 10;

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

	DBG("voice registration status is %d", status);

	nd->tech = tech;
	cb(&error, status, lac, ci, tech, cbd->data);
}
示例#3
0
文件: gprs.c 项目: mkuukkane/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;

	DBG("");

	if (gd && 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(gd->ril, 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->fake_timer_id > 0)
			&& ((status == NETWORK_REGISTRATION_STATUS_REGISTERED
				|| status == NETWORK_REGISTRATION_STATUS_ROAMING)
				|| !gd->ofono_attached)) {
		remove_fake_timer(gd);
		gd->true_status = -1;
	}

	if (status > 10)
		status = status - 10;

	if (!registered) {
		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);
	}

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

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

	DBG(" attached:%d, status:%d", gd->ofono_attached, status);

	if (!gd->ofono_attached) {
		if (status == NETWORK_REGISTRATION_STATUS_ROAMING) {
			if (!gd->notified && cb) {
				if (ril_roaming_allowed() == FALSE)
					ofono_gprs_detached_notify(gprs);

				/*
				 * This prevents core ending
				 * into eternal loop with driver
				 */
				decode_ril_error(&error, "FAIL");

				ofono_gprs_status_notify(gprs, status);
			}
		} else {
			if (status == NETWORK_REGISTRATION_STATUS_SEARCHING &&
								!gd->notified &&
								cb)
				/*
				 * This is a hack that prevents core ending
				 * into eternal loop with driver
				 */
				decode_ril_error(&error, "FAIL");

			ofono_gprs_status_notify(gprs, status);
		}

		if (cb)
			gd->notified = TRUE;

		gd->rild_status = status;
		goto error;
	}

	if (status == NETWORK_REGISTRATION_STATUS_ROAMING ||
		status == NETWORK_REGISTRATION_STATUS_REGISTERED) {
			ofono_gprs_status_notify(gprs, status);
			gd->rild_status = status;
	} else {
		if (gd->fake_timer_id <= 0) {
			gd->fake_cbd = cb_data_new(NULL, NULL);
			gd->fake_cbd->user = gprs;
			DBG("Start rilmodem fake status timer");
			gd->fake_timer_id = g_timeout_add_seconds(
						FAKE_STATE_TIMER,
						ril_fake_response, gd->fake_cbd);
		}

		gd->true_status = status;

		if (gd->rild_status == NETWORK_REGISTRATION_STATUS_ROAMING)
			status = NETWORK_REGISTRATION_STATUS_ROAMING;
		else
			status = NETWORK_REGISTRATION_STATUS_REGISTERED;

		gd->rild_status = status;
	}

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

	if (cb)
		cb(&error, status, cbd->data);
}