i believe this is how resync should work
This commit is contained in:
parent
fdd767cf9f
commit
87429fb8a6
@ -80,7 +80,6 @@ class Tester():
|
|||||||
raise RuntimeError('Cbor is supposed to have payload')
|
raise RuntimeError('Cbor is supposed to have payload')
|
||||||
except CtapError as e:
|
except CtapError as e:
|
||||||
assert(e.code == CtapError.ERR.INVALID_LENGTH)
|
assert(e.code == CtapError.ERR.INVALID_LENGTH)
|
||||||
pass
|
|
||||||
print('PASS: no data cbor')
|
print('PASS: no data cbor')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -88,9 +87,15 @@ class Tester():
|
|||||||
raise RuntimeError('MSG is supposed to have payload')
|
raise RuntimeError('MSG is supposed to have payload')
|
||||||
except CtapError as e:
|
except CtapError as e:
|
||||||
assert(e.code == CtapError.ERR.INVALID_LENGTH)
|
assert(e.code == CtapError.ERR.INVALID_LENGTH)
|
||||||
pass
|
|
||||||
print('PASS: no data msg')
|
print('PASS: no data msg')
|
||||||
|
|
||||||
|
try:
|
||||||
|
r = self.send_data(CTAPHID.INIT, '')
|
||||||
|
except CtapError as e:
|
||||||
|
print('resync fail: ', e)
|
||||||
|
return
|
||||||
|
print('PASS: resync')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
15
ctaphid.c
15
ctaphid.c
@ -94,7 +94,7 @@ static int is_broadcast(CTAPHID_PACKET * pkt)
|
|||||||
|
|
||||||
static int is_init_pkt(CTAPHID_PACKET * pkt)
|
static int is_init_pkt(CTAPHID_PACKET * pkt)
|
||||||
{
|
{
|
||||||
return (pkt->pkt.init.cmd == CTAPHID_INIT) && ctaphid_packet_len(pkt) == 8;
|
return (pkt->pkt.init.cmd == CTAPHID_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_cont_pkt(CTAPHID_PACKET * pkt)
|
static int is_cont_pkt(CTAPHID_PACKET * pkt)
|
||||||
@ -294,10 +294,19 @@ start_over:
|
|||||||
if (is_init_pkt(pkt))
|
if (is_init_pkt(pkt))
|
||||||
{
|
{
|
||||||
printf("received abort request from %08x\n", pkt->cid);
|
printf("received abort request from %08x\n", pkt->cid);
|
||||||
|
ctaphid_write_buffer_init(&wb);
|
||||||
|
|
||||||
|
wb.cid = active_cid;
|
||||||
|
active_cid_timestamp = millis();
|
||||||
|
|
||||||
set_next_cid(active_cid); // reuse last CID in current channel
|
|
||||||
ctaphid_init();
|
ctaphid_init();
|
||||||
buffer_packet(pkt);
|
|
||||||
|
active_cid = wb.cid;
|
||||||
|
wb.cmd = CTAPHID_INIT;
|
||||||
|
wb.bcnt = 0;
|
||||||
|
ctaphid_write(&wb, ctap_buffer, buffer_len());
|
||||||
|
ctaphid_write(&wb, NULL, 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!is_cont_pkt(pkt) && buffer_status() == BUFFERING)
|
else if (!is_cont_pkt(pkt) && buffer_status() == BUFFERING)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user