Stuck on Downlink Analysis

Does anyone have a working example of a downlink analysis? I have gone through the example documentation and template a few times and am stuck on the line

“Missing “form_payload” in the data scope”

I suspect there is more customisation I need to do, and in my ignorance I am missing it. I am trying to send downlink through TTI.

Thanks

Dayne

Hi Dayne,

are you calling the Analysis through a Dashboard’s Widget?
if so, in the template, the lines

  const payload = scope.find(x => x.variable === 'form_payload') || { value: env.payload, origin: env.device_id };
  const port = scope.find(x => x.variable === 'form_port') || { value: env.default_PORT };

are searching the variables form_payload and form_port in the data sent by the widget or through the Environment variables if it don’t find in the Widget’s data, so you need to make an Input Form Widget with these two inputs and put in the Environment variables a default value in case the Widget’s data doesn’t have the payload or the port. You can see that is searching in the Widget, because of the following line:

if (!scope[0]) return context.log('This analysis must be triggered by a widget.');

If you are trying to use the Analysis without it been through a Dashboard’s Widget, then you will need to remove the line:

if (!scope[0]) return context.log('This analysis must be triggered by a widget.');

and make changes in the other lines:

  //const payload = scope.find(x => x.variable === 'form_payload') || { value: env.payload, origin: env.device_id };
  const payload = { value: env.payload, origin: env.device_id };
  //const port = scope.find(x => x.variable === 'form_port') || { value: env.default_PORT };
  const port = { value: env.default_PORT }

but that way, you will need to inform these variables in the Environment variables menu, present in the Analysis. Hope it helps.

Best regards,
Gustavo Daniel

Hi Gabriel,

I am feeling like I am missing something basic.

I am using the model dashboard and the widget Input Form. In that I have defined variable as payload which is existing variable in my device.

I had assumed that this would be automatically converted to form_payload. Do I need to change this manually to form_payload (or other name_payload)?

Thanks

Dayne

Hi Dayne,

if in your Input Form Widget you are using the variable payload, please change the one in the Analysis from form_payload to payload, and if you are using port, do that aswell.

Best regards,
Gustavo Daniel

Thanks Gustavo,

This gets me past this step ok, and I apologise for another problem, but downlink application is very important for my application.

Next issue is

I couldn’t find quite follow where downlink comes from and where to check it. (I know TTI has a downlink, but assume it is correct in connector, and connector is where analysis is looking for this?)

Thanks
Dayne