-1

The problem: I need to get information from one Beaglebone across an ethernet network to another Beaglebone, which will actuate a light based on the information the first Beaglebone provides. My background is mostly just in hardware, though, so I don't know if this is even feasible. I imagine there's a way to transmit information directly to/from IP addresses, but this is mostly speculation - no idea how to do it. I have not been able to find much of anything on this using Google, either.

My mission is, effectively, to push a button in one room and light up an LED in another room. The tools available to me are two BBBs, a local network, a few Arduino Unos, and a few PICs. The BBBs seem best for the job. It is not feasible to run a direct wire between them in any way. If there is a better way to go about this mission, input would be appreciated (perhaps as a comment, and then I'll start a new, appropriate post using that idea)?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Ed Sawden
  • 39
  • 3

1 Answers1

3

I would advise you to use a Node.js and a bonescript, which is the library created specifically for BBB. In my opinions it's the fastest and easiest way to make two BBBs talk to each other via TCP/IP. By default BBB already has node.js and bonescript installed. As a simplest IDE you can use Cloud9 that can be accessed on port 3000 on your BBB.

  1. Setup static IP addresses for you BBBs. To do so, follow Derek Molloy instructions.
  2. Take a look on how you can manage buttons and LEDs with bonescript.

  3. Create a javascript file for for the server (that will receive command and turn on the LEDs/etc), for instance name it "server.js", then run it from the console with the command "node server.js", here is simple example:

// I am server.js
var net = require('net');

var server = net.createServer(function(c) {
    console.log('client connected');

    c.on('data',function(data) {
        console.log("Received data is: " + data);
        var reponse = "Hello form BBB Server!";
        // Do something more
        c.write(reponse);
    });

    c.on('end', function() {
        console.log('client disconnected');
    });
});


server.listen(8124, function() {
  console.log('Server is launched.');
});
  1. Create a javascript file for for the client (that will send the command when the button is pressed), for instance "client.js", and run it from the console with the command "node client.js", here is a simple client example
// I am client.js
var net = require('net');

var server_ip = '192.168.7.2';      // here enter your BBB-server IP address
var client = net.connect(8124, server_ip, function() {
  console.log('connected to server!');
  client.write('Hello from BBB client');
});

client.on('data', function(data) {
  console.log(data.toString());
  client.end();
});

client.on('end', function() {
  console.log('disconnected from server');
});

Combine these steps and you will get what you want.

  • Perfect answer! I am extremely impressed by its clarity and helpfulness. As soon as I get this done, I'll post an update and (hopefully) mark your answer as "Accepted". – Ed Sawden Nov 17 '16 at 13:57
  • Good luck! Btw, a simple server/client example can be tested even on the single BBB, you have to open two consoles and run both files simultaneously, you should also (in this case) omit IP address entirely (only pass port), because it defaults to 'localhost'. – Andrejs Gasilovs Nov 17 '16 at 16:14