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

DEVICE_NOT_FOUND error with Scorpio Broker #135

Open
mohitNEC opened this issue Jul 19, 2023 · 11 comments
Open

DEVICE_NOT_FOUND error with Scorpio Broker #135

mohitNEC opened this issue Jul 19, 2023 · 11 comments

Comments

@mohitNEC
Copy link

Hi,

I'm trying to integrate Scorpio Broker with FIWARE IoT Agent for Sigfox Protocol. In the device provisioning the NGSI-LD entity is created successfully. But when I am trying to send measurements to the Sigfox IoT Agent it is showing error.
Firstly, I register the service and the device to the agent. As you can see from below:

Service Provisioning:

curl --location --request POST 'http://<Sigfox-IoTAgent>:4041/iot/services' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "services": [
        {
            "cbroker": "http://scorpio:9090",
            "resource": "/sigfoxDev",
            "apikey": "23HJK3Y9090DSFL173209HV8801232",
            "type": "Device",
            "commands": [],
            "lazy": [],
            "active": []
        }
    ]
}'

Device Provisioning:

curl --location --request POST 'http://<Sigfox-IoTAgent>:4041/iot/devices' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "devices": [
        {
            "device_id": "sigApp1",
            "entity_name": "urn:ngsi-ld:Device:sigApp1",
            "entity_type": "Device",
            "protocol": "SIGFOX",
            "timezone": "America/Santiago",
            "attributes": [
                {
                    "name": "time",
                    "type": "String"
                },
                {
                    "name": "statin",
                    "type": "String"
                },
                {
                    "name": "lng",
                    "type": "String"
                },
                {
                    "name": "lat",
                    "type": "String"
                },
                {
                    "name": "theCounter",
                    "type": "Integer"
                },
                {
                    "name": "theParam1",
                    "type": "Integer"
                },
                {
                    "name": "param2",
                    "type": "Integer"
                },
                {
                    "name": "tempDegreesCelsius",
                    "type": "Integer"
                },
                {
                    "name": "voltage",
                    "type": "Integer"
                }
            ],
            "lazy": [],
            "static_attributes": [],
            "commands": [],
            "internal_attributes": [
                {
                    "mapping": "theCounter::uint:32  theParam1::uint:32 param2::uint:8 tempDegreesCelsius::uint:8  voltage::uint:16"
                }
            ]
        }
    ]
}'

After that, the NGSI-LD entity in Scorpio Broker is:

{
    "id": "urn:ngsi-ld:Device:sigApp1",
    "type": "Device"
}

After follow these steps, when I try to send measures using the following GET callback:

curl --location -g --request GET 'http://<Sigfox-IP>:17428/update?id=urn:ngsi-ld:Device:sigApp1&data={theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw ''

RESPONSE:

{
    "name": "DEVICE_NOT_FOUND",
    "message": "No device was found with id:urn:ngsi-ld:Device:sigApp1",
    "code": 404
}

Sigfox IoT Agent Logs:

time=2023-07-18T06:20:50.705Z | lvl=DEBUG | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentSIGFOX.SigfoxServer | from=n/a | srv=dumbmordor | subsrv=/deserts | msg=Request for path [/update] from [172.30.48.45:17428] | comp=IoTAgent
time=2023-07-18T06:20:50.705Z | lvl=DEBUG | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentSIGFOX.SigfoxServer | from=n/a | srv=dumbmordor | subsrv=/deserts | msg=Body:

undefined

 | comp=IoTAgent
time=2023-07-18T06:20:50.706Z | lvl=DEBUG | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentSIGFOX.SigfoxHandlers | from=n/a | srv=dumbmordor | subsrv=/deserts | msg=Handling request with query [{"id":"urn:ngsi-ld:Device:sigApp1","data":"{theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}"}] | comp=IoTAgent
time=2023-07-18T06:20:50.706Z | lvl=DEBUG | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentNGSI.MongoDBDeviceRegister | from=n/a | srv=howtoService | subsrv=/howto | msg=Looking for device with id [urn:ngsi-ld:Device:sigApp1]. | comp=IoTAgent
time=2023-07-18T06:20:50.711Z | lvl=DEBUG | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentNGSI.MongoDBDeviceRegister | from=n/a | srv=howtoService | subsrv=/howto | msg=Device [urn:ngsi-ld:Device:sigApp1] not found. | comp=IoTAgent
time=2023-07-18T06:20:50.711Z | lvl=ERROR | corr=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | trans=0e5fbb1c-ec9a-44a9-b0a5-f618dfcfef18 | op=IoTAgentNGSI.Alarms | from=n/a | srv=dumbmordor | subsrv=/deserts | msg=Raising [MONGO-ALARM]: {"name":"DEVICE_NOT_FOUND","message":"No device was found with id:urn:ngsi-ld:Device:sigApp1","code":404} | comp=IoTAgent

Same issue has been raised before with Orion-v2.
Can anyone help me sending measure to the IoT Agent Sigfox?

Thanks.

@fgalan
Copy link
Member

fgalan commented Aug 8, 2023

Maybe @jason-fox could provide feedback on this.

@jason-fox
Copy link
Contributor

The provisioning of the device is incorrect. On provisioning you stated:

 "device_id": "sigApp1",
"entity_name": "urn:ngsi-ld:Device:sigApp1",

BUT

curl --location -g --request GET 'http://<Sigfox-IP>:17428/update?id=urn:ngsi-ld:Device:sigApp1&data={theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw ''

It looks like the IoT Agent is expecting to map device id=sigApp1 in the real world to URN urn:ngsi-ld:Device:sigApp within the context broker. You are then sending a SigFox request with id=urn:ngsi-ld:Device:sigApp which hasn't got a mapping key.

I assume:

curl --location -g --request GET 'http://<Sigfox-IP>:17428/update?id=sigApp1&data={theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw ''

Would work for you.

@mohitNEC
Copy link
Author

mohitNEC commented Aug 9, 2023

Hi @jason-fox ,

Thank You for the continuous support.

I have followed the same steps to provision device in Sigfox IoT Agent with entity_name same as device_id, like as:

curl --location --request POST 'http://<Sigfox-IoTAgent>:4041/iot/devices' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "devices": [
        {
            "device_id": "sigApp1",
            "entity_name": "sigApp1",
            "entity_type": "Device",
            "protocol": "SIGFOX",
            "timezone": "America/Santiago",
            "attributes": [
                {
                    "name": "time",
                    "type": "String"
                },
                {
                    "name": "statin",
                    "type": "String"
                },
                {
                    "name": "lng",
                    "type": "String"
                },
                {
                    "name": "lat",
                    "type": "String"
                },
                {
                    "name": "theCounter",
                    "type": "Integer"
                },
                {
                    "name": "theParam1",
                    "type": "Integer"
                },
                {
                    "name": "param2",
                    "type": "Integer"
                },
                {
                    "name": "tempDegreesCelsius",
                    "type": "Integer"
                },
                {
                    "name": "voltage",
                    "type": "Integer"
                }
            ],
            "lazy": [],
            "static_attributes": [],
            "commands": [],
            "internal_attributes": [
                {
                    "mapping": "theCounter::uint:32  theParam1::uint:32 param2::uint:8 tempDegreesCelsius::uint:8  voltage::uint:16"
                }
            ]
        }
    ]
}'

After that, when I try to send measures using the following GET callback that you suggested:

curl --location -g --request GET 'http://<Sigfox-IoTAgent>:17428/update?id=sigApp1&data={theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}' \
--header 'fiware-service: dumbMordor' \
--header 'fiware-servicepath: /deserts' \
--header 'Content-Type: application/json'

Still I'm getting the same error as :

{
    "name": "DEVICE_NOT_FOUND",
    "message": "No device was found with id:sigApp1",
    "code": 404
}

@jason-fox
Copy link
Contributor

I think

"device_id": "sigApp1",
 "entity_name": "urn:ngsi-ld:Device:sigApp1",

With http://<Sigfox-IoTAgent>:17428/update?id=sigApp1&data={theCounter: 2, theparam1: 0,param2: 0,tempDegreesCelsius: 35,voltage: 3183}

is more likely to work -- entities within Scorpio should be urns.

@mohitNEC
Copy link
Author

Hi,
Still getting the same error.

@mohitNEC
Copy link
Author

Hi,
Any update regarding this issue. We are still getting the same issue.

BR,
Mohit Chauhan

@mohitNEC
Copy link
Author

Hi,
Is there any update regarding this issue?

Best Regards,
Mohit Chauhan

@mohitNEC
Copy link
Author

Hi,
Is there any update regarding this issue?

@mohitNEC
Copy link
Author

Hi,
Is there any update regarding this issue. We are still getting the same error.

@fgalan
Copy link
Member

fgalan commented Dec 12, 2023

Maybe @jason-fox could provide some feedback on this?

@jason-fox
Copy link
Contributor

I'm not actively working with the SigFox protocol.

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

No branches or pull requests

4 participants