#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" #if CFG_USBMSC #error "MSC is defined" #endif #if !CFG_USBCDC #error "CDC is not defined" #endif /**************************************************************************/ #include "SECRETS" void r_init(void){ nrf_init(); struct NRF_CFG config = { .channel= REMOTE_CHANNEL, .txmac= REMOTE_MAC, .nrmacs=1, .mac0= REMOTE_MAC, .maclen ="\x10", }; nrf_config_set(&config); }; void s_init(void){ usbCDCInit(); nrf_init(); struct NRF_CFG config = { .channel= REMOTE_CHANNEL, .txmac= REMOTE_MAC, .nrmacs=1, .mac0= REMOTE_MAC, .maclen ="\x10", }; nrf_config_set(&config); }; void process(uint8_t * input){ __attribute__ ((aligned (4))) uint8_t buf[32]; puts("process: "); puts(input); puts("\r\n"); if(input[0]=='M'){ buf[0]=0x10; // Length: 16 bytes buf[1]='M'; // Proto buf[2]=0x01; buf[3]=0x01; // Unused uint32touint8p(0,buf+4); uint32touint8p(0x41424344,buf+8); buf[12]=0xff; // salt (0xffff always?) buf[13]=0xff; nrf_snd_pkt_crc_encr(16,buf,remotekey); nrf_rcv_pkt_start(); }; }; #define INPUTLEN 99 void r_recv(void){ __attribute__ ((aligned (4))) uint8_t buf[32]; int len; uint8_t input[INPUTLEN+1]; int inputptr=0; nrf_rcv_pkt_start(); puts("D start"); getInputWaitRelease(); while(!getInputRaw()){ delayms(100); // Input int l=INPUTLEN-inputptr; CDC_OutBufAvailChar (&l); if(l>0){ CDC_RdOutBuf (input+inputptr, &l); input[inputptr+l+1]=0; for(int i=0;i0){ lcdPrint("Got!"); lcdDisplay(); break; }; delayms(10); }; };