Enhance a bit, and adapt to crc-including send functions

This commit is contained in:
Stefan `Sec` Zehl 2011-07-17 00:52:02 +02:00
parent 2ee9846d1c
commit 4af33c9074
1 changed files with 84 additions and 9 deletions

View File

@ -12,11 +12,22 @@
#include "funk/rftransfer.h"
/**************************************************************************/
#define BEACON_CHANNEL 81
#define BEACON_MAC "\x1\x2\x3\x2\1"
void f_init(void){
nrf_init();
int dx=0;
int dy=8;
dx=DoString(0,dy,"Done."); ;dy+=8;
struct NRF_CFG config = {
.channel= BEACON_CHANNEL,
.txmac= BEACON_MAC,
.nrmacs=1,
.mac0= BEACON_MAC,
.maclen ="\x10",
};
nrf_config_set(&config);
lcdPrintln("Done.");
};
void f_status(void){
@ -67,10 +78,66 @@ void f_recv(void){
};
void f_cfg(void){
struct NRF_CFG config;
nrfconfig cfg=&config;
nrf_config_get(cfg);
lcdPrint("ch:");lcdPrintInt( cfg->channel ); lcdNl();
lcdPrint("nr:");lcdPrintInt( cfg->nrmacs ); lcdNl();
lcdPrint("0:");
lcdPrintCharHex(cfg->mac0[0]);
lcdPrintCharHex(cfg->mac0[1]);
lcdPrintCharHex(cfg->mac0[2]);
lcdPrintCharHex(cfg->mac0[3]);
lcdPrintCharHex(cfg->mac0[4]);
lcdNl();
lcdPrint("1:");
lcdPrintCharHex(cfg->mac1[0]);
lcdPrintCharHex(cfg->mac1[1]);
lcdPrintCharHex(cfg->mac1[2]);
lcdPrintCharHex(cfg->mac1[3]);
lcdPrintCharHex(cfg->mac1[4]);
lcdNl();
lcdPrint("2345:");
lcdPrintCharHex(cfg->mac2345[0]);
lcdPrintCharHex(cfg->mac2345[1]);
lcdPrintCharHex(cfg->mac2345[2]);
lcdPrintCharHex(cfg->mac2345[3]);
lcdNl();
lcdPrint("tx:");
lcdPrintCharHex(cfg->txmac[0]);
lcdPrintCharHex(cfg->txmac[1]);
lcdPrintCharHex(cfg->txmac[2]);
lcdPrintCharHex(cfg->txmac[3]);
lcdPrintCharHex(cfg->txmac[4]);
lcdNl();
lcdPrint("len:");
lcdPrintCharHex(cfg->maclen[0]);
lcdPrintCharHex(cfg->maclen[1]);
lcdPrintCharHex(cfg->maclen[2]);
lcdPrintCharHex(cfg->maclen[3]);
lcdPrintCharHex(cfg->maclen[4]);
lcdNl();
};
void f_cfg_set(void){
struct NRF_CFG config = {
.channel= 13,
.txmac= "R0KET",
.nrmacs=1,
.mac0= "R0KET",
.maclen ="\x10",
};
nrf_config_set(&config);
};
void f_send(void){
static char ctr=1;
int dx=0;
int dy=8;
uint8_t buf[32];
int status;
@ -79,10 +146,14 @@ void f_send(void){
buf[2]=0xff; // Flags (0xff)
buf[3]=0xff; // Send intensity
/*
buf[4]=0x00; // ctr
buf[5]=0x00; // ctr
buf[6]=0x00; // ctr
buf[7]=ctr++; // ctr
*/
*(int*)(buf+4)=ctr++;
buf[8]=0x0; // Object id
buf[9]=0x0;
@ -92,10 +163,11 @@ void f_send(void){
buf[12]=0xff; // salt (0xffff always?)
buf[13]=0xff;
status=nrf_snd_pkt_crc(14,buf);
dx=DoString(0,dy,"St:"); DoIntX(dx,dy,status); dy+=8;
status=nrf_snd_pkt_crc(16,buf);
lcdPrint("Status:");
lcdPrintCharHex(status);
lcdNl();
};
void gotoISP(void) {
@ -135,6 +207,8 @@ const struct MENU_DEF menu_init = {"F Init", &f_init};
const struct MENU_DEF menu_status = {"F Status", &f_status};
const struct MENU_DEF menu_rcv = {"F Recv", &f_recv};
const struct MENU_DEF menu_snd = {"F Send", &f_send};
const struct MENU_DEF menu_cfg = {"F Cfg", &f_cfg};
const struct MENU_DEF menu_cfg2 = {"F CfgSet", &f_cfg_set};
const struct MENU_DEF menu_sndblock={"F Send block", &f_sendBlock};
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
@ -145,7 +219,8 @@ static menuentry menu[] = {
&menu_status,
&menu_rcv,
&menu_snd,
&menu_sndblock,
&menu_cfg,
&menu_cfg2,
&menu_nop,
&menu_mirror,
&menu_volt,