Adding reflection

fetching variable values (or executing function) through a REST API is a great feature but for this to be more useful when you have multiple cores logging different type of data it would be great to add a reflection api.

So I set ut to add the code into the core. However when I started to implement it I found that there is already some code present in spark_protocol.cpp that does this. There is a CoAPMessageType::DESCRIBE message type that returns the function names, variables and types.

To try it out I added some code that returned this info when requesting a string with name ‘~’ and got (with a slightly changed main program)

“result”: “{“f”:[“digitalread”,“digitalwrite”,“analogread”,“analogwrite”],“v”:{“temperature”:9,“humidity”:9,”~":4}}"

So my question is how to access this cool information through the rest API?

Hi @madlers

If understand your question correctly, you want to read this doc

And then use


Where 48…12 is replaced by your device id and 01234…56789 is replaced by your access token.

This will return something like this:

  "id": "48...12",
  "name": "your_core_name",
  "connected": true,
  "variables": {},
  "functions": []

If you leave off the device id from the request, you get all your devices.

1 Like

Yes, thats exactly what I was looking for. I missed it completely when reading the documentation (I was looking further down at the variable and function section).


1 Like