Use new utility functions and receive interface

This commit is contained in:
Stefan `Sec` Zehl 2011-07-16 20:26:00 +02:00
parent afd01eada1
commit fc610dbd1e
1 changed files with 12 additions and 21 deletions

View File

@ -3,6 +3,7 @@
#include "basic/basic.h" #include "basic/basic.h"
#include "lcd/lcd.h" #include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h" #include "funk/nrf24l01p.h"
@ -46,31 +47,23 @@ void f_status(void){
}; };
void f_recv(void){ void f_recv(void){
int dx=0; __attribute__ ((aligned (4))) uint8_t buf[32];
int dy=8;
uint8_t buf[32];
int len; int len;
len=nrf_rcv_pkt_time(500,sizeof(buf),buf); len=nrf_rcv_pkt_time(1000,sizeof(buf),buf);
if(len==0){ if(len==0){
dx=DoString(0,dy,"No pkt"); dy+=8; lcdPrintln("No pkt (Timeout)");
return;
}else if (len ==-1){
dx=DoString(0,dy,"Pkt too lg"); dy+=8;
return;
}else if (len ==-2){
dx=DoString(0,dy,"No pkt error?"); dy+=8;
return;
}; };
dx=DoString(0,dy,"Size:"); DoInt(dx,dy,len); dy+=8; lcdPrint("Size:");lcdPrintInt(len);lcdNl();
dx=DoString(0,dy,"1:"); DoIntX(dx,dy,*(int*)(buf+0));dy+=8; lcdPrint("1:");lcdPrintIntHex( *(int*)(buf+ 0) ); lcdNl();
dx=DoString(0,dy,"2:"); DoIntX(dx,dy,*(int*)(buf+4));dy+=8; lcdPrint("2:");lcdPrintIntHex( *(int*)(buf+ 4) ); lcdNl();
dx=DoString(0,dy,"3:"); DoIntX(dx,dy,*(int*)(buf+8));dy+=8; lcdPrint("3:");lcdPrintIntHex( *(int*)(buf+ 8) ); lcdNl();
dx=DoString(0,dy,"4:"); DoIntX(dx,dy,*(int*)(buf+12));dy+=8; lcdPrint("4:");lcdPrintShortHex( *(int*)(buf+12) ); lcdNl();
len=crc16(buf,14); len=crc16(buf,14);
dx=DoString(0,dy,"c:"); DoIntX(dx,dy,len);dy+=8; lcdPrint("crc:");lcdPrintShortHex(len); lcdNl();
}; };
@ -80,7 +73,6 @@ void f_send(void){
int dy=8; int dy=8;
uint8_t buf[32]; uint8_t buf[32];
int status; int status;
uint16_t crc;
buf[0]=0x10; // Length: 16 bytes buf[0]=0x10; // Length: 16 bytes
buf[1]=0x17; // Proto - fixed at 0x17? buf[1]=0x17; // Proto - fixed at 0x17?
@ -133,10 +125,9 @@ void f_sendBlock(void)
{ {
uint8_t data[] = "hallo welt, das hier ist ein langer string, der" uint8_t data[] = "hallo welt, das hier ist ein langer string, der"
"per funk verschickt werden soll."; "per funk verschickt werden soll.";
rftransfer_send(strlen(data), data); rftransfer_send(strlen((char *)data), data);
} }
/**************************************************************************/ /**************************************************************************/
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP}; const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};