Example #1
0
static void bcs_notify(GAtResult *result, gpointer user_data)
{
	struct hfp *hfp = user_data;
	struct hfp_slc_info *info = &hfp->info;
	GAtResultIter iter;
	char str[32];
	int value;

	g_at_result_iter_init(&iter, result);

	if (!g_at_result_iter_next(&iter, "+BCS:"))
		return;

	if (!g_at_result_iter_next_number(&iter, &value))
		return;

	if (ofono_handsfree_card_set_codec(hfp->card, value) == FALSE) {
		/* Unsupported codec, re-send our codecs */
		if (ofono_handsfree_audio_has_wideband())
			sprintf(str, "AT+BAC=%d,%d", HFP_CODEC_CVSD,
							HFP_CODEC_MSBC);
		else
			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);

		goto done;
	}

	/* Confirm the codec */
	sprintf(str, "AT+BCS=%d", value);

done:
	g_at_chat_send(info->chat, str, none_prefix, NULL, NULL, NULL);
}
Example #2
0
File: slc.c Project: CODeRUS/ofono
static void brsf_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
	struct slc_establish_data *sed = user_data;
	struct hfp_slc_info *info = sed->info;
	GAtResultIter iter;

	if (!ok)
		goto error;

	g_at_result_iter_init(&iter, result);

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

	g_at_result_iter_next_number(&iter, (gint *)&info->ag_features);

	if (info->ag_features & HFP_AG_FEATURE_CODEC_NEGOTIATION &&
			info->hf_features & HFP_HF_FEATURE_CODEC_NEGOTIATION) {
		char str[32];

		memset(str, 0, sizeof(str));

		if (ofono_handsfree_audio_has_wideband())
			sprintf(str, "AT+BAC=%d,%d", HFP_CODEC_CVSD,
							HFP_CODEC_MSBC);
		else
			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);

		slc_establish_data_ref(sed);
		g_at_chat_send(info->chat, str, NULL, bac_cb, sed,
						slc_establish_data_unref);
		return;
	}

	slc_establish_data_ref(sed);
	g_at_chat_send(info->chat, "AT+CIND=?", cind_prefix,
				cind_cb, sed, slc_establish_data_unref);
	return;

error:
	slc_failed(sed);
}