From 5574ca2cdc1e042b29f11783092a197d26ec29fd Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Sun, 17 Jul 2011 02:09:48 +0200 Subject: [PATCH 1/2] Create default r0ket.cfg if missing --- firmware/applications/default.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/firmware/applications/default.c b/firmware/applications/default.c index 7a54111..6aa970d 100644 --- a/firmware/applications/default.c +++ b/firmware/applications/default.c @@ -28,8 +28,35 @@ int lcdInitConfig(){ lcdPrint("open:"); lcdPrintln(f_get_rc_string(res)); if(res){ - lcdPrintln("r0ket.cfg missing!"); - return 1; + lcdPrintln("new r0ket.cfg..."); + + res=f_open(&file[0], "r0ket.cfg", FA_OPEN_ALWAYS|FA_WRITE); + lcdPrint("create:"); + lcdPrintln(f_get_rc_string(res)); + if(res){ + return 1; + }; + + buf[0]='0'; + buf[1]='0'; + res = f_write(&file[0], buf, 2, &readbytes); + lcdPrint("write:"); + lcdPrintln(f_get_rc_string(res)); + if(res){ + return 1; + }; + + lcdPrint("wrote:"); + lcdPrintInt(readbytes); + lcdPrintln("b"); + + res=f_close(&file[0]); + lcdPrint("close:"); + lcdPrintln(f_get_rc_string(res)); + if(res){ + return 1; + }; + return 2; // created. Still show screen }; for(int i=0;i Date: Sun, 17 Jul 2011 02:23:07 +0200 Subject: [PATCH 2/2] Start of counter-receive code. TBD. --- firmware/applications/remote.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/firmware/applications/remote.c b/firmware/applications/remote.c index 6dec093..d4bbdf0 100644 --- a/firmware/applications/remote.c +++ b/firmware/applications/remote.c @@ -67,12 +67,13 @@ void f_recv(void){ void f_send(void){ int ctr=1; __attribute__ ((aligned (4))) uint8_t buf[32]; + int len; int status; while(1){ buf[0]=0x10; // Length: 16 bytes - buf[1]='C'; // Proto - fixed at 0x17? + buf[1]='C'; // Proto buf[2]=getInputRaw(); buf[3]=0x00; // Unused @@ -101,7 +102,10 @@ void f_send(void){ if(buf[2]==BTN_ENTER) break; lcdDisplay(0); - delayms(10); + len=nrf_rcv_pkt_time_encr(10,sizeof(buf),buf,testkey); + if(len>0){ + lcdPrint("Got!"); + }; };