solo1/main.c

82 wiersze
1.6 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"
2018-06-02 18:44:12 +00:00
#include "device.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-26 15:36:55 +00:00
#ifndef TEST
2018-06-02 18:44:12 +00:00
2018-04-28 17:40:28 +00:00
int main(int argc, char * argv[])
{
2018-06-02 19:48:29 +00:00
int count = 0;
2018-06-02 18:44:12 +00:00
uint64_t t1 = 0;
2018-06-03 04:50:46 +00:00
uint64_t t2 = 0;
uint64_t accum = 0;
2018-06-02 18:44:12 +00:00
uint8_t hidmsg[64];
2018-05-18 15:40:17 +00:00
set_logging_mask(
2018-06-02 22:30:59 +00:00
/*TAG_MC |*/
/*TAG_GA |*/
/*TAG_CP |*/
2018-06-03 04:50:46 +00:00
/*TAG_CTAP|*/
2018-06-02 22:30:59 +00:00
/*TAG_U2F|*/
/*TAG_PARSE |*/
2018-06-03 04:50:46 +00:00
/*TAG_TIME|*/
2018-06-02 22:30:59 +00:00
/*TAG_DUMP|*/
/*TAG_GREEN|*/
/*TAG_RED|*/
2018-06-03 04:50:46 +00:00
TAG_ERR
2018-05-18 15:40:17 +00:00
);
2018-06-02 18:44:12 +00:00
printf("init device\n");
device_init();
2018-04-29 01:40:13 +00:00
printf("init ctaphid\n");
ctaphid_init();
2018-06-02 18:44:12 +00:00
2018-05-17 02:44:31 +00:00
printf("init ctap\n");
ctap_init();
2018-04-28 17:40:28 +00:00
memset(hidmsg,0,sizeof(hidmsg));
printf("recv'ing hid msg \n");
while(1)
{
2018-06-02 18:44:12 +00:00
if (millis() - t1 > 100)
{
/*printf("heartbeat %ld\n", beat++);*/
heartbeat();
t1 = millis();
}
if (usbhid_recv(hidmsg) > 0)
{
2018-06-02 22:30:59 +00:00
printf1(TAG_DUMP,"%d>> ",count++); dump_hex1(TAG_DUMP, hidmsg,sizeof(hidmsg));
2018-06-03 04:50:46 +00:00
t2 = millis();
ctaphid_handle_packet(hidmsg);
2018-06-03 04:50:46 +00:00
accum += millis() - t2;
printf1(TAG_TIME,"accum: %lu\n", (uint32_t)accum);
memset(hidmsg, 0, sizeof(hidmsg));
}
2018-06-02 18:44:12 +00:00
else
{
2018-06-03 04:50:46 +00:00
/*main_loop_delay();*/
2018-06-02 18:44:12 +00:00
}
ctaphid_check_timeouts();
2018-04-28 17:40:28 +00:00
}
2018-06-02 18:44:12 +00:00
// Should never get here
2018-04-28 17:40:28 +00:00
usbhid_close();
printf("done\n");
return 0;
}
2018-06-02 18:44:12 +00:00
2018-05-26 15:36:55 +00:00
#endif