luna-send

luna-send is a command-line tool accessible through a shell on the Emulator or a device. luna-send is mainly used to test calls to services accessible on the device bus through the Luna System Manager.

If your app is going to call services, luna-send is a good way to learn service API syntax and experiment; after, you can write the code to do what you already did at the command line.

See Device Shell for information about opening a shell on a device or the Emulator.

See webOS Service APIs for a list of services available to 3rd party apps.

Another useful tool for testing services is ls-monitor, which lets you see traffic going over the webOS service bus, similar to a network sniffer that lets you observe HTTP traffic.

Usage

luna-send [OPTIONS...] URL '{JSON object}'

Options

 -h this help screen
 -P send over the public bus (send over private bus is default)
 -s send a signal
 -a send specified appId in message (default is none)
 -m service name (default is none)
 -d turn debug logging on
 -i turn on interactive mode
 -t x average over x times getting one response
 -n x exit interactive mode after x replies
 -l number responses
 -f format JSON responses usefully
 -q apply specific query to responses (multiple queries may be supplied), e.g.:
        -q 'returnValue' -q 'queues[0]'

Usage Notes

For testing services accessible to 3rd party apps, always use the -P option to send on the public bus. The private bus is reserved for com.palm applications.

The -a option (impersonate app) is useful with services like DB8 where the app ID is used to determine ownership access to data resources.

You usually want to specify either -n 1 or -i. This lets you see responses from the service. If you do interactive mode, you will need to hit Ctrl+C to exit the tool.

The -f switch (format JSON response) is really useful for services that return a lot of data, for example, the Download Manager's listPending call.

Here's an example - call the Download Manager to download a website file:

luna-send -P -n 1 palm://com.palm.downloadmanager/download '{"target":"http://example.com/file.mp3"}'

The single quotes around the JSON body are very important - it tells the shell to group everything inside as a single argument and not to interpret any inside characters as special. JSON requires double-quoted strings, so use those inside.

To do the same download but see status updates as it downloads, you would code:

luna-send -P -i palm://com.palm.downloadmanager/download '{"target":"http://example.com/file.mp3", "subscribe":true}'

The two changes here are using full interactive mode (-i) and adding "subscribe":true to the request. You would have to exit the luna-send tool once you get the final response to get back to the shell prompt.

Examples

  luna-send -n 1 -P -a com.palm.contacts luna://com.palm.db/delKind '{"id":"com.palm.test:1"}'
  {"returnValue":true}

  luna-send -f -P -i palm://com.palm.location/getCurrentPosition '{"subscribe":true}'
  {
      "altitude": 0,
      "errorCode": 0,
      "heading": 0,
      "horizAccuracy": 20,
      "latitude": 37.390196,
      "longitude": -122.037845,
      "returnValue": true,
      "timestamp": 2147483647,
      "velocity": 0,
      "vertAccuracy": 0
  }

  luna-send -n -i -P palm://com.palm.keys/audio/status '{"subscribe":true}'
  { "returnValue": true, "subscribed": true }
  { "key": "volume_up", "state": "down" }
  { "key": "volume_up", "state": "up" }
  . . .