diff --git a/firmware/applications/serial/remote.c b/firmware/applications/serial/remote.c index 7a479ba..be96720 100644 --- a/firmware/applications/serial/remote.c +++ b/firmware/applications/serial/remote.c @@ -62,20 +62,71 @@ void s_init(void){ 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); }; };