MonoBrick Tunnel

TunnelBlockThe MonoBrick Tunnel makes it possible to communicate with the LEGO Mindstorms NXT Brick over a Wi-Fi or internet connection using MonoBrick or the MonoBrick Remote. The idea is simply to have the MonoBrick Tunnel connect to the LEGO Brick via USB or Bluetooth and have clients connect to the Tunnel. This setup makes it possible to forward messages from TCP/IP to USB/Bluetooth and vice versa. All features from the MonoBrick communication library and the MonoBrick Remote can be used with the Tunnel. This provides a very easy way to read sensor value, start a program, upload a file and even drive a vehicle over the Internet. The Tunnel runs as a simple command line program and can run on Windows, Linux and Mac OS. With MonoBrick Tunnel you can:

  • Log events and store these in a file
  • Throw off clients when the server is running
  • Have multiple clients connect
  • Select whether IP addresses should be rejected or accepted
  • Connect to the client when behind a firewall or the IP address is not visible (NAT’ed)

Running And Setting Up The Tunnel

On Windows and Linux the MonoBrick Tunnel is distributed as a zip file while Mac users have a dedicated DMG installer  – use the download link to get the latest version.

  • Windows
    • Unzip all files from the download to a folder of your choice
    • Run the exe-file found in the folder where you unzipped the download from a command prompt
  • Linux
    • Unzip all files from the download to a folder of your choice
    • Install Mono Runtime and LibUsb using this this guide
    • From a terminal use Mono to run the exe-file found in where you unzipped the download
  • Mac OS
    • Install the Mono Runtime from the Mono websiteThis guide might be helpfull.
    • Install MonoBrick Tunnel using the Mac OS installer
    • From a terminal use Mono to run the exe-file found in /Applications/MonoBrick\ Tunnel.app/Contents/MacOs/MonoBrick\

By default this will connect to the Brick using USB and listening for clients on port 1500. To make the tunnel connect to the client on startup simply write

MonoBrickTunnel.exe -connect 89.398.34.55

When the tunnel is running the following keyboard commands can be applied

  • Press Q to stop the tunnel
  • Press C to connect to a client
  • Press T to throw off all clients

In most cases these commands to should be enough to establish a network connection to your LEGO Brick. Below some more advanced settings are described.

Using the settings file

The Tunnel gets it settings from a XML file which is located in the same folder as the exe file. If the file is missing a new file with default settings will be created. Below the default settings file is shown.

<?xml version="1.0" encoding="utf-8"?>
<ConfigRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ListenForClients>true</ListenForClients>
  <LogFile>log.txt</LogFile>
  <IPFilter>
    <IPAddresses>
      <Range>
        <Lower>192.168.0.100</Lower>
        <Upper>192.168.0.150</Upper>
      </Range>
    </IPAddresses>
    <IPRangeMode>Disable</IPRangeMode>
  </IPFilter>
  <Connection>usb</Connection>
  <Port>1500</Port>
  <MaxConnections>1</MaxConnections>
</ConfigRoot>

The XML tags have the following meaning

  • ListenForClients – when set to true the tunnel accepts incomming connections from clients
  • LogFile – the name of the log file. Leave this tag empty to disable creating a log file
  • Lower IP – set the low address of the IP filter
  • Upper IP – set the high address of the IP filter
  • IPRangeMode – set the mode of the IP filter this can be set to “Disable” , “Reject”  or “Accept”
  • Connection
    • To use USB this should be “usb”
    • To use Bluetooth on Windows use for example “com6″ to connect via comport 6
    • To use Bluetooth on Mac OS use for example “/dev/tty.Great-DevB” where to Great is the name of the LEGO Brick
  • Port – set the port number to use
  • MaxConnections – determine the maximum number of clients that simultaneously can be connected to the tunnel

Support

Questions related to the MonoBrick Tunnel can be found in the MonoBrick communication library forum.

10 comments on “MonoBrick Tunnel
  1. Author Image Konne says:

    Hey Anders,

    First of all, thanks for your superb work on the monobrick.

    Maybe you can help me, ’cause I got a problem running the monobrick tunnel.

    I tried to connect the PC-software with the android tunnel but I’m not able to build up a connection. The IP, I’d entered in the android tunnel is definitely correct and obviously the PC device wants to build an USB connection. Unfortunately I am a complete start-up and so it is difficult for me to understand, what you mean with: “To make the tunnel connect to the client on startup simply write MonoBrickTunnel.exe -connect 89.398.34.55″.

    So please help me, I can’t wait to drive my robots around the house!!!

    Best wishes!
    Konne

    • Hi – thanks for visiting my site.

      What brick type are you using – NXT or EV3? Also to me it is not clear what you are trying to do – are you using the MonoBrick tunnel or the Android MonoBrick tunnel?

      Whan using either you first need to make the tunnel connect to the brick. Once this is done have the PC connect to the tunnel – which will then forward messages between the brick and the PC program. Are you able to get the tunnel to connect to the brick?

      • Author Image Konne says:

        Hey Anders, thanks for your reply!

        I’m using the Monobrick Tunnel for Android and the connection via Bluetooth works perfectly.

        Then I downloaded the Monobrick Tunnel for PC and try to connect the Android tunnel and the PC tunnel, but that seems to be the wrong way.

        Do I have to connect with the Monobrick remote software?

        Greets!
        Konne

        • Ok so the Android tunnel connect to the NXT brick – that is good news. Now you need to connect to the Android tunnel using the NXT remote. Simply enter the IP-Address of the phone. When you connect to the Brick the IP-Address is written on the screen of the phone.

          Anders

          • Author Image Konne says:

            Hi Anders,

            The problem persists…

            I downloaded the NXT Remote. (By the way: I’m using ev3. May this be the Problem?)
            The Log Output from the Remote Android Tunnel says:
            “Connection attempt from [my IP]
            Client created
            Cleants connected 1
            Connect From [my IP]
            Forward GetDeviceInfo with replay to NXT”

            But now nothing happens. The controls in the PC software stay grey and not controlable, and in the Android tunel I cannot stop the connection.

            Am I doing something completely wrong, or is there a technical problem, what I can’t see in the moment?

            Greets,
            Konne

          • The Tunnel does not work with the EV3 yet.

            Anders

  2. Author Image Konne says:

    UUU that’s bad…

    Do you have an idea, when you will update the tunnel and the remote so we can use it with the ev3?

Leave a Reply

Login with:

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Make a donation

Download