Transparent Transmissions

These examples will show you how to send and receive messages in transparent mode.

In this mode, each device who share the same channel and address will be able to communicate with each other.

Receiver

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

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

examples/transmit_transparent/receiver.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 transparent transmission mode.  (Default)
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_TRANSPARENT
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} between devices with the 0x{e32.address:x} address ...")
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()

Monitor

Monitors channel 4 for messages by using the 0xFFFF address.

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

examples/transmit_transparent/monitor.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 transparent transmission mode.  (Default)
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_TRANSPARENT
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24print(f"Monitoring 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()

Sender

Sends a 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_transparent/sender.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=0x1337, channel=4)
17
18# Switching to transparent transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_TRANSPARENT
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24# Message content:
25#  * Message: b'Hello World !'
26# The target channel and address are the same as the module's.
27message = b'Hello World !'
28
29# Sending with helper
30e32.send(message)
31
32time.sleep(0.5)  # Waiting to prevent RF spamming
33
34# Switching to an empty shared address and sending another message.
35e32.address = 0xBEEF
36message = b'You shouldn\'t receive this !'
37e32.send(message)
38e32.wait_aux()
39
40# The message may be truncated at specific lengths depending on the frequencies used.
41# Please check the documentation for more information !

Broadcast

Broadcasts a messages to all modules on channel 4 by using the 0xFFFF address.

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

examples/transmit_transparent/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=0xFFFF, channel=4)
17
18# Switching to transparent transmission mode.
19e32.tx_mode = ebyte_e32.TransmissionMode.TRANSMISSION_TRANSPARENT
20
21# Switching to mode 0.  (Normal mode)
22e32.mode = ebyte_e32.Modes.MODE_NORMAL
23
24# Message content:
25#  * Message: b'Hello World !'
26# The target channel is the same as the module's.
27message = b'Hello World !'
28
29# Sending with helper
30e32.send(message)
31
32time.sleep(0.5)  # Waiting to prevent RF spamming
33
34# Switching to an empty channel and sending another message.
35e32.channel = 5
36message = b'You shouldn\'t receive this !'
37e32.send(message)
38e32.wait_aux()
39
40# The message may be truncated at specific lengths depending on the frequencies used.
41# Please check the documentation for more information !