Go Down

Topic: Yun TCP/IP Connection (Read 82 times) previous topic - next topic


Sep 12, 2017, 10:06 pm Last Edit: Sep 12, 2017, 11:17 pm by Silvertail_Hawk
Hello, I am working on a Yun setup in conjunction with a RPI-3, using the RPI as a wireless access point for multiple Yuns to connect to so they can pass to it packets containing arbitrary date. This is so that I can sniff the incoming packets and train a neural network to distinguish between trojans which I will introduce at a later phase.

Currently, I am using the bridge client to sent TCP packets and have gotten that much to work, but I don't know how to set up the other end to complete both sides of the transaction. I am not even sure I am using the right library to be doing this. I tried looking in the bridgeServer.h library to understand what is going on, but I am not able to figure out how to reproduce this in python on the RPI. Can someone please point me in the right direction on how to set up the RPI to communicate over TCP with the arduino? Should I maybe be using another library other than BridgeClient?

Thank you.


I went ahead and wrote a python script on the RPI to try to get a connection. This is what I have:

Code: [Select]

import socket
import sys

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = ('localhost', 5055)
print >>sys.stderr, 'starting up on %s port %s' % server_address

# Listen for incoming connections

while True:
    # Wait for a connection
    print >>sys.stderr, 'waiting for a connection'
    connection, client_address = sock.accept()

        print >>sys.stderr, 'connection from', client_address

        # Receive the data in small chunks and retransmit it
        while True:
            data = connection.recv(16)
            print >>sys.stderr, 'received "%s"' % data
            if data:
                print >>sys.stderr, 'sending data back to the client'
                print >>sys.stderr, 'no more data from', client_address
        # Clean up the connection

It runs fine, but it looks like it isn't seeing anything from the Arduino. Using a packet sniffer on the RPI hotspot, I can see some UDP packets being sent from the Arduino in question where it is looping through the code. Here is what it looks like.

Code: [Select]

#include <Bridge.h>
#include <BridgeClient.h>

const byte SERVER_ADDR[] = {172, 24, 1, 1};
const int SERVER_PORT = 5055;

BridgeClient client;
long OpenWRTBaud = 250000;

void setup() {

void loop() {
  client.connect(SERVER_ADDR, SERVER_PORT);



My python listener on the RPI is not hearing the packets, even though they are getting sent to 5055. I don't know why this is, but I am guessing the libraries are not compatible?

P.S. is there any way to send more than one char in a packet?


Go Up