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