solo1/main.c

64 wiersze
1.1 KiB
C
Czysty Zwykły widok Historia

2018-04-28 17:40:28 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "cbor.h"
#include "usbhid.h"
2018-04-29 01:40:13 +00:00
#include "ctaphid.h"
2018-04-28 17:40:28 +00:00
#include "util.h"
2018-05-18 15:40:17 +00:00
#include "log.h"
2018-05-17 02:44:31 +00:00
#include "ctap.h"
2018-04-28 17:40:28 +00:00
2018-05-03 02:52:41 +00:00
static void check_ret(CborError ret)
2018-04-28 17:40:28 +00:00
{
if (ret != CborNoError)
{
printf("CborError: %d\n", ret);
exit(1);
}
}
2018-05-01 03:27:26 +00:00
2018-04-28 17:40:28 +00:00
int main(int argc, char * argv[])
{
2018-05-18 15:40:17 +00:00
set_logging_mask(
TAG_MC |
TAG_GA |
TAG_CP |
TAG_CTAP |
TAG_PARSE |
TAG_DUMP|
2018-05-24 03:30:08 +00:00
TAG_GREEN|
TAG_RED|
2018-05-18 15:40:17 +00:00
TAG_ERR
);
2018-04-28 17:40:28 +00:00
printf("init usbhid\n");
usbhid_init();
2018-04-29 01:40:13 +00:00
printf("init ctaphid\n");
ctaphid_init();
2018-05-17 02:44:31 +00:00
printf("init ctap\n");
ctap_init();
2018-04-28 17:40:28 +00:00
2018-05-01 03:27:26 +00:00
int count = 0;
2018-04-28 17:40:28 +00:00
uint8_t hidmsg[64];
memset(hidmsg,0,sizeof(hidmsg));
printf("recv'ing hid msg \n");
while(1)
{
usbhid_recv(hidmsg);
2018-05-01 03:27:26 +00:00
printf("%d>> ",count++); dump_hex(hidmsg,sizeof(hidmsg));
2018-05-03 02:52:41 +00:00
ctaphid_handle_packet(hidmsg);
2018-05-01 03:27:26 +00:00
memset(hidmsg, 0, sizeof(hidmsg));
2018-04-28 17:40:28 +00:00
}
usbhid_close();
printf("done\n");
return 0;
}