solo1/fido2/main.c

94 wiersze
1.8 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-07-06 03:20:33 +00:00
//#include "bsp.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-07-23 03:40:27 +00:00
#include "app.h"
2018-04-28 17:40:28 +00:00
2018-06-04 23:39:52 +00:00
#if !defined(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-07-06 03:20:33 +00:00
uint32_t t1 = 0;
uint32_t t2 = 0;
uint32_t accum = 0;
uint32_t dt = 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-04 23:35:34 +00:00
/*0*/
2018-07-14 19:55:57 +00:00
TAG_GEN|
2018-06-02 22:30:59 +00:00
/*TAG_MC |*/
/*TAG_GA |*/
2018-07-14 19:55:57 +00:00
TAG_WALLET |
2018-07-12 01:55:20 +00:00
TAG_STOR |
2018-06-02 22:30:59 +00:00
/*TAG_CP |*/
2018-09-05 02:11:21 +00:00
TAG_CTAP|
2018-07-06 03:20:33 +00:00
// TAG_HID|
2018-06-02 22:30:59 +00:00
/*TAG_U2F|*/
/*TAG_PARSE |*/
2018-07-07 21:11:13 +00:00
// TAG_TIME|
2018-07-14 00:29:14 +00:00
/*TAG_DUMP|*/
2018-06-02 22:30:59 +00:00
/*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
device_init();
printf1(TAG_GEN,"init device\n");
2018-06-02 18:44:12 +00:00
2018-06-04 23:35:34 +00:00
printf1(TAG_GEN,"init ctaphid\n");
2018-04-29 01:40:13 +00:00
ctaphid_init();
2018-06-02 18:44:12 +00:00
2018-06-04 23:35:34 +00:00
printf1(TAG_GEN,"init ctap\n");
ctap_init();
memset(hidmsg,0,sizeof(hidmsg));
printf1(TAG_GEN,"recv'ing hid msg \n");
while(1)
{
if (millis() - t1 > 100)
{
/*printf("heartbeat %ld\n", beat++);*/
heartbeat();
t1 = millis();
}
if (usbhid_recv(hidmsg) > 0)
{
printf1(TAG_DUMP,"%d>> ",count++); dump_hex1(TAG_DUMP, hidmsg,sizeof(hidmsg));
t2 = millis();
ctaphid_handle_packet(hidmsg);
accum += millis() - t2;
2018-07-06 03:20:33 +00:00
printf1(TAG_TIME,"accum: %d\n", (uint32_t)accum);
printf1(TAG_TIME,"dt: %d\n", t2 - dt);
dt = t2;
2018-06-04 23:35:34 +00:00
memset(hidmsg, 0, sizeof(hidmsg));
}
else
{
/*main_loop_delay();*/
}
ctaphid_check_timeouts();
}
// Should never get here
usbhid_close();
printf("done\n");
return 0;
}
#endif