transmit_variable_length.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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_preamble_length_bytes(2)
  11. # transceiver.set_sync_word(b"\x12\x34")
  12. # transceiver.disable_checksum()
  13. print(transceiver)
  14. print("state", transceiver.get_marc_state().name)
  15. print("base frequency", transceiver.get_base_frequency_hertz(), "Hz")
  16. print("symbol rate", transceiver.get_symbol_rate_baud(), "Baud")
  17. print("modulation format", transceiver.get_modulation_format().name)
  18. sync_mode = transceiver.get_sync_mode()
  19. print("sync mode", sync_mode)
  20. if sync_mode != cc1101.SyncMode.NO_PREAMBLE_AND_SYNC_WORD:
  21. print("preamble length", transceiver.get_preamble_length_bytes(), "bytes")
  22. print("sync word", transceiver.get_sync_word())
  23. print("\nstarting transmission")
  24. transceiver.transmit(b"\xff\xaa\x00 message")
  25. time.sleep(1.0)
  26. transceiver.transmit(bytes([0, 0b10101010, 0xFF]))
  27. for i in range(16):
  28. time.sleep(1.0)
  29. transceiver.transmit(bytes([i, i, i]))