diff --git a/pkg/webui/console/components/mac-settings-section/index.js b/pkg/webui/console/components/mac-settings-section/index.js
index bdbf6e133d..979a2f865e 100644
--- a/pkg/webui/console/components/mac-settings-section/index.js
+++ b/pkg/webui/console/components/mac-settings-section/index.js
@@ -124,9 +124,6 @@ const maxDutyCycleOptions = [
{ value: 'DUTY_CYCLE_16384', label: '0.006%' },
]
-const encodeAdrMode = value => ({ [value]: {} })
-const decodeAdrMode = value => (value !== undefined ? Object.keys(value)[0] : null)
-
const MacSettingsSection = props => {
const {
activationMode,
@@ -238,6 +235,20 @@ const MacSettingsSection = props => {
[values],
)
+ const getEncodedAdrModeValue = useCallback(mode => {
+ if (mode === 'static') {
+ return {
+ data_rate_index: 0,
+ tx_power_index: 0,
+ nb_trans: 1,
+ }
+ }
+ return {}
+ }, [])
+
+ const encodeAdrMode = value => ({ [value]: getEncodedAdrModeValue(value) })
+ const decodeAdrMode = value => (value !== undefined ? Object.keys(value)[0] : null)
+
return (
{
component={Input}
type="number"
inputWidth="xs"
+ max={15}
/>
{
component={Input}
type="number"
inputWidth="xs"
+ min={1}
+ max={15}
/>
>
)}
diff --git a/pkg/webui/console/views/device-general-settings/network-server-form/validation-schema.js b/pkg/webui/console/views/device-general-settings/network-server-form/validation-schema.js
index c9afd4168d..904a1baa26 100644
--- a/pkg/webui/console/views/device-general-settings/network-server-form/validation-schema.js
+++ b/pkg/webui/console/views/device-general-settings/network-server-form/validation-schema.js
@@ -356,8 +356,13 @@ const validationSchema = Yup.object()
return Yup.object().shape({
static: Yup.object().shape({
data_rate_index: Yup.number().nullable(),
- tx_power_index: Yup.number().nullable(),
- nb_trans: Yup.number().nullable(),
+ tx_power_index: Yup.number()
+ .nullable()
+ .max(15, Yup.passValues(sharedMessages.validateNumberLte)),
+ nb_trans: Yup.number()
+ .nullable()
+ .min(1, Yup.passValues(sharedMessages.validateNumberGte))
+ .max(15, Yup.passValues(sharedMessages.validateNumberLte)),
}),
})
} else if (value && 'disabled' in value) {
diff --git a/sdk/js/src/service/devices/index.js b/sdk/js/src/service/devices/index.js
index a3a975a1d2..dc89fe91d0 100644
--- a/sdk/js/src/service/devices/index.js
+++ b/sdk/js/src/service/devices/index.js
@@ -114,7 +114,7 @@ class Devices {
}
}
- if (paths.includes('mac_settings')) {
+ if (paths.some(path => path.includes('mac_settings'))) {
const { mac_settings = {} } = device
if (
@@ -137,7 +137,7 @@ class Devices {
}
if (typeof mac_settings.adr.static.nb_trans === 'undefined') {
- mac_settings.adr.static.nb_trans = 0
+ mac_settings.adr.static.nb_trans = 1
}
if (typeof mac_settings.adr.static.tx_power_index === 'undefined') {