Headless Operation

Note that the runtime properties are "sticky". You only need to specify them once during setup, when you launch the application the next time it will use those settings. It's easier to setup the server with the GUI first, then switch to headless. For example, on smaller systems like an rPI

this might work: http://lxde.org/.

So to configure use the GUI to set it up, discover your wemos, register your clients. If you can't run a GUI, use the "-cli" flag for an interactive command mode. Once you've got things configured and running the way you want them start the headless server using the "-run" flag for normal operation. The settings from the GUI or CLI are persisted and will be used by the server.

On a RaspberryPi (thanks Alex!):

  1. login as pi
  2. install java with sudo apt-get update && sudo \ apt-get install oracle-java7-jdk
  3. install (copy) the jar file to the pi
  4. start LXDE with startx and run the java app in a terminal window with your normal command
  5. configure WemoServer (see below)
    • in particular ensure the host address and GPS location are correct
  6. don't run it normally in the X - the logging window cripples the pi performance
  7. exit/terminate the server
  8. edit rc.local with the sudo -u pi command below. You may want to redirect for long running operation with:

> /dev/null 2>&1 &


For headless (no gui) operation, use (note the use of -cp vs -jar):

  • for help:

java -cp WemoServer.jar mpp.wemo.server.Headless -help

  • to run the server

java -cp WemoServer.jar mpp.wemo.server.Headless [-port port] [-event port] -run [-log] [-upnp] [-windows]

e.g. to run on port 4033 with the log written to stdout:

java -cp WemoServer.jar mpp.wemo.server.Headless -port 4033 -run -log

where:

-upnp - enables Upnp discovery (port 1900 must be available on your server)

-windows - checks the windows network neighborhood, you need to have enabled Upnp discovery on windows and refreshed it recently

-event is for the event port (see WemoCLI)

-gcmProject for your GCM project number (or 0 to disable) (deprecated)

-gcmApiKey for the server authorization key (deprecated)

  • to run an interactive command line to register clients and wemos

java -cp WemoServer.jar mpp.wemo.server.Headless -cli

use the commands help, list, quit as needed

  • to use "Finding Wemo"

java -cp WemoServer.jar mpp.wemo.server.Headless -wemo ipAddress

e.g.:

java -cp WemoServer.jar mpp.wemo.server.Headless -wemo 192.168.0.146

  • to forget a device

java -cp WemoServer.jar mpp.wemo.server.Headless -udn udnString

e.g.:

java -cp WemoServer.jar mpp.wemo.server.Headless -udn Socket-1_0-221219K01007AB

  • to forget all devices

java -cp WemoServer.jar mpp.wemo.server.Headless -clear

  • to accept or remove a remote client (use WemoRemote to register):

java -cp WemoServer.jar mpp.wemo.server.Headless -accept clientId

java -cp WemoServer.jar mpp.wemo.server.Headless -remove clientId

e.g.:

java -cp WemoServer.jar mpp.wemo.server.Headless -accept b0e826a96401f9d0

java -cp WemoServer.jar mpp.wemo.server.Headless -remove b0e826a96401f9d0

  • to set your location:

java -cp WemoServer.jar mpp.wemo.server.Headless -latitude d.ddd -longitude d.ddd

  • to set your device's IP address (needed for event callbacks from wemo), reserve in your DHCP server:

java -cp WemoServer.jar mpp.wemo.server.Headless -ip nnn.nnn.nnn.nnn

  • to list devices and clients:

java -cp WemoServer.jar mpp.wemo.server.Headless -list