/* This project is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Multiprotocol is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Multiprotocol. If not, see . */ #if defined(EAZYRC_NRF24L01_INO) #include "iface_xn297.h" //#define FORCE_EAZYRC_ORIGINAL_ID #define EAZYRC_PAYLOAD_SIZE 10 #define EAZYRC_RF_NUM_CHANNELS 4 #define EAZYRC_BIND_CHANNEL 18 #define EAZYRC_PACKET_PERIOD 5000 enum { EAZYRC_BINDTX=0, EAZYRC_BINDRX, EAZYRC_DATA, }; static void __attribute__((unused)) EAZYRC_send_packet() { //Bind: // TX: C=18 S=Y A= AA BB CC DD EE P(10)= 1A A0 01 00 00 00 1E 00 78 51 // packet[0..2]=tx_addr, packet[6]=first rf channel, packet[8]=unk, packet[9]=sum(packet[0..8]) // RX: C=18 S=Y A= AA BB CC DD EE P(10)= 41 AD 01 1A A0 01 1E 00 87 4F // packet[0..2]=rx_addr, packet[3..5]=tx_addr, packet[6]=first rf channel, packet[8]=unk but swapped, packet[9]=sum(packet[0..8]) //Normal: C=30 S=Y A= 1A A0 41 AD 02 P(10)= 7F 7F 1F 19 00 00 1E 00 AB FF // packet[0]=THR, packet[1]=ST, packet[2]=unk, packet[3]=unk, packet[6]=first rf channel, packet[8]=unk, packet[9]=sum(packet[0..8]) //Bound : C=18 S=Y A= AA BB CC DD EE P(10)= 1A A0 01 41 AD 01 1E 00 79 41 // packet[0..2]=tx_addr, packet[3..5]=rx_addr, packet[6]=first rf channel, packet[8]=unk, packet[9]=sum(packet[0..8]) // sent every 12 packets in normal mode, but is it really needed if the car loose power then you need to rebind... //Packet period around 5ms with a large jitter memset(&packet[3], 0x00, 7); if(IS_BIND_IN_PROGRESS) { memcpy(&packet,rx_tx_addr,3); packet[6] = hopping_frequency[0]; packet[8] = 0x78; //??? packet type? } else { XN297_Hopping(hopping_frequency_no); hopping_frequency_no++; hopping_frequency_no &= 3; packet[0] = convert_channel_8b(THROTTLE); packet[1] = convert_channel_8b(AILERON); packet[2] = 0x1F; //??? additional channel? packet[3] = 0x19; //??? additional channel? packet[6] = hopping_frequency[0]; packet[8] = 0xAB; //??? packet type? } for(uint8_t i=0;i