LEGO Mindstorms EV3


Bluetooth description

 Support of up to 7 connection - either 7 outgoing or 1 incoming connection.

 Scatter-net is not supported. If connected from outside (by bluetooth) then
 the  connection is closed if an outgoing connection is made from the brick.

 Pin agent is used to handle pairing.

 DBUS is used to handle connection creation.

 Sockets are used to communicate with the remote devices.


 Bluetooth buffer setup
 ----------------------

 RX side:

 Bluetooth socket
      |
       --> c_bt RxBuf - Fragmented async. data bytes
               |
                --> c_bt Msg buffer  - Collected as complete LEGO protocol messages
                           |
                            --> c_com rx buffer - Transferred to c_com level for interpretation


 Tx side:

 c_com tx buffer
       |
        --> c_bt WriteBuf Buffer
                    |
                     -->  Bluetooth socket





 In mode2:
 ---------

 RX:

 Bluetooth socket
       |
        --> Mode2Buf - Fragmented data bytes (c_bt.c)
                |
                 --> Mode2InBuf - Fragmented data bytes (c_i2c.c)
                          |
                           --> Transfer to Mode2 decoding
                                  |
                                   --> READBUF (return bytes from mode2 decoding) -> for mode1 decoding
                                  |
                                  |
                                   --> WriteBuf (return bytes from mode2 decoding) -> for tx to remote mode2 device


 TX:

 Mode2WriteBuf   (c_bt.c)
     |
      --> Transfer to mode2 decoding  (data read in c_i2c.c)
             |
              --> WriteBuf (return bytes from mode2 decoding) -> for tx  (c_bt.c)
                                          |
                                           -->  Bluetooth socket



 CONNECTION MANAGEMENT
 ---------------------


   CONNECTING:

   Connecting brick:                                        Remote brick:

   Connect to brick (Issued from byte codes)     |
   - Set busy flag                               |
   - Disable page inquiry                        |
   - Open socket                           --->  |  --->    EVT_CONN_REQUEST
                                                 |          - Issue remote name request
                                                 |
   Optional pin/passkey exchange (agent)   <-->  |  <-->    optional pin/passkey exchange (agent)
                                                 |
   EVT_CONN_COMPLETE                       <---  |  --->    EVT_CONN_COMPLETE
   - Disable page inquiry                        |          - Disable page inquiry        (Cannot be connected to more than one, as a slave)
   - Update Device list                          |          - Insert all info in dev list (Except connected)
   - Update Search list                          |
                                                 |
   Socket write ready (Remote socket open) <---  |  --->    Success on accept listen socket (Socket gives remote address)
   - NoOfConnDevices++                           |          - Set slave mode
   - Update Search list to connected             |          - NoOfConnDevices++
   - Update Device list to connected             |          - Update Device list to connected
                                                 |          - Update Search list to connected
                                                 |


   DISCONNECTING:

   Disconnecting brick:                          |          Remote brick:
                                                 |
   Disconnect  (Issued from byte codes)          |
   - Close bluetooth socket                --->  |  --->    Socket indicates remote socket closed
                                                 |          - Close socket
                                                 |
                                                 |
   EVT_DISCONN_COMPLETE                    <---  |  --->    EVT_DISCONN_COMPLETE
   - Update Search list to disconnected          |          - Update Search list to disconnected
   - Update Device list to disconnected          |          - Update Device list to disconnected
   - NoofConnDevices--                           |          - NoofConnDevices--
   - If NoofConnDevices = 0 -> set idle mode     |          - If NoofConnDevices = 0 -> set idle mode

LEGO® Robotics Firmware Documentation
Confidential Information © 2013 The LEGO Group