snippets/ev3/bluetooth: update mailbox name

In examples, it is helpful to give unrelated things different names.
This commit is contained in:
Laurens Valk
2020-03-25 12:59:16 +01:00
parent af926c5f19
commit 6a57abbff6
2 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -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 -2
View File
@@ -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!')