コード例 #1
0
static int
ble_hs_startup_reset_tx(void *arg)
{
    int rc;

    assert(ble_hs_startup_state == BLE_HS_STARTUP_STATE_RESET);

    ble_hci_sched_set_ack_cb(ble_hs_startup_gen_ack, NULL);
    rc = host_hci_cmd_reset();
    if (rc != 0) {
        return rc;
    }

    return 0;
}
コード例 #2
0
static int
ble_hs_startup_le_read_buf_sz_tx(void *arg)
{
    int rc;

    assert(ble_hs_startup_state == BLE_HS_STARTUP_STATE_LE_READ_BUF_SZ);

    ble_hci_sched_set_ack_cb(ble_hs_startup_le_read_buf_size_ack, NULL);
    rc = host_hci_cmd_le_read_buffer_size();
    if (rc != 0) {
        return rc;
    }

    return 0;
}
コード例 #3
0
static int
ble_hs_startup_set_evmask_tx(void *arg)
{
    int rc;

    assert(ble_hs_startup_state == BLE_HS_STARTUP_STATE_SET_EVMASK);

    ble_hci_sched_set_ack_cb(ble_hs_startup_gen_ack, NULL);
    rc = host_hci_cmd_set_event_mask(0x20001fffffffffff);
    if (rc != 0) {
        return rc;
    }

    return 0;
}
コード例 #4
0
static int
ble_hs_startup_le_read_sup_f_tx(void *arg)
{
    int rc;

    assert(ble_hs_startup_state == BLE_HS_STARTUP_STATE_LE_READ_SUP_F);

    ble_hci_sched_set_ack_cb(ble_hs_startup_le_read_sup_f_ack, NULL);
    rc = host_hci_cmd_le_read_loc_supp_feat();
    if (rc != 0) {
        return rc;
    }

    return 0;
}
コード例 #5
0
int
host_hci_cmd_send(uint8_t ogf, uint8_t ocf, uint8_t len, void *cmddata)
{
    int rc;
    uint8_t *cmd;
    uint16_t opcode;

    /* Don't allow multiple commands "in flight." */
    assert(host_hci_outstanding_opcode == 0);

    rc = -1;
    cmd = os_memblock_get(&g_hci_cmd_pool);
    if (cmd) {
        opcode = (ogf << 10) | ocf;
        htole16(cmd, opcode);
        cmd[2] = len;
        if (len) {
            memcpy(cmd + BLE_HCI_CMD_HDR_LEN, cmddata, len);
        }
        rc = host_hci_cmd_transport(cmd);
        BLE_HS_LOG(DEBUG, "host_hci_cmd_send: ogf=0x%02x ocf=0x%02x len=%d\n",
                   ogf, ocf, len);
        if (rc == 0) {
            host_hci_outstanding_opcode = opcode;
        }
    }

    /* Cancel ack callback if transmission failed. */
    if (rc != 0) {
        ble_hci_sched_set_ack_cb(NULL, NULL);
    } else {
        STATS_INC(ble_hs_stats, hci_cmd);
    }

    return rc;
}