Wifi communication between Raspberry Pi 2 and BeagleBone Black - raspberry-pi2

I have a raspi 2 with a WiFi dongle and is setup to act as an access point/router. I also have 2 BeagleBone Blacks that also have WiFi dongles and they are connected to the raspi's network as well as a 9 axis sensor (accelerometer, gyro, etc). But I am unsure on how to send data from one board to another. And it has to be wirelessly.

If your RPi2 is configured as an access point, it must be running dhcpd on it. You will have to configure BBB to connect to RPi's wifi network and make use of some server client program (Could be in any language) to exchange the data. It should not be very difficult if you know what you're doing. I suggest you to break things in part and conquer, like
If you're able to ping Rpi from BBB and vice versa to check your both wifi configuration.
Once done, how about taking TCP server client code from web and test it to exchange simple strings.
and so on...
Hope it helps.

Related

Proper way to connect to IOT devices (UDP or ICMP)

What is the proper way to connect an app to a device? At the moment, I have a raspberry pi 3 that controls something about electricity and an iPhone app I created. Every time the app goes to foreground, it sends a UDP broadcast message, when the app receives a response from the raspberry pi, it uses that IP address (in the IP header) to consume the web services I created in the hub. This UDP process is done all the time you run the app. Is this what IOT devices usually do? I assume the raspberry pi IP will change sooner or later.
A colleague of mine told me another way: After the first time I get the IP address, instead of using UDP broadcast messages every time the app runs, use ICMP to ping the previously saved IP address to see if it is responding. In that case, I use the web services with that IP address, otherwise, use the UPD broadcast message again.
I don't see the point of that. Basically because the system is not faster using ICMP. (a UDP request is more or less as fast as an ICMP request). Moreover, maybe, another device started using that IP address now (like a smart TV or a smart plug) and for that reason, it is not going to reply to the network requests sent by the app. In that case, the app cannot recover, because it thinks it is already connected to the proper device. As far as I understand, ICMP is a protocol use for diagnosis, not for devices discovery.
What do you think? What's the process used by devices like Alexa, Philips Hue, Smart plugs... to solve the problem of discovering the devices by their apps?
It seems Philips HUE is using SSDP, which under the hood uses a UDP broadcast message. Is it used every time you run the app to discover the IP address? (I am going to check this later with wireshark)
Thanks for suggestions.
You can enable the hostname of your Raspberry Pi to be accessible on your local network through:
http://raspberrypi.local
To enable it, you need to install Bonjour support on your Raspberry Pi by installing the Avahi mDNS daemon (implements Apple's Zeroconf architecture):
$ sudo apt-get install avahi-daemon
Update boot startup:
$ sudo insserv avahi-daemon
Restart to apply the new configuration:
$ sudo /etc/init.d/avahi-daemon restart

How to scan network for devices, using C Obj C or Swift

I have a server running on a Raspberry Pi and a client running on my Mac and iPhone (soon Apple Watch). I would like to connect to my server automatically without finding the Raspberry pi's Ip-address.
Is there a way to lookup all the devices on the network, and select by Mac-address, name or something else? I know that the first 3 bytes of the mac-address is the same for all Pies. (B8:27:EB) Maby i can use that information.
I have been looking for a solution for this issue a while but i can't seem to find one.
Zeroconf (aka Bonjour)
IMO, the best way to do this is to have your Raspberry Pi advertise itself on the network using Zeroconf (aka. Bonjour).
On the Raspberry Pi, install avahi-daemon and configure it to advertise whichever service you'd like to connect to connect to, for example, if you're connecting via SSH, you'll need to do something like this.
In Cocoa, you can use NSNetServiceBrowser to find the advertised service.
Possible MAC Address solution
Alternatively, if Avahi-daemon is not an option, you may be able to use the MAC address. I will not go into the specifics in Objective-C, just a high-level overview using the command-line.
In terminal, type ping 255.255.255.255. You will get back ping packets from every device on the local network. For each IP address, send an individual ping e.g. ping -c 1 192.168.x.x. Then, type arp -a. You will see the MAC address for each IP on the local network. From here, you can perhaps use your MAC address filter to find Raspberry Pis.
Why does this work? Well, the first command ping 255.255.255.255 sends a ping in an IP packet to the 'broadcast' address, which means all machines on the local network respond. When you ping the individual IP addresses, the low-level networking stack uses ARP to find the MAC address of the IP to directly send a ping to it. In doing so, the ARP tables on the local machine are updated with the cached values.
Maybe you can use this method in your app to discover local Raspberry Pis.

connecting 2 Kinect sensors to my notebook

I am trying to connect 2 kinect sensors to my notebook. I know that I have to have at least 2 separate USB 2.0 controllers. According to tis website: LINK I have the same settings as in the picture. So I think that connecting 2 kinect sensors should be possible for me. I have 3 regular USB2 ports and one combined with e-SATA. So I have 4 ports to connect USB devices. However, when I try to connect 2 Kinect sensors (each time into different ports), I am always getting error message on one device (in windows device manager):
This device cannot start. (Code 10)
Can anyone help me please? I do not have any other computer and dont want to buy new just because USB controllers. I thing there has to be a way to do this. Thank you
can you please get a schematic of your notebook's motherboard and double check how your 3 ports are connected to the 2 controllers you mention. Hopefully 1 out of the 3 ports will be connected to a different controller from other 2 ports.
Does your notebook allow you to connect an express card to it ? Perhaps you could get an additional port this way.
With a custom built PC and a PCI Express USB expansion card we've got 3 kinects connected at the same time for an art-installation/robotics project.
I remember though at the time getting 2 Kinects running at the same time on my old 2008 macbook with no problems. Note that this was with either the libfreenect and OpenNI drivers, since the Kinect SDK driver doesn't work on osx.
Also, since you're using the Kinect SDK, I'm guessing you are using either Kinect for Windows (v1 if you will) or Kinect for Xbox360 and not the Kinect 2 for Windows since the current Alpha release of the SDK currently only allows a single sensor.
Update
Had a quick look here:
although couldn't easily find the schematics. My guess is two USB ports are connected to the same controller and the 3rd USB port might(don't take my word for it, check the manufacturers specs) be connected to a separate usb controller, in which case connecting one kinect to one side of your laptop and the other kinect to the port on the opposite should work. Make sure you see both sensors in Device Manager(run devmgmt.msc).
Also, just to double check your sensors as well, try connecting one, running a demo/test, then disconnecting and using a second sensor on the same port.
If both sensors work individually work on the same port, test them also on the usb port on the opposite side. You just want to make sure neither the sensors nor your ports are faulty. Lastly, if your hardware looks fine (power is good, sensors and ports are good), double check your code and me sure you don't accidentally open the same sensor twice or any other mistake that might be easy to miss.
If you have a friend you can either borrow another laptop for a short time just to test that would also be good. You can also try getting an USB Express Cardâ„¢ card for your laptop. Although a long shot, you could try to disable other usb devices on your laptop, leaving as much bandwidth available to the ports as possible. You should be able to do this either from Device Manager or your potentially from BIOS settings.

how to transmit serial data from GPS device to computer through IP?

Well..I have found some third party application regarding sending data from com port to IP. but I have not found any basic tutorial regarding them. so can anyone help me with this? I have a GPS device which I will connect to my laptop through usb to serial adapter.Now I need to send that data from a laptop to another laptop on same network. Can I use putty to view that data in another laptop(receiver)? Is virtual serial port driver meant for this kind of application?
If you do not want to write your own tool for it, you can simply use ncat and set up a daemon that reads piped data from one process and broadcasts it to all connected clients.
If you want something that reads the data from the serial port and then transmits it to clients, you'll need to write a server application that accepts connections and sends data around, but there's entire books on this. It should be easy to do for your purposes as written here, but it depends on the amount of control you need.
Alternatively you can use a virtual serial port application as you had mentioned, which might be the easiest route. The two devices will need to be on the same network unless the application supports TCP based virtualization instead of the common Ethernet based implementation.
This Python script works very well as a free "device server". Just enter the serial port configuration and the IP address and port information.
https://github.com/jaredly/pydbgp/blob/master/symbian/serial_tcp_redirect.py
This can work on both Windows and Linux.
You need pyserial.
You can always try using stand alone hardware such as the SENA LS100 device server.

UDP Hole punching unsuccessful, but tests show it should work (mobile network)

For the past two week I have been unsuccessfully trying to implement udp hole punching, but I'm not sure why. I understand that the algorithm for hole punching is not guaranteed to work, but I believe it should work in my test case because I have noticed that once I bind my socket on my home-network, the port is the same to the outside world as it is locally, and stays that way for all connections made from this socket. Any help after reviewing my trials would be appreciated.
I have three computers, my osx desktop, my iPhone, and my amazon ec2 ami.
on the desktop I've built a cocoa app which uses the GCDAsyncUDPSocket library to bind a port and contact the ec2 server, where a java app using apache's mina library stores the sockets external ip/port and associates it with a username passed in the payload.
the iphone, which is on the AT&T network runs an app which uses the same GCDAsyncUDPSocket library to contact the ec2 server with the same username, which then the ec2 does a lookup for the username, finds the desktops info and informs the desktop of the iphones address and the iphone of the desktops address.
now the iphone & the desktop know about each other they start shooting off packets at each other in hopes to get a punched hole.
in theory this should work, but maybe I am missing something about mobile networks that would make this difficult? But then again running a simple udp echoer on a 4th external computer to manually msg the desktop did not work either, so maybe its my router, but I don't see how that could be as all my tests show that the port the desktop asks for is the same one assigned by the router.
I've been at this for nearly two weeks with little progress and any tips would be appreciated!
"once I bind my socket on my home-network, the port is the same to the outside world as it is locally"
I highly doubt that. To traverse NAT given peers A and B which have sent datagrams to a 3rd party: S you need to send datagrams from A to B and vice versa using their public IPs as seen by S and their port as seen by S (i.e. not the port A, B are bound to from their point of view).