My doorbell works with tristate protocol. I get data every time someone rings the bell.
Action: push button
Incoming: 20;0F;TriState;ID=0068a6;SWITCH=03;CMD=ON;
Result: the bell is ringing
I include the Plugin_003.c to send (TX) and tried to call from RFLink (serial/serial2net), the command works but nothing happens.
I corrected the code twice. First to compile, then add a fix like in other plugins.
A small piece of code (for example from the plugin)
`
void TriState_Send(unsigned long bitstream)
{
int fpulse = 360; // Pulse width in microseconds
int fretrans = 8; // Number of code retransmissions
uint32_t fdatabit;
uint32_t fdatamask = 0x00000003;
uint32_t fsendbuff=0; // fix: warning: 'fsendbuff' may be used uninitialized in this function
// fixes like cpainchaud 's in other TX plugins
noInterrupts();
Radio::set_Radio_mode(Radio::States::Radio_TX);
// reverse data bits (2 by 2)
for (unsigned short i = 0; i < 12; i++)
{ // reverse data bits (12 times 2 bits = 24 bits in total)
fsendbuff <<= 2;
fsendbuff |= (bitstream & B11);
bitstream >>= 2;
}
bitstream = fsendbuff; // store result
for (int nRepeat = 0; nRepeat <= fretrans; nRepeat++)
{
fsendbuff = bitstream;
// Send command
for (int i = 0; i < 12; i++)
{ // 12 times 2 bits = 24 bits in total
// read data bit
fdatabit = fsendbuff & fdatamask; // Get most right 2 bits
fsendbuff = (fsendbuff >> 2); // Shift right
// data can be 0, 1 or float.
if (fdatabit == 0)
{ // Write 0
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 3);
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 3);
}
else if (fdatabit == 1)
{ // Write 1
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse 3);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 1);
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse 3);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 1);
}
else
{ // Write float
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse 1);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 3);
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse 3);
digitalWrite(Radio::pins::TX_DATA, LOW);
delayMicroseconds(fpulse 1);
}
}
// Send sync bit
digitalWrite(Radio::pins::TX_DATA, HIGH);
delayMicroseconds(fpulse 1);
digitalWrite(Radio::pins::TX_DATA, LOW); // and lower the signal
delayMicroseconds(fpulse 31);
}
// fixes like cpainchaud 's in other TX plugins
Radio::set_Radio_mode(Radio::States::Radio_RX);
interrupts();
}
My doorbell works with tristate protocol. I get data every time someone rings the bell.
Action: push button Incoming: 20;0F;TriState;ID=0068a6;SWITCH=03;CMD=ON; Result: the bell is ringing
I include the Plugin_003.c to send (TX) and tried to call from RFLink (serial/serial2net), the command works but nothing happens. I corrected the code twice. First to compile, then add a fix like in other plugins.
Send: 10;TriState;0068a6;3;ON; Answer: 20;01;OK; Result: silence :(
A small piece of code (for example from the plugin)
` void TriState_Send(unsigned long bitstream) { int fpulse = 360; // Pulse width in microseconds int fretrans = 8; // Number of code retransmissions uint32_t fdatabit; uint32_t fdatamask = 0x00000003; uint32_t fsendbuff=0; // fix: warning: 'fsendbuff' may be used uninitialized in this function
// fixes like cpainchaud 's in other TX plugins noInterrupts(); Radio::set_Radio_mode(Radio::States::Radio_TX);
// reverse data bits (2 by 2) for (unsigned short i = 0; i < 12; i++) { // reverse data bits (12 times 2 bits = 24 bits in total) fsendbuff <<= 2; fsendbuff |= (bitstream & B11); bitstream >>= 2; } bitstream = fsendbuff; // store result
for (int nRepeat = 0; nRepeat <= fretrans; nRepeat++) { fsendbuff = bitstream; // Send command for (int i = 0; i < 12; i++) { // 12 times 2 bits = 24 bits in total // read data bit fdatabit = fsendbuff & fdatamask; // Get most right 2 bits fsendbuff = (fsendbuff >> 2); // Shift right // data can be 0, 1 or float. if (fdatabit == 0) { // Write 0 digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 3); digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 3); } else if (fdatabit == 1) { // Write 1 digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse 3); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 1); digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse 3); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 1); } else { // Write float digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse 1); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 3); digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse 3); digitalWrite(Radio::pins::TX_DATA, LOW); delayMicroseconds(fpulse 1); } } // Send sync bit digitalWrite(Radio::pins::TX_DATA, HIGH); delayMicroseconds(fpulse 1); digitalWrite(Radio::pins::TX_DATA, LOW); // and lower the signal delayMicroseconds(fpulse 31); } // fixes like cpainchaud 's in other TX plugins Radio::set_Radio_mode(Radio::States::Radio_RX); interrupts(); }
endif //PLUGIN_TX_003
`
Where to dig, what else can I try?