Atos-Research-and-Innovation / IoTagent-LoRaWAN

FIWARE IoT Agent for LoRaWAN protocol (with CayenneLpp and CBOR data models)
https://fiware-lorawan.readthedocs.io/en/latest/
Other
34 stars 40 forks source link

Null payload from MQTT to the agent #62

Closed filgiuff closed 5 years ago

filgiuff commented 5 years ago

Hi all, we did some experiments with this agent. Since the documentation is very minimal, we have several doubts. We don't have any devices yet. We installed loraserver.io and tried to send measures using the MQTT broker exposed by loraserver.io. Is it a correct way to proceed ?

We registered a fake sensor on the server and on the agent, trying to send measures in JSON format over MQTT, through an MQTT client. The notification arrives on the agent but the error "Could not cast message to NGSI" appears.

We tried to debug the agent, adding several console.log, but arriving on the messageHandler function we noticed that the paylod was null.

Is there any documentation about the format of the message that arrives on the MQTT broker ?

In general, is it possible to test this flow without physical gateway/sensors ?

dcalvoalonso commented 5 years ago

Hi @filgiuff,

We tried to debug the agent, adding several console.log, but arriving on the messageHandler function we noticed that the paylod was null.

Could you please provide an example of the payload you are sending? Which is the structure / format? Please note that CayenneLpp and IETF Cbor are the only ones supported now.

In general, is it possible to test this flow without physical gateway/sensors ?

I will try to provide an example without real devices as soon as possible. :)

filgiuff commented 5 years ago

Hi @dcalvoalonso,

without a satisfactory documentation, we did some attempts.

For example, we registered this sensor on the agent

{
             "device_id": "lora_n_0049",
             "service": "test",
             "service_path": "/test_issues",
             "entity_name": "Device:lora_n_0049",
             "entity_type": "Device",
             "attributes": [
                 {
                     "object_id": "t1",
                     "name": "t1",
                     "type": "Number"
                 }
             ],
             "lazy": [],
             "commands": [],
             "static_attributes": [],
             "internal_attributes": {
                 "lorawan": {
                     "application_server": {
                        "host": "XXX.XXX.XXX:XXX:8083",
                         "username": "",
                         "password": "",
                         "provider": "TTN"
                     },
                     "dev_eui": "1119343755556A14",
                     "app_eui": "4569343567897875",
                     "application_id": "ari_ioe_app_demo1",
                     "application_key": "444B8EF16415B5F6ED777EAFE695C49",
                     "data_model": "cayennelpp"
                 }
             }
         }

"host": "XXX.XXX.XXX:XXX:8083" is the address of the MQTT broker, is it correct ?

it created this entity on Orion:

{
        "id": "Device:lora_n_0049",
        "type": "Device",
        "TimeInstant": {
            "type": "DateTime",
            "value": "2019-04-08T15:19:28.00Z",
            "metadata": {}
        },
        "t1": {
            "type": "Number",
            "value": " ",
            "metadata": {}
        }
    }

We tried to send this measure on the topic ari_ioe_app_demo1/devices/lora_n_0049/up

{"t1":123} or {"t1":"123"}

We also added this service

{
    "services": [
        {
            "commands": [],
            "lazy": [],
            "attributes": [],
            "_id": "5ca72b11feed6c0f22e4e221",
            "resource": "/iot/d",
            "apikey": "jaeHttv92e2q5MexK",
            "service": "test",
            "subservice": "/test_issues",
            "trust": "1110A9078A103H3BL19PINEQRW1111HBAMS",
            "cbHost": "orion:1026",
            "__v": 0,
            "static_attributes": [],
            "internal_attributes": [],
            "entity_type": "Device"
        }
    ]
}

on the Agent start up, this message appears

iotagent-lora_1 | {"timestamp":"2019-04-09T09:38:24.102Z","level":"error","message":"lorawan attribute must be specified inside internal_attributes"}

What should these attributes and values be? How to manage services in LoRaWan IoT Agent?

Thanks

dcalvoalonso commented 5 years ago

@filgiuff,

I think that the most appropriate way to go is to prepare some additional tutorials that allow testing the agent without devices and without deploying a complete LoRaWAN infrastructure.

In this sense, I have created a new one that is prepared to be run completely in a local environment and without the complexity of deploying the network server, application server, etc: https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/blob/task/improveDocumentation/docs/tutorialLocal.md

Could you please check if it works? With this first one, you will be able to run a very basic simulation and then, we can increase the complexity and introduce LoRaServer or TTN, and payload formats.

filgiuff commented 5 years ago

@dcalvoalonso

I've tried the example of your tutorial on my docker installation.

After the creation, I've used an MQTT client with this body (without escape)

{"payload_fields":{"temperature_1":12345}}

and it works fine!

It is a good starting point!

dcalvoalonso commented 5 years ago

Ok, great news!

Is it OK for you if I merge https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/blob/task/improveDocumentation branch and close this issue?

BTW: I will add more tutorials in the incoming days.

filgiuff commented 5 years ago

Yes, your reply solved my problem, so you can close this issue.

In general, I think adding more tutorials would be very useful!