fix hid write back buffering

This commit is contained in:
Conor Patrick
2018-05-07 00:00:06 -04:00
parent 7722fb0c56
commit 71a0f1b55c
5 changed files with 117 additions and 95 deletions

View File

@@ -12,46 +12,12 @@
#include "usbhid.h"
void ctap_write_block(uint8_t * data)
void ctaphid_write_block(uint8_t * data)
{
printf("<< "); dump_hex(data, 64);
usbhid_send(data);
}
void ctap_write(void * _data, int len)
{
static uint8_t buf[HID_MESSAGE_SIZE];
static int offset = 0;
uint8_t * data = (uint8_t *) _data;
if (len == 0)
{
if (offset > 0)
{
memset(buf + offset, 0, HID_MESSAGE_SIZE - offset);
ctap_write_block(buf);
}
offset = 0;
return;
}
else if (len == -1)
{
memset(buf, 0, HID_MESSAGE_SIZE);
offset = 0;
}
int i;
for (i = 0; i < len; i++)
{
buf[offset++] = data[i];
if (offset == HID_MESSAGE_SIZE)
{
ctap_write_block(buf);
offset = 0;
}
}
}
int ctap_user_presence_test()
{