diff --git a/android/handsfree.c b/android/handsfree.c
index f11e0a1..c52b4ce 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
static void at_cmd_unknown(const char *command, void *user_data)
{
+ struct hf_device *dev = user_data;
uint8_t buf[IPC_MTU];
struct hal_ev_handsfree_unknown_at *ev = (void *) buf;
- if (device.state != HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED) {
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
- hfp_gw_disconnect(device.gw);
+ if (dev->state != HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED) {
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
+ hfp_gw_disconnect(dev->gw);
return;
}
memcpy(ev->buf, command, ev->len);
if (ev->len > IPC_MTU - sizeof(*ev)) {
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
return;
}
static void at_cmd_vgm(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_volume ev;
unsigned int val;
HAL_EV_HANDSFREE_VOLUME, sizeof(ev), &ev);
/* Framework is not replying with result for AT+VGM */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_vgs(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_volume ev;
unsigned int val;
HAL_EV_HANDSFREE_VOLUME, sizeof(ev), &ev);
/* Framework is not replying with result for AT+VGS */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_cops(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
switch (type) {
if (hfp_gw_result_has_next(result))
break;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_bia(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val, i, def;
bool tmp[IND_COUNT];
switch (type) {
case HFP_GW_CMD_TYPE_SET:
for (i = 0; i < IND_COUNT; i++)
- tmp[i] = device.inds[i].active;
+ tmp[i] = dev->inds[i].active;
i = 0;
do {
- def = (i < IND_COUNT) ? device.inds[i].active : 0;
+ def = (i < IND_COUNT) ? dev->inds[i].active : 0;
if (!hfp_gw_result_get_number_default(result, &val, def))
goto failed;
goto failed;
if (i < IND_COUNT) {
- tmp[i] = val || device.inds[i].always_active;
+ tmp[i] = val || dev->inds[i].always_active;
i++;
}
} while (hfp_gw_result_has_next(result));
for (i = 0; i < IND_COUNT; i++)
- device.inds[i].active = tmp[i];
+ dev->inds[i].active = tmp[i];
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_TEST:
case HFP_GW_CMD_TYPE_READ:
}
failed:
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_a(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
switch (type) {
HAL_EV_HANDSFREE_ANSWER, 0, NULL);
/* Framework is not replying with result for ATA */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_SET:
case HFP_GW_CMD_TYPE_READ:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_d(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
char buf[IPC_MTU];
struct hal_ev_handsfree_dial *ev = (void *) buf;
int cnt;
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_ccwa(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
if (hfp_gw_result_has_next(result))
break;
- device.ccwa_enabled = val;
+ dev->ccwa_enabled = val;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_chup(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
switch (type) {
HAL_EV_HANDSFREE_HANGUP, 0, NULL);
/* Framework is not replying with result for AT+CHUP */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_clcc(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
switch (type) {
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_cmee(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
if (hfp_gw_result_has_next(result))
break;
- device.cmee_enabled = val;
+ dev->cmee_enabled = val;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_clip(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
if (hfp_gw_result_has_next(result))
break;
- device.clip_enabled = val;
+ dev->clip_enabled = val;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_vts(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_dtmf ev;
char str[2];
HAL_EV_HANDSFREE_DTMF, sizeof(ev), &ev);
/* Framework is not replying with result for AT+VTS */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_cnum(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
switch (type) {
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_binp(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
/* TODO */
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_bldn(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_dial ev;
DBG("");
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_bvra(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_vr_state ev;
unsigned int val;
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_nrec(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_nrec ev;
unsigned int val;
HAL_EV_HANDSFREE_NREC, sizeof(ev), &ev);
/* Framework is not replying with result for AT+NREC */
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_bsir(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
/* TODO */
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_btrh(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
/* TODO */
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static gboolean sco_watch_cb(GIOChannel *chan, GIOCondition cond,
static void at_cmd_bcc(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
+
DBG("");
switch (type) {
case HFP_GW_CMD_TYPE_COMMAND:
- if (!(device.features & HFP_HF_FEAT_CODEC))
+ if (!(dev->features & HFP_HF_FEAT_CODEC))
break;
if (hfp_gw_result_has_next(result))
break;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
/* we haven't negotiated codec, start selection */
- if (!device.negotiated_codec) {
+ if (!dev->negotiated_codec) {
select_codec(0);
return;
}
* we try connect to negotiated codec. If it fails, and it isn't
* CVSD codec, try connect CVSD
*/
- if (!connect_sco() && device.negotiated_codec != CODEC_ID_CVSD)
+ if (!connect_sco() && dev->negotiated_codec != CODEC_ID_CVSD)
select_codec(CODEC_ID_CVSD);
return;
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_bcs(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
break;
/* Remote replied with other codec. Reply with error */
- if (device.proposed_codec != val) {
- device.proposed_codec = 0;
+ if (dev->proposed_codec != val) {
+ dev->proposed_codec = 0;
break;
}
- device.proposed_codec = 0;
- device.negotiated_codec = val;
+ dev->proposed_codec = 0;
+ dev->negotiated_codec = val;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
/* Connect sco with negotiated parameters */
connect_sco();
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_ckpd(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_HSP_KEY_PRESS, 0, NULL);
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void register_post_slc_at(void)
{
if (device.hsp) {
- hfp_gw_register(device.gw, at_cmd_ckpd, "+CKPD", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_vgs, "+VGS", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_vgm, "+VGM", NULL, NULL);
+ hfp_gw_register(device.gw, at_cmd_ckpd, "+CKPD", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_vgs, "+VGS", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_vgm, "+VGM", &device, NULL);
return;
}
- hfp_gw_register(device.gw, at_cmd_a, "A", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_d, "D", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_ccwa, "+CCWA", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_chup, "+CHUP", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_clcc, "+CLCC", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_cops, "+COPS", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_cmee, "+CMEE", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_clip, "+CLIP", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_vts, "+VTS", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_cnum, "+CNUM", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bia, "+BIA", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_binp, "+BINP", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bldn, "+BLDN", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bvra, "+BVRA", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_nrec, "+NREC", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_vgs, "+VGS", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_vgm, "+VGM", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bsir, "+BSIR", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_btrh, "+BTRH", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bcc, "+BCC", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bcs, "+BCS", NULL, NULL);
+ hfp_gw_register(device.gw, at_cmd_a, "A", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_d, "D", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_ccwa, "+CCWA", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_chup, "+CHUP", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_clcc, "+CLCC", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_cops, "+COPS", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_cmee, "+CMEE", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_clip, "+CLIP", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_vts, "+VTS", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_cnum, "+CNUM", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bia, "+BIA", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_binp, "+BINP", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bldn, "+BLDN", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bvra, "+BVRA", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_nrec, "+NREC", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_vgs, "+VGS", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_vgm, "+VGM", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bsir, "+BSIR", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_btrh, "+BTRH", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bcc, "+BCC", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bcs, "+BCS", &device, NULL);
}
static void at_cmd_cmer(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
switch (type) {
if (hfp_gw_result_has_next(result))
break;
- device.indicators_enabled = val;
+ dev->indicators_enabled = val;
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
- if (device.features & HFP_HF_FEAT_3WAY)
+ if (dev->features & HFP_HF_FEAT_3WAY)
return;
register_post_slc_at();
- set_state(&device, HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED);
+ set_state(dev, HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED);
return;
case HFP_GW_CMD_TYPE_TEST:
case HFP_GW_CMD_TYPE_READ:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_cind(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
char *buf, *ptr;
int len;
unsigned int i;
* If device supports Codec Negotiation, AT+BAC should be
* received first
*/
- if ((device.features & HFP_HF_FEAT_CODEC) &&
- !device.codecs[CVSD_OFFSET].remote_supported)
+ if ((dev->features & HFP_HF_FEAT_CODEC) &&
+ !dev->codecs[CVSD_OFFSET].remote_supported)
break;
len = strlen("+CIND:") + 1;
for (i = 0; i < IND_COUNT; i++) {
len += strlen("(\"\",(X,X)),");
- len += strlen(device.inds[i].name);
+ len += strlen(dev->inds[i].name);
}
buf = g_malloc(len);
for (i = 0; i < IND_COUNT; i++) {
ptr += sprintf(ptr, "(\"%s\",(%d%c%d)),",
- device.inds[i].name,
- device.inds[i].min,
- device.inds[i].max == 1 ? ',' : '-',
- device.inds[i].max);
+ dev->inds[i].name,
+ dev->inds[i].min,
+ dev->inds[i].max == 1 ? ',' : '-',
+ dev->inds[i].max);
}
ptr--;
*ptr = '\0';
- hfp_gw_send_info(device.gw, "%s", buf);
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_info(dev->gw, "%s", buf);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
g_free(buf);
return;
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_brsf(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int feat;
switch (type) {
break;
/* TODO verify features */
- device.features = feat;
+ dev->features = feat;
- hfp_gw_send_info(device.gw, "+BRSF: %u", hfp_ag_features);
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_info(dev->gw, "+BRSF: %u", hfp_ag_features);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void at_cmd_chld(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
struct hal_ev_handsfree_chld ev;
unsigned int val;
HAL_EV_HANDSFREE_CHLD, sizeof(ev), &ev);
return;
case HFP_GW_CMD_TYPE_TEST:
- hfp_gw_send_info(device.gw, "+CHLD: (%s)", HFP_AG_CHLD);
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_info(dev->gw, "+CHLD: (%s)", HFP_AG_CHLD);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
register_post_slc_at();
- set_state(&device, HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED);
+ set_state(dev, HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_COMMAND:
break;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static struct hfp_codec *find_codec_by_type(uint8_t type)
static void at_cmd_bac(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
void *user_data)
{
+ struct hf_device *dev = user_data;
unsigned int val;
DBG("");
switch (type) {
case HFP_GW_CMD_TYPE_SET:
- if (!(device.features & HFP_HF_FEAT_CODEC))
+ if (!(dev->features & HFP_HF_FEAT_CODEC))
goto failed;
/* set codecs to defaults */
- init_codecs(&device);
- device.negotiated_codec = 0;
+ init_codecs(dev);
+ dev->negotiated_codec = 0;
/*
* At least CVSD mandatory codec must exist
val != CODEC_ID_CVSD)
goto failed;
- device.codecs[CVSD_OFFSET].remote_supported = true;
+ dev->codecs[CVSD_OFFSET].remote_supported = true;
if (hfp_gw_result_get_number(result, &val)) {
if (val != CODEC_ID_MSBC)
goto failed;
- device.codecs[MSBC_OFFSET].remote_supported = true;
+ dev->codecs[MSBC_OFFSET].remote_supported = true;
}
while (hfp_gw_result_has_next(result)) {
codec->remote_supported = true;
}
- hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
- if (device.proposed_codec)
+ if (dev->proposed_codec)
select_codec(0);
return;
case HFP_GW_CMD_TYPE_TEST:
}
failed:
- hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+ hfp_gw_send_result(dev->gw, HFP_RESULT_ERROR);
}
static void register_slc_at(void)
{
- hfp_gw_register(device.gw, at_cmd_brsf, "+BRSF", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_cind, "+CIND", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_cmer, "+CMER", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_chld, "+CHLD", NULL, NULL);
- hfp_gw_register(device.gw, at_cmd_bac, "+BAC", NULL, NULL);
+ hfp_gw_register(device.gw, at_cmd_brsf, "+BRSF", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_cind, "+CIND", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_cmer, "+CMER", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_chld, "+CHLD", &device, NULL);
+ hfp_gw_register(device.gw, at_cmd_bac, "+BAC", &device, NULL);
}
static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)