Beispiel #1
0
static void ril_sim_read_record(struct ofono_sim *sim, int fileid,
				int record, int length,
				const unsigned char *path,
				unsigned int path_len,
				ofono_sim_read_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sd);
	char *hex_path;
	struct parcel rilp;

	DBG("file %04x", fileid);

	hex_path = get_path(g_ril_vendor(sd->ril),
					sd->app_type, fileid, path, path_len);
	if (hex_path == NULL) {
		ofono_error("Couldn't build SIM read info request - NULL path");
		goto error;
	}

	parcel_init(&rilp);
	parcel_w_int32(&rilp, CMD_READ_RECORD);
	parcel_w_int32(&rilp, fileid);
	parcel_w_string(&rilp, hex_path);
	parcel_w_int32(&rilp, record);      /* P1 */
	parcel_w_int32(&rilp, 4);           /* P2 */
	parcel_w_int32(&rilp, length);      /* P3 */
	parcel_w_string(&rilp, NULL);       /* data; only req'd for writes */
	parcel_w_string(&rilp, NULL);       /* pin2; only req'd for writes */
	parcel_w_string(&rilp, sd->aid_str); /* AID (Application ID) */

	/* sessionId, specific to latest MTK modems (harmless for older ones) */
	if (g_ril_vendor(sd->ril) == OFONO_RIL_VENDOR_MTK)
		parcel_w_int32(&rilp, 0);

	g_ril_append_print_buf(sd->ril, "(cmd=0x%.2X,efid=0x%.4X,path=%s,"
					"%d,%d,%d,(null),pin2=(null),aid=%s)",
					CMD_READ_RECORD, fileid, hex_path,
					record, 4, length, sd->aid_str);
	g_free(hex_path);

	if (g_ril_send(sd->ril, RIL_REQUEST_SIM_IO, &rilp,
				ril_file_io_cb, cbd, g_free) > 0)
		return;

error:
	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
}
Beispiel #2
0
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);
}
Beispiel #3
0
static void ste_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_gprs_context_up_cb_t cb = cbd->cb;
	struct ofono_gprs_context *gc = cbd->user;
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
	struct cb_data *ncbd = NULL;
	char buf[128];
	struct conn_info *conn;
	GSList *l;

	if (!ok) {
		struct ofono_error error;

		gcd->active_context = 0;

		decode_at_error(&error, g_at_result_final_response(result));
		cb(&error, NULL, 0, NULL, NULL, NULL, NULL, cbd->data);
		return;
	}

	ncbd = g_memdup(cbd, sizeof(struct cb_data));

	l = g_slist_find_custom(g_caif_devices, GUINT_TO_POINTER(0),
				conn_compare_by_cid);

	if (!l) {
		DBG("at_cgdcont_cb, no more available devices");
		goto error;
	}

	conn = l->data;
	conn->cid = gcd->active_context;
	snprintf(buf, sizeof(buf), "AT*EPPSD=1,%u,%u",
			conn->channel_id, conn->cid);

	if (g_at_chat_send(gcd->chat, buf, NULL,
				ste_eppsd_up_cb, ncbd, g_free) > 0)
		return;

error:
	if (ncbd)
		g_free(ncbd);

	gcd->active_context = 0;

	CALLBACK_WITH_FAILURE(cb, NULL, 0, NULL, NULL,
				NULL, NULL, cbd->data);
}
Beispiel #4
0
static void ril_rat_mode_cb(struct ril_msg *message, gpointer user_data)
{
	DBG("");
	struct cb_data *cbd = user_data;
	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
	struct parcel rilp;
	int mode = OFONO_RADIO_ACCESS_MODE_ANY;
	int pref;

	if (message->error == RIL_E_SUCCESS) {
		ril_util_init_parcel(message, &rilp);
		/*first item in int[] is len so let's skip that*/
		parcel_r_int32(&rilp);
		pref = parcel_r_int32(&rilp);

		switch (pref) {
		case PREF_NET_TYPE_LTE_ONLY:
			mode = OFONO_RADIO_ACCESS_MODE_LTE;
		case PREF_NET_TYPE_GSM_ONLY:
			mode = OFONO_RADIO_ACCESS_MODE_GSM;
			break;
		case PREF_NET_TYPE_GSM_WCDMA_AUTO:/* according to UI design */
			if (!cb)
				ril_force_rat_mode(cbd->user, pref);
		case PREF_NET_TYPE_WCDMA:
		case PREF_NET_TYPE_GSM_WCDMA: /* according to UI design */
			mode = OFONO_RADIO_ACCESS_MODE_UMTS;
			break;
		case PREF_NET_TYPE_LTE_CDMA_EVDO:
		case PREF_NET_TYPE_LTE_GSM_WCDMA:
		case PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA:
			if (!cb)
				ril_force_rat_mode(cbd->user, pref);
			break;
		case PREF_NET_TYPE_CDMA_EVDO_AUTO:
		case PREF_NET_TYPE_CDMA_ONLY:
		case PREF_NET_TYPE_EVDO_ONLY:
		case PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO:
		default:
			break;
		}
		if (cb)
			CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
	} else {
		if (cb)
			CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
		ofono_error("rat mode query failed");
	}
}
Beispiel #5
0
static void ste_set_rat_mode(struct ofono_radio_settings *rs,
				enum ofono_radio_access_mode mode,
				ofono_radio_settings_rat_mode_set_cb_t cb,
				void *data)
{
	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
	struct cb_data *cbd = cb_data_new(cb, data);
	char buf[20];
	enum ste_radio_mode value;

	if (!ofono_mode_to_ste_mode(mode, &value)) {
		CALLBACK_WITH_FAILURE(cb, data);
		g_free(cbd);
		return;
	}

	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);

	if (g_at_chat_send(rsd->chat, buf, none_prefix,
					rat_modify_cb, cbd, g_free) == 0) {
		CALLBACK_WITH_FAILURE(cb, data);
		g_free(cbd);
	}
}
Beispiel #6
0
static void at_discover_apps(struct ofono_sim_auth *sa,
				ofono_sim_list_apps_cb_t cb,
				void *data)
{
	struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
	struct cb_data *cbd = cb_data_new(cb, data);

	if (g_at_chat_send(sad->chat, "AT+CUAD", cuad_prefix,
					at_discover_apps_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
}
static void ril_clir_query(struct ofono_call_settings *cs,
			ofono_call_settings_clir_cb_t cb, void *data)
{
	struct settings_data *sd = ofono_call_settings_get_data(cs);
	struct cb_data *cbd = cb_data_new(cb, data, cs);
	int ret;

	ret = g_ril_send(sd->ril, RIL_REQUEST_GET_CLIR, NULL,
				ril_clir_query_cb, cbd, g_free);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, -1, -1, data);
	}
}
Beispiel #8
0
static void at_query_revision(struct ofono_devinfo *info,
				ofono_devinfo_query_cb_t cb, void *data)
{
	struct cb_data *cbd = cb_data_new(cb, data);
	GAtChat *chat = ofono_devinfo_get_data(info);

	cbd->user = "******";

	if (g_at_chat_send(chat, "AT+CGMR", NULL, attr_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, NULL, data);
}
Beispiel #9
0
static void ril_set_rat_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_rat_mode_set_cb_t cb = cbd->cb;

	if (message->error == RIL_E_SUCCESS) {
		g_ril_print_response_no_args(rd->ril, message);
		CALLBACK_WITH_SUCCESS(cb, cbd->data);
	} else {
		ofono_error("%s: rat mode setting failed", __func__);
		CALLBACK_WITH_FAILURE(cb, cbd->data);
	}
}
Beispiel #10
0
static void ril_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb,
				void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sd);
	struct parcel rilp;

	g_ril_request_read_imsi(sd->ril, sd->aid_str, &rilp);

	if (g_ril_send(sd->ril, RIL_REQUEST_GET_IMSI, &rilp,
			ril_imsi_cb, cbd, g_free) == 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, NULL, data);
	}
}
Beispiel #11
0
static void ril_ussd_cancel(struct ofono_ussd *ussd,
				ofono_ussd_cb_t cb, void *user_data)
{
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct cb_data *cbd = cb_data_new(cb, user_data, ussd);
	int ret;

	ret = g_ril_send(ud->ril, RIL_REQUEST_CANCEL_USSD, NULL,
				ril_ussd_cancel_cb, cbd, g_free);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, user_data);
	}
}
Beispiel #12
0
static void at_discover_apps_cb(gboolean ok, GAtResult *result,
				gpointer user_data)
{
	struct cb_data *cbd = user_data;
	GAtResultIter iter;
	ofono_sim_list_apps_cb_t cb = cbd->cb;
	struct ofono_error error;
	const unsigned char *dataobj;
	gint linelen;
	unsigned char *buffer;
	int len;

	decode_at_error(&error, g_at_result_final_response(result));

	if (!ok) {
		cb(&error, NULL, 0, cbd->data);
		return;
	}

	g_at_result_iter_init(&iter, result);

	len = 0;
	while (g_at_result_iter_next(&iter, "+CUAD:")) {
		if (!g_at_result_iter_next_hexstring(&iter, NULL, &linelen))
			goto error;

		len += linelen;
	}

	g_at_result_iter_init(&iter, result);

	buffer = g_malloc(len);
	len = 0;

	while (g_at_result_iter_next(&iter, "+CUAD:")) {
		g_at_result_iter_next_hexstring(&iter, &dataobj, &linelen);
		memcpy(buffer + len, dataobj, linelen);
		len += linelen;
	}

	cb(&error, buffer, len, cbd->data);

	g_free(buffer);
	return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
}
Beispiel #13
0
static void ril_registration(struct ofono_call_forwarding *cf, int type,
                             int cls,
                             const struct ofono_phone_number *number,
                             int time, ofono_call_forwarding_set_cb_t cb,
                             void *data)
{
    struct forw_data *fd = ofono_call_forwarding_get_data(cf);
    struct cb_data *cbd = cb_data_new(cb, data);
    struct parcel rilp;
    int ret = 0;

    ofono_info("cf registration");

    parcel_init(&rilp);

    parcel_w_int32(&rilp, CF_ACTION_REGISTRATION);

    parcel_w_int32(&rilp, type);

    /*
     * Modem seems to respond with error to all queries
     * or settings made with bearer class
     * BEARER_CLASS_DEFAULT. Design decision: If given
     * class is BEARER_CLASS_DEFAULT let's map it to
     * SERVICE_CLASS_NONE as with it e.g. ./send-ussd '*21*<phone_number>#'
     * returns cls:53 i.e. 1+4+16+32 as service class.
    */
    if (cls == BEARER_CLASS_DEFAULT)
        cls = SERVICE_CLASS_NONE;

    parcel_w_int32(&rilp, cls);

    parcel_w_int32(&rilp, number->type);

    parcel_w_string(&rilp, (char *) number->number);

    parcel_w_int32(&rilp, time);

    ret = g_ril_send(fd->ril, RIL_REQUEST_SET_CALL_FORWARD,
                     rilp.data, rilp.size, ril_set_forward_cb, cbd, g_free);

    /* In case of error free cbd and return the cb with failure */
    if (ret <= 0) {
        ofono_error("CF registration failed");
        g_free(cbd);
        CALLBACK_WITH_FAILURE(cb, data);
    }
}
Beispiel #14
0
static void cgact_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
	struct ofono_gprs_context *gc = user_data;
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);

	DBG("ok %d", ok);

	if (!ok) {
		CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
		return;
	}

	gcd->active_context = 0;

	CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
}
static void hfp_signal_strength(struct ofono_netreg *netreg,
				ofono_netreg_strength_cb_t cb, void *data)
{
	struct netreg_data *nd = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, data);

	cbd->user = netreg;

	if (g_at_chat_send(nd->chat, "AT+CIND?", cind_prefix,
				signal_strength_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, -1, data);
}
Beispiel #16
0
static void qmi_signal_strength(struct ofono_netreg *netreg,
				ofono_netreg_strength_cb_t cb, void *user_data)
{
	struct netreg_data *data = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, user_data);

	DBG("");

	if (qmi_service_send(data->nas, QMI_NAS_GET_RSSI, NULL,
					get_rssi_cb, cbd, g_free) > 0)
		return;

	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);

	g_free(cbd);
}
Beispiel #17
0
static void qmi_list_operators(struct ofono_netreg *netreg,
			ofono_netreg_operator_list_cb_t cb, void *user_data)
{
	struct netreg_data *data = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, user_data);

	DBG("");

	if (qmi_service_send(data->nas, QMI_NAS_SCAN_NETS, NULL,
					scan_nets_cb, cbd, g_free) > 0)
		return;

	CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd->data);

	g_free(cbd);
}
Beispiel #18
0
static void enter_pin_done(const struct ofono_error *error, void *data)
{
	struct change_state_cbd *csd = data;
	struct sim_data *sd = ofono_sim_get_data(csd->sim);

	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
		ofono_error("%s: wrong password", __func__);
		sd->unlock_pending = FALSE;
		CALLBACK_WITH_FAILURE(csd->cb, csd->data);
	} else {
		ril_pin_change_state(csd->sim, csd->passwd_type, csd->enable,
					csd->passwd, csd->cb, csd->data);
	}

	g_free(csd);
}
Beispiel #19
0
static void isi_sca_query(struct ofono_sms *sms,
				ofono_sms_sca_query_cb_t cb, void *data)
{
	struct sms_data *sd = ofono_sms_get_data(sms);
	struct isi_cb_data *cbd = isi_cb_data_new(sms, cb, data);

	if (cbd == NULL || sd->sim == NULL)
		goto error;

	if (sca_sim_query(sd->sim, cbd, g_free))
		return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, data);
	g_free(cbd);
}
Beispiel #20
0
static void ril_set_online_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ril_data *rd = cbd->user;
	ofono_modem_online_cb_t cb = cbd->cb;

	if (message->error == RIL_E_SUCCESS) {
		DBG("%s: set_online OK: rd->ofono_online: %d", __func__,
			rd->ofono_online);
		CALLBACK_WITH_SUCCESS(cb, cbd->data);
	} else {
		ofono_error("%s: set_online: %d failed", __func__,
				rd->ofono_online);
		CALLBACK_WITH_FAILURE(cb, cbd->data);
	}
}
Beispiel #21
0
static void tc65_set_online(struct ofono_modem *modem, ofono_bool_t online,
			ofono_modem_online_cb_t cb, void *user_data)
{
	GAtChat *chat = ofono_modem_get_data(modem);
	struct cb_data *cbd = cb_data_new(cb, user_data);
	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=7";

	DBG("modem %p %s", modem, online ? "online" : "offline");

	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, cbd->data);
}
Beispiel #22
0
static void qmi_read_imsi(struct ofono_sim *sim,
				ofono_sim_imsi_cb_t cb, void *user_data)
{
	struct sim_data *data = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, user_data);

	DBG("");

	if (qmi_service_send(data->dms, QMI_DMS_GET_IMSI, NULL,
					get_imsi_cb, cbd, g_free) > 0)
		return;

	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);

	g_free(cbd);
}
Beispiel #23
0
static void phonesim_ctm_query(struct ofono_ctm *ctm,
				ofono_ctm_query_cb_t cb, void *data)
{
	GAtChat *chat = ofono_ctm_get_data(ctm);
	struct cb_data *cbd = cb_data_new(cb, data);

	DBG("");

	if (g_at_chat_send(chat, "AT+PTTY?", ptty_prefix,
				ctm_query_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, 0, data);
}
Beispiel #24
0
static void qmi_read_file_info(struct ofono_sim *sim, int fileid,
				ofono_sim_file_info_cb_t cb, void *user_data)
{
	unsigned char access[3] = { 0x0f, 0xff, 0xff };

	DBG("file id 0x%04x", fileid);

	switch (fileid) {
	case SIM_EF_ICCID_FILEID:
		CALLBACK_WITH_SUCCESS(cb, 10, 0, 0, access, 1, user_data);
		break;
	default:
		CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL, 0, user_data);
		break;
	}
}
static void ril_clip_query(struct ofono_call_settings *cs,
			ofono_call_settings_status_cb_t cb, void *data)
{
	struct settings_data *sd = ofono_call_settings_get_data(cs);
	struct cb_data *cbd = cb_data_new(cb, data, cs);
	int ret;

	ret = g_ril_send(sd->ril, RIL_REQUEST_QUERY_CLIP, NULL,
				ril_clip_query_cb, cbd, g_free);

	/* In case of error free cbd and return the cb with failure */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, -1, data);
	}
}
Beispiel #26
0
static void ril_call_barring_query(struct ofono_call_barring *cb,
					const char *lock, int cls,
					ofono_call_barring_query_cb_t callback,
					void *data)
{
	struct barring_data *bd = ofono_call_barring_get_data(cb);
	struct cb_data *cbd = cb_data_new(callback, data);
	struct parcel rilp;
	int ret = 0;
	char cls_textual[RIL_MAX_SERVICE_LENGTH];

	DBG("lock: %s, services to query: %i", lock, cls);

	/*
	 * RIL modems do not support 7 as default bearer class. According to
	 * the 22.030 Annex C: When service code is not given it corresponds to
	 * "All tele and bearer services"
	 */
	if (cls == BEARER_CLASS_DEFAULT)
		cls = SERVICE_CLASS_NONE;

	sprintf(cls_textual, "%d", cls);

	/*
	 * See 3GPP 27.007 7.4 for parameter descriptions.
	 * According to ril.h password should be empty string "" when not
	 * needed, but in reality we only need to give string length as 0
	 */
	parcel_init(&rilp);
	parcel_w_int32(&rilp, RIL_QUERY_STRING_COUNT);	/* Nbr of strings */
	parcel_w_string(&rilp, (char *) lock);		/* Facility code */
	parcel_w_int32(&rilp, RIL_LENGTH_ZERO);		/* Password length */
	parcel_w_string(&rilp, (char *) cls_textual);
	parcel_w_string(&rilp, NULL); /* AID (for FDN, not yet supported) */

	ret = g_ril_send(bd->ril, RIL_REQUEST_QUERY_FACILITY_LOCK,
			rilp.data, rilp.size, ril_call_barring_query_cb,
			cbd, g_free);

	parcel_free(&rilp);

	if (ret <= 0) {
		ofono_error("Sending Call Barring query failed, err: %i", ret);
		g_free(cbd);
		CALLBACK_WITH_FAILURE(callback, -1, data);
	}
}
Beispiel #27
0
static void ril_registration(struct ofono_call_forwarding *cf, int type,
				int cls,
				const struct ofono_phone_number *number,
				int time, ofono_call_forwarding_set_cb_t cb,
				void *data)
{
	struct forw_data *fd = ofono_call_forwarding_get_data(cf);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int ret = 0;

	parcel_init(&rilp);

	parcel_w_int32(&rilp, CF_ACTION_REGISTRATION);

	parcel_w_int32(&rilp, type);

	/* Modem seems to respond with error to all queries
	 * or settings made with bearer class
	 * BEARER_CLASS_DEFAULT. Design decision: If given
	 * class is BEARER_CLASS_DEFAULT let's map it to
	 * SERVICE_CLASS_VOICE effectively making it the
	 * default bearer. This in line with API which is
	 * contains only voice anyways. TODO: Checkout
	 * the behaviour with final modem
	*/

	if (cls == BEARER_CLASS_DEFAULT)
		cls = BEARER_CLASS_VOICE;

	parcel_w_int32(&rilp, cls);

	parcel_w_int32(&rilp, number->type);

	parcel_w_string(&rilp, (char *) number->number);

	parcel_w_int32(&rilp, time);

	ret = g_ril_send(fd->ril, RIL_REQUEST_SET_CALL_FORWARD,
		rilp.data, rilp.size, ril_set_forward_cb, cbd, g_free);

	/* In case of error free cbd and return the cb with failure */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Beispiel #28
0
static void phonesim_activate_primary(struct ofono_gprs_context *gc,
				const struct ofono_gprs_primary_context *ctx,
				ofono_gprs_context_cb_t cb, void *data)
{
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
	struct cb_data *cbd = cb_data_new(cb, data);
	char buf[OFONO_GPRS_MAX_APN_LENGTH + 128];
	int len = 0;

	cbd->user = gc;
	gcd->proto = ctx->proto;

	switch (ctx->proto) {
	case OFONO_GPRS_PROTO_IP:
		len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"",
				ctx->cid);
		break;

	case OFONO_GPRS_PROTO_IPV6:
		len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV6\"",
				ctx->cid);
		break;

	case OFONO_GPRS_PROTO_IPV4V6:
		len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV4V6\"",
				ctx->cid);
		break;
	}

	if (ctx->apn)
		snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
				ctx->apn);

	/* Assume always succeeds */
	if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0)
		goto error;

	sprintf(buf, "AT+CGACT=1,%u", ctx->cid);
	if (g_at_chat_send(gcd->chat, buf, none_prefix,
				at_cgact_up_cb, cbd, g_free) > 0)
		return;

error:
	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, data);
}
Beispiel #29
0
static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_netreg_operator_cb_t cb = cbd->cb;
	struct ofono_network_operator op;
	GAtResultIter iter;
	int format;
	const char *name;
	struct ofono_error error;

	decode_at_error(&error, g_at_result_final_response(result));

	if (!ok) {
		cb(&error, NULL, cbd->data);
		return;
	}

	g_at_result_iter_init(&iter, result);

	if (!g_at_result_iter_next(&iter, "+COPS:"))
		goto error;

	g_at_result_iter_skip_next(&iter);

	ok = g_at_result_iter_next_number(&iter, &format);

	if (ok == FALSE || format != 0)
		goto error;

	if (g_at_result_iter_next_string(&iter, &name) == FALSE)
		goto error;

	strncpy(op.name, name, HFP_MAX_OPERATOR_NAME_LENGTH);
	op.name[HFP_MAX_OPERATOR_NAME_LENGTH] = '\0';

	op.mcc[0] = '\0';
	op.mnc[0] = '\0';
	op.status = 2;
	op.tech = -1;

	cb(&error, &op, cbd->data);

	return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
static void telit_portcfg_check_cb(gboolean ok, GAtResult *result,
					gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_location_reporting_enable_cb_t cb = cbd->cb;
	struct ofono_location_reporting *lr = cbd->user;
	struct gps_data *gd = ofono_location_reporting_get_data(lr);
	struct ofono_error error;
	int requested_portcfg, current_portcfg;
	GAtResultIter iter;

	DBG("lr=%p ok=%d", lr, ok);

	decode_at_error(&error, g_at_result_final_response(result));

	if (!ok) {
		cb(&error, -1, cbd->data);

		g_free(cbd);
		return;
	}

	g_at_result_iter_init(&iter, result);

	if (!g_at_result_iter_next(&iter, "#PORTCFG:"))
		goto fail;

	if (!g_at_result_iter_next_number(&iter, &requested_portcfg))
		goto fail;

	if (!g_at_result_iter_next_number(&iter, &current_portcfg))
		goto fail;

	if (current_portcfg != 8) {
		ofono_warn("Unable to start GPS, modem configuration invalid");
		ofono_warn("Refer to doc/telit-modem.txt section HE910/GPS");
		goto fail;
	}

	if (g_at_chat_send(gd->chat, "AT$GPSP=1", none_prefix,
				telit_gps_enable_cb, cbd, NULL) > 0)
		return;

fail:
	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
	g_free(cbd);
}