dasdigidings / the_things_stack_v3_tabs_decoder

Decoder in javascript for the family of tabs sensors for the things stack v3
GNU Affero General Public License v3.0
14 stars 8 forks source link

Formatter script size exceeds maximum allowed size (4096) #3

Closed ctandi closed 3 years ago

ctandi commented 3 years ago

Hi @dasdigidings,

thank you very much for providing a decoder for the tabs devices. Sadly, I run into an error. It seems as if the TTN v3 now has a maximum formatter size of 4096 letters.

When trowing in decodeUplink.js, TTN returns an error:

{
  "code": 3,
  "message": "error:pkg/applicationserver:field_value (invalid value of field `default_formatters.up_formatter_parameter`)",
  "details": [
    {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/applicationserver",
      "name": "field_value",
      "message_format": "invalid value of field `{field}`",
      "attributes": {
        "field": "default_formatters.up_formatter_parameter"
      },
      "correlation_id": "d36b60698cdd442ba4290c8ee0e16431",
      "cause": {
        "namespace": "pkg/applicationserver",
        "name": "formatter_script_too_large",
        "message_format": "formatter script size exceeds maximum allowed size",
        "attributes": {
          "max_size": 4096,
          "size": 6554
        },
        "code": 3
      },
      "code": 3
    }
  ],
  "request_details": {
    "url": "/as/applications/tbms100-ctamo/link",
    "method": "put",
    "stack_component": "as"
  }
}

I suppose the only option is to separate the decoder into one for each device.

Drasek commented 3 years ago

Thank you very much for opening the issue! I just run the code through a minifier and its under 4k again. Ofcourse it doesn't look as good and readable now so i added another file "decodeUplink.min.js" to use. Its all in this commit - i have not tested it atm - if you used a larger decoder bevor the patch it is still working, only new applications/decoders need the new smaller decoder. Please try it and if you find a error report back, thank you very much! We got another repo btw now with more v3 decoders (will have a look into them as well for the size, paycounter for exaple is to big as well): https://github.com/dasdigidings/The_Things_Stack_v3-payload_functions

ctandi commented 3 years ago

Hi @Drasek,

thanks for your swift reaction to my issue. I have just tested the minified decoder: It doesn't throw an error and seems to work fine with the TBMS100-868. I do not have any other tabs device at hand at the moment, so I can't confirm it working for anything other than the motion sensor.

Drasek commented 3 years ago

Thank you for testing the decoder. I will try my TABS with the minified decoder in the coming days, but hearing a first positive response is great! Will close the issue now and if there is another problem with the decoder just open a new issue please.