Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. #ifndef IR_PROTOCOLS_H_
  2. #define IR_PROTOCOLS_H_
  3.  
  4. #include "ircommon.h"
  5. /* Maybe ircommon.h should be removed and its contents be placed here instead.
  6.  * After all, there's not much 'common' about it anymore. */
  7.  
  8. /* Protocol data structure */
  9. typedef struct {
  10.     uint8_t protocol;
  11.     uint32_t data;
  12.     uint16_t timeout;
  13. } Ir_Protocol_Data_t;
  14.  
  15. /* Which protocols to use. These should perhaps be configuration options
  16.  * (config.inc). */
  17. #define IR_PROTOCOLS_USE_SIRC       1
  18. #define IR_PROTOCOLS_USE_RC5        1
  19. #define IR_PROTOCOLS_USE_SHARP      1
  20. #define IR_PROTOCOLS_USE_NEC        1
  21. #define IR_PROTOCOLS_USE_SAMSUNG    1
  22.  
  23. /* All these functions take a buffer with pulse times and tries to parse it
  24.  * to a Ir_Protocol_Data_t structure. They return IR_OK on success
  25.  * and IR_NOT_CORRECT_DATA if there was no match. */
  26. #if (IR_PROTOCOLS_USE_SIRC)
  27. int8_t parseSIRC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  28. #endif
  29. #if (IR_PROTOCOLS_USE_RC5)
  30. int8_t parseRC5(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  31. #endif
  32. #if (IR_PROTOCOLS_USE_SHARP)
  33. int8_t parseSharp(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  34. #endif
  35. #if (IR_PROTOCOLS_USE_NEC)
  36. int8_t parseNEC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  37. #endif
  38. #if (IR_PROTOCOLS_USE_SAMSUNG)
  39. int8_t parseSamsung(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  40. #endif
  41. /* Try to parse all above protocols until a match is found. */
  42. int8_t parseProtocol(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  43. /* The Hash protocol always succeeds and creates a one-way signature of the
  44.  * pulse times buffer that is supposed to be unique and constant for a specific
  45.  * IR event. It may be used to send a valid event even if the protocol hasn't
  46.  * been implemented or decoded yet. */
  47. int8_t parseHash(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto);
  48.  
  49. /* These functions expand a Ir_Protocol_Data_t structure into a raw buffer with
  50.  * pulse lengths. They return IR_OK on success and IR_NOT_CORRECT_DATA if the
  51.  * Ir_Protocol_Data_t structure is for another protocol or contains invalid
  52.  * data. */
  53. int8_t expandSIRC(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  54. int8_t expandRC5(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  55. int8_t expandSharp(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  56. int8_t expandNEC(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  57. int8_t expandSamsung(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  58. /* Pass the Ir_Protocol_Data_t automatically to the correct function. */
  59. int8_t expandProtocol(uint16_t *buf, uint8_t len, const Ir_Protocol_Data_t *proto);
  60.  
  61. #endif /*IR_PROTOCOLS_H_*/
  62.