static void bt_hid_interrupt_sdu(void *opaque, const uint8_t *data, int len)

{

    struct bt_hid_device_s *hid = opaque;



    if (len > BT_HID_MTU || len < 1)

        goto bad;

    if ((data[0] & 3) != BT_DATA_OUTPUT)

        goto bad;

    if ((data[0] >> 4) == BT_DATA) {

        if (hid->intr_state)

            goto bad;



        hid->data_type = BT_DATA_OUTPUT;

        hid->intrdataout.len = 0;

    } else if ((data[0] >> 4) == BT_DATC) {

        if (!hid->intr_state)

            goto bad;

    } else

        goto bad;



    memcpy(hid->intrdataout.buffer + hid->intrdataout.len, data + 1, len - 1);

    hid->intrdataout.len += len - 1;

    hid->intr_state = (len == BT_HID_MTU);

    if (!hid->intr_state) {

        memcpy(hid->dataout.buffer, hid->intrdataout.buffer,

                        hid->dataout.len = hid->intrdataout.len);

        bt_hid_out(hid);

    }



    return;

bad:

    fprintf(stderr, "%s: bad transaction on Interrupt channel.\n",

                    __func__);

}

static void bt_hid_interrupt_sdu(void *opaque, const uint8_t *data, int len)

{

    struct bt_hid_device_s *hid = opaque;



    if (len > BT_HID_MTU || len < 1)

        goto bad;

    if ((data[0] & 3) != BT_DATA_OUTPUT)

        goto bad;

    if ((data[0] >> 4) == BT_DATA) {

        if (hid->intr_state)

            goto bad;



        hid->data_type = BT_DATA_OUTPUT;

        hid->intrdataout.len = 0;

    } else if ((data[0] >> 4) == BT_DATC) {

        if (!hid->intr_state)

            goto bad;

    } else

        goto bad;



    memcpy(hid->intrdataout.buffer + hid->intrdataout.len, data + 1, len - 1);

    hid->intrdataout.len += len - 1;

    hid->intr_state = (len == BT_HID_MTU);

    if (!hid->intr_state) {

        memcpy(hid->dataout.buffer, hid->intrdataout.buffer,

                        hid->dataout.len = hid->intrdataout.len);

        bt_hid_out(hid);

    }



    return;

bad:

    fprintf(stderr, "%s: bad transaction on Interrupt channel.\n",

                    __func__);

}

static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    struct bt_hid_device_s *VAR_3 = VAR_0;



    if (VAR_2 > BT_HID_MTU || VAR_2 < 1)

        goto bad;

    if ((VAR_1[0] & 3) != BT_DATA_OUTPUT)

        goto bad;

    if ((VAR_1[0] >> 4) == BT_DATA) {

        if (VAR_3->intr_state)

            goto bad;



        VAR_3->data_type = BT_DATA_OUTPUT;

        VAR_3->intrdataout.VAR_2 = 0;

    } else if ((VAR_1[0] >> 4) == BT_DATC) {

        if (!VAR_3->intr_state)

            goto bad;

    } else

        goto bad;



    memcpy(VAR_3->intrdataout.buffer + VAR_3->intrdataout.VAR_2, VAR_1 + 1, VAR_2 - 1);

    VAR_3->intrdataout.VAR_2 += VAR_2 - 1;

    VAR_3->intr_state = (VAR_2 == BT_HID_MTU);

    if (!VAR_3->intr_state) {

        memcpy(VAR_3->dataout.buffer, VAR_3->intrdataout.buffer,

                        VAR_3->dataout.VAR_2 = VAR_3->intrdataout.VAR_2);

        bt_hid_out(VAR_3);

    }



    return;

bad:

    fprintf(stderr, "%s: bad transaction on Interrupt channel.\n",

                    __func__);

}

static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ struct bt_hid_device_s *VAR_3 = VAR_0; if (VAR_2 > BT_HID_MTU || VAR_2 < 1)
goto bad; if ((VAR_1[0] & 3) != BT_DATA_OUTPUT)
goto bad; if ((VAR_1[0] >> 4) == BT_DATA) { if (VAR_3->intr_state)
goto bad; VAR_3->data_type = BT_DATA_OUTPUT; VAR_3->intrdataout.VAR_2 = 0; } else if ((VAR_1[0] >> 4) == BT_DATC) { if (!VAR_3->intr_state)
goto bad; } else goto bad; memcpy(VAR_3->intrdataout.buffer + VAR_3->intrdataout.VAR_2, VAR_1 + 1, VAR_2 - 1); VAR_3->intrdataout.VAR_2 += VAR_2 - 1; VAR_3->intr_state = (VAR_2 == BT_HID_MTU); if (!VAR_3->intr_state) { memcpy(VAR_3->dataout.buffer, VAR_3->intrdataout.buffer,
VAR_3->dataout.VAR_2 = VAR_3->intrdataout.VAR_2); bt_hid_out(VAR_3); } return; bad:
fprintf(stderr, "%s: bad transaction on Interrupt channel.\n",
__func__); }