mirror of
https://github.com/pybricks/pybricks-projects.git
synced 2026-09-15 02:52:41 +00:00
snippets/ev3/bluetooth: update mailbox name
In examples, it is helpful to give unrelated things different names.
This commit is contained in:
@@ -4,15 +4,16 @@
|
||||
# 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 we are connecting to.
|
||||
SERVER = 'ev3dev'
|
||||
|
||||
client = BluetoothMailboxClient()
|
||||
mbox = TextMailbox('mbox', client)
|
||||
mbox = TextMailbox('greeting', client)
|
||||
|
||||
# The server must be started before the client!
|
||||
print('establishing connection...')
|
||||
client.connect(SERVER)
|
||||
print('connected!')
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
# 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 BluetoothMailboxServer, TextMailbox
|
||||
|
||||
server = BluetoothMailboxServer()
|
||||
mbox = TextMailbox('mbox', server)
|
||||
mbox = TextMailbox('greeting', server)
|
||||
|
||||
# The server must be started before the client!
|
||||
print('waiting for connection...')
|
||||
@@ -18,4 +20,4 @@ print('connected!')
|
||||
# and then sends a reply.
|
||||
mbox.wait()
|
||||
print(mbox.read())
|
||||
mbox.send('hello to you too!')
|
||||
mbox.send('hello to you!')
|
||||
|
||||
Reference in New Issue
Block a user