mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 09:05:07 +00:00
First pass including Image and ImageFile. Largely migrated from old ev3dev version. We can refine this for the embedded version in the next commits.
24 lines
693 B
Python
24 lines
693 B
Python
# Before running this program, make sure the client and server EV3 bricks are
|
|
# paired using Bluetooth, but do NOT connect them. The program will take care
|
|
# of establishing the connection.
|
|
|
|
# The server must be started before the client!
|
|
|
|
from pybricks.messaging import BluetoothMailboxClient, TextMailbox
|
|
|
|
# This is the name of the remote EV3 or PC we are connecting to.
|
|
SERVER = "ev3dev"
|
|
|
|
client = BluetoothMailboxClient()
|
|
mbox = TextMailbox("greeting", client)
|
|
|
|
print("establishing connection...")
|
|
client.connect(SERVER)
|
|
print("connected!")
|
|
|
|
# In this program, the client sends the first message and then waits for the
|
|
# server to reply.
|
|
mbox.send("hello!")
|
|
mbox.wait()
|
|
print(mbox.read())
|