3 Replies Latest reply on Jul 14, 2015 12:26 AM by tonu

    Unable to receive data from cloud(https://dashboard.us.enableiot.com/ui/auth#/login)

    tonu

      Hi,

      I am using Intel edison with arduino board. Using Arduino IDE I am trying to connect to cloud(Intel iot dashboard website).

      I have connected edison to internet via cellphone hotspot(--wifi option).

      I am able to send data for sensors and actuators but unable to receive data for actuators(using default powerswitch.v1.0 as alias  "power").

      I have taken all the necessary steps like activating device,connecting via mqtt protocol, registering component as power etc. and following these instructions  https://software.intel.com/en-us/intel-iot-developer-kit-cloud-based-analytics-user-guide


      I am creating and sending actuator requests.

       

      I suspect it is unable to call the callback function as in the code given below.

      --------------------------------------------------------------------------------------------------------------------------------------------

       

       

      #include <IoTkit.h>    // include IoTkit.h to use the Intel IoT Kit

      #include <Ethernet.h>  // must be included to use IoTkit

      #include <aJSON.h>

      #include <stdio.h>

       

       

      // create an object of the IoTkit class

      IoTkit iotkit;

      int temp;

      char buf[112];

       

       

      void setup() {

        Serial.begin(115200);

        // call begin on the IoTkit object before calling any other methods

        iotkit.begin();

        delay(10500);

        iotkit.send("power", 1);

      }

       

       

      void loop() {

       

        Serial.println("inside loop");

        int a=iotkit.receive(callback);

       

        Serial.println(a);

        delay(5000);

      }

       

       

      void callback(char* json) {

       

       

        Serial.println("inside callback");

        Serial.println(json);

        aJsonObject* parsed = aJson.parse(json);

        if (&parsed == NULL) {

          // invalid or empty JSON

          Serial.println("recieved invalid JSON");

          return;

        }

       

        aJsonObject* component = aJson.getObjectItem(parsed, "component");

        aJsonObject* command = aJson.getObjectItem(parsed, "command");

        aJsonObject* argv = aJson.getObjectItem(parsed, "argv");

        aJsonObject* argvArray = argv->child;

        aJsonObject* name = argvArray->child; // name : on

        aJsonObject* value = name->next; // value: 1/0

       

        if ((component != NULL)) {

          if (strcmp(component->valuestring, "power") == 0) {

            if ((command != NULL)) {

              if (strcmp(command->valuestring, "LED.v1.0") == 0 && strcmp(value->valuestring, "0") == 0) {

                Serial.println("Light Off!");

                pinMode(13, OUTPUT);

                digitalWrite(13, false);

              }

              if (strcmp(command->valuestring, "LED.v1.0") == 0 && strcmp(value->valuestring, "1") == 0) {

                Serial.println("Light on!");

                pinMode(13, OUTPUT);

                digitalWrite(13, true);

              }

            }

          }

        }

      }