hfp_hf: Reorganize common code into hfpmodem

This commit is contained in:
Denis Kenzior 2011-07-20 14:55:31 -05:00
parent 77ae92efc0
commit b33d6b5fcb
9 changed files with 411 additions and 282 deletions

View File

@ -210,6 +210,8 @@ builtin_modules += hfpmodem
builtin_sources += drivers/atmodem/atutil.h \
drivers/hfpmodem/hfpmodem.h \
drivers/hfpmodem/hfpmodem.c \
drivers/hfpmodem/slc.h \
drivers/hfpmodem/slc.c \
drivers/hfpmodem/voicecall.c \
drivers/hfpmodem/network-registration.c \
drivers/hfpmodem/call-volume.c

View File

@ -31,15 +31,15 @@
#include <unistd.h>
#include <glib.h>
#include <gatchat.h>
#include <gatresult.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/call-volume.h>
#include "gatchat.h"
#include "gatresult.h"
#include "hfpmodem.h"
#include "slc.h"
#define HFP_CALL_VOLUME_MAX 15
@ -186,12 +186,12 @@ static void hfp_call_volume_initialized(gpointer user_data)
static int hfp_call_volume_probe(struct ofono_call_volume *cv,
unsigned int vendor, void *data)
{
struct hfp_data *d = data;
struct hfp_slc_info *info = data;
struct cv_data *vd;
DBG("");
vd = g_new0(struct cv_data, 1);
vd->chat = d->chat;
vd->chat = g_at_chat_clone(info->chat);
ofono_call_volume_set_data(cv, vd);

View File

@ -23,19 +23,12 @@
#include <config.h>
#endif
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <glib.h>
#include <gatchat.h>
#include <gatresult.h>
#include "hfpmodem.h"

View File

@ -22,37 +22,6 @@
#include <drivers/atmodem/atutil.h>
#include <ofono/dbus.h>
#define AG_CHLD_0 0x01
#define AG_CHLD_1 0x02
#define AG_CHLD_1x 0x04
#define AG_CHLD_2 0x08
#define AG_CHLD_2x 0x10
#define AG_CHLD_3 0x20
#define AG_CHLD_4 0x40
enum hfp_indicator {
HFP_INDICATOR_SERVICE = 0,
HFP_INDICATOR_CALL,
HFP_INDICATOR_CALLSETUP,
HFP_INDICATOR_CALLHELD,
HFP_INDICATOR_SIGNAL,
HFP_INDICATOR_ROAM,
HFP_INDICATOR_BATTCHG,
HFP_INDICATOR_LAST
};
struct hfp_data {
GAtChat *chat;
char *handsfree_path;
DBusMessage *slc_msg;
unsigned int ag_features;
unsigned int ag_mpty_features;
unsigned int hf_features;
unsigned char cind_pos[HFP_INDICATOR_LAST];
unsigned int cind_val[HFP_INDICATOR_LAST];
gboolean agent_registered;
};
extern void hfp_netreg_init(void);
extern void hfp_netreg_exit(void);

View File

@ -30,16 +30,17 @@
#include <stdio.h>
#include <glib.h>
#include <gatchat.h>
#include <gatresult.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/netreg.h>
#include "gatchat.h"
#include "gatresult.h"
#include "common.h"
#include "hfpmodem.h"
#include "slc.h"
#define HFP_MAX_OPERATOR_NAME_LENGTH 16
@ -301,14 +302,14 @@ static gboolean hfp_netreg_register(gpointer user_data)
static int hfp_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
void *user_data)
{
struct hfp_data *data = user_data;
struct hfp_slc_info *info = user_data;
struct netreg_data *nd;
nd = g_new0(struct netreg_data, 1);
nd->chat = data->chat;
memcpy(nd->cind_pos, data->cind_pos, HFP_INDICATOR_LAST);
memcpy(nd->cind_val, data->cind_val, HFP_INDICATOR_LAST);
nd->chat = g_at_chat_clone(info->chat);
memcpy(nd->cind_pos, info->cind_pos, HFP_INDICATOR_LAST);
memcpy(nd->cind_val, info->cind_val, HFP_INDICATOR_LAST);
ofono_netreg_set_data(netreg, nd);

304
drivers/hfpmodem/slc.c Normal file
View File

@ -0,0 +1,304 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include <gatchat.h>
#include <gatresult.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/emulator.h>
#include <drivers/atmodem/atutil.h>
#include "slc.h"
static const char *brsf_prefix[] = { "+BRSF:", NULL };
static const char *cind_prefix[] = { "+CIND:", NULL };
static const char *cmer_prefix[] = { "+CMER:", NULL };
static const char *chld_prefix[] = { "+CHLD:", NULL };
struct slc_establish_data {
gint ref_count;
struct hfp_slc_info *info;
hfp_slc_cb_t failed_cb;
hfp_slc_cb_t connect_cb;
gpointer userdata;
};
void hfp_slc_info_init(struct hfp_slc_info *info)
{
info->ag_features = 0;
info->ag_mpty_features = 0;
info->hf_features = HFP_HF_FEATURE_3WAY;
info->hf_features |= HFP_HF_FEATURE_CLIP;
info->hf_features |= HFP_HF_FEATURE_REMOTE_VOLUME_CONTROL;
info->hf_features |= HFP_HF_FEATURE_ENHANCED_CALL_STATUS;
info->hf_features |= HFP_HF_FEATURE_ENHANCED_CALL_CONTROL;
memset(info->cind_val, 0, sizeof(info->cind_val));
memset(info->cind_pos, 0, sizeof(info->cind_pos));
}
static void slc_establish_data_unref(gpointer userdata)
{
struct slc_establish_data *sed = userdata;
if (g_atomic_int_dec_and_test(&sed->ref_count))
g_free(sed);
}
static void slc_establish_data_ref(struct slc_establish_data *sed)
{
g_atomic_int_inc(&sed->ref_count);
}
static void slc_failed(struct slc_establish_data *sed)
{
sed->failed_cb(sed->userdata);
}
static void slc_established(struct slc_establish_data *sed)
{
struct hfp_slc_info *info = sed->info;
g_at_chat_send(info->chat, "AT+CMEE=1", NULL, NULL, NULL, NULL);
sed->connect_cb(sed->userdata);
}
static void chld_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
unsigned int ag_mpty_feature = 0;
GAtResultIter iter;
const char *str;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CHLD:"))
goto error;
if (!g_at_result_iter_open_list(&iter))
goto error;
while (g_at_result_iter_next_unquoted_string(&iter, &str)) {
if (!strcmp(str, "0"))
ag_mpty_feature |= AG_CHLD_0;
else if (!strcmp(str, "1"))
ag_mpty_feature |= AG_CHLD_1;
else if (!strcmp(str, "1x"))
ag_mpty_feature |= AG_CHLD_1x;
else if (!strcmp(str, "2"))
ag_mpty_feature |= AG_CHLD_2;
else if (!strcmp(str, "2x"))
ag_mpty_feature |= AG_CHLD_2x;
else if (!strcmp(str, "3"))
ag_mpty_feature |= AG_CHLD_3;
else if (!strcmp(str, "4"))
ag_mpty_feature |= AG_CHLD_4;
}
if (!g_at_result_iter_close_list(&iter))
goto error;
info->ag_mpty_features = ag_mpty_feature;
slc_established(sed);
return;
error:
slc_failed(sed);
}
static void cmer_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
if (!ok) {
slc_failed(sed);
return;
}
if (info->ag_features & HFP_AG_FEATURE_3WAY) {
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+CHLD=?", chld_prefix,
chld_cb, sed, slc_establish_data_unref);
} else
slc_established(sed);
}
static void cind_status_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
GAtResultIter iter;
int index;
int value;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CIND:"))
goto error;
index = 1;
while (g_at_result_iter_next_number(&iter, &value)) {
int i;
for (i = 0; i < HFP_INDICATOR_LAST; i++) {
if (index != info->cind_pos[i])
continue;
info->cind_val[i] = value;
}
index += 1;
}
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+CMER=3,0,0,1", cmer_prefix,
cmer_cb, sed, slc_establish_data_unref);
return;
error:
slc_failed(sed);
}
static void cind_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
GAtResultIter iter;
const char *str;
int index;
int min, max;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CIND:"))
goto error;
index = 1;
while (g_at_result_iter_open_list(&iter)) {
if (!g_at_result_iter_next_string(&iter, &str))
goto error;
if (!g_at_result_iter_open_list(&iter))
goto error;
while (g_at_result_iter_next_range(&iter, &min, &max))
;
if (!g_at_result_iter_close_list(&iter))
goto error;
if (!g_at_result_iter_close_list(&iter))
goto error;
if (g_str_equal("service", str) == TRUE)
info->cind_pos[HFP_INDICATOR_SERVICE] = index;
else if (g_str_equal("call", str) == TRUE)
info->cind_pos[HFP_INDICATOR_CALL] = index;
else if (g_str_equal("callsetup", str) == TRUE)
info->cind_pos[HFP_INDICATOR_CALLSETUP] = index;
else if (g_str_equal("callheld", str) == TRUE)
info->cind_pos[HFP_INDICATOR_CALLHELD] = index;
else if (g_str_equal("signal", str) == TRUE)
info->cind_pos[HFP_INDICATOR_SIGNAL] = index;
else if (g_str_equal("roam", str) == TRUE)
info->cind_pos[HFP_INDICATOR_ROAM] = index;
else if (g_str_equal("battchg", str) == TRUE)
info->cind_pos[HFP_INDICATOR_BATTCHG] = index;
index += 1;
}
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+CIND?", cind_prefix,
cind_status_cb, sed, slc_establish_data_unref);
return;
error:
slc_failed(sed);
}
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);
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);
}
void hfp_slc_establish(struct hfp_slc_info *info, hfp_slc_cb_t connect_cb,
hfp_slc_cb_t failed_cb, void *userdata)
{
char buf[64];
struct slc_establish_data *sed = g_new0(struct slc_establish_data, 1);
sed->ref_count = 1;
sed->connect_cb = connect_cb;
sed->failed_cb = failed_cb;
sed->userdata = userdata;
sed->info = info;
snprintf(buf, sizeof(buf), "AT+BRSF=%d", info->hf_features);
g_at_chat_send(info->chat, buf, brsf_prefix,
brsf_cb, sed, slc_establish_data_unref);
}

56
drivers/hfpmodem/slc.h Normal file
View File

@ -0,0 +1,56 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#define AG_CHLD_0 0x01
#define AG_CHLD_1 0x02
#define AG_CHLD_1x 0x04
#define AG_CHLD_2 0x08
#define AG_CHLD_2x 0x10
#define AG_CHLD_3 0x20
#define AG_CHLD_4 0x40
enum hfp_indicator {
HFP_INDICATOR_SERVICE = 0,
HFP_INDICATOR_CALL,
HFP_INDICATOR_CALLSETUP,
HFP_INDICATOR_CALLHELD,
HFP_INDICATOR_SIGNAL,
HFP_INDICATOR_ROAM,
HFP_INDICATOR_BATTCHG,
HFP_INDICATOR_LAST
};
typedef void (*hfp_slc_cb_t)(void *userdata);
struct hfp_slc_info {
GAtChat *chat;
unsigned int ag_features;
unsigned int ag_mpty_features;
unsigned int hf_features;
unsigned char cind_pos[HFP_INDICATOR_LAST];
unsigned int cind_val[HFP_INDICATOR_LAST];
};
void hfp_slc_info_init(struct hfp_slc_info *info);
void hfp_slc_info_free(struct hfp_slc_info *info);
void hfp_slc_establish(struct hfp_slc_info *info, hfp_slc_cb_t connect_cb,
hfp_slc_cb_t failed_cb, void *userdata);

View File

@ -29,15 +29,17 @@
#include <stdio.h>
#include <glib.h>
#include <gatchat.h>
#include <gatresult.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/voicecall.h>
#include "common.h"
#include "gatchat.h"
#include "gatresult.h"
#include "hfpmodem.h"
#include "slc.h"
#define POLL_CLCC_INTERVAL 2000
#define CLIP_TIMEOUT 500
@ -1115,17 +1117,17 @@ static void hfp_voicecall_initialized(gboolean ok, GAtResult *result,
static int hfp_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
gpointer user_data)
{
struct hfp_data *data = user_data;
struct hfp_slc_info *info = user_data;
struct voicecall_data *vd;
vd = g_new0(struct voicecall_data, 1);
vd->chat = data->chat;
vd->ag_features = data->ag_features;
vd->ag_mpty_features = data->ag_mpty_features;
vd->chat = g_at_chat_clone(info->chat);
vd->ag_features = info->ag_features;
vd->ag_mpty_features = info->ag_mpty_features;
memcpy(vd->cind_pos, data->cind_pos, HFP_INDICATOR_LAST);
memcpy(vd->cind_val, data->cind_val, HFP_INDICATOR_LAST);
memcpy(vd->cind_pos, info->cind_pos, HFP_INDICATOR_LAST);
memcpy(vd->cind_val, info->cind_val, HFP_INDICATOR_LAST);
ofono_voicecall_set_data(vc, vd);

View File

@ -42,7 +42,7 @@
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
#include <drivers/hfpmodem/hfpmodem.h>
#include <drivers/hfpmodem/slc.h>
#include <ofono/dbus.h>
@ -57,14 +57,16 @@
#define DBUS_TYPE_UNIX_FD -1
#endif
static const char *brsf_prefix[] = { "+BRSF:", NULL };
static const char *cind_prefix[] = { "+CIND:", NULL };
static const char *cmer_prefix[] = { "+CMER:", NULL };
static const char *chld_prefix[] = { "+CHLD:", NULL };
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
char *handsfree_path;
DBusMessage *slc_msg;
gboolean agent_registered;
};
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@ -72,24 +74,11 @@ static void hfp_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
static void clear_data(struct ofono_modem *modem)
static void slc_established(gpointer userdata)
{
struct ofono_modem *modem = userdata;
struct hfp_data *data = ofono_modem_get_data(modem);
if (data->chat == NULL)
return;
g_at_chat_unref(data->chat);
data->chat = NULL;
memset(data->cind_val, 0, sizeof(data->cind_val));
memset(data->cind_pos, 0, sizeof(data->cind_pos));
}
static void service_level_conn_established(struct ofono_modem *modem)
{
DBusMessage *msg;
struct hfp_data *data = ofono_modem_get_data(modem);
ofono_modem_set_powered(modem, TRUE);
@ -99,12 +88,11 @@ static void service_level_conn_established(struct ofono_modem *modem)
data->slc_msg = NULL;
ofono_info("Service level connection established");
g_at_chat_send(data->chat, "AT+CMEE=1", NULL, NULL, NULL, NULL);
}
static void service_level_conn_failed(struct ofono_modem *modem)
static void slc_failed(gpointer userdata)
{
struct ofono_modem *modem = userdata;
struct hfp_data *data = ofono_modem_get_data(modem);
DBusMessage *msg;
@ -117,200 +105,20 @@ static void service_level_conn_failed(struct ofono_modem *modem)
ofono_error("Service level connection failed");
ofono_modem_set_powered(modem, FALSE);
clear_data(modem);
}
static void chld_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
unsigned int ag_mpty_feature = 0;
GAtResultIter iter;
const char *str;
if (!ok)
return;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CHLD:"))
return;
if (!g_at_result_iter_open_list(&iter))
return;
while (g_at_result_iter_next_unquoted_string(&iter, &str)) {
if (!strcmp(str, "0"))
ag_mpty_feature |= AG_CHLD_0;
else if (!strcmp(str, "1"))
ag_mpty_feature |= AG_CHLD_1;
else if (!strcmp(str, "1x"))
ag_mpty_feature |= AG_CHLD_1x;
else if (!strcmp(str, "2"))
ag_mpty_feature |= AG_CHLD_2;
else if (!strcmp(str, "2x"))
ag_mpty_feature |= AG_CHLD_2x;
else if (!strcmp(str, "3"))
ag_mpty_feature |= AG_CHLD_3;
else if (!strcmp(str, "4"))
ag_mpty_feature |= AG_CHLD_4;
}
if (!g_at_result_iter_close_list(&iter))
return;
data->ag_mpty_features = ag_mpty_feature;
service_level_conn_established(modem);
}
static void cmer_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
if (!ok) {
service_level_conn_failed(modem);
return;
}
if (data->ag_features & HFP_AG_FEATURE_3WAY)
g_at_chat_send(data->chat, "AT+CHLD=?", chld_prefix,
chld_cb, modem, NULL);
else
service_level_conn_established(modem);
}
static void cind_status_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
GAtResultIter iter;
int index;
int value;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CIND:"))
goto error;
index = 1;
while (g_at_result_iter_next_number(&iter, &value)) {
int i;
for (i = 0; i < HFP_INDICATOR_LAST; i++) {
if (index != data->cind_pos[i])
continue;
data->cind_val[i] = value;
}
index += 1;
}
g_at_chat_send(data->chat, "AT+CMER=3,0,0,1", cmer_prefix,
cmer_cb, modem, NULL);
return;
error:
service_level_conn_failed(modem);
}
static void cind_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
GAtResultIter iter;
const char *str;
int index;
int min, max;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CIND:"))
goto error;
index = 1;
while (g_at_result_iter_open_list(&iter)) {
if (!g_at_result_iter_next_string(&iter, &str))
goto error;
if (!g_at_result_iter_open_list(&iter))
goto error;
while (g_at_result_iter_next_range(&iter, &min, &max))
;
if (!g_at_result_iter_close_list(&iter))
goto error;
if (!g_at_result_iter_close_list(&iter))
goto error;
if (g_str_equal("service", str) == TRUE)
data->cind_pos[HFP_INDICATOR_SERVICE] = index;
else if (g_str_equal("call", str) == TRUE)
data->cind_pos[HFP_INDICATOR_CALL] = index;
else if (g_str_equal("callsetup", str) == TRUE)
data->cind_pos[HFP_INDICATOR_CALLSETUP] = index;
else if (g_str_equal("callheld", str) == TRUE)
data->cind_pos[HFP_INDICATOR_CALLHELD] = index;
else if (g_str_equal("signal", str) == TRUE)
data->cind_pos[HFP_INDICATOR_SIGNAL] = index;
else if (g_str_equal("roam", str) == TRUE)
data->cind_pos[HFP_INDICATOR_ROAM] = index;
else if (g_str_equal("battchg", str) == TRUE)
data->cind_pos[HFP_INDICATOR_BATTCHG] = index;
index += 1;
}
g_at_chat_send(data->chat, "AT+CIND?", cind_prefix,
cind_status_cb, modem, NULL);
return;
error:
service_level_conn_failed(modem);
}
static void brsf_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
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 *)&data->ag_features);
g_at_chat_send(data->chat, "AT+CIND=?", cind_prefix,
cind_cb, modem, NULL);
return;
error:
service_level_conn_failed(modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
}
static void hfp_disconnected_cb(gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct hfp_data *data = ofono_modem_get_data(modem);
ofono_modem_set_powered(modem, FALSE);
clear_data(modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
}
/* either oFono or Phone could request SLC connection */
@ -320,7 +128,6 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
GIOChannel *io;
GAtSyntax *syntax;
GAtChat *chat;
char buf[64];
io = g_io_channel_unix_new(fd);
if (io == NULL) {
@ -342,10 +149,8 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
if (getenv("OFONO_AT_DEBUG"))
g_at_chat_set_debug(chat, hfp_debug, "");
snprintf(buf, sizeof(buf), "AT+BRSF=%d", data->hf_features);
g_at_chat_send(chat, buf, brsf_prefix,
brsf_cb, modem, NULL);
data->chat = chat;
data->info.chat = chat;
hfp_slc_establish(&data->info, slc_established, slc_failed, modem);
return -EINPROGRESS;
}
@ -418,11 +223,7 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
if (data == NULL)
goto free;
data->hf_features |= HFP_HF_FEATURE_3WAY;
data->hf_features |= HFP_HF_FEATURE_CLIP;
data->hf_features |= HFP_HF_FEATURE_REMOTE_VOLUME_CONTROL;
data->hf_features |= HFP_HF_FEATURE_ENHANCED_CALL_STATUS;
data->hf_features |= HFP_HF_FEATURE_ENHANCED_CALL_CONTROL;
hfp_slc_info_init(&data->info);
data->handsfree_path = g_strdup(device);
if (data->handsfree_path == NULL)
@ -642,7 +443,8 @@ static int hfp_disable(struct ofono_modem *modem)
DBG("%p", modem);
clear_data(modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
if (data->agent_registered) {
status = bluetooth_send_with_reply(data->handsfree_path,
@ -663,9 +465,9 @@ static void hfp_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
ofono_voicecall_create(modem, 0, "hfpmodem", data);
ofono_netreg_create(modem, 0, "hfpmodem", data);
ofono_call_volume_create(modem, 0, "hfpmodem", data);
ofono_voicecall_create(modem, 0, "hfpmodem", &data->info);
ofono_netreg_create(modem, 0, "hfpmodem", &data->info);
ofono_call_volume_create(modem, 0, "hfpmodem", &data->info);
}
static void hfp_post_sim(struct ofono_modem *modem)