psgrade.c
JIG_Task:
void JIG_Task(void)
{
static int bytes_out = 0, bytes_in = 0;
... ... //prepare the response
HMACInit(jig_key,20);//place HMAInit here and delete it from main
jig_challenge_res[1]--;
jig_challenge_res[3]++;
... ...
Endpoint_Write_Stream_LE(&jig_challenge_res[bytes_in], 8, NO_STREAM_CALLBACK);
//Fix the bug
}
main:
int main(void)
{
SetupHardware();
//HMACInit(jig_key,20); //move to JIG_Task otherwise cause problem on some boards.
LED(~GREEN);
state = init;
switch_port(5);//modify switch_port(0) to 5, with the same reason.
...... }
key.h
//Add the key
const uint8_t jig_key[20] = {
0x04, 0x4E, 0x61, 0x1B, 0xA6, 0xA6, 0xE3, 0x9A,
0x98, 0xCF, 0x35, 0x81, 0x2C, 0x80, 0x68, 0xC7,
0xFC, 0x5F, 0x7A, 0xE8,
};