Select Resource is not avaiable in RPI-3


#1

I am trying to use thinger in RPI-3
I have followed the basic tutorial.
When I try to create a dashboard, the Select Resource option does not appear.

Anybody has the same problem?


#2

Hi, the basic example for RPI3 does not add any output resource, so you cannot plot any information on the dashboard by default. Try to add a sample output resource, like the following, that will generate a random number:

  thing["random"] >> (pson& out){
        out = rand(); // or just a fixed number (out = 3;)
  };

You many need to include the following header for using rand.

#include <stdlib.h> 

Hope it helps!


#3

Hello

I had the same doubt, and i tried the example that you wrote, but when i compile the coding i get some errors.

My code:

#include "thinger/thinger.h"
#include <stdlib.h>

#define USER_ID             "asdasd"
#define DEVICE_ID           "asdasd"
#define DEVICE_CREDENTIAL   "asdasd"

int main(int argc, char *argv[])
{
    thinger_device thing(USER_ID, DEVICE_ID, DEVICE_CREDENTIAL);

    // define thing resources here. i.e, this is a sum example
    thing["sum"] = [](pson& in, pson& out){
        out["result"] = (int) in["value1"] + (int) in["value2"];
    };
    thing["random"] >> (pson& out2){
        out2 = rand(); // or just a fixed number (out = 3;)
    };
    thing.start();
    return 0;
}

The errors:

/home/pi/Linux-Client/src/main.cpp: In function ‘int main(int, char**)’:
/home/pi/Linux-Client/src/main.cpp:39:29: error: expected primary-expression before ‘&’ token
thing[“random”] >> (pson& out2){
^
/home/pi/Linux-Client/src/main.cpp:39:31: error: ‘out2’ was not declared in this scope
thing[“random”] >> (pson& out2){
^
CMakeFiles/thinger.dir/build.make:62: recipe for target ‘CMakeFiles/thinger.dir/src/main.cpp.o’ failed
make[3]: *** [CMakeFiles/thinger.dir/src/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/thinger.dir/all’ failed
make[2]: *** [CMakeFiles/thinger.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target ‘CMakeFiles/thinger.dir/rule’ failed
make[1]: *** [CMakeFiles/thinger.dir/rule] Error 2
Makefile:118: recipe for target ‘thinger’ failed
make: *** [thinger] Error 2

Any help?


#4

Sorry, the resource was wrong. It should be:

thing["random"] >> [](pson& out){
  out = rand(); // or just a fixed number (out = 3;)
};

Hope it helps!


#5

Thanks :smiley:
It works
Now to find out hoy to read and write GPIO in C++