sui77 / rc-switch

Arduino lib to operate 433/315Mhz devices like power outlet sockets.
1.9k stars 658 forks source link

Why synchronization is sending at the end ? #385

Open almol opened 3 years ago

almol commented 3 years ago

According my measurements and code, sync is sending at the end:

  for (int nRepeat = 0; nRepeat < nRepeatTransmit; nRepeat++) {
    for (int i = length-1; i >= 0; i--) {
      if (code & (1L << i))
        this->transmit(protocol.one);
      else
        this->transmit(protocol.zero);
    }
    this->transmit(protocol.syncFactor);   //Transmit SYNC
  }

That work because that send multiple frames: frame 1 is ignored, frame 1 sync is read as frame 2 sync start and so on.

Will be:

  for (int nRepeat = 0; nRepeat < nRepeatTransmit; nRepeat++) {
    this->transmit(protocol.syncFactor);   //Transmit SYNC
    for (int i = length-1; i >= 0; i--) {
      if (code & (1L << i))
        this->transmit(protocol.one);
      else
        this->transmit(protocol.zero);
    }

  }

.. that would be if I understood everything correctly....

Thanks.