About

This is an example of implementing REST and JSON-RPC services for a Particle Photon System-On-Module. The intent of this example is to demonstrate μcuREST capabilities and show technics for implementing various REST resources with μcuREST: plain variables, objects, custom-stringified variables (such as IP and MAC addresses), web pages and binary data.

This example exposes a set of URI’s for communicating between the SOM and the browser.

URI Methods Description
/io GET Returns bootstrap html page with embedded io data
/* All [1], [2] Returns states of all inputs/outputs as a JSON object
/d/* All Returns/controls states of all digital outputs (D0-D11) as a JSON array
/d/<N> All Returns/controls state of digital output D<N>, where <N> is 0 to 11
/a/* GET Returns states of all analog inputs (A0-A9) as a JSON array
/a/<N> GET Returns state of analog input A<N>, where <N> is 0 to 9
/rpcc GET Returns html page with JSON-RPC web console
/rpc PUT Exposes JSON-RPC API
/meta/rpc GET Returns a list with all functions of JSON-RPC API
/meta/const GET Returns a list of constants
/demo GET Returns bootstrap html page with an enum - list of pin modes
/logical All Returns/accepts content of variable[3] bool logical
/natural All Returns/accepts content of variable unsigned natural
/text All Returns/accepts content of variable char text[32]
/mode All Returns/accepts content of variable enum mode_t mode
/modes GET Returns list of enum mode_t values
/mac All Returns/accepts content of variable mac_addr mac
/ip All Returns/accepts content of variable ip_addr ip
/rtc All Returns/accepts data from/to PLC’s Real Time Clock
/blob All Returns/accepts binary object – content of array byte blob[1400]

For more information about μcuREST please visit these links:

Source code for this example can be found on github.



[1] All supported method: GET/PUT/POST
[2] POST/PUT data must not include sections a and in
[3] All variables are allocated on PLC’s RAM