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

TTN flow, empty measure on Orion #66

Closed filgiuff closed 5 years ago

filgiuff commented 5 years ago

I've registered a real device on The things network , it sends measures and I see them on the app server TTN:

{
  "barometric_pressure_2": 1073.2,
  "gps_3": {
    "altitude": 2,
    "latitude": 52.3736,
    "longitude": 4.8865
  },
  "luminosity_4": 1018,
  "temperature_1": 27.2
}

I've tried to do the provisioning of this device on the IoTagent-LoRaWAN:

 {
    "devices": [{
        "device_id": "fake_device14",
        "entity_name": "LORA-DEVICE14",
        "entity_type": "LoraDevice",
        "timezone": "America/Santiago",
        "attributes": [{
                     "object_id": "t1",
                     "name": "temperature_1",
                    "type": "number"
                 }],
        "internal_attributes": {
            "lorawan": {
                "application_server": {
                    "host": "eu.thethings.network",
                    "username": "XXXXXXXX",
                                     "password": "YYYYYYYYYYYY",
                    "provider": "TTN"
                },
                "app_eui": "JJJJJJJJJJJJJJJJJ",
                "application_id": "XXXXXXXX",
                "application_key": "KKKKKK",
                "data_model": "cayennelpp",
                "dev_eui": "ZZZZZZZZZZ"
            }
        }
    }]
}

it creates the entity on Orion and the Mqtt topic is subscribed correctly:

 iotagent-lora_1  | {"timestamp":"2019-05-07T15:25:41.692Z","level":"info","message":"Subscribing to MQTT topic:XXXXXXXX/devices/fake_device14/up"}
iotagent-lora_1  | {"timestamp":"2019-05-07T15:25:41.693Z","level":"info","message":"Mqtt topic subscribed:XXXXXXXX/devices/fake_device14/up"}

But the value of the measure is empty

[
    {
        "id": "LORA-DEVICE14",
        "type": "LoraDevice",
        "TimeInstant": {
            "type": "DateTime",
            "value": "2019-05-07T15:35:45.00Z",
            "metadata": {}
        },
        "temperature_1": {
            "type": "number",
            "value": " ",
            "metadata": {}
        }
    }
]
dcalvoalonso commented 5 years ago

Some questions to try to understand where is the problem:

filgiuff commented 5 years ago

1) Yes. There is it.

...
iotagent-lora_1  | {"timestamp":"2019-05-07T15:13:48.535Z","level":"info","message":"Connected to MQTT server"}
iotagent-lora_1  | {"timestamp":"2019-05-07T15:13:48.536Z","level":"info","message":"Application started."}
...

2) No. There isnt't this line on the agent log.

dcalvoalonso commented 5 years ago

Could you please share the raw message as it is sent by the device (Base64)?

filgiuff commented 5 years ago

here it is

01670110027329EC046503FA038807FDD800BEE10000C8

dcalvoalonso commented 5 years ago

I checked the payload and the IoT agent is able to process it correctly. Therefore the error must be in the connection between the TTN server and the IoT Agent.

dcalvoalonso commented 5 years ago

The problem was that the device_id used in the device provisioning did not match the actual device_id used by TTN.

filgiuff commented 5 years ago

The problem was that the value of "device_id" on the provisioning payload must be the same of the TTN server. Now I have the correct value. Thanks