Cannot send downlink in analysis using the python SDK

Hi,

I am currently running an external analysis on my work laptop using the latest tagoio_sdk on pip and the sendDownlink function doesn’t seem to work.

Here is a snippet of code including how I import it and use it:

from tagoio_sdk import Analysis, Device, Resources
from tagoio_sdk.modules.Utils.sendDownlink import sendDownlink

result = sendDownlink(
    resource= app.res,
    device_id=package["id"],
    dn_options={"port": DOWNLINK_PORT, "payload": value},
)

print(result)

it throws this error:
¬ Unexpected error: TypeError: Cannot read properties of undefined (reading ‘tags’)

1 Like

Hi @charlesp,

You’re right the sendDownlink method from the Python SDK utils has an issue and wasn’t sending the downlink to the device as expected. I’ve already fixed this in the following pull request, and once it’s approved and released, I’ll let you know here:
:backhand_index_pointing_right: https://github.com/tago-io/sdk-python/pull/51

However, the error you mentioned seems different from the one I experienced. Could you please confirm if you passed the correct instance of the Resources class to the resource parameter? If the class wasn’t instantiated with a Profile Token, make sure your Analysis has the proper permissions in Access Management (AM). This is required because the command internally runs queries using the Resources instance, such as:

  • Getting the device token
  • Getting the device to retrieve its network
  • Getting the network to obtain the middleware URL
  • Getting/setting the device’s configuration parameters

Here are some useful references:

1 Like

@charlesp The fixes have been released in v5.0.4

2 Likes