コード例 #1
0
bool CGenericBluetoothStack::CancelInquiry()
{
    if (!SendHCICommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, 0, NULL)) {
        return false;
    }
    return WaitHCICommandComplete();
}
コード例 #2
0
bool CGenericBluetoothStack::Authenticate(int handle)
{
    if (!SendHCICommand(OGF_LINK_CONTROL, OCF_AUTH_REQUEST, sizeof(handle),
            &handle)) {
        return false;
    }
    return WaitHCICommandStatus();
}
コード例 #3
0
bool CGenericBluetoothStack::Encrypt(int handle, bool enable)
{
    struct {
        unsigned short handle;
        unsigned char enable;
    } __PPACKED__ request;
    request.handle = handle;
    request.enable = enable ? 1 : 0;
    if (!SendHCICommand(OGF_LINK_CONTROL, OCF_ENCRYPT_REQUEST, sizeof(request),
            &request)) {
        return false;
    }
    return WaitHCICommandStatus();
}
コード例 #4
0
bool CGenericBluetoothStack::StartInquiry(int accessCode)
{
    struct {
        unsigned char lap[3];
        unsigned char length;
        unsigned char num;
    } __PPACKED__ request;
    request.lap[0] = accessCode;
    request.lap[1] = accessCode >> 8;
    request.lap[2] = accessCode >> 16;
    request.length = 0x10;
    request.num = 0;
    if (!SendHCICommand(OGF_LINK_CONTROL, OCF_INQUIRY, sizeof(request),
            &request)) {
        return false;
    }
    return WaitHCICommandStatus();
}
コード例 #5
0
bool CGenericBluetoothStack::AskFriendlyName(bt_bdaddr_t addr)
{
    struct {
        unsigned char addr[6];
        unsigned char scanRepMode;
        unsigned char reserved;
        unsigned short clock;
    } __PPACKED__ request;
    
    memcpy(request.addr, addr, BT_ADDRESS_SIZE);
    request.scanRepMode = 1;
    request.reserved = 0;
    request.clock = 0;
    if (!SendHCICommand(OGF_LINK_CONTROL, OCF_NAME_REQUEST, sizeof(request),
            &request)) {
        return false;
    }
    return WaitHCICommandStatus();
}
コード例 #6
0
A_STATUS SendHCICommandWaitCommandComplete(AR3K_CONFIG_INFO *pConfig,
                                           A_UINT8          *pHCICommand,
                                           int              CmdLength,
                                           A_UINT8          **ppEventBuffer,
                                           A_UINT8          **ppBufferToFree)
{
    A_STATUS    status = A_OK;
    A_UINT8     *pBuffer = NULL;
    A_UINT8     *pTemp;
    int         length;
    A_BOOL      commandComplete = FALSE;
    A_UINT8     opCodeBytes[2];

    do {

        length = max(HCI_MAX_EVT_RECV_LENGTH,CmdLength);
        length += pConfig->pHCIProps->HeadRoom + pConfig->pHCIProps->TailRoom;
        length += pConfig->pHCIProps->IOBlockPad;

        pBuffer = (A_UINT8 *)A_MALLOC(length);
        if (NULL == pBuffer) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Failed to allocate bt buffer \n"));
            status = A_NO_MEMORY;
            break;
        }

            /* get the opcodes to check the command complete event */
        opCodeBytes[0] = pHCICommand[HCI_CMD_OPCODE_BYTE_LOW_OFFSET];
        opCodeBytes[1] = pHCICommand[HCI_CMD_OPCODE_BYTE_HI_OFFSET];

            /* copy HCI command */
        A_MEMCPY(pBuffer + pConfig->pHCIProps->HeadRoom,pHCICommand,CmdLength);
            /* send command */
        status = SendHCICommand(pConfig,
                                pBuffer + pConfig->pHCIProps->HeadRoom,
                                CmdLength);
        if (A_FAILED(status)) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Failed to send HCI Command (%d) \n", status));
            AR_DEBUG_PRINTBUF(pHCICommand,CmdLength,"HCI Bridge Failed HCI Command");
            break;
        }

            /* reuse buffer to capture command complete event */
        A_MEMZERO(pBuffer,length);
        status = RecvHCIEvent(pConfig,pBuffer,&length);
        if (A_FAILED(status)) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: HCI event recv failed \n"));
            AR_DEBUG_PRINTBUF(pHCICommand,CmdLength,"HCI Bridge Failed HCI Command");
            break;
        }

        pTemp = pBuffer + pConfig->pHCIProps->HeadRoom;
        if (pTemp[0] == HCI_CMD_COMPLETE_EVENT_CODE) {
            if ((pTemp[HCI_EVENT_OPCODE_BYTE_LOW] == opCodeBytes[0]) &&
                (pTemp[HCI_EVENT_OPCODE_BYTE_HI] == opCodeBytes[1])) {
                commandComplete = TRUE;
            }
        }

        if (!commandComplete) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR3K Config: Unexpected HCI event : %d \n",pTemp[0]));
            AR_DEBUG_PRINTBUF(pTemp,pTemp[1],"Unexpected HCI event");
            status = A_ECOMM;
            break;
        }

        if (ppEventBuffer != NULL) {
                /* caller wants to look at the event */
            *ppEventBuffer = pTemp;
            if (ppBufferToFree == NULL) {
                status = A_EINVAL;
                break;
            }
                /* caller must free the buffer */
            *ppBufferToFree = pBuffer;
            pBuffer = NULL;
        }

    } while (FALSE);

    if (pBuffer != NULL) {
        A_FREE(pBuffer);
    }

    return status;
}