Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with configuration group for devices #113

Open
pasquy73 opened this issue Feb 23, 2018 · 19 comments
Open

Problem with configuration group for devices #113

pasquy73 opened this issue Feb 23, 2018 · 19 comments

Comments

@pasquy73
Copy link

pasquy73 commented Feb 23, 2018

Hi all,
I'm testing the configuration provisioning at this link https://github.com/Fiware/iot.IoTagent-LWM2M/blob/1cdf6abc96654aca2f912cad01d5fdfcd21d7ec8/docs/configurationProvisioning.md and I'm using the configuration group for devices with type WeatherBaloon.
I noticed that there was a change from 'attributes' to 'active' in the payload of REST call (curl localhost:4041/iot/services ...) and my old test doesn't work.

I'm not sure if this is the right solution, but I've added back 'registeredDevice.attributes' in the commonLwm2m.js file as follow:

if (registeredDevice.active) {
    activeAttributes = registeredDevice.active;
}else if (registeredDevice.attributes) {
    activeAttributes = registeredDevice.attributes;
} else if (commons.getConfig().ngsi.types[registeredDevice.type]) {
    activeAttributes = commons.getConfig().ngsi.types[registeredDevice.type].attributes;
}

So with these changes, my tests work for both service and device (https://github.com/Fiware/iot.IoTagent-LWM2M/blob/1cdf6abc96654aca2f912cad01d5fdfcd21d7ec8/docs/deviceProvisioning.md) configuration.
Please let me know if I'm right or not.

@fgalan
Copy link
Member

fgalan commented Feb 23, 2018

Did grunt test goes ok after the proposed change?

@pasquy73
Copy link
Author

I'm using the doc: I start the IoT Agent (node bin/lwm2mAgent.js) with my configuration and I run my JS Client to create/update object and connect to the server ... the same steps that the doc provides (LWM2M-Client> ...)

@fgalan
Copy link
Member

fgalan commented Feb 23, 2018

Maybe I'm not making my point clearly... :)

Apart from the test you describe, note this repository includes a set of unit tests that act as regression for any new change. The command grunt test runs this regressions and reports any potencial error.

(Note however this is a necessary but not sufficient condition. Unit tests are not perfect and doesn't cover all the possible cases so grunt test could be ok and the modification of the code introduce some bug/issue. However, let's have at least that minimal check).

If the grunt test goes ok, I'd suggest as next step you create a pull request with the proposed change. Eventually that PR will be reviewed and merged.

Thanks!

@dcalvoalonso
Copy link
Contributor

Dear @pasquy73,

I think that the problem is that https://github.com/Fiware/iot.IoTagent-LWM2M/blob/1cdf6abc96654aca2f912cad01d5fdfcd21d7ec8/docs/configurationProvisioning.md is not updated.

As you can see in the reference documentation for the IoT Agents https://github.com/telefonicaid/iotagent-node-lib#configurationapi, the payload field to define active attributes is now active.

Could you please check if the example works using active instead of attributes? If it does, I will submit a PR to upload the example.

Thanks in advance and BR.

Daniel

@pasquy73
Copy link
Author

pasquy73 commented Feb 26, 2018

Here the installation and execution steps of my test on my Win7 with active attribute in the payload for "Power Control" in configuration provisioning and no change in the commonLwm2m.js (only registeredDevice.active):

git clone https://github.com/Fiware/iot.IoTagent-LWM2M.git
cd iot.IoTagent-LWM2M
npm install

start the server
node bin/lwm2mAgent.js config-blank.js

git clone https://github.com/telefonicaid/lwm2m-node-lib.git
cd lwm2m-node-lib
npm install

start the client
node bin/iotagent-lwm2m-client.js

run the test

  1. configuration provisioning (https://github.com/Fiware/iot.IoTagent-LWM2M/blob/1cdf6abc96654aca2f912cad01d5fdfcd21d7ec8/docs/configurationProvisioning.md):
LWM2M-Client> create /6/0
LWM2M-Client> create /3303/0
LWM2M-Client> create /3312/0
LWM2M-Client> set /6/0 0 12
LWM2M-Client> set /6/0 1 -4
LWM2M-Client> set /3303/0 0 23
LWM2M-Client> set /3312/0 0 On

connection
LWM2M-Client> connect localhost 5684 weather1 /weatherBaloon

test in orion
curl -v http://orion:1026/v2/entities/weather1:WeatherBaloon -s -S --header "fiware-service: smartGondor" --header "fiware-servicepath: /gardens"

response (Power Control empty - I expected "On" value)
{"id":"weather1:WeatherBaloon","type":"WeatherBaloon","Power Control":{"type":"Boolean","value":" ","metadata":{}}}

  1. device provisioning (https://github.com/Fiware/iot.IoTagent-LWM2M/blob/1cdf6abc96654aca2f912cad01d5fdfcd21d7ec8/docs/deviceProvisioning.md)

bin/iotagent-lwm2m-client.js

LWM2M-Client> create /7392/0

LWM2M-Client> set /7392/0 1 89
LWM2M-Client> set /7392/0 2 "First robot here"
LWM2M-Client> set /7392/0 3 "[0, 0]"

connection
LWM2M-Client> connect localhost 5684 robot1 /

update battery attribute:
LWM2M-Client> set /7392/0 1 67

curl -v http://orion:1026/v2/entities/Robot:robot1/attrs/Battery -s -S --header "fiware-service: smartGondor" --header "fiware-servicepath: /gardens"

response (OK)
{"type":"number","value":"67","metadata":{}}

Please note that both the tests I've this error:
... An error occurred creating COAP Listener: {"code":"EACCES", "errno":"EACCES","syscall":"bind","address":"0.0.0.0","port":53517}
but at the end ...
... COAP Server started successfully

@pasquy73
Copy link
Author

Anyway, if I use the LWM2M 0.3.0, then my test works both device and service provisioning:

git clone https://github.com/Fiware/iot.IoTagent-LWM2M.git iot.IoTagent-LWM2M-0.3.0 --branch 0.3.0 --single-branch

dcalvoalonso added a commit to dcalvoalonso/lightweightm2m-iotagent that referenced this issue Mar 15, 2018
- Trying to fix bug
dcalvoalonso added a commit to dcalvoalonso/lightweightm2m-iotagent that referenced this issue Mar 15, 2018
- Fixing bug
@fgalan fgalan mentioned this issue Mar 15, 2018
@fgalan
Copy link
Member

fgalan commented Mar 19, 2018

Fixed by PR #119

@fgalan
Copy link
Member

fgalan commented Mar 19, 2018

PR #119 has been merged into master and we understand this issue is solved (so the issue is closed). Could you confirm @pasquy73 ?

@fgalan fgalan closed this as completed Mar 19, 2018
@pasquy73
Copy link
Author

Hi all,
I repeated the test above and it doesn't still work, but the query to orion provides:
{"error":"NotFound","description":"The requested entity has not been found. Check type and id"}

@fgalan
Copy link
Member

fgalan commented Mar 20, 2018

@pasquy73 thanks for the report. I'm reopening the issue.

@dcalvoalonso , as author of the PR that addressed this issue (PR #119), what do you think on this?

@fgalan fgalan reopened this Mar 20, 2018
@dcalvoalonso
Copy link
Contributor

Hi @pasquy73 , could you please confirm that you are using FIWARE service and subservice with lowercases in all the requests?
It would be also good that you delete old MongoDB databases.

@pasquy73
Copy link
Author

Hi Alonso,
yes I'm using lowercase for service and subservice; I deleted the data in mongo (/iot/services?apikey=&resource=/weatherBaloon), I tried both config-blank (deviceRegistry = memory) and with mongo.

My provisioning is a POST to /iot/services (you can try my example above using the config-blank):

"services":[  
      {  
         "resource":"/weatherBaloon",
         "apikey":"",
         "type":"WeatherBaloon",
         "commands":[],
         "lazy":[  
            {  
               "name":"Longitude",
               "type":"double"
            },
            {  
               "name":"Latitude",
               "type":"double"
            },
            {  
               "name":"Temperature Sensor",
               "type":"degrees"
            }
         ],
         "active":[  
            {  
               "name":"Power Control",
               "type":"Boolean"
            }
         ]
      }
   ]
} 

@fgalan
Copy link
Member

fgalan commented Mar 20, 2018

@pasquy73 for reference... which exact version of IOTA are you usring? I mean, the githash corresponding to the version you are using for testing.

@pasquy73
Copy link
Author

I'm not sure to understand your request; I used git clone https://github.com/Fiware/iot.IoTagent-LWM2M.git and it's master. I also saw that https://github.com/telefonicaid/lightweightm2m-iotagent.git is a mirror of https://github.com/Fiware/iot.IoTagent-LWM2M.git.
Anyway in my '.git/refs/heads' folder I've a master file with:
f97f62bb872a3e0e94b087eeb1cc3e26dfe75207

@dcalvoalonso
Copy link
Contributor

dcalvoalonso commented Mar 20, 2018

@pasquy73 , in order to send the query to the CB are you using the following request?

curl -s -S --header 'Content-Type: application/json' \
  --header 'Accept: application/json' --header 'fiware-service: weather' --header 'fiware-servicepath: /baloons' -d '
{ 
    "entities": [
        {
            "type": "WeatherBaloon",
            "isPattern": "false",
            "id": "weather1:WeatherBaloon"
        }
    ],
    "attributes" : [
        "Latitude"
    ]    
}

' 'http://localhost:1026/v1/queryContext'

@fgalan
Copy link
Member

fgalan commented Mar 20, 2018

Anyway in my '.git/refs/heads' folder I've a master file with:
f97f62b

That's the githash I were referring. Thanks!

(Another way of getting it is running git log | head -n 1 in your working copy)

@letavia
Copy link

letavia commented Apr 22, 2019

Any update on this issue? I tried with the latest docker image on fiware/lightweightm2m-iotagent
repo, using "active" instead of "attributes" in the payload for device provisioning, but when I checked in the database, it was not recorded, there were only lazy and commands attributes.

@fgalan
Copy link
Member

fgalan commented Apr 24, 2019

@letavia is your last comment in this issue related with what you mentions here: #112 (comment) ?

@letavia
Copy link

letavia commented Apr 25, 2019

Yes, and I will continue in issue #112.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants