#include #include "basic/basic.h" #include "basic/byteorder.h" #include "lcd/lcd.h" #include "lcd/print.h" #include "funk/nrf24l01p.h" #include "usbcdc/usb.h" #include "usbcdc/usbcore.h" #include "usbcdc/usbhw.h" #include "usbcdc/cdcuser.h" #include "usbcdc/cdc_buf.h" #include "usbcdc/util.h" #include #define REMOTE_CHANNEL 91 #define REMOTE_MAC "REM0T" #define MESH_CHANNEL 85 #define MESH_MAC "MESHB" #define BEACON_CHANNEL 81 #define BEACON_MAC "\x1\x2\x3\x2\1" uint32_t const beaconkey[4] = { 0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E }; uint32_t remotekey[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; uint32_t meshkey[4] = { 0x0, 0x0, 0x0, 0x0 }; #if CFG_USBMSC #error "MSC is defined" #endif #if !CFG_USBCDC #error "CDC is not defined" #endif /**************************************************************************/ uint32_t thekey[4] = { 0x0, 0x0, 0x0, 0x0 }; struct NRF_CFG config = { .channel= BEACON_CHANNEL, .txmac= BEACON_MAC, .nrmacs=1, .mac0= BEACON_MAC, .maclen ="\x10", }; int process(char * input); #define INPUTLEN 99 void dwim(void){ char input[INPUTLEN+1]; int inputptr=0; usbCDCInit(); delayms(500); getInputWaitRelease(); puts("D start\r\n"); while(!getInputRaw()){ delayms(10); // Input int l=INPUTLEN-inputptr; CDC_OutBufAvailChar (&l); if(l>0){ CDC_RdOutBuf (input+inputptr, &l); input[inputptr+l]=0; puts(&input[inputptr]); for(int i=0;i'9')?input[p]-'a'+10:input[p]-'0')*16+ ((input[p+1]>'9')?input[p+1]-'a'+10:input[p+1]-'0'); // puts(IntToStrX( c,2 )); // puts("."); buf[bp]=c; bp++;p+=2; }; // puts("\r\n"); if(bp<10) bp=10; bp+=2; puts("S Len:"); puts(IntToStrX( bp,2 )); puts("\r\n"); status=nrf_snd_pkt_crc_encr(bp,buf,thekey); puts("P "); puts("[");puts(IntToStrX(bp,2));puts("] "); for(int i=0;igetTimer()); nrf_rcv_pkt_end(); }else{ puts("D no action\r\n"); }; puts("D done.\r\n"); return 0; };