0

Here's my situation:

  • I wrote a desktop app using nw.js (a node.js-based platform to write desktop apps within an offline Chromium browser that has access to the file system). Users will make 'projects' with this app. What's relevant for now is that the data used to represent each "project" is saved as a JSON formatted file on the user's computer.
  • I want users to click on a button that says "Upload Project", select one of their projects from a list, and transfer that JSON formatted data file to a Raspberry Pi.
  • The Pi will be running a program at boot that uses the JSON file to do fun stuff.

I'm kind of stuck right now. This needs to be user friendly. This app will be packaged and distributed to several people who don't know how to navigate a file system, let alone set up a Pi to work on their personal WiFi and SSH in. I need a way to transfer the JSON data file from their PC to the Pi.

The solution:

  • does not depend on wifi. Anyone should be able to use this anywhere, so it should be wired. Some sort of USB-to-serial cable, ethernet cord, or something is probably the most user friendly way to go. This wired solution would connect from their computer to the Pi.
  • allows their computer to detect what drive the aforementioned cable is connected to.
  • is auto-detected by the Pi. When I plug that wire in, the Pi should know it's there immediately and take the file offered to it (or request the file it needs).
  • should dump the file in a place the Pi can reach it, even after the cable is disconnected.

So yeah, this is a big question. What's the best hardware for this job? How do I tell the PC where to look? How do I tell the Pi where to look? How do I make this automatic and somewhat user-friendly/universal?

  • How about a flash drive they are automatically mounted and don't require any kind of network. – Steve Robillard Apr 13 '16 at 0:16
  • I'll default back to this if the answer below doesn't work. Good to have options! Thanks. – Ryan Schuster Apr 14 '16 at 13:37
1

As long as you're using Raspbian, connecting directly to a PC using an ethernet cable should just work provided you put in a little legwork. The best/easiest route is, I think, to use avahi. This will allow you to connect to a Pi over an ethernet cable using its hostname (e.g. raspberrypi.local). There's a set of instructions on the elinux.org RPi Advanced Setup page on setting up avahi.

You can figure out which Pi/drive you're connected to by creating unique hostnames for the Pi's. When connecting to a given Pi from the PC you'll use raspberrypi1.local, raspberrypi2.local, etc.

Provided you've created a folder on the Pi which is fully read/writeable by the PC (likely using samba), the Pi will happily accept any file sent there from the PC with no intervention.

My understanding of your language of choice is limited. I think you should be able to use the Node.js Child Process functions to launch net view in a shell. The stdout message from this should give you a list of connected devices. Parsing this list should allow you to determine whether one of your Pi's is connected and, if you've set up unique hostnames, which Pi it is.

Something like:

User presses Upload
Program runs `net view`
Program parses output
If output contains 'MyPi[x]'
   Write file to public folder
Else
   Show error 'Please connect a Pi'
  • This sounds like a good, comprehensive answer! I might get stuck on a couple points, but you gave me enough info to find my way out of it. Will try this tonight and see what happens. – Ryan Schuster Apr 14 '16 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.