Send the calculated command bitstream twice, to be more robust against missed commands on the receiving side.

This commit is contained in:
he.so 2020-02-25 20:47:48 +01:00
parent e25f14f37a
commit 91dfc7aa0b
1 changed files with 25 additions and 25 deletions

View File

@ -112,19 +112,22 @@ void CmdSendButton(void)
jaroliftDevice.count++;
Settings.keeloq_count = jaroliftDevice.count;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("sync frame"));
digitalWrite(TX_PORT, LOW); // CC1101 in TX Mode+
delayMicroseconds(1150);
SendSyncPreamble(13);
delayMicroseconds(3500);
for(int i=72; i>0; i--)
for(int repeat = 0; repeat <= 1; repeat++)
{
SendBit(jaroliftDevice.pack & 0x0000000000000001);
jaroliftDevice.pack >>= 1;
}
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("finished sending bits at %d"), micros());
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("sync frame"));
digitalWrite(TX_PORT, LOW); // CC1101 in TX Mode+
delayMicroseconds(1150);
SendSyncPreamble(13);
delayMicroseconds(3500);
for(int i=72; i>0; i--)
{
SendBit(jaroliftDevice.pack & 0x0000000000000001);
jaroliftDevice.pack >>= 1;
}
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("finished sending bits at %d"), micros());
delay(16); // delay in loop context is save for wdt
delay(16); // delay in loop context is save for wdt
}
}
}
@ -157,7 +160,7 @@ void CmndSendRaw(void)
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("cmd send called at %d"), micros());
noInterrupts();
entertx();
for(int repeat = 0; repeat < 1; repeat++)
for(int repeat = 0; repeat <= 1; repeat++)
{
if (XdrvMailbox.data_len > 0)
{
@ -190,11 +193,8 @@ void enterrx() {
{
if (micros() - rx_time > 50000) break; // Quit when marcState does not change...
}
} // void enterrx
}
//####################################################################
// put CC1101 to send mode
//####################################################################
void entertx() {
unsigned char marcState = 0;
cc1101.setTxState();
@ -204,7 +204,7 @@ void entertx() {
{
if (micros() - rx_time > 50000) break; // Quit when marcState does not change...
}
} // void entertx
}
void SendSyncPreamble(int l)
{