solo1/fido2/main.c

86 wiersze
1.5 KiB
C
Czysty Zwykły widok Historia

2019-02-12 22:18:17 +00:00
// Copyright 2019 SoloKeys Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
2018-04-28 17:40:28 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
2018-04-28 17:40:28 +00:00
#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-12-01 19:42:49 +00:00
#include APP_CONFIG
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
int main(int argc, char *argv[])
2018-04-28 17:40:28 +00:00
{
2018-06-02 18:44:12 +00:00
uint8_t hidmsg[64];
uint32_t t1 = 0;
2018-06-02 18:44:12 +00:00
2018-05-18 15:40:17 +00:00
set_logging_mask(
/*0*/
//TAG_GEN|
2019-04-24 22:36:36 +00:00
// TAG_MC |
// TAG_GA |
2019-04-24 01:12:40 +00:00
TAG_WALLET |
TAG_STOR |
//TAG_NFC_APDU |
TAG_NFC |
//TAG_CP |
2019-04-24 22:36:36 +00:00
// TAG_CTAP|
//TAG_HID|
2019-04-24 01:12:40 +00:00
TAG_U2F|
//TAG_PARSE |
//TAG_TIME|
2019-04-24 22:36:36 +00:00
// TAG_DUMP|
TAG_GREEN|
TAG_RED|
2019-04-24 01:57:27 +00:00
TAG_EXT|
TAG_ERR
);
2018-05-18 15:40:17 +00:00
2019-04-24 01:12:40 +00:00
device_init(argc, argv);
2018-06-04 23:35:34 +00:00
memset(hidmsg,0,sizeof(hidmsg));
while(1)
{
2018-12-04 01:30:35 +00:00
if (millis() - t1 > HEARTBEAT_PERIOD)
2018-06-04 23:35:34 +00:00
{
heartbeat();
t1 = millis();
}
2018-10-26 01:25:49 +00:00
device_manage();
2018-06-04 23:35:34 +00:00
if (usbhid_recv(hidmsg) > 0)
{
ctaphid_handle_packet(hidmsg);
memset(hidmsg, 0, sizeof(hidmsg));
}
else
{
}
ctaphid_check_timeouts();
2019-01-08 02:20:07 +00:00
2018-06-04 23:35:34 +00:00
}
// Should never get here
usbhid_close();
printf1(TAG_GREEN, "done\n");
2018-06-04 23:35:34 +00:00
return 0;
}
#endif