enableiot / iotkit-samples

Demonstration code for the IoT Kit
Other
43 stars 36 forks source link

Not Able register Component #14

Closed SunilNpl closed 8 years ago

SunilNpl commented 10 years ago

Hi ,

I am trying to register component and send observation to the cloud. But I did't succeed.I am running following commands. ./iotkit-admin.js register temperature temerature.v1.0 get following error

2014-07-17T07:15:44.192Z - info: Starting registration ... 2014-07-17T07:15:44.651Z - info: Activating ... 2014-07-17T07:15:47.950Z - error: Activation Rejected: {"code":1410,"message":"Invalid Activation Code"} --> error 2014-07-17T07:15:47.969Z - error: Error in the registration process ... 300

While sending observation 2014-07-17T07:16:57.278Z - error: Activation Rejected: {"code":1410,"message":"Invalid Activation Code"} --> error 2014-07-17T07:16:57.300Z - error: Error in the Observation Submission process ... 300

Please help me out.

Thanks, Sunil

scalectrix commented 10 years ago

Hi Sunil,

you do have a typo: it's "temperature.v1.0" rather than "temerature.v1.0".

FYI: if you use iotkit-admin register the iotkit-agent isn't informed. That's why the documentation says you should only use the "iotkit-admin register" for test purposes. Likewise you shouldn't really use "iotkit-admin observation" as it bypasses the agent and you have to face a huge latency as all the handshaking with the cloud needs to be done for every observation you send.

I order to register you should rather talk directly to iotkit-agent (e.g. via python as shown below):

cat > registerComponent << EOF
#! /usr/bin/env python
import socket
import sys

UDP_PORT = 41234 # UDP port iotkit-agent is listening: defined in /etc/iotkit-agent/config.json

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
if (len(sys.argv) <= 2):
    print "usage: " + str(sys.argv[0]) + " <sensor name>  <sensor type> "
    exit
else:
    sock.sendto('{"n":"' + str(sys.argv[1]) + '","t":"' + str(sys.argv[2]) + '"}', ('localhost', UDP_PORT))
EOF

chmod +x registerComponent

and

cat > sendObservation <<EOF
#! /usr/bin/env python
import socket
import sys

UDP_PORT = 41234 # UDP port iotkit-agent is listening: defined in /etc/iotkit-agent/config.json

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
if (len(sys.argv) <= 2):
    print "usage: " + str(sys.argv[0]) + " <sensor name>  <value> "
    exit
else:
    sock.sendto('{"n":"' + str(sys.argv[1]) + '","v":"' + str(sys.argv[2]) + '"}', ('localhost', UDP_PORT))
EOF

chmod +x sendObservation

to test:

./registerComponent temp temperature.v1.0
./sendObservation temp 22.6
SunilNpl commented 10 years ago

Hi, Hi,

Thanks for the prompt response!!! for the above steps I have a couples of doubt: 1-) I have to work with pre-installed agent or clone from the githup because both are different 2-)Default iot-kit agent does't have iotkit admin 3-) if I use default iot-kit agent then How I activate my device using activation key ?

Thanks, Sunil

scalectrix commented 10 years ago

1) I don't know which image you have and hence no clue what is pre-installed. 2) well, you were referring to iotkit-admin in your initial request so I assume you do have it installe 3) activation is ok via "iotkit-admin activate "

scalectrix commented 10 years ago

a, just see in your output that you don't even seem to have activated the board at all. That's a required initial step

SunilNpl commented 10 years ago

Hi , In the Dash board in status it is showing active. I activated it using iotkit-admin activate "activation code" which I get from the iotkit-dash board. I am using iotdevkit image.

Thanks, Sunil

SunilNpl commented 10 years ago

Hi,

Here is work summary: When I am installing agent using "npm install iotkit-agent" When run node agent.js it is connecting to following cloud: "https://manager.enableiot.com/sensors/mainPage.html?#DeviceList" and get success registration message and this is something some other cloud. I check my board with muzzley cloud led test application but yet not able to run with intel cloud. If I can get some steps to register component and send observation to the cloud so that would be much appreciated.

Regards, Sunil

scalectrix commented 10 years ago

you can change the cloud by "iotkit-admin host", or directly changing config.json file. Once the board is shown active you should be fine to

  1. register components
  2. send observations you may use my scripts
scalectrix commented 10 years ago

as a first stage you may try "iotkit-admin test" to test the connection

SunilNpl commented 10 years ago

Hi ,

Stil,I am on the same place I am using after hitting iotkit-admin test getting following response 2014-07-18T05:09:20.504Z - info: Trying to connect to host ... 2014-07-18T05:09:23.464Z - info: Connected to dashboard.us.enableiot.com 2014-07-18T05:09:23.480Z - info: Environment: prod 2014-07-18T05:09:23.485Z - info: Build: 0.9.1118

I also use your above script but not able to find any component register with this board: I made this change into the above script: UDP_PORT = 41234 # UDP port iotkit-agent is listening: defined in /home/iotkit-agent/config.json print "usage: " + str(sys.argv[0]) + " temperature sensor "

I also tried with iotkit-admin register temperature temperature.v1.0 and getting following response 2014-07-18T05:13:48.996Z - info: Starting registration ... 2014-07-18T05:13:49.450Z - info: Activating ... 2014-07-18T05:13:52.458Z - error: Activation Rejected: {"code":1409,"message":"Device already exists"} --> error 2014-07-18T05:13:52.474Z - error: Error in the registration process ... 300 root@clanton:/usr/lib/node_modules/iotkit-agent#

As per your reply I am assuming that it should be work but something is wrong with my board and configuration side.I am trying to debug it more.

Thanks, Sunil

scalectrix commented 10 years ago
  • have you actually started the iotkit agent?
  • can you pls send the exact calls you are running and the outputs/logs?
  • in particular, pls send the output of the iotkit-agent
SunilNpl commented 10 years ago

Hi,

What I did from begining:

1-) Install fresh Iotdevkit Image which I get from Intel 2-) It contain agent in /usr/lib/node_module/iotdevkit 3-) Then I run node agent.js then get following response

2014-07-18T06:53:11.470Z - info: IoT Kit Cloud Agent: 98-4F-EE-00-08-D2 2014-07-18T06:53:12.208Z - info: Cloud client created 2014-07-18T06:53:12.275Z - info: Starting listeners... express deprecated app.configure: Check app.get('env') in an if statement listeners/rest.js:35:8 connect deprecated methodOverride: use method-override module directly listeners/rest.js:39:24 2014-07-18T06:53:18.261Z - info: REST listener started on port: 9090 2014-07-18T06:53:18.312Z - info: TCP listener started on port: 7070 2014-07-18T06:53:18.351Z - info: MQTT listener started on port: 1883 2014-07-18T06:53:18.387Z - info: UDP listener started on port: 41234 2014-07-18T06:53:21.136Z - info: STATUS: /server/registration_status { "response" : { "device_id" : "98-4F-EE-00-08-D2", "account_id" : "sunilksi", "status" : true }, "msg_type" : "device_registration_status_msg", "sender_id" : "SVUUID00000001", "timestamp" : 1405666516685 } 2014-07-18T06:53:21.155Z - info: Devices registered successfully Which I configured on the https://manager.enableiot.com/sensors/mainPage.html?#DeviceList But into this location not able to find how to register the component and send the data. Further I moved into the :https://dashboard.us.enableiot.com/v1/ui/dashboard#/control by visiting https://github.com/enableiot/iotkit-agent And register my galileo device by using ID and Gateway:"98-4F-EE-00-08-D2" Then I downlaod https://github.com/enableiot/iotkit-agent/archive/master.zip on copy and extract in /home directory. iotkit-admin test and get success response iotkit-admin activate which I get from the dashboard Then it show active on the dash board 2014-07-18T07:04:59.762Z - info: # of Component @ Catalog : 4 id : t kind measure
humidity.v1.0 sensor humidity
powerswitch.v1.0 actuator powerswitch â temperature.v1.0 sensor temperature temperature.v1.1 sensor temperature I used :root@clanton:/usr/lib/node_modules/iotkit-agent# ./iotkit-admin.js register temperature temperature.v1.0 2014-07-18T07:08:21.715Z - info: Starting registration ... 2014-07-18T07:08:22.169Z - info: Activating ... 2014-07-18T07:08:25.943Z - error: Activation Rejected: {"code":1410,"message":"Invalid Activation Code"} --> error// 2014-07-18T07:08:25.959Z - error: Error in the registration process ... 300 And some time showing 2014-07-18T07:08:25.943Z - error: Activation Rejected: {"code":1410,"message":"Device all ready exit"} --> e these are things which I did Regards, Sunil

SunilNpl commented 10 years ago

Can you please comment where I am doing mistake ?

SunilNpl commented 10 years ago

HI ,

Did you find any thing need to be change as per above logs. Kindly provide you comments and suggestion.

Thanks, Sunil

scalectrix commented 10 years ago

I think you mentioned that you changed the cloud host at some stage. Sometimes cached data from former installations might prevent correct working. So you might try:

  • delete & recreate your cloud account
  • "iotkit-admin initialize"
  • "iotkit-admin reset-code"

and then start over again with activating and registrating components.

Some more questions:

  • "I also use your above script but not able to find any component register with this board" how do you mean? which "component register" do you talk about? are you referring to "./registerComponent"? This would obviously just be the name of the 1st script
  • "fresh Iotdevkit" - which version (date) is it?
  • "into this location not able to find how to register the component and send the data." You need to register from within your board (e.g. with the script "registerComponent" I provided
  • "Then I downlaod https://github.com/enableiot/iotkit-agent/archive/master.zip" - why? you were using agent.js before I thought?; in particular
  • "I used :root@clanton:/usr/lib/node_modules/iotkit-agent# ./iotkit-admin.js register temperature temperature.v1.0" as mentioned: you should rather go via iotkit-agent to register components. Otherwise you'd have to restart the iotkit-agent to pick up the newly registered components; BTW: any reason you are registering "temperature.v1.0" and not "temperature.v1.1" which you seem to have created?
SunilNpl commented 10 years ago

Hi ,

Thanks for the reply: 1-) "I also use your above script but not able to find any component register with this board" how do you mean? which "component register" do you talk about? are you referring to "./registerComponent"? This would obviously just be the name of the 1st script

"Means after running the script which you mentioned above the I change only print "usage: " + str(sys.argv[0]) + " temperature temperature.v1.0 " and understand this is the name of the script then execute ./iotkit-admin components and not able to find any component on dashboard as well.

2-)"fresh Iotdevkit" - which version (date) is it?

I am using "iot-devkit-201402201605-mmcblkp0.direct" 3-)"Then I downlaod https://github.com/enableiot/iotkit-agent/archive/master.zip" - why? you were using agent.js before I thought?; in particular Because I was not able to find iotkit-admin.js for activating the board and component. there are nothing to be document and that how to use agent.js for activating the board and register the component

4-) I tried with both iotkit-agent.js and iotkit-admin.js to register the component. there are no specific reason to use specific component at this point I am focusing to how galileo works with cloud. Still it is not working! Thanks, Sunil

SunilNpl commented 10 years ago

Hi ,

As per our above conversation seems problem is occurring due to agent.like iotkit-admin,iotkit-agent and agend.js moving forward can I get the steps to register device and component on to the cloud. I am using "iot-devkit-201402201605-mmcblkp0.direct" .

Thanks, Sunil

SunilNpl commented 10 years ago

Hi ,

Is there any other updated iot-devkit publish image instead of "iot-devkit-201402201605-mmcblkp0.direct" ?

Regards, Sunil

scalectrix commented 10 years ago

not that I am aware of - you would need to Yocto build yourself

SunilNpl commented 10 years ago

Hi ,

I another thing I found that when I am running iotkit-admin.js test then able to connect with the cloud. But When I am running iotkit-agent.js then find the error. root@clanton:/iotkit-agent# ./iotkit-agent.js test 2014-07-22T12:16:44.611Z - debug: Proxy Connector : rest to be Set 2014-07-22T12:16:44.756Z - debug: Rest Proxy Created 2014-07-22T12:16:44.868Z - debug: Proxy Connector : mqtt to be Set 2014-07-22T12:16:45.384Z - debug: MQTT Control Proxy Created 2014-07-22T12:16:48.886Z - debug: Filename /iotkit-agent/certs/token.json read deviceToken=false, accountId=false 2014-07-22T12:16:48.907Z - debug: Cloud Proxy Created with Cloud Handler rest 2014-07-22T12:16:48.917Z - debug: Starting Activate Process function 2014-07-22T12:16:48.923Z - info: Activating ... 2014-07-22T12:16:48.935Z - debug: Called activate function 2014-07-22T12:16:48.940Z - debug: ...trying activation 2014-07-22T12:16:52.268Z - debug: Device Register undefined 2014-07-22T12:16:52.274Z - error: Activation Rejected: {"code":1409,"message":"Device already exists"} --> error 2014-07-22T12:16:52.280Z - debug: Activation Data Received: status=300 2014-07-22T12:16:52.289Z - error: Error in activation... err # : 300 root@clanton:/iotkit-agent# PFA.. Seem the device is not getting activation response from the cloud. Is the problem with the cloud .Can you please comment ? untitled

scalectrix commented 10 years ago

well, possibly your manual installation doesn't fully work. Maybe iotkit-admin and iotkit-agent are looking into different config folders? iotkit-agent seems to look for /iotkit-agent/certs/token.json

SunilNpl commented 10 years ago

Hi ,

I am to send the data to the cloud .I re imaged the sd card and followed above process and send data to the cloud. I have an another question Can we send Boolean data from cloud to device for controlling the hardware ? Thanks for the support !!!

Sunil

scalectrix commented 10 years ago

good to see you're one step further now. Actually never tested what you try so can't tell you

marcinma commented 8 years ago

not issue with samples