5 Replies Latest reply on Mar 25, 2015 11:36 AM by ForumMigrationAdmin

    Trouble with registration to the cloud - Galileo

    ForumMigrationAdmin

      I am reposting this as a separate topic, I had posted this originally under the topic "Connecting BeagleBone Black" where some registration problems were discussed, but figured it was a bit confusing since I am having trouble with the Galileo board and not BeagleBone.

      I am trying to get my Galileo to register with the cloud. I upgraded my node on Galileo to 0.10.22 and I am able to fire up agent.js etc. I followed the steps to get the mac addr and registered a device in my enableiot account - All good.

      When I reboot galileo, everything fires up fine, but what is happening is that the Status returned for my device is "FALSE".  to be clear, here is the snippet of code from cloud.js:

      ---

      me.client    

      .subscribe(me.topics.status)    

      .on('message', function(topic, message) {      

      me.logger.info('STATUS: %s', topic, message);      

      var regStatus = JSON.parse(message);       // Check registration status is true and device_id is ours

       

      if(regStatus !== undefined &&        regStatus.response !== undefined &&    regStatus.response.status &&          regStatus.response.device_id == me.deviceId){

      ...

      ...   

      ---etc.

      I am getting the response.status as FALSE. The accountid being returned for my galileo board's mac addr is correct, so it looks like it is looking it up correctly in the cloud, but the status returned is false.

      Here is the registration packet I am sending:

      {"protocol_version":"1.0","timestamp":1398128594081,"sender_id":"98-4F-EE-00-0F-A2","msg_type":"device_registration_msg","properties":{"hardware_vendor":"Intel(R) Quark SoC X1000 CPU @ 339MHz","hardware_model":"linux","Model Name":"ia32","Firmware Version":"3.8.7-yocto-standard"},"peripherals":[{"uuid":"self","type":"gateway","properties":{},"services":[{"name":"98-4F-EE-00-0F-A2-sensor","version":"1.0"}]}],"service_metadata":[{"loaded":true,"capabilities":[],"enabled":true,"name":"98-4F-EE-00-0F-A2-sensor","version":"1.0","metrics":[]}]}

      I hardcoded the "hardware_vendor" string, since os.cpus[0].model is returning "05/09" in my Galileo.Not sure it matters though, I am still having the status returned as false.

      And this is the response:

      Note, my account Id being returned is fine, so I know I registered it correctly.

      2014-04-22T01:03:23.809Z - info: STATUS: /server/registration_status {

        "response" : {

          "device_id" : "98-4F-EE-00-0F-A2",

          "account_id" : "pravici",

         "status" : false

        },

        "msg_type" : "device_registration_status_msg",

        "sender_id" : "SVUUID00000001",

        "timestamp" : 1398128725099

      }

       

      What could be the problem ?.

       

        • 1. Re: Trouble with registration to the cloud - Galileo
          ForumMigrationAdmin

          sorry, not completely clear to me: to which cloud do you aim to connect?

          BTW: pls post codes in code blocks [see description below comment box]

           

          e.g. "\[bash\] / \[/bash\]" for bash

          example - bash "dice game":

           

          1echo "dice - quit (q)"; while true; do echo $((RANDOM % 6 + 1)); read -t 2 -n 1 -s q; if [ [ $q == "q" ] ] ; then break; fi; done

           

           

          • 2. Re: Trouble with registration to the cloud - Galileo
            ForumMigrationAdmin

            Hello Mathias,

            I am trying to connect to the Intel IOT Cloud Analytics as documented in https://software.intel.com/sites/default/files/managed/42/1f/IoT_Developer_Kit-Cloud_Analytics_Getting_Started_Guide.pdf.

            I managed to get step 2.1 "Download and install jot kit agent" done successfully. As specified there, I made a note of the Mac Addr of my Galileo (Step 6 of 2.1).

            I also completed step 2.2 successfully, and was able to login and create my account. Again, in step 2.3, I correctly specified the Gateway to be the Mac Address from Step 6 of 2.1. In my case, it is "98-4F-EE-00-0F-A2".

            When I reboot my Galileo as specified in step 4 of 2.3, Galileo comes up but it seems to have a problem successfully connecting to the cloud. I looked at forever.log, and here is the JSON returned from the cloud:

            2014-04-22T01:03:23.809Z - info: STATUS: /server/registration_status {

              "response" : {

                "device_id" : "98-4F-EE-00-0F-A2",

                "account_id" : "pravici",

                "status" : false

              },

              "msg_type" : "device_registration_status_msg",

              "sender_id" : "SVUUID00000001",

              "timestamp" : 1398128725099

             

            As you can see, it looks like it is correctly identifying my Galileo MAC Addr with my account_id ("pravici") but the "Status" is returned as "FALSE".

             

            When I look at the following snippet of code in cloud.js since regStatus.response.status is "FALSE", m.registrationCompleted is never set to TRUE.

             

             

            01me.client = mqtt.createSecureClient(port, host, args);

             

             

            02  me.logger.info('Cloud client created');

             

             

            03

             

             

            04  me.topics = {

             

             

            05    reg: conf.reg_topic || '/server/registration',

             

             

            06    status: conf.status_topic || '/server/registration_status',

             

             

            07    metric: conf.metric_topic || '/server/metric/'

             

             

            08  };

             

             

            09

             

             

            10  me.registrationCompleted = false;

             

             

            11                           

             

             

            12  me.client

             

             

            13    .subscribe(me.topics.status)

             

             

            14    .on('message', function(topic, message) {

             

             

            15      me.logger.info('STATUS: %s', topic, message);

             

             

            16      var regStatus = JSON.parse(message);

             

             

            17      // Check registration status is true and device_id is ours

             

             

            18      if(regStatus !== undefined &&

             

             

            19         regStatus.response !== undefined &&

             

             

            20                         regStatus.response.status &&

             

             

            21         regStatus.response.device_id == me.deviceId){ 

             

             

            22        me.accountId = regStatus.response.account_id;

             

             

            23        me.topics.metric = '/server/metric/' + me.accountId + '/' + me.deviceId;

             

             

            24            me.sensorsStore.saveSensorsList(me.sensorsList);

             

             

            25        me.registrationCompleted = true;

             

             

            26        me.logger.info('Devices registered successfully');

             

             

            27      }

             

             

            28    });

             

             

             

            I put some debug script in cloud-message.js, sent the "msg" to console.log in the code snippet below:

             

             

             

            01IoTKitCloudMessages.prototype.getRegMsg = function(deviceId, deviceName, dataSrcName, sensorList) {

             

             

            02  var me = this;

             

             

            03

             

             

            04  if (!deviceId){

             

             

            05    me.logger.error("Null argument (deviceId)");

             

             

            06    return;

             

             

            07  }

             

             

            08

             

             

            09  if (!deviceName) deviceName = deviceId;

             

             

            10  if (!dataSrcName) dataSrcName = deviceName + "-sensor";

             

             

            11

             

             

            12  var sensorArray = [];

             

             

            13  for (var sensorName in sensorList) {

             

             

            14      sensorArray.push(sensorList[sensorName]);

             

             

            15  }

             

             

            16

             

             

            17  var msg = {

             

             

            18    "protocol_version": "1.0",

             

             

            19    "timestamp": me.utils.getTimeStamp(),

             

             

            20    "sender_id": deviceId,

             

             

            21    "msg_type": "device_registration_msg",

             

             

            22    "properties": {

             

             

            23      /* "hardware_vendor": os.cpus()[0].model, */

             

             

            24      "hardware_vendor": 'Intel(R) Quark SoC X1000 CPU @ 339MHz',

             

             

            25      "hardware_model": os.platform(),

             

             

            26      "Model Name": os.arch(),

             

             

            27      "Firmware Version": os.release()

             

             

            28    },

             

             

            29    "peripherals": [

             

             

            30      {

             

             

            31        "uuid": "self",

             

             

            32        "type": "gateway",

             

             

            33        "properties": {},

             

             

            34        "services": [

             

             

            35          {

             

             

            36            "name": dataSrcName,

             

             

            37            "version": "1.0"

             

             

            38          }

             

             

            39        ]

             

             

            40      }

             

             

            41    ],

             

             

            42    "service_metadata": [

             

             

            43      {

             

             

            44        "loaded": true,

             

             

            45        "capabilities": [],

             

             

            46        "enabled": true,

             

             

            47        "name": dataSrcName,

             

             

            48        "version": "1.0",

             

             

            49        "metrics": sensorArray

             

             

            50      }

             

             

            51    ]

             

             

            52  };

             

             

            53  var newmsg = JSON.stringify(msg);

             

             

            54  console.log("REG MSG IS: " + newmsg);

             

             

            55  return msg;

             

             

            56};

             

             

            57

             

             

            58

             

             

             

            Here is the msg from console.log (output of the line console.log("REG MSG IS: " + newmsg);). This is the registration JSON message my Galileo is sending to the cloud:

             

            {"protocol_version":"1.0","timestamp":1398128594081,"sender_id":"98-4F-EE-00-0F-A2","msg_type":"device_registration_msg","properties":{"hardware_vendor":"Intel(R) Quark SoC X1000 CPU @ 339MHz","hardware_model":"linux","Model Name":"ia32","Firmware Version":"3.8.7-yocto-standard"},"peripherals":[{"uuid":"self","type":"gateway","properties":{},"services":[{"name":"98-4F-EE-00-0F-A2-sensor","version":"1.0"}]}],"service_metadata":[{"loaded":true,"capabilities":[],"enabled":true,"name":"98-4F-EE-00-0F-A2-sensor","version":"1.0","metrics":[]}]}

             

            The only change I made in the code that sends the msg string was the following:

             

             

             

            1      /* "hardware_vendor": os.cpus()[0].model, */

             

             

            2      "hardware_vendor": 'Intel(R) Quark SoC X1000 CPU @ 339MHz',

             

             

            3

             

             

             

            The reason was, in my Galileo os.cpus()[0].model was returning the string "05/09" which looked strange, so I thought I will change that to a more meaningful string. Anyway, I tried with and without the above change, seems to make no difference. I am always getting the status to be returned as "FALSE".

             

            When I log into my cloud account and check the status of my device it says "Not Registered".

             

            Can you help me debug this issue ?. Many thanks.

             

             

            • 3. Re: Trouble with registration to the cloud - Galileo
              ForumMigrationAdmin

              Update: Resolved the issue! The only change I made is to set the time correctly on my Galileo to Local Time (AZ time for me). Now it was able to register itself.

              • 4. Re: Trouble with registration to the cloud - Galileo
                ForumMigrationAdmin

                thanks for the update and great you got it working fine

                • 5. Re: Trouble with registration to the cloud - Galileo
                  ForumMigrationAdmin

                  Hi ,

                  I am facing the same issue to register with cloud here is the logs:

                   

                  2014-06-04T12:03:23.849Z - info: IoT Kit Cloud Agent:  98-4F-EE-00-08-D2
                  2014-06-04T12:03:24.828Z - info: Cloud client created
                  2014-06-04T12:03:24.894Z - debug: Reg doc: {"protocol_version":"1.0","timestamp":1401883404879,"sender_id":"98-4F-EE-00-08-D2","msg_type":"device_registration_msg","properties":{"hardware_vendor":"05/09","hardware_model":"linux","Model Name":"ia32","Firmware Version":"3.8.7-yocto-standard"},"peripherals":[{"uuid":"self","type":"gateway","properties":{},"services":[{"name":"98-4F-EE-00-08-D2-sensor","version":"1.0"}]}],"service_metadata":[{"loaded":true,"capabilities":[],"enabled":true,"name":"98-4F-EE-00-08-D2-sensor","version":"1.0","metrics":[]}]}
                  2014-06-04T12:03:24.900Z - debug: SEND: /server/registration protocol_version=1.0, timestamp=1401883404879, sender_id=98-4F-EE-00-08-D2, msg_type=device_registration_msg, hardware_vendor=05/09, hardware_model=linux, Model Name=ia32, Firmware Version=3.8.7-yocto-standard, peripherals=[uuid=self, type=gateway, , services=[name=98-4F-EE-00-08-D2-sensor, version=1.0]], service_metadata=[loaded=true, capabilities=[], enabled=true, name=98-4F-EE-00-08-D2-sensor, version=1.0, metrics=[]]
                  2014-06-04T12:03:24.926Z - info: Starting listeners...
                  connect: methodOverride: use method-override module directly
                  2014-06-04T12:03:28.381Z - info: REST listener started on port:  9090
                  2014-06-04T12:03:28.431Z - info: TCP listener started on port:   7070
                  2014-06-04T12:03:28.469Z - info: MQTT listener started on port:  1883
                  2014-06-04T12:03:28.503Z - info: UDP listener started on port:  41234
                  2014-06-04T12:03:31.046Z - info: STATUS: /server/registration_status {
                    "response" : {
                      "device_id" : "",
                      "account_id" : "",
                      "status" : false
                    },
                    "msg_type" : "device_registration_status_msg",
                    "sender_id" : "SVUUID00000001",
                    "timestamp" : 1401883498892
                  }

                   

                  Can any one help me out.

                  Thanks,

                  Sunil