Merge branch 'master' of github.com:r0ket/r0ket

This commit is contained in:
iggy 2011-08-03 22:02:01 +02:00
commit 3f3d1a9d23
10 changed files with 33 additions and 209 deletions

View File

@ -73,6 +73,8 @@ clean:
for dir in $(SUBDIRS); do \
$(MAKE) $(CONFIG_MAKE_PRINTDIRECTORY) -C $$dir clean; \
done
$(MAKE) $(CONFIG_MAKE_PRINTDIRECTORY) -C l0dable clean
flash: all
../tools/bootloader/autoflash

View File

@ -7,7 +7,7 @@
TARGET = LPC13xx
FLASH = 32K
SRAM = 8K
RAMCODE=2048
RAMCODE=2548
# For USB HID support the LPC134x reserves 384 bytes from the sram,
# if you don't want to use the USB features, just use 0 here.

View File

@ -4,6 +4,8 @@ Ck<hex>: set encryptionkey
Ct<hex>: set txmac
Cc<hex>: set channel
Ct<hex>: set rxmac(0)
Cl<hex>: set rxlens
Ce<hex>: sec encrpytion on/off
s <hex>: send packet
s+ <hex>: send packet 10 times

View File

@ -22,59 +22,6 @@ void init_mesh(void){
initMesh();
};
void m_tset(void){
_timet=1311961112;
};
//# MENU debug MeshInfo
void m_time(void){
struct tm* tm;
char c[2]={0,0};
getInputWaitRelease();
delayms(100);
do{
lcdClear();
tm= mygmtime(getSeconds());
lcdPrint(IntToStr(tm->tm_hour,2,F_LONG));
lcdPrint(":");
lcdPrint(IntToStr(tm->tm_min,2,F_LONG|F_ZEROS));
lcdPrint(":");
lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS));
lcdNl();
lcdPrint(IntToStr(tm->tm_mday,2,F_LONG));
lcdPrint(".");
lcdPrint(IntToStr(tm->tm_mon+1,2,0));
lcdPrint(".");
lcdPrint(IntToStr(tm->tm_year+YEAR0,4,F_LONG|F_ZEROS));
lcdNl();
lcdNl();
lcdPrint("<");
for(int i=0;i<MESHBUFSIZE;i++){
if(!meshbuffer[i].flags&MF_USED){
c[0]='_';
}else{
c[0]=meshbuffer[i].pkt[0];
};
lcdPrint(c);
};
lcdPrintln(">");
lcdPrint("Gen:");
lcdPrintInt(meshgen);
lcdNl();
lcdRefresh();
delayms_queue(50);
}while ((getInputRaw())==BTN_NONE);
};
inline void blink(char a, char b){
gpioSetValue (a,b, 1-gpioGetValue(a,b));
};
int choose(char * texts, int8_t menuselection){
uint8_t numentries = 0;
uint8_t visible_lines = 0;

View File

@ -13,147 +13,6 @@
/**************************************************************************/
//# MENU debug ChkLight
void ChkLight(void) {
int dx=0;
int dy=8;
dx=DoString(0,dy,"Light:");
DoString(0,dy+16,"Night:");
while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetLight());
DoInt(dx,dy+16,isNight());
DoInt(dx,dy+8,GLOBAL(daytrig));
lcdDisplay();
delayms_queue(100);
};
dx=DoString(0,dy+24,"Done.");
}
//# MENU debug ChkBattery
void ChkBattery(void) {
do{
lcdClear();
lcdPrintln("Voltage:");
lcdPrintln(IntToStr(GetVoltage(),5,0));
lcdNl();
lcdPrintln("Chrg_stat:");
if(gpioGetValue(RB_PWR_CHRG)){
lcdPrintln("1");
}else{
lcdPrintln("0");
};
lcdRefresh();
delayms_queue(100);
} while ((getInputRaw())==BTN_NONE);
}
//# MENU debug Uptime
void uptime(void) {
int t;
int h;
char flag;
while ((getInputRaw())==BTN_NONE){
lcdClear();
lcdPrintln("Uptime:");
t=getTimer()/(1000/SYSTICKSPEED);
h=t/60/60;
flag=F_ZEROS;
if(h>0){
lcdPrint(IntToStr(h,2,flag));
lcdPrint("h");
flag|=F_LONG;
};
h=t/60%60;
if(h>0){
lcdPrint(IntToStr(h,2,flag));
lcdPrint("m");
flag|=F_LONG;
};
h=t%60;
if(h>0){
lcdPrint(IntToStr(h,2,flag));
lcdPrint("s");
};
lcdNl();
lcdNl();
lcdPrintln("Ticks:");
lcdPrint(IntToStr(_timectr,10,0));
lcdRefresh();
delayms_queue(200);
};
lcdPrintln("done.");
}
//# MENU debug Uuid
void uuid(void) {
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
lcdClear();
lcdPrintln("UUID:");
lcdPrintIntHex(iap_return.Result[0]); lcdNl();
lcdPrintIntHex(iap_return.Result[1]); lcdNl();
lcdPrintIntHex(iap_return.Result[2]); lcdNl();
lcdPrintIntHex(iap_return.Result[3]); lcdNl();
lcdNl();
lcdPrintln("Beacon ID:");
lcdPrintln(IntToStrX(GetUUID32(),4));
lcdRefresh();
}
//# MENU debug Qstatus
void Qstatus(void) {
int dx=0;
int dy=8;
lcdClear();
dx=DoString(0,dy+16,"Qdepth:");
while ((getInputRaw())!=BTN_ENTER){
DoInt(dx,dy+16,(the_queue.qend-the_queue.qstart+MAXQENTRIES)%MAXQENTRIES);
lcdDisplay();
if(getInputRaw()!=BTN_NONE)
work_queue();
else
delayms(10);
};
dy+=16;
dx=DoString(0,dy,"Done.");
};
void blink_led0(void){
gpioSetValue (RB_LED0, 1-gpioGetValue(RB_LED0));
};
void tick_alive(void){
static int foo=0;
if(GLOBAL(alivechk)==0)
return;
if(foo++>500/SYSTICKSPEED){
foo=0;
if(GLOBAL(alivechk)==2)
push_queue(blink_led0);
else
blink_led0();
};
return;
};
//# MENU debug ShowSP
void getsp(void) {
int dx=0;
int dy=8;
int x;
lcdClear();
dx=DoString(0,dy,"SP:");
while ((getInputRaw())==BTN_NONE){
__asm( "mov %0, sp\n" : "=r" (x) :);
DoIntX(0,dy+8,x);
lcdDisplay();
delayms_queue(50);
};
dy+=16;
dx=DoString(0,dy,"Done.");
};
//# MENU msc
void msc_menu(void){

View File

@ -29,10 +29,9 @@ uint32_t const beaconkey[4] = {
uint32_t remotekey[4] = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
};
uint32_t meshkey[4] = {
0x0, 0x0, 0x0, 0x0
};
extern uint32_t const meshkey[4];
char funkencrypt=0;
#if CFG_USBMSC
#error "MSC is defined"
@ -151,6 +150,7 @@ int process(char * input){
config.nrmacs=1;
nrf_config_set(&config);
memcpy(thekey,meshkey,sizeof(thekey));
funkencrypt=1;
}else if(input[1]=='r'){
config.channel=REMOTE_CHANNEL;
memcpy(config.txmac,REMOTE_MAC,5);
@ -159,6 +159,7 @@ int process(char * input){
config.nrmacs=1;
nrf_config_set(&config);
memcpy(thekey,remotekey,sizeof(thekey));
funkencrypt=1;
}else if(input[1]=='b'){
config.channel=BEACON_CHANNEL;
memcpy(config.txmac,BEACON_MAC,5);
@ -167,6 +168,7 @@ int process(char * input){
config.nrmacs=1;
nrf_config_set(&config);
memcpy(thekey,beaconkey,sizeof(thekey));
funkencrypt=1;
}else if(input[1]=='?'){
nrf_config_get(&config);
puts_plus("Ch: ");puts_plus(IntToStrX( config.channel,2 )); puts_plus("\r\n");
@ -202,6 +204,10 @@ int process(char * input){
puts_plus(" ");
};
puts_plus("\r\n");
puts_plus("encrypt : ");
puts_plus(IntToStrX( funkencrypt,2 ));
puts_plus("\r\n");
};
}else if(input[0]=='C'){
int len;
@ -228,6 +234,15 @@ int process(char * input){
}else if(input[1]=='c'){
config.channel=*hex;
nrf_config_set(&config);
}else if(input[1]=='l'){
config.maclen[0]=uint8ptouint32(hex);
config.maclen[1]=uint8ptouint32(hex+4);
config.maclen[2]=uint8ptouint32(hex+8);
config.maclen[3]=uint8ptouint32(hex+12);
config.maclen[4]=uint8ptouint32(hex+16);
nrf_config_set(&config);
}else if(input[1]=='e'){
funkencrypt= uint8ptouint32(hex);
};
}else if (input[0]=='s'){
__attribute__ ((aligned (4))) uint8_t buf[32];
@ -251,7 +266,7 @@ int process(char * input){
len+=2; // Add crc!
memcpy(buf,hex,len);
status=nrf_snd_pkt_crc_encr(len,buf,thekey);
status=nrf_snd_pkt_crc_encr(len,buf,funkencrypt?thekey:NULL);
puts_plus("P ");
puts_plus("[");puts_plus(IntToStrX(len,2));puts_plus("] ");
@ -266,7 +281,7 @@ int process(char * input){
while(--ctr>0){
delayms(23);
memcpy(buf,hex,len);
status=nrf_snd_pkt_crc_encr(len,buf,thekey);
status=nrf_snd_pkt_crc_encr(len,buf,funkencrypt?thekey:NULL);
};
}else if (input[1]=='t'){
static int ctr=1;
@ -283,7 +298,7 @@ int process(char * input){
buf[12]=0xff; // salt (0xffff always?)
buf[13]=0xff;
status=nrf_snd_pkt_crc_encr(16,buf,thekey);
status=nrf_snd_pkt_crc_encr(16,buf,funkencrypt?thekey:NULL);
}else{
};
puts_plus("S state=");
@ -310,7 +325,7 @@ int process(char * input){
puts_plus("D receive ...\r\n");
nrf_rcv_pkt_start();
do{
len=nrf_rcv_pkt_poll_dec(sizeof(buf),buf,thekey);
len=nrf_rcv_pkt_poll_dec(sizeof(buf),buf,funkencrypt?thekey:NULL);
// Receive
if(len==0||len==-1||len==-2){ //No pkt, Pkt2large, NoPktError
delayms(10);

View File

@ -30,7 +30,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
dst=(void (*)(void)) (sram_top);
lcdPrint("T:"); lcdPrintIntHex(dst); lcdNl();
*/
dst=(void (*)(void)) 0x10001800;
dst=(void (*)(void)) 0x1000160C;
res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);

View File

@ -12,7 +12,7 @@ char meshincctr=0; // Generation
MPKT meshbuffer[MESHBUFSIZE];
uint32_t const meshkey[4] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000
0x00000042, 0x000005ec, 0x00000023, 0x00000005
};
struct NRF_CFG oldconfig;

View File

@ -153,14 +153,13 @@ int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]){
return len;
cmpcrc=crc16(pkt,len-2);
if(cmpcrc != (pkt[len-2] <<8 | pkt[len-1])) {
if(key!=NULL)
xxtea_decode_words((uint32_t*)pkt,len/4,key);
cmpcrc=crc16(pkt,len-2);
if(cmpcrc != (pkt[len-2] <<8 | pkt[len-1])) {
return -3; // CRC failed
};
};
return len;
};