key_emulator.h 826 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "pulse_sequencer.h"
  3. #include "../ibutton_key.h"
  4. #include <one_wire_slave.h>
  5. #include <one_wire_device_ds_1990.h>
  6. #include <atomic>
  7. class KeyEmulator {
  8. public:
  9. KeyEmulator(OneWireSlave* onewire_slave);
  10. ~KeyEmulator();
  11. void start(iButtonKey* key);
  12. bool emulated();
  13. void stop();
  14. private:
  15. DS1990 dallas_key;
  16. OneWireSlave* onewire_slave;
  17. PulseSequencer pulser;
  18. uint32_t pulse_data[72];
  19. std::atomic<bool> anything_emulated;
  20. void start_cyfral_emulate(iButtonKey* key);
  21. void start_metakom_emulate(iButtonKey* key);
  22. void start_dallas_emulate(iButtonKey* key);
  23. void set_pulse_data_cyfral(uint8_t index, const uint32_t* data);
  24. void set_pulse_data_metakom(uint8_t index, const uint32_t* data);
  25. void result_callback(bool success, void* ctx);
  26. };