Software Archive
Read-only legacy content
17061 Discussions

Trouble with registration to the cloud - Galileo

Pravici
Beginner
448 Views

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 ?. 

0 Kudos
5 Replies
Matthias_H_Intel
Employee
448 Views

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":

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

0 Kudos
Pravici
Beginner
448 Views

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.

 

[jscript]

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

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

 

  me.topics = {

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

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

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

  };

 

  me.registrationCompleted = false;

                            

  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){  

        me.accountId = regStatus.response.account_id;

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

            me.sensorsStore.saveSensorsList(me.sensorsList);

        me.registrationCompleted = true;

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

      }

    });

[/jscript]

 

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

 

[jscript]

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

  var me = this;

 

  if (!deviceId){

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

    return;

  }

 

  if (!deviceName) deviceName = deviceId;

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

 

  var sensorArray = [];

  for (var sensorName in sensorList) {

      sensorArray.push(sensorList[sensorName]);

  }

 

  var msg = {

    "protocol_version": "1.0",

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

    "sender_id": deviceId,

    "msg_type": "device_registration_msg",

    "properties": {

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

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

      "hardware_model": os.platform(),

      "Model Name": os.arch(),

      "Firmware Version": os.release()

    },

    "peripherals": [

      {

        "uuid": "self",

        "type": "gateway",

        "properties": {},

        "services": [

          {

            "name": dataSrcName,

            "version": "1.0"

          }

        ]

      }

    ],

    "service_metadata": [

      {

        "loaded": true,

        "capabilities": [],

        "enabled": true,

        "name": dataSrcName,

        "version": "1.0",

        "metrics": sensorArray

      }

    ]

  };

  var newmsg = JSON.stringify(msg);

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

  return msg;

};

 

 

[/jscript]

 

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:

 

[jscript]

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

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

 

[/jscript]

 

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.

 

 

0 Kudos
Pravici
Beginner
448 Views

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. 

0 Kudos
Matthias_H_Intel
Employee
448 Views

thanks for the update and great you got it working fine

0 Kudos
sunil_s_
Beginner
448 Views

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

 

0 Kudos
Reply