case BLE_HCI_OP()

in nimble/controller/src/ble_ll_hci.c [1672:1816]


    case BLE_HCI_OP(BLE_HCI_OGF_LINK_CTRL, 0x01): /* Inquiry */
        ble_ll_hci_cmd_fake_dual_mode_inquiry(cmdbuf[3]);
        rc = BLE_ERR_MAX + 1;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_LINK_CTRL, 0x02): /* Inquiry Cancel */
        ble_ll_hci_cmd_fake_dual_mode_inquiry(0);
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x05): /* Set Event Filter */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x13): /* Write Local Name */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x16): /* Write Connection Accept Timeout */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x18): /* Write Page Timeout */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1a): /* Write Scan Enable */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1c): /* Write Page Scan Activity */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x1e): /* Write Inquiry Scan Activity */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x20): /* Write Authentication Enable */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x24): /* Write Class Of Device */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x33): /* Host Buffer Size */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x45): /* Write Inquiry Mode */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x52): /* Write Extended Inquiry Response */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x56): /* Write Simple Pairing Mode */
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x6d): /* Write LE Host Support */
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x14): /* Read Local Name */
        memset(rspbuf, 0, 248);
        strcpy((char *)rspbuf, "NimBLE");
        *rsplen = 248;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x23): /* Read Class Of Device */
        put_le24(rspbuf, 0);
        *rsplen = 3;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x25): /* Read Voice Settings */
        put_le16(rspbuf, 0);
        *rsplen = 2;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x38): /* Read Number Of Supported IAC */
        rspbuf[0] = 1;
        *rsplen = 1;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x39): /* Read Current IAC LAP */
        rspbuf[0] = 1;
        put_le24(&rspbuf[1], 0x9e8b33);
        *rsplen = 4;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, 0x58): /* Read Inquiry Response Transmit Power Level */
        rspbuf[0] = 0x04;
        *rsplen = 1;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT):
        put_le64(rspbuf, 0x877bffdbfe0ffebf);
        *rsplen = 8;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_INFO_PARAMS, 0x04): /* Read Local Extended Features */
        rspbuf[0] = 0;
        rspbuf[1] = 0;
        put_le64(&rspbuf[2], 0x877bffdbfe0ffebf);
        *rsplen = 10;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_BUF_SIZE):
        put_le16(rspbuf, 255);
        rspbuf[2] = 0;
        put_le16(rspbuf + 3, 4);
        put_le16(rspbuf + 5, 0);
        *rsplen = 7;
        rc = 0;
        break;
    case BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUPP_STATES):
        put_le64(rspbuf, 0x000003ffffffffff);
        *rsplen = 8;
        rc = 0;
        break;
    default:
        rc = -1;
    }

    return rc;
}
#endif


void
ble_ll_hci_post_cmd_cb_set(ble_ll_hci_post_cmd_complete_cb cb, void *user_data)
{
    BLE_LL_ASSERT(hci_cmd_post_cb == NULL);
    hci_cmd_post_cb = cb;
    hci_cmd_post_cb_user_data = user_data;
}

/**
 * Called to process an HCI command from the host.
 *
 * @param ev Pointer to os event containing a pointer to command buffer
 */
static void
ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
{
    int rc;
    uint8_t ogf;
    uint8_t rsplen;
    struct ble_hci_cmd *cmd;
    uint16_t opcode;
    uint16_t ocf;
    struct ble_hci_ev *hci_ev;
    struct ble_hci_ev_command_status *cmd_status;
    struct ble_hci_ev_command_complete *cmd_complete;
    uint8_t *rspbuf;

    BLE_LL_DEBUG_GPIO(HCI_CMD, 1);

    /* The command buffer is the event argument */
    cmd = ble_npl_event_get_arg(ev);
    BLE_LL_ASSERT(cmd != NULL);

    /* Get the opcode from the command buffer */
    opcode = le16toh(cmd->opcode);
    ocf = BLE_HCI_OCF(opcode);
    ogf = BLE_HCI_OGF(opcode);

    /*
     * The command response pointer points into the same buffer as the
     * command data itself. That is fine, as each command reads all the data
     * before crafting a response.
     * Also reuse cmd buffer for complete event
     */
    hci_ev = (struct ble_hci_ev *) cmd;
    rspbuf = hci_ev->data + sizeof(*cmd_complete);

    /* Assume response length is zero */
    rsplen = 0;

#if MYNEWT_VAL(BLE_LL_DTM)
    /* if DTM test is enabled disallow any command other than LE Test End or
     * HCI Reset
     */
    if (ble_ll_dtm_enabled()) {