android: Add support for handling remove bond command

Bond state change is send when command complete for unpair device is
received and status was success.
This commit is contained in:
Szymon Janc 2013-10-31 11:23:33 +01:00 committed by Johan Hedberg
parent 08e6aadd83
commit 42876422b2

View File

@ -751,6 +751,34 @@ static bool cancel_bond(void *buf, uint16_t len)
NULL) > 0;
}
static void unpair_device_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
const struct mgmt_rp_unpair_device *rp = param;
DBG("status %u", status);
if (status != MGMT_STATUS_SUCCESS)
return;
send_bond_state_change(&rp->addr.bdaddr, HAL_STATUS_SUCCESS,
HAL_BOND_STATE_NONE);
}
static bool remove_bond(void *buf, uint16_t len)
{
struct hal_cmd_remove_bond *cmd = buf;
struct mgmt_cp_unpair_device cp;
cp.disconnect = 1;
cp.addr.type = BDADDR_BREDR;
android2bdaddr(cmd->bdaddr, &cp.addr.bdaddr);
return mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE,
adapter->index, sizeof(cp), &cp,
unpair_device_complete, NULL, NULL) > 0;
}
static uint8_t pin_reply(void *buf, uint16_t len)
{
struct hal_cmd_pin_reply *cmd = buf;
@ -928,6 +956,11 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
if (!cancel_bond(buf, len))
goto error;
break;
case HAL_OP_REMOVE_BOND:
if (!remove_bond(buf, len))
goto error;
break;
case HAL_OP_PIN_REPLY:
status = pin_reply(buf, len);