aREST
aREST copied to clipboard
aREST returning arrays
I have a sensed value that is an array of measured statuses
Looks like this int FLowOn[]={1,0,1,1,1,0,1,1}; Is it viable as an arest.variable(FLowOn, &FlowOn) ??
Thanks Theo
Looking at the code, arrays are not supported. Only simple type are. But String are. So you can just declare a string and serialize the data in it. Based on your example, it would look like that: String FlowOn="0101111"; you'll then add the setup of the string into the setup function: rest.variable("FlowOn", &FlowOn); and when you'll call the arest function you'll get Something like: {"variables": {"temperature": 24, "humidity": 40, "FlowOn": "0101111"}, "id": "1", "name": "esp8266", "hardware": "esp8266", "connected": true} I just added the 2 lines of code in the basic ESP8266 example and run it. You'll then have to convert your serialized string into a table again
Hello, indeed for now at least arrays are not supported, but the method given by @Ellerbach is great! :) I'll mark that as a feature request :)
Hi @marcoschwartz I found a way to allow the functions to return String. I modified the arest.h and additionally I had to comment out one of the templates that are in the end of the file. How can I make sure if what I did is ok or if I need to rename the function in order not to comment out that template? Are those templates in the end of the file mandatory?