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

LoRaWan Agent TTN V3 stack #111

Closed jcheca closed 2 years ago

jcheca commented 3 years ago

I would like to know if it is supported TTN V3 Stack with this agent. I would like a configuration example because does not work for me. I can connect via MQTT so i have to add @ttn as username, the new host is supplied but doesn't work to post information from agent to context broker.

Any help would be appreciated. Thanks in advance.

pacs27 commented 3 years ago

Hi José,

I believe that currently does not support the new version, but it can be implemented. I think that the differences are that the topics in v3 start with 'v3 /' and the payload is different.

You have to change the library files.

I am working in Rabanales in a PhD, in the hydraulic department, so I can help you if you have any questions about how to implement it.

pacs27 commented 3 years ago

I have modified the lib and it works fine. However, I have yet to test it.

If you use Docker you can try it with this image: franciscopuig/iotagent-lorawan:latest.

Also this image supports Orion-LD in case you want to use it.

Device provisioning should look like this example:

curl --location --request POST 'http://localhost:4041/iot/devices' \
--header 'fiware-service: rabanales' \
--header 'fiware-servicepath: /parcelaOlivar' \
--header 'Content-Type: application/json' \
--data-raw '{
    "devices": [
        {
           "device_id":"<LoraDeviceId>",
           "entity_name": "urn:ngsi-ld:HumiditySensor:humidity001",
            "entity_type": "HumiditySensor",
            "attributes": [
        {
          "object_id": "h",
          "name": "soilMoistureVwc",
          "type": "Property",
          "metadata": { "unitCode": {"type": "Text", "value": "5K" }}
        }
      ],
                "static_attributes": [
          {"name": "refParcel", "type": "Relationship","value": "urn:ngsi-ld:AgriParcel:001"}
       ],
       "internal_attributes": {
          "lorawan": {
            "application_server": {
              "host": "eu1.cloud.thethings.network",
              "username": "<LoraAppID>@ttn",
              "password": "<LoraMQTTKey>",
              "provider": "TTS-V3"
            },
            "app_eui": "<LoraAppEui>",
            "application_id": "<LoraAppID>@ttn",
            "application_key": "<LoraAppKey>",
            "data_model": "application_server"
          }
      },
      "protocol": "LORAJSON"

        }
    ]
}'
jcheca commented 3 years ago

Thxs Francisco for your help. Do you have a GIT with the modifications you have made? I would like to review the code for other types of data models; I use Cayenne frequently. Investigating with MQTT I could see the difference in the topic, so I asked if ATOS plans to modify its development for the V3 stack. I have not been able to test the docker you have suggested, I have run out of gateway in V3, when they start it up again, I will test it.

sirnino commented 3 years ago

Hi all, any news about this issue?

luisdelacalle commented 2 years ago

good afternoon,

In the following commits https://github.com/luisdelacalle/IoTagent-LoRaWAN/commit/9e8823b16978d88130944327c4696aa749d39422 and https://github.com/luisdelacalle/IoTagent-LoRaWAN/commit/c35817f7c81fb1657d8de95a86133fc7123ea3bd I have made the basic changes to make it works with the TTN v3. This is the fork https://github.com/luisdelacalle/IoTagent-LoRaWAN

The topic has been changed to "v3/{application_id}@{tenant_id}/devices/{device_id}/up" as @pacs27 has said. More info: https://www.thethingsindustries.com/docs/integrations/mqtt/

On the other hand, the payload has also changed, in my case (CayenneLPP) the payload, within the JSON, is found in: uplink_message.decoded_payload.

johncaipa commented 2 years ago

Dear Luis, this update to V3 are available with docker too?

jcheca commented 2 years ago

You could pass the modified file on docker instance via mount volumes from local filesystem, so you won't need to rebuild the docker image, using the old existing one for V2, as in the following example:

` volumes:

chicco785 commented 2 years ago

hi, we had a meeting with @ICollantes from Atos by march the support will be officially released including testing. be patient :)

johncaipa commented 2 years ago

Hi, any news about the release! thanks.

johncaipa commented 2 years ago

Hi, any example about provisioning device and service for TTNV3

johncaipa commented 2 years ago
curl --location --request POST 'http://localhost:4041/iot/devices' \
--header 'fiware-service: openiot' \
--header 'fiware-servicepath: /' \
--header 'Content-Type: application/json' \
--data-raw '{
    "devices": [
        {
           "device_id":"<LoraDeviceId>",
           "entity_name": "urn:ngsi-ld:HumiditySensor:humidity001",
            "entity_type": "HumiditySensor",
            "attributes": [
        {
          "object_id": "h",
          "name": "soilMoistureVwc",
          "type": "Property",
          "metadata": { "unitCode": {"type": "Text", "value": "5K" }}
        }
      ],
                "static_attributes": [
          { "name":"refStore", "type": "Relationship", "value": "urn:ngsi-ld:Store:001"}
       ],
       "internal_attributes": {
          "lorawan": {
            "application_server": {
              "host": "nam1.cloud.thethings.network",
              "username": "<LoraAppID>@ttn",
              "password": "<LoraMQTTKey>",
              "provider": "TTN"
            },
            "dev_eui": "<LoraDevEui>",
            "app_eui": "<LoraAppEui>",
            "application_id": "<LoraAppID>@ttn",
            "application_key": "<LoraAppKey>",
            "data_model": "application_server"
          }
      },
      "protocol": "LORAJSON"  
        }
    ]
}'
johncaipa commented 2 years ago

this example works for me integrating with TTN v3

chicco785 commented 2 years ago

@johncaipa the main different w.r.t. ttn v2 is the application id as explained in the note in the documentation:

https://fiware-lorawan.readthedocs.io/en/latest/users_manual/index.html#the-things-network-ttn

N.B.: With TTN v3 Application ID may be different and include the Tenant ID as follows: {application id}@{tenant id} (cf .here). If you are using The Things Stack Open Source, your Application ID will be as before: {application id}.