From 9f963642b337d7884c6bb711e41081b4c1bd421e Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Sat, 6 Aug 2011 16:52:29 +0200 Subject: [PATCH] rudimentary filter stuff --- firmware/SERIAL_DOKU | 5 ++- firmware/applications/serial/serial.c | 63 +++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/firmware/SERIAL_DOKU b/firmware/SERIAL_DOKU index d49daca..99bb071 100644 --- a/firmware/SERIAL_DOKU +++ b/firmware/SERIAL_DOKU @@ -4,7 +4,8 @@ pm: preset funk for mesh pM: preset funk for pubMesh pr: preset funk for rem0te -t: set packet dump type (b/m/0) +t: set packet dump type (b/B/m/M/0) +f: set filter stuff ck: set encryptionkey cm: set rxmac(0) @@ -19,4 +20,4 @@ sd : send packet with debugoutput r: recv packets r+: recv packets for seconds -r-: recv packets (5 seconds max) +r-: recv packets diff --git a/firmware/applications/serial/serial.c b/firmware/applications/serial/serial.c index 14490f9..30ffae2 100644 --- a/firmware/applications/serial/serial.c +++ b/firmware/applications/serial/serial.c @@ -48,6 +48,9 @@ struct NRF_CFG config = { }; char type=0; +char filter=0; +uint8_t filterdata[10]; +char outc[2]= {0,0}; static int process(char * input); @@ -314,6 +317,26 @@ static int process(char * input){ ; }; puts_plus("\r\n"); + }else if (input[0]=='f'){ + int len; + filter=input[1]; + uint8_t *hex=hextobyte(input+2,&len); + if(len>9) + len=9; + memcpy(filterdata,hex,len); + puts_plus("F "); + if(filter){ + puts_plus("["); + outc[0]=filter; + puts_plus(outc); + puts_plus("]"); + for(int i=0;i0) t=getTimer()+t*1000/SYSTICKSPEED; nrf_rcv_pkt_start(); @@ -346,12 +375,16 @@ static int process(char * input){ delayms(10); continue; }; - puts_plus("R "); - if(len==-3){ - puts_plus("[!crc] "); - len=32; + if (!filter){ + if(len==-3){ + puts_plus("[!crc] "); + len=32; + }; }; - if(type=='m'){ + if(type=='m' || type=='M'){ + if(filter && filter!=buf[0]) + continue; + puts_plus("R "); puts_plus(IntToStrX( buf[0],2 )); puts_plus(" "); puts_plus(IntToStrX( buf[1],2 )); @@ -373,7 +406,19 @@ static int process(char * input){ puts_plus(IntToStrX( buf[30],2 )); puts_plus(IntToStrX( buf[31],2 )); puts_plus(" "); + }else if(type=='B'){ + if(filter) + if(uint8ptouint32(buf+8)!=uint8ptouint32(filterdata)) + continue; + puts_plus("RF "); + puts_plus(IntToStrX( buf[2],2 )); + puts_plus(" "); + puts_plus(IntToStrX( uint8ptouint32(buf+8),8 )); }else if(type=='b'){ + if(filter) + if(uint8ptouint32(buf+8)!=uint8ptouint32(filterdata)) + continue; + puts_plus("R "); puts_plus(IntToStrX( buf[0],2 )); puts_plus(" "); puts_plus(IntToStrX( buf[1],2 )); @@ -391,15 +436,15 @@ static int process(char * input){ puts_plus(" "); puts_plus(IntToStrX( buf[14],2 )); puts_plus(IntToStrX( buf[15],2 )); - puts_plus(" "); }else{ + puts_plus("R "); puts_plus("[");puts_plus(IntToStrX(len,2));puts_plus("] "); for(int i=0;i0){ @@ -410,7 +455,7 @@ static int process(char * input){ puts("\r\n"); if(--pctr==0) break; - }while(t>((t==-1)?getTimer():0)); + }while((t>0)?(t>getTimer()):1); nrf_rcv_pkt_end(); }else{