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 queryContext from ContextBroker #13

Open
koff-fkd opened this issue Aug 25, 2016 · 0 comments
Open

problem with queryContext from ContextBroker #13

koff-fkd opened this issue Aug 25, 2016 · 0 comments

Comments

@koff-fkd
Copy link

koff-fkd commented Aug 25, 2016

I want to get a contextdata from an IoT Broker via an ContextBroker with NGSI10:queryContext.
IoTBroker can get the contextdata from device,
but ContextBroker can't get the contextdata from IoTBroker.
the ContextBroker give me this error.

Following, the portion of interest of the ContextBroker log:

time=2016-08-25T01:16:21.320Z | lvl=WARN | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=postQueryContext.cpp[198]:queryForward | msg=Internal Error (error parsing reply from prov app: )

Following, the portion of interest of the IoTBroker response log:

2016-08-25 10:27:25 INFO  NgsiStructure:291 - Ojbect not sane.<?xml version="1.0" encoding="UTF-8"?><queryContextResponse>
  <contextResponseList>
    <contextElementResponse>
      <contextElement>
        <contextAttributeList>
          <contextAttribute>
            <name>humidity</name>
            <type>float</type>
          </contextAttribute>
          <contextAttribute>
            <name>temperature</name>
            <type>float</type>
          `</contextAttribute>`
        </contextAttributeList>
      </contextElement>
      <statusCode>
        <code>200</code>
        <reasonPhrase>OK</reasonPhrase>
      </statusCode>
    </contextElementResponse>
  </contextResponseList>
</queryContextResponse>
2016-08-25 10:27:25 INFO  NgsiStructure:328 - Trying to deserialize json {
  "contextResponses" : [
    {
      "contextElement" : {
        "type" : "thermometer",
        "isPattern" : "false",
        "id" : "thermo1",
        "attributes" : [
          {
            "name" : "humidity",
            "type" : "float",
            "value" : "30.00",
            "contextMetadata" : [
              {
                "name" : "unit",
                "type" : "string",
                "value" : "%"
              }
            ]
          },
          {
            "name" : "temperature",
            "type" : "float",
            "value" : "20.00",
            "contextMetadata" : [
              {
                "name" : "unit",
                "type" : "string",
                "value" : "celsius"
              }
            ]
          }
        ]
      },
      "statusCode" : {
        "code" : "200",
        "reasonPhrase" : "OK"
      }
    }
  ]
}

・regisiterContext to ContextBroker

(curl localhost:1026/v1/registry/registerContext -s -S --header 'Content-Type: application/json' \
    --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
{
    "contextRegistrations": [
        {
            "entities": [
                {
                    "type": "thermometer",
                    "isPattern": "false",
                    "id": "thermo1"
                }
            ],
            "attributes": [
                {
                    "name": "temperature",
                    "type": "float",
                    "isDomain": "false",
                    "metadatas": [
                      {
                        "name": "unit",
                        "type": "string",
                        "value": "test"
                      }
                    ]
                },
                {
                    "name": "humidity",
                    "type": "float",
                    "isDomain": "false",
                    "metadatas": [
                      {
                        "name": "unit",
                        "type": "string",
                        "value": "test"
                      }
                    ]
                },
                {
                  "name": "measurement_time",
                  "type": "timestamp",
                  "isDomain": "false"
                }
            ],
            "providingApplication": "http://localhost:8060/ngsi10"
        }
    ],
    "duration": "P1Y"
}
EOF

・registerContext to IoTBroker

(curl localhost:8060/ngsi9/registerContext -s -S \
    --header  'Content-Type: application/xml' --header 'Accept: application/xml' \
    -d @-) <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<registerContextRequest>
<contextRegistrationList>
    <contextRegistration>
        <entityIdList>
            <entityId type="thermometer" isPattern="false">
                <id>thermo1</id>
            </entityId>
        </entityIdList>
        <contextRegistrationAttributeList>
        <contextRegistrationAttribute>
            <name>temperature</name>
            <type>float</type>
            <isDomain>false</isDomain>
            <metadata>
                        <contextMetadata>
                            <name>unit</name>
                            <type>string</type>
                        </contextMetadata>
            </metadata>
        </contextRegistrationAttribute>
        <contextRegistrationAttribute>
            <name>humidity</name>
            <type>float</type>
            <isDomain>false</isDomain>
            <metadata>
                        <contextMetadata>
                            <name>unit</name>
                            <type>string</type>
                        </contextMetadata>
            </metadata>
        </contextRegistrationAttribute>
        <contextRegistrationAttribute>
            <name>measurement_time</name>
            <type>timestamp</type>
            <isDomain>false</isDomain>
        </contextRegistrationAttribute>
        </contextRegistrationAttributeList>
        <providingApplication>http://localhost:<device's port>/ngsi10</providingApplication>
    </contextRegistration>
</contextRegistrationList>
<duration>P1Y</duration>
<registrationId></registrationId>
</registerContextRequest>
EOF

・queryContext to ContextBroker

(curl localhost:1026/ngsi10/queryContext -s -S --header 'Content-Type: application/json' \
    --header 'Accept: application/json' -d @-| python -mjson.tool) <<EOF
{
    "entities": [
        {
            "isPattern": "false",
            "id": "thermo1"
        }
    ]
}
EOF

How can I get the contextdata?
Best Regards
Shunya

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

1 participant