Skip to content

sending 25 bit ook signal. #185

@adminy

Description

@adminy

transmit only takes bytes and I'd like to send 25 bits of information about 4 times,

my parameters are the following:

[~ (50kHz) ]            # define a base frequency
[_ (2100us) ]             # define a long gap (6 clks)
[0 (~344us) (1238us) ]   # define a short pulse and long gap (1:3)
[1 (~1032us) (344us) ]   # define a long pulse and short gap (3:1)

And the key is 0011011101100111101111000.

code = '006ecf78'

code = int(code, 16).to_bytes(4, byteorder='big')

print(code, len(code))

import cc1101, math


MESSAGE_BITS = 25
MESSAGE_REPEAT = 4

SYNC_WORD = bytes([255, 168])  # 168 might be sender-specific


with cc1101.CC1101() as transceiver:
    transceiver.set_base_frequency_hertz(433.92e6)
    transceiver.set_symbol_rate_baud(2048)
    transceiver.set_sync_mode(cc1101.SyncMode.TRANSMIT_16_MATCH_15_BITS, _carrier_sense_threshold_enabled=True)
    transceiver.set_sync_word(SYNC_WORD)
    transceiver.disable_checksum()
    
    transmission_length_bytes = math.ceil(MESSAGE_BITS * MESSAGE_REPEAT / 8)
    transceiver.set_packet_length_mode(cc1101.PacketLengthMode.FIXED)
    transceiver.set_packet_length_bytes(transmission_length_bytes - len(SYNC_WORD))

    transceiver._set_filter_bandwidth(mantissa=3, exponent=3)

    print(transceiver)
    transceiver.transmit(code)

    packet = transceiver._wait_for_packet(timeout=0, gdo0_gpio_line_name=b"GPIO24")
    print(packet)

Also not sure that this is the correct way to both receive and transmit at the same time. I suspect this makes sense in a callback way of doing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions