Download the file
  1. #include "listener.h"
  2.  
  3. bool Listener::canRun(uint32_t now) {
  4. if (rf12_recvDone()) {
  5. //Serial.println("recvDone");
  6. return (rf12_crc == 0 && rf12_len <= BUFFER_LEN);
  7. }
  8. return false;
  9. }
  10.  
  11. void Listener::run(uint32_t now) {
  12. recv_buffer_len = rf12_len;
  13. memcpy((void *)recv_buffer, (void *)rf12_data, recv_buffer_len);
  14. //SHOW_BUFFER("RECV: ", rf12_hdr, recv_buffer, recv_buffer_len);
  15. if (rf12_hdr == (RF12_HDR_CTL | (SLAVE_ID & RF12_HDR_MASK)))
  16. // received an ACK from SLAVE
  17. protocol->got_ack();
  18. else {
  19. if (RF12_WANTS_ACK) {
  20. //SHOW_BUFFER("SACK: ", RF12_ACK_REPLY, recv_buffer, 0);
  21. rf12_sendStart(RF12_ACK_REPLY, 0, 0);
  22. rf12_sendWait(0);
  23. }
  24. protocol->handle(recv_buffer, recv_buffer_len);
  25. }
  26. }
  27.  
  28. // vim:ft=arduino
  29.