blanks_writer.h 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "one_wire_master.h"
  3. #include "maxim_crc.h"
  4. typedef enum {
  5. KEY_DS1990, /**< DS1990 */
  6. KEY_CYFRAL, /**< CYFRAL*/
  7. KEY_METAKOM, /**< METAKOM */
  8. } KeyType;
  9. typedef enum {
  10. WR_OK,
  11. WR_SAME_KEY,
  12. WR_ERROR,
  13. } WriterResult;
  14. class BlanksWriter {
  15. private:
  16. const GpioPin* gpio;
  17. OneWireMaster* onewire;
  18. void onewire_release(void);
  19. void onewire_write_one_bit(bool value, uint32_t delay);
  20. bool write_TM2004(const uint8_t* key, uint8_t key_length);
  21. bool write_1990_1(const uint8_t* key, uint8_t key_length);
  22. bool write_1990_2(const uint8_t* key, uint8_t key_length);
  23. bool write_TM01(KeyType type, const uint8_t* key, uint8_t key_length);
  24. void write_byte_ds1990(uint8_t data);
  25. bool compare_key_ds1990(const uint8_t* key, uint8_t key_length);
  26. public:
  27. BlanksWriter(const GpioPin* one_wire_gpio);
  28. ~BlanksWriter();
  29. WriterResult write(KeyType type, const uint8_t* key, uint8_t key_length);
  30. void start();
  31. void stop();
  32. };