Fixed Transmissions

These examples will show you how to send and receive messages in fixed mode in unicast and broadcast.

In this mode, each message needs to contain the target channel and address before the actual data.
You can also use the special 0xFFFF address to monitor or broadcast messages on a given channel.

Unicast Receiver

Waits on channel 4 with the 0x1337 address for any incoming unicast or broadcast messages.

⚠️ Received messages may be truncated at specific lengths depending on the frequencies and operating parameters used due to RF regulations.

examples/transmit_fixed/receiver_unicast.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import time
 7
 8import ebyte_e32
 9
10PIN_M0 = board.B3
11PIN_M1 = board.B4
12PIN_RXD = board.A2  # Pin marked as RX on the module
13PIN_TXD = board.A3  # Pin marked as TX on the module
14PIN_AUX = board.B7
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD, address=0x1337, channel=4)
17
18# Switching to fixed transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_FIXED
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24print(f"Waiting for messages... on channel {e32.channel} for 0x{e32.address:x}...")
25
26while True:
27    # Checking if the module sent us some data
28    if e32.in_buffer > 0:
29        # Wait for the module to finish receiving data
30        e32.wait_aux()
31        
32        # We grab the data, and can process it here
33        data = e32.read()
34        
35        # We print it and exit
36        print(f"We received a {len(data)} byte(s) long message:")
37        print(data)
38    
39    # If nothing was received, we wait.
40    time.sleep(0.1)
41
42print()
43print("Now exiting...")
44e32.deinit()

Monitoring Receiver

Waits on channel 4 with the special 0xFFFF address for any unicast or broadcast messages on that channel.

⚠️ Received messages may be truncated at specific lengths depending on the frequencies and operating parameters used due to RF regulations.

examples/transmit_fixed/receiver_broadcast.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import time
 7
 8import ebyte_e32
 9
10PIN_M0 = board.B3
11PIN_M1 = board.B4
12PIN_RXD = board.A2  # Pin marked as RX on the module
13PIN_TXD = board.A3  # Pin marked as TX on the module
14PIN_AUX = board.B7
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD, address=0xFFFF, channel=4)
17
18# Switching to fixed transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_FIXED
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24print(f"Monitoring for messages... on channel {e32.channel}...")
25
26while True:
27    # Checking if the module sent us some data
28    if e32.in_buffer > 0:
29        # Wait for the module to finish receiving data
30        e32.wait_aux()
31        
32        # We grab the data, and can process it here
33        data = e32.read()
34        
35        # We print it and exit
36        print(f"We received a {len(data)} byte(s) long message:")
37        print(data)
38    
39    # If nothing was received, we wait.
40    time.sleep(0.1)
41
42print()
43print("Now exiting...")
44e32.deinit()

Unicast Sender

Sends a unicast message to any modules on channel 4 with the 0x1337 address.

⚠️ Sent messages may be truncated at specific lengths depending on the frequencies and operating parameters used due to RF regulations.

examples/transmit_fixed/sender_unicast.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import time
 7
 8import ebyte_e32
 9
10PIN_M0 = board.IO13
11PIN_M1 = board.IO12
12PIN_RXD = board.IO11  # Pin marked as RX on the module
13PIN_TXD = board.IO10  # Pin marked as TX on the module
14PIN_AUX = board.IO9
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD, address=0xBEEF, channel=4)
17
18# Switching to fixed transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_FIXED
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24# Message content:
25#  * Receiver's address: 0x1337  (b'\x13\x37')
26#  * Receiver's channel: 4  (b'\x04')
27#  * Message: b'Hello World !'
28message = b'\x13\x37\x04Hello World !'
29
30# Sending with helper
31e32.send(message)
32
33# The message may be truncated at specific lengths depending on the frequencies used.
34# Please check the documentation for more information !

Broadcast Sender

Sends a broadcast message to any modules on channel 4 by using the target address 0xFFFF.

⚠️ Sent messages may be truncated at specific lengths depending on the frequencies and operating parameters used due to RF regulations.

examples/transmit_fixed/sender_broadcast.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import time
 7
 8import ebyte_e32
 9
10PIN_M0 = board.IO13
11PIN_M1 = board.IO12
12PIN_RXD = board.IO11  # Pin marked as RX on the module
13PIN_TXD = board.IO10  # Pin marked as TX on the module
14PIN_AUX = board.IO9
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD, address=0xBEEF, channel=4)
17
18# Switching to fixed transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_FIXED
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24# Message content:
25#  * Receiver's address: 0xFFFF  (b'\xFF\xFF')
26#  * Receiver's channel: 4  (b'\x04')
27#  * Message: b'Hello World !'
28message = b'\xFF\xFF\x04Hello World !'
29
30# Sending with helper
31e32.send(message)
32
33# The message may be truncated at specific lengths depending on the frequencies used.
34# Please check the documentation for more information !