Thank you all for the feedback - I'm working on a new local server and firmware to go with it, it is about 75% done and based heavily on some contract work I've done over the last 6 months - I hope to finish it late this week or early next.
Here is the work in progress readme for it that outlines the functionality - it is written in Javascript and runs on Node.JS with no binary dependencies so it will work on any platform node works on without hassle. It can use a built in sqlite database or a mysql server for data storage which makes it possible to integrate with the database directly as well as the API - more to come!
**SUBSCRIBE**
POST to /subscribe/[key]
POST body is URL for Webhook or ID,CallbackSlot for Device
or stumpSubscribe(String key, StumpCallbackFunction) returns true/false
callback function: void callback(String data)
**UNSUBSCRIBE**
POST to /unsubscribe/[key]
POST body is URL for Webhook to unsubscribe
or stumpUnsubscribe() returns true/false - unsubscribes from ALL events the device is subscribed to
**PUBLISH**
POST to /[key]
POST body is data
OPTIONAL:
OPTIONAL: add ?from=NAME to set the name of who/what published that data (automatically set for devices). "from" cannot contain any commas, newlines, or similar
or stumpPublish(String key, String data) returns true/false
**DEVICE SPECIFIC COMMANDS**
To publish to a specific device do a publish to /devices/DEVICE_ID - this data will be sent to the device's callback set by stumpDeviceMessage() in the device sketch and not available anywhere else
To reboot a device publish any data to /devices/DEVICE_ID/reboot
To flash a device programatically POST the .bin file you'd like to flash to /devices/DEVICE_ID/flash - returns 200 regardless of whether it flashes.
The device will check to see if it is different then current firmware first so calling periodically will not result in continously flashing the device.
The file will be set to the new firmware for the device (until overridden from a command or the Arduino IDE), so when the device checks in after power on/reboot it will update if it is not yet current.
**DEVICE GROUPS FOR FLASHING**
To add a device to a group (or create a new group) POST the DEVICE_ID to /groups/GROUP_NAME
To remove a device from a group GET to /groups/GROUP_NAME/DEVICE_ID
To reboot a group publish any data to /groups/GROUP_NAME/reboot
To flash a group programatically POST the .bin file you'd like to flash to /groups/GROUP_NAME/flash - returns 200 regardless of whether it flashes.
The device will check to see if it is different then current firmware first so calling periodically will not result in continously flashing the device.
The file will be set to the new firmware for devices in that group (until overridden from a command or the Arduino IDE), so when a device checks in after power on/reboot it will update if it is not yet current.
If the flash device is used after a flash group or vice versa, the most recently uploaded file will be sent to that device.
**GET CURRENT DATA**
GET to /[key]
or stumpGet(String key) returns data as String
**GET RANGE OF DATA**
GET to /[key]?start=DATETIME&end=DATETIME
where DATETIME is any string the works with PHP's strtotime() (
http://php.net/manual/en/function.strtotime.php) - NOTE: strtotime() is not actually used, but acceptable syntax should be identical
omitting end (or setting it to "all") will return all results from the defined start through the current time
omitting start (or setting it to "all") will return all results until the defined end
GET to /[key]?limit=X
where X is the number of results you want returned will return X newest results (or less if X are not available) - can combine with start or end
omitting all three options will return only the most recent result - use ?start=all and omit end or set it to "all" to get all results
**GET DATA ONLY FROM ONE DEVICE/CLIENT**
GET to /[key]?from=NAME
**KEY RULES**
Must be valid URL characters (rfc3986) or URL encoded, may not contain an asterisk (see wildcards).
Cannot start with "subscribe/", "device/", or "stream/"
Wildcards: Use a wildcard/asterisk "*" at the end of a key to get all keys that start with that key (inclusive) - only a single wildcard may be used and only at the end of a key
GET to /* will get the most recent data from any key. Use /* with other options to get a range of all data.
**GET FORMATS**
You can optionally append the following to a get request URL for various formats:
?type=json [DEFAULT]
Returns a json object (or array of objects for multiple results) that includes key, data, from, and timestamp.
?type=csv
Returns a csv file with one line per result in the following format - key, data, from, and timestamp. Double quotes will enclose the data.
?type=csvh
Returns a csv file with one line per result in the following format - key, data, from, and timestamp. Double quotes will enclose the data. The first line will be a header with the field names.
?type=raw
Returns a plaintext file with only the data on one line per result
**WEBSOCK**
Open a websocket connection to /[key] to open a websocket connection for all new events sent to that key.
NOTE: when it first opens there may be no data shown, it will not show until a new data item is published to that key
Wildcard can be used on this as well. GET to /* will get new data for all keys.
This will always use JSON format and will send one event at a time.
SPECIAL CASE: Open a websocket connection to /debug to get all new events and debuggin info on connections and other actions