static int update_le_address(const bdaddr_t *le_addr)
{
int hdev = 0;
+ struct hci_request req;
le_set_random_address_cp cp;
+ uint8_t status = 0;
+ int ret;
hdev = hci_open_dev(0);
if (hdev < 0) {
bacpy(&cp.bdaddr, le_addr);
- if (hci_send_cmd(hdev, OGF_LE_CTL, OCF_LE_SET_RANDOM_ADDRESS,
- LE_SET_RANDOM_ADDRESS_CP_SIZE, &cp) < 0) {
- error("hci_send_cmd is failed");
+ memset(&req, 0x00, sizeof(req));
+ req.ogf = OGF_LE_CTL;
+ req.ocf = OCF_LE_SET_RANDOM_ADDRESS;
+ req.cparam = &cp;
+ req.clen = LE_SET_RANDOM_ADDRESS_CP_SIZE;
+ req.rparam = &status;
+ req.rlen = sizeof(status);
+
+ ret = hci_send_req(hdev, &req, 5000);
+ if (ret < 0 || status) {
+ error("Cannot set random address [ret : %d] / errno : %d", ret, errno);
hci_close_dev(hdev);
return -1;
}