/*
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(WFLYRF_A7105_INO)
#include "iface_a7105.h"
#define WFLYRF_FORCE_ID
//WFLYRF constants & variables
#define WFLYRF_BIND_COUNT 2500
#define WFLYRF_PACKET_SIZE 32
enum{
WFLYRF_BIND,
WFLYRF_DATA,
WFLYRF_PLL_TX,
WFLYRF_RX,
};
static void __attribute__((unused)) WFLYRF_send_bind_packet()
{
//Header
packet[0] = 0x0F; // Bind packet
//ID
packet[1] = rx_tx_addr[3];
packet[2] = rx_tx_addr[2];
packet[3] = rx_tx_addr[1];
//Unknown
packet[4] = 0x00;
packet[5] = 0x01;
//Freq
packet[6] = (hopping_frequency_no<<1)+0x0E;
rf_ch_num = (hopping_frequency_no<<2)+0x2C;
hopping_frequency_no++; // not sure which frequencies are used since the dump only goes from 0x0E to 0x2C and stops...
if(hopping_frequency_no > 0x1A) hopping_frequency_no=0x00;
//Unknown
memset(&packet[7],0x00,25);
//Debug
#if 0
debug("ch=%02X P=",rf_ch_num);
for(uint8_t i=0; i>8;
//RF channel
int8_t prev = rf_ch_num & 0x1F;
rf_ch_num = (pseudo ^ (pseudo >> 7)) & 0x57;
if(rf_ch_num & 0x10)
{
rf_ch_num |= 0x08;
rf_ch_num &= 0x4F;
}
if(rf_ch_num & 0x40)
{
rf_ch_num |= 0x10;
rf_ch_num &= 0x1F;
}
rf_ch_num ^= rx_tx_addr[3] & 0x1F;
if(abs((int8_t)rf_ch_num-prev) <= 9)
{
if(high_bit)
rf_ch_num |= 0x20;
}
else
if(!high_bit)
rf_ch_num |= 0x20;
//Partial ID
packet[3] = rx_tx_addr[3];
packet[4] = rx_tx_addr[2] & 0x1F; //not sure... could be 0x1F down to 0x03
//10 channels
for(uint8_t i = 0; i < 5; i++)
{
uint16_t temp=convert_channel_16b_nolimit(i*2 , 0x0000, 0x0FFF); // need to check channels min/max...
packet[5 + i*3] = temp&0xFF; // low byte
packet[7 + i*3] = (temp>>8)&0x0F; // high byte
temp=convert_channel_16b_nolimit(i*2+1, 0x0000, 0x0FFF); // need to check channels min/max...
packet[6 + i*3] = temp&0xFF; // low byte
packet[7 + i*3] |= (temp>>4)&0xF0; // high byte
}
//Unknown
memset(&packet[20],0x00,12);
//Debug
#if 0
debug("ch=%02X,%02X P=",rf_ch_num,(rf_ch_num<<1)+0x10);
for(uint8_t i=0; i