Simple example showing interaction between Agent and Device

I’ve read all documentation about Agents and most of it I don’t understand at all.
I found 1 example (Twillo), but when I past this in the IDE I get a compile error.
Does anyone has a complete example showing a simple interaction between Agent and Device (only server logs will be ok), so a can see a working model. The docs I’ve read are mostly partial, so I can’t do anything with it.

For instance, the Mailgun example does work, but I can’t figure out how to call it from the program.

EXAMPLE STOCK TICKER HTTP IN/OUT
http://forums.electricimp.com/discussion/618/example-stock-ticker-http-inout#Item_1

Also I did this interaction digram might help
http://forums.electricimp.com/discussion/693/agent-imp-interaction-diagram#Item_1

thanks.

I did try your stockticker, but I don’t have the required hardware, but I will look closer into the code to make something out of it (maybe serverlogs as output).

The diagram looks promising but maybe it is too difficult for me to understand as an AgentDummy

Try this diagram and see if it makes sense. Follow the flow counter clockwise with the http incoming request on the left and down and the returning data coming up the right hand side back to the calling host. I am using this to pass data from a host to a serial device and sending the serial data response back to the host in the response. The incoming data in the http is urlencoded, so use urldecode to get it back to plain text at some point in the flow.
If someone has a better way to do this, I would appreciate any suggestions. Note that I had to put a bit more complex timer logic to respond back to the host after 4 seconds if the Serial Device died or does not respond quickly so the web page does not just hang. Let me know if anyone wants to see that code.

thanks apineda,
this diagram is exactly the kind of example of what I’m looking for.
I suppose you all won’t see me on this board for a while.
thanks again

apineda neat digram =;

as this is exactly one of the scenarios I need, would be nice to have a peek at the code (still getting used to this squirrel language :slight_smile:

Dirk

I will try to make a working example based on this diagram

I have trimmed aloharich’s EXAMPLE STOCK TICKER HTTP IN/OUT to use it without the Emma hardware. It logs the called functions and dataflow.
first file is the agent code, second is device code
to send commands to the Agent I use the Simple REST Client Chrome extension

No problem, I have attached some sample code with lots of comments:
SerialGatewayAgent.txt = agent code
SerialGatewayDevice.txt = device code
SerialGateway_test.txt = change to “.html” to send test data in (must run in web server somewhere)

thanks apineda,
works great!