Is it possible to call the Decoder function in the Encoder function? I have a Dragino LoRa I/O Controller (LT-33222) connected on TTN and integrated to ThingsBoard for remote monitoring and control. Now, I would like to control the digital output of LT-33222 by RPC call from buttons in ThingsBoard dashboard. Before sending the downlink command, I need to read and compare the status of digital output from the uplink from which I can then set appropriate downlink to be sent to the end device.
No, that is not supported.
So, you would need to create an application outside of TTN to have access to all data you need, and simply do the encoding there too, without the need for any Payload Formats in TTN Console. (You wouldn’t even need a decoder in TTN Console either; you can just do that in your own application as well.) But you would already need such application anyhow, to schedule the downlink.
Also beware that, when creating a downlink partially based on uplink data, the downlink might only be sent after the next uplink. (Maybe especially in cases where an earlier/outdated downlink was already pending, which might be sent immediately after receiving the next uplink, before you even got the chance to replace it.) And beware that downlinks might not be received by the device at all: it’s radio after all, and also gateways might be too busy to transmit it if your region enforces maximum duty cycles.
In short: make sure that LoRaWAN is a good choice for your use case.