vcard: first working things

This commit is contained in:
schneider 2011-07-16 20:17:46 +02:00
parent 64ee2abbd7
commit c75b52238c
2 changed files with 16 additions and 6 deletions

View File

@ -58,6 +58,7 @@ int receiveKey(uint8_t type, uint8_t *x, uint8_t *y)
uint8_t n; uint8_t n;
n = nrf_rcv_pkt_time(1000, 30, buf); n = nrf_rcv_pkt_time(1000, 30, buf);
lcdPrint("pkt:"); lcdPrintInt(n);lcdPrintln(""); lcdRefresh();
if( n == 30 && buf[0] == type && buf[1] == 'X' ){ if( n == 30 && buf[0] == type && buf[1] == 'X' ){
for(int i=0; i<NUMWORDS*4; i++) for(int i=0; i<NUMWORDS*4; i++)
x[i] = buf[i+2]; x[i] = buf[i+2];
@ -155,6 +156,8 @@ int receiveKeys(uint8_t *px, uint8_t *py, uint8_t *mac)
} }
if( receivePublicKey(px,py) ) if( receivePublicKey(px,py) )
continue; continue;
lcdPrintln("Got PUBKEY");
lcdRefresh();
if( receiveMac(mac) ) if( receiveMac(mac) )
continue; continue;
lcdPrintln("Done"); lcdPrintln("Done");
@ -189,6 +192,7 @@ void receiveFile(void)
while( !done ){ while( !done ){
lcdClear(); lcdClear();
lcdSetCrsr(0,0);
lcdPrintln("Receiving file"); lcdPrintln("Receiving file");
lcdPrintln("Down=Abort"); lcdPrintln("Down=Abort");
lcdRefresh(); lcdRefresh();
@ -199,10 +203,11 @@ void receiveFile(void)
} }
if( receiveR(rx,ry) ) if( receiveR(rx,ry) )
continue; continue;
lcdPrintln("Got R");
lcdRefresh();
ECIES_decryptkeygen(rx, ry, k1, k2, Priv); ECIES_decryptkeygen(rx, ry, k1, k2, Priv);
delayms(2000); //if( filetransfer_receive(mac,k1) )
if( filetransfer_receive(mac,k1) ) // continue;
continue;
lcdPrintln("Done"); lcdPrintln("Done");
lcdPrintln("Right=OK"); lcdPrintln("Right=OK");
lcdPrintln("Left=Retry"); lcdPrintln("Left=Retry");
@ -242,7 +247,10 @@ void sendFile(char *filename)
lcdClear(); lcdClear();
lcdPrintln("Sending file");lcdRefresh(); lcdPrintln("Sending file");lcdRefresh();
sendR(rx,ry); sendR(rx,ry);
filetransfer_send((uint8_t*)filename, 0, mac, (uint32_t*)k1); lcdPrintln("Sent R");
lcdRefresh();
delayms(3000);
//filetransfer_send((uint8_t*)filename, 0, mac, (uint32_t*)k1);
lcdPrintln("Done"); lcdPrintln("Done");
lcdPrintln("Right=OK"); lcdPrintln("Right=OK");
lcdPrintln("Left=Retry"); lcdPrintln("Left=Retry");
@ -265,9 +273,11 @@ void main_vcard(void) {
char key; char key;
nrf_init(); nrf_init();
f_mount(0, &FatFs[0]); f_mount(0, &FatFs[0]);
nrf_set_rx_mac(0, 32, 5, mac);
while (1) { while (1) {
key= getInput(); key= getInput();
delayms(20);
// Easy flashing // Easy flashing
if(key==BTN_LEFT){ if(key==BTN_LEFT){

View File

@ -67,7 +67,7 @@ int filetransfer_receive(uint8_t *mac, uint32_t const k[4])
nrf_set_rx_mac(0, 32, 5, mac); nrf_set_rx_mac(0, 32, 5, mac);
nrf_rcv_pkt_time_xxtea(1000, 30, metadata, k); nrf_rcv_pkt_time_xxtea(1000, 30, metadata, k);
nrf_set_rx_mac(0, 32, 5, macbuf); //nrf_set_rx_mac(0, 32, 5, macbuf);
metadata[19] = 0; //enforce termination metadata[19] = 0; //enforce termination
size = (metadata[20] << 8) | metadata[21]; size = (metadata[20] << 8) | metadata[21];
@ -83,7 +83,7 @@ int filetransfer_receive(uint8_t *mac, uint32_t const k[4])
nrf_set_rx_mac(0, 32, 5, mac); nrf_set_rx_mac(0, 32, 5, mac);
rftransfer_receive(buf, wordcount*4, 1000); rftransfer_receive(buf, wordcount*4, 1000);
nrf_set_rx_mac(0, 32, 5, macbuf); //nrf_set_rx_mac(0, 32, 5, macbuf);
xxtea_decode_words((uint32_t *)buf, wordcount, k); xxtea_decode_words((uint32_t *)buf, wordcount, k);