diff --git a/firmware/funk/mesh.c b/firmware/funk/mesh.c index f64b22b..d79973b 100644 --- a/firmware/funk/mesh.c +++ b/firmware/funk/mesh.c @@ -7,6 +7,7 @@ #include "basic/byteorder.h" #include "basic/random.h" #include "basic/config.h" +#include "lcd/print.h" char meshgen=0; // Generation char meshincctr=0; @@ -28,6 +29,23 @@ void initMesh(void){ meshbuffer[0].flags=MF_USED; }; +int mesh_sanity(uint8_t * pkt){ + if(MO_TYPE(pkt)>='A' && MO_TYPE(pkt)<='Z'){ + if(MO_TIME(pkt)>1313803870) + return 1; + if(MO_TIME(pkt)<1312075898) + return 1; + }else if(MO_TYPE(pkt)>='a' && MO_TYPE(pkt)<='z'){ + if(MO_TIME(pkt)>16777216) + return 1; + if(MO_TIME(pkt)<0) + return 1; + }; + if(MO_TYPE(pkt)>0x7f || MO_TYPE(pkt)<0x20) + return 1; + return 0; +}; + MPKT * meshGetMessage(uint8_t type){ int free=-1; for(int i=0;iSECS_DAY) meshbuffer[i].flags=MF_FREE; }; + if(mesh_sanity(meshbuffer[i].pkt)){ + meshbuffer[i].flags=MF_FREE; +#if 1 + setSystemFont(); + lcdClear(); + lcdPrintln("MESH PANIC!"); + lcdPrint(IntToStr(i,2,0)); + lcdPrintln(":"); + lcdPrint(IntToStrX(meshbuffer[i].pkt[0],2)); + lcdPrint(" "); + lcdPrintln(IntToStrX(meshbuffer[i].pkt[1],2)); + lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[i].pkt+2),8)); + lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[i].pkt+6),8)); + lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[i].pkt+10),8)); + lcdRefresh(); + while ((getInputRaw())==BTN_NONE); +#endif + }; }; }; }; @@ -153,6 +189,11 @@ uint8_t mesh_recvqloop_work(void){ return 0; }; + if(mesh_sanity(buf)){ + meshincctr++; + return 0; + }; + if(MO_GEN(buf)>meshgen){ if(meshgen) meshgen++; diff --git a/firmware/funk/mesh.h b/firmware/funk/mesh.h index ceceb9d..318dd2a 100644 --- a/firmware/funk/mesh.h +++ b/firmware/funk/mesh.h @@ -8,7 +8,7 @@ #define M_RECVINT 1000 #define M_RECVTIM 100 -#define MESH_CHANNEL 85 +#define MESH_CHANNEL 83 #define MESH_MAC "MESHB" #define MO_TYPE(x) (x[0]) diff --git a/tools/image/template.png b/tools/image/template.png new file mode 100644 index 0000000..e9c1ea5 Binary files /dev/null and b/tools/image/template.png differ