crashtest-r0ket/firmware/applications/mesh/mesh.c

107 lines
1.9 KiB
C
Raw Normal View History

2011-07-29 17:40:24 +00:00
#include <sysinit.h>
#include <string.h>
#include <time.h>
#include "basic/basic.h"
#include "basic/byteorder.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h"
2011-07-30 14:10:30 +00:00
#include "funk/mesh.h"
2011-07-29 17:40:24 +00:00
2011-07-30 14:10:30 +00:00
#include <string.h>
2011-07-29 17:40:24 +00:00
/**************************************************************************/
void m_init(void){
nrf_init();
struct NRF_CFG config = {
.channel= MESH_CHANNEL,
.txmac= MESH_MAC,
.nrmacs=1,
.mac0= MESH_MAC,
.maclen ="\x20", // XXX: MESHPKTSIZE
};
nrf_config_set(&config);
2011-07-30 14:10:30 +00:00
initMesh();
2011-07-29 17:49:24 +00:00
};
void m_tset(void){
2011-07-29 17:40:24 +00:00
_timet=1311961112;
};
void m_time(void){
struct tm* tm;
2011-07-30 14:10:30 +00:00
char c[2]={0,0};
2011-07-29 17:40:24 +00:00
getInputWaitRelease();
delayms(100);
do{
lcdClear();
tm= mygmtime(getSeconds());
lcdPrintInt(tm->tm_hour);
lcdPrint(":");
lcdPrintInt(tm->tm_min);
lcdPrint(":");
lcdPrintInt(tm->tm_sec);
lcdNl();
lcdPrintInt(tm->tm_mday);
lcdPrint(".");
lcdPrintInt(tm->tm_mon+1);
lcdPrint(".");
lcdPrintInt(tm->tm_year+YEAR0);
lcdNl();
2011-07-30 14:10:30 +00:00
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();
2011-07-29 17:40:24 +00:00
lcdRefresh();
delayms_queue(50);
2011-07-29 17:40:24 +00:00
}while ((getInputRaw())==BTN_NONE);
};
2011-07-30 14:10:30 +00:00
inline void blink(char a, char b){
gpioSetValue (a,b, 1-gpioGetValue(a,b));
};
/***********************************************************************/
void m_cleanup(void){
mesh_cleanup();
};
void m_recv(void){
mesh_recvloop();
}
void m_send(void){
mesh_sendloop();
};
void tick_mesh(void){
mesh_systick();
};