transmit_variable_length.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import logging
  2. import time
  3. import cc1101
  4. logging.basicConfig(level=logging.INFO)
  5. with cc1101.CC1101() as transceiver:
  6. print("defaults:", transceiver)
  7. transceiver.set_base_frequency_hertz(433.5e6)
  8. transceiver.set_symbol_rate_baud(600)
  9. # transceiver.set_sync_mode(cc1101.SyncMode.NO_PREAMBLE_AND_SYNC_WORD)
  10. # transceiver.set_sync_word(b"\x12\x34")
  11. # transceiver.disable_checksum()
  12. print(transceiver)
  13. print("state", transceiver.get_marc_state().name)
  14. print("base frequency", transceiver.get_base_frequency_hertz(), "Hz")
  15. print("symbol rate", transceiver.get_symbol_rate_baud(), "Baud")
  16. print("modulation format", transceiver.get_modulation_format().name)
  17. sync_mode = transceiver.get_sync_mode()
  18. print("sync mode", sync_mode)
  19. print(
  20. "sync word",
  21. transceiver.get_sync_word()
  22. if sync_mode != cc1101.SyncMode.NO_PREAMBLE_AND_SYNC_WORD
  23. else "disabled",
  24. )
  25. print("starting transmission")
  26. transceiver.transmit(b"\xff\xaa\x00 message")
  27. time.sleep(1.0)
  28. transceiver.transmit(bytes([0, 0b10101010, 0xFF]))
  29. for i in range(16):
  30. time.sleep(1.0)
  31. transceiver.transmit(bytes([i, i, i]))