Bluez5: backend-native: HSP AG release SCO link on AT+CKPD=200

Bluetooth PTS test HSP/AG/ACR/BV-01-I request AG to release the SCO link
upon reception of AT+CKPD=200 reception
This commit is contained in:
Frédéric Danis 2023-11-27 13:07:31 +01:00 committed by Wim Taymans
parent c2e4e336ac
commit 442a208382
3 changed files with 29 additions and 2 deletions

View file

@ -422,7 +422,7 @@ static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_vol
static bool rfcomm_hsp_ag(struct rfcomm *rfcomm, char* buf)
{
struct impl *backend = rfcomm->backend;
unsigned int gain, dummy;
unsigned int gain;
/* There are only three HSP AT commands:
* AT+VGS=value: value between 0 and 15, sent by the HS to AG to set the speaker gain.
@ -445,8 +445,9 @@ static bool rfcomm_hsp_ag(struct rfcomm *rfcomm, char* buf)
rfcomm_send_reply(rfcomm, "ERROR");
spa_log_debug(backend->log, "RFCOMM receive unsupported VGM gain: %s", buf);
}
} else if (sscanf(buf, "AT+CKPD=%d", &dummy) == 1) {
} else if (spa_strstartswith(buf, "AT+CKPD=200") == 1) {
rfcomm_send_reply(rfcomm, "OK");
spa_bt_device_emit_switch_profile(rfcomm->device);
} else {
return false;
}

View file

@ -1370,12 +1370,34 @@ static void device_connected(void *userdata, bool connected)
}
}
static void device_switch_profile(void *userdata)
{
struct impl *this = userdata;
uint32_t profile;
switch(this->profile) {
case DEVICE_PROFILE_OFF:
profile = DEVICE_PROFILE_HSP_HFP;
break;
case DEVICE_PROFILE_HSP_HFP:
profile = DEVICE_PROFILE_OFF;
break;
default:
return;
}
spa_log_debug(this->log, "%p: device switch profile %d -> %d", this, this->profile, profile);
set_profile(this, profile, 0, false);
}
static const struct spa_bt_device_events bt_dev_events = {
SPA_VERSION_BT_DEVICE_EVENTS,
.connected = device_connected,
.codec_switched = codec_switched,
.profiles_changed = profiles_changed,
.device_set_changed = device_set_changed,
.switch_profile = device_switch_profile,
};
static int impl_add_listener(void *object,

View file

@ -462,6 +462,9 @@ struct spa_bt_device_events {
/** Device set configuration changed */
void (*device_set_changed) (void *data);
/** Switch profile between OFF and HSP_HFP */
void (*switch_profile) (void *data);
/** Device freed */
void (*destroy) (void *data);
};
@ -554,6 +557,7 @@ void spa_bt_device_update_last_bluez_action_time(struct spa_bt_device *device);
#define spa_bt_device_emit_codec_switched(d,...) spa_bt_device_emit(d, codec_switched, 0, __VA_ARGS__)
#define spa_bt_device_emit_profiles_changed(d,...) spa_bt_device_emit(d, profiles_changed, 0, __VA_ARGS__)
#define spa_bt_device_emit_device_set_changed(d) spa_bt_device_emit(d, device_set_changed, 0)
#define spa_bt_device_emit_switch_profile(d) spa_bt_device_emit(d, switch_profile, 0)
#define spa_bt_device_emit_destroy(d) spa_bt_device_emit(d, destroy, 0)
#define spa_bt_device_add_listener(d,listener,events,data) \
spa_hook_list_append(&(d)->listener_list, listener, events, data)