#include #include #include #include #include #include "basic/basic.h" #include "lcd/render.h" #include "lcd/allfonts.h" #include "basic/ecc.h" #include "funk/nrf24l01p.h" #include "filesystem/ff.h" #include "filesystem/diskio.h" #include "funk/filetransfer.h" #include "lcd/print.h" FATFS FatFs[_VOLUMES]; /* File system object for logical drive */ /**************************************************************************/ uint8_t mac[5] = {1,2,3,2,1}; void sendPublicKey(void) { uint8_t exp[2 + 4*NUMWORDS + 2]; char buf[42]; UINT readbytes; FIL file; if( f_open(&file, "pubx.key", FA_OPEN_EXISTING|FA_READ) ){ return; } if( f_read(&file, buf, 41, &readbytes) || readbytes != 41 ){ return; } f_close(&file); buf[41] = 0; exp[0] = 'P'; bitstr_parse_export((char*)exp+2, buf); exp[1] = 'X'; nrf_snd_pkt_crc(32, exp); delayms(10); if( f_open(&file, "puby.key", FA_OPEN_EXISTING|FA_READ) ){ return; } if( f_read(&file, buf, 41, &readbytes) || readbytes != 41 ){ return; } f_close(&file); buf[41] = 0; exp[1] = 'Y'; bitstr_parse_export((char*)exp+2, buf); nrf_snd_pkt_crc(32, exp); delayms(10); } void sendR(uint8_t *rx, uint8_t *ry) { uint8_t exp[2 + 4*NUMWORDS + 2]; exp[0] = 'R'; for(int i=0; i<4*NUMWORDS; i++) exp[2+i] = rx[i]; exp[1] = 'X'; nrf_snd_pkt_crc(32, exp); delayms(10); exp[1] = 'Y'; for(int i=0; i<4*NUMWORDS; i++) exp[2+i] = ry[i]; nrf_snd_pkt_crc(32, exp); delayms(10); } int receiveKey(uint8_t type, uint8_t *x, uint8_t *y) { uint8_t buf[32]; uint8_t n; n = nrf_rcv_pkt_time(1000, 32, buf); if( n == 32 && buf[0] == type && buf[1] == 'X' ){ for(int i=0; i