Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ADR API usage #5353

Merged
merged 8 commits into from
Apr 12, 2022
Merged

Refactor ADR API usage #5353

merged 8 commits into from
Apr 12, 2022

Conversation

adriansmares
Copy link
Contributor

@adriansmares adriansmares commented Mar 30, 2022

Summary

Closes #3820
Closes #5092
References #40
References TheThingsIndustries/protoc-gen-fieldmask#43

Changes

  • Add error checking to the CLI SetFields calls
    • The errors would be hidden previously, which would cause weird behavior
  • While retrieving an end device from multiple components in the CLI, ensure that the bottom level fields are actually reachable
    • This is relevant for oneof fields, as the bottom level fields could contain multiple oneof options
  • Add ADR settings validation
    • mac_settings.adr is mutually exclusive with use_adr/adr_margin
    • The dynamic settings need to be well defined - both the min and the max must be valid data rates / TX power indices, and they need to be monotonic (min <= max)
    • The static settings need to be well defined - same rules
    • If the band does not allow ADR (ISM2400 does this), it is illegal to attempt to use the dynamic settings. Using static values / disabling ADR completely is still valid for those
  • Refactor ADR algorithm
    • Add aliases for the MAC state and the current/desired parameters. The dev.MacState.*Parameters spam is not adding any value in my opinion, but let me know your thoughts
    • For cases in which we run the algorithm (so no static settings / disabled), add parameter clamping options

Testing

Unit testing and CLI testing. Unit tests have been added for the clamping logic, while the CLI has been used extensively for the validation.

Mutual exclusivity of the fields
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.use_adr
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T14:21:27.176106985Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "use_adr": true
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.use_adr`)
    field=mac_settings.use_adr
    correlation_id=02f68c7580944eac993effbd1c703976
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.use_adr.value`)
    field=mac_settings.use_adr.value
    correlation_id=e7be3d06bcbc4ad19f459f11c6503a2c
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.disabled
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.use_adr`)
    field=mac_settings.use_adr
    correlation_id=ffc77bbd8e91405e9ce61e45702b4a52
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --unset mac-settings.use_adr
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T14:22:30.940208634Z",
  "network_server_address": "localhost",
  "mac_settings": {}
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.disabled
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T14:22:34.026777613Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "disabled": {}
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T14:22:37.647174521Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "static": {}
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T14:22:41.545353259Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {}
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.use_adr
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr`)
    field=mac_settings.adr
    correlation_id=c5b488ec27d94b54a74f81590d087979
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr_margin 16.2
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic`)
    field=mac_settings.adr.mode.dynamic
    correlation_id=b05ae7f396cb4879b1b08844f1085528
exit status 255
Disallowing dynamic ADR settings when the band does not allow it
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-3123213123123123 --mac-settings.use_adr
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.use_adr.value`)
    field=mac_settings.use_adr.value
    correlation_id=d2c2b0dc867e48e2af59cc66887a09c4
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-3123213123123123 --mac-settings.adr.mode.dynamic
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic`)
    field=mac_settings.adr.mode.dynamic
    correlation_id=28b5d28c60f94043b4c5851bc5b22841
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-3123213123123123 --mac-settings.adr.mode.static
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-3123213123123123",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "3123213123123123",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T17:13:06.443Z",
  "updated_at": "2022-04-01T15:02:49.615395852Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "static": {}
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-3123213123123123 --mac-settings.adr.mode.disabled
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-3123213123123123",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "3123213123123123",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T17:13:06.443Z",
  "updated_at": "2022-04-01T15:02:54.382600251Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "disabled": {}
    }
  }
}
Parameter well definedness
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-data-rate-index 3
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:12:48.528713620Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "min_data_rate_index": 3
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-data-rate-index 10
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.min_data_rate_index.value`)
    field=mac_settings.adr.mode.dynamic.min_data_rate_index.value
    correlation_id=6d0ad7ec95d5450bb9cac471c7ce26d2
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-data-rate-index 5
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:13:14.361201128Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "max_data_rate_index": 5
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-data-rate-index 2
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_data_rate_index.value`)
    field=mac_settings.adr.mode.dynamic.max_data_rate_index.value
    correlation_id=49e425fcb04a4cefaa2af2fd6b1fbbd5
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-data-rate-index 11
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_data_rate_index.value`)
    field=mac_settings.adr.mode.dynamic.max_data_rate_index.value
    correlation_id=2ee504a08c004af7abb509e761f14d72
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-tx-power-index 3
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:14:25.136783161Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "min_tx_power_index": 3
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-tx-power-index 10
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.min_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.min_tx_power_index
    correlation_id=87d467e1290249d786bfb3b445168efe
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 5
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:14:39.413107444Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "max_tx_power_index": 5
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 2
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.max_tx_power_index
    correlation_id=75e66333b6ec49d98813a9334464ee29
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 11
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.max_tx_power_index
    correlation_id=b3ef7c63fb2e4018bd214017d8ffb747
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-tx-power-index 3
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:14:25.136783161Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "min_tx_power_index": 3
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-tx-power-index 10
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.min_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.min_tx_power_index
    correlation_id=87d467e1290249d786bfb3b445168efe
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 5
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:14:39.413107444Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "max_tx_power_index": 5
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 2
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.max_tx_power_index
    correlation_id=75e66333b6ec49d98813a9334464ee29
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-tx-power-index 11
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_tx_power_index`)
    field=mac_settings.adr.mode.dynamic.max_tx_power_index
    correlation_id=b3ef7c63fb2e4018bd214017d8ffb747
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --unset mac-settings.adr
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:16:03.222665510Z",
  "network_server_address": "localhost",
  "mac_settings": {}
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-nb-trans 2
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:16:17.075643181Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "min_nb_trans": 2
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.min-nb-trans 4
WARN    Using insecure connection to OAuth server
error:pkg/errors:validation (invalid `end_device`: embedded message failed validation)
    name=SetEndDeviceRequestValidationError
    reason=embedded message failed validation
    field=end_device
    correlation_id=75af952296fd4129863692d7d1e124dd
--- error:pkg/errors:validation (invalid `mac_settings`: embedded message failed validation)
    reason=embedded message failed validation
    field=mac_settings
    name=EndDeviceValidationError
    correlation_id=64c807380a23413595ade989fba1f42b
--- error:pkg/errors:validation (invalid `adr`: embedded message failed validation)
    field=adr
    name=MACSettingsValidationError
    reason=embedded message failed validation
    correlation_id=049cff3812cf472bb93f9da6ad2f9eaa
--- error:pkg/errors:validation (invalid `dynamic`: embedded message failed validation)
    name=ADRSettingsValidationError
    reason=embedded message failed validation
    field=dynamic
    correlation_id=5981d2dc85fb46e3a01f46f00e049920
--- error:pkg/errors:validation (invalid `min_nb_trans`: value must be inside range [1, 3])
    field=min_nb_trans
    name=ADRSettings_DynamicModeValidationError
    reason=value must be inside range [1, 3]
    correlation_id=8f1486bfa707466685497e1c8799e94b
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-nb-trans 3
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:16:35.085298787Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "dynamic": {
        "max_nb_trans": 3
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.dynamic.max-nb-trans 1
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.dynamic.max_nb_trans`)
    field=mac_settings.adr.mode.dynamic.max_nb_trans
    correlation_id=f1ea4952683b4bcc8666a3857ed44f17
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static.data-rate-index 5
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:20:23.653655368Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "static": {
        "data_rate_index": 5
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static.data-rate-index 11WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.static.data_rate_index`)
    field=mac_settings.adr.mode.static.data_rate_index
    correlation_id=fd74f69320c54f69a31adb418b6b77cf
exit status 255
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static.tx-power-index 2
WARN    Using insecure connection to OAuth server
{
  "ids": {
    "device_id": "eui-1231231231231231",
    "application_ids": {
      "application_id": "app1"
    },
    "dev_eui": "1231231231231231",
    "join_eui": "0000000000000000"
  },
  "created_at": "2022-03-31T15:36:50.104Z",
  "updated_at": "2022-04-01T16:20:33.623149431Z",
  "network_server_address": "localhost",
  "mac_settings": {
    "adr": {
      "static": {
        "tx_power_index": 2
      }
    }
  }
}
adriansmares@A98BCD2222F1:~/go/src/go.thethings.network/lorawan-stack$ ttn-lw-cli dev set app1 eui-1231231231231231 --mac-settings.adr.mode.static.tx-power-index 15
WARN    Using insecure connection to OAuth server
error:pkg/networkserver:field_value (invalid value of field `mac_settings.adr.mode.static.tx_power_index`)
    field=mac_settings.adr.mode.static.tx_power_index
    correlation_id=2b22f1e722144882a3a0f1ff27430521
exit status 255

I'll add these CLI only tests as unit tests in a future PR.

Regressions

As part of this PR I've had to fix some field validation which was previously broken - you will see in the code that some extra loop variable aliases are added, since these variables are captured in certain function definitions which are called later. These checks where previously not working, so it is possible that we now reject some input that was previously accepted as valid. Depending on the reports we will need to check if validation is broken or the request is broken.

Notes for Reviewers

@johanstokking main reviewer.

If you would like to test this locally, regenerate the protos using TheThingsIndustries/protoc-gen-fieldmask#43, otherwise you will have a hard time switching between modes (as currently switching the type of oneof field in a single roundtrip is not possible).

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@adriansmares adriansmares added this to the v3.19.0 milestone Mar 30, 2022
@adriansmares adriansmares self-assigned this Mar 30, 2022
@github-actions github-actions bot added c/network server This is related to the Network Server ui/cli This is related to ttn-lw-cli labels Mar 30, 2022
@adriansmares adriansmares force-pushed the feature/5092-adr-impl branch 3 times, most recently from 74015c3 to 2d7a48e Compare April 1, 2022 14:45
@adriansmares adriansmares changed the title Refactor ADR implementation Refactor ADR API usage Apr 1, 2022
@adriansmares adriansmares force-pushed the feature/5092-adr-impl branch 4 times, most recently from 35e6e57 to 2c8af6b Compare April 1, 2022 16:49
@adriansmares adriansmares marked this pull request as ready for review April 1, 2022 16:51
@adriansmares adriansmares force-pushed the feature/5092-adr-impl branch 6 times, most recently from ca8b970 to e42259e Compare April 1, 2022 21:00
pkg/networkserver/grpc_deviceregistry.go Outdated Show resolved Hide resolved
pkg/networkserver/mac/adr.go Outdated Show resolved Hide resolved
pkg/ttnpb/fieldmask_utils.go Show resolved Hide resolved
Base automatically changed from feature/5092-max-nb-trans to v3.19 April 12, 2022 15:33
@adriansmares adriansmares force-pushed the feature/5092-adr-impl branch from 9bca024 to 6ec492c Compare April 12, 2022 15:34
@adriansmares adriansmares force-pushed the feature/5092-adr-impl branch from 6ec492c to 504c28e Compare April 12, 2022 15:51
Copy link
Contributor

@pgalic96 pgalic96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI part LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/network server This is related to the Network Server ui/cli This is related to ttn-lw-cli
Projects
None yet
3 participants