solo1/fido2/main.c

107 wiersze
2.3 KiB
C
Czysty Zwykły widok Historia

2018-09-13 21:58:34 +00:00
/*
2018-12-17 00:05:33 +00:00
* Copyright (C) 2018 SoloKeys, Inc. <https://solokeys.com/>
*
* This file is part of Solo.
*
* Solo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Solo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Solo. If not, see <https://www.gnu.org/licenses/>
*
* This code is available under licenses for commercial use.
* Please contact SoloKeys for more information.
*/
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-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
2018-04-28 17:40:28 +00:00
int main(int argc, char * argv[])
{
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(
2018-06-04 23:35:34 +00:00
/*0*/
2018-10-28 20:30:55 +00:00
// TAG_GEN|
// TAG_MC |
// TAG_GA |
// TAG_WALLET |
2018-07-12 01:55:20 +00:00
TAG_STOR |
2018-10-28 20:30:55 +00:00
// TAG_CP |
// TAG_CTAP|
2018-10-28 20:30:55 +00:00
// TAG_HID|
2018-06-02 22:30:59 +00:00
/*TAG_U2F|*/
2018-10-28 20:30:55 +00:00
// TAG_PARSE |
// TAG_TIME|
2018-10-28 20:30:55 +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
device_init();
printf1(TAG_GEN,"init device\n");
2018-06-02 18:44:12 +00:00
2018-12-03 01:30:28 +00:00
usbhid_init();
printf1(TAG_GEN,"init usb\n");
2018-04-29 01:40:13 +00:00
ctaphid_init();
2018-12-03 01:30:28 +00:00
printf1(TAG_GEN,"init ctaphid\n");
2018-06-02 18:44:12 +00:00
2018-06-04 23:35:34 +00:00
ctap_init();
2018-12-03 01:30:28 +00:00
printf1(TAG_GEN,"init ctap\n");
2018-06-04 23:35:34 +00:00
memset(hidmsg,0,sizeof(hidmsg));
printf1(TAG_GEN,"recv'ing hid msg \n");
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();
}
// Should never get here
usbhid_close();
printf1(TAG_GREEN, "done\n");
2018-06-04 23:35:34 +00:00
return 0;
}
#endif