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

Fix claiming issues in frontend #6335

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For details about compatibility between different releases, see the **Commitment
### Fixed

- Fix payload formatter page launching malformed requests in the Console.
- Fix end device claiming issues in the Console and improve error messaging.
- HTTP API routes for parsing QR codes for the QR Generator service. We exercise our right to break compatibility with third party HTTP clients since this is a bug.
- `/qr-code/end-devices/parse` is changed to `/qr-codes/end-devices/parse`.
- `/qr-code/end-devices/{format_id}/parse` is changed to `/qr-codes/end-devices/{format_id}/parse`.
Expand Down
12 changes: 11 additions & 1 deletion pkg/webui/console/containers/device-onboarding-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ const DeviceOnboardingForm = () => {

const handleSubmit = useCallback(
async (values, { resetForm }, cleanedValues) => {
const { _registration } = values
const { _registration, _claim } = values
const applicationIds = { application_id: appId }
const { mac_state = {} } = cleanedValues
const isClaiming = _claim === true

setError()

Expand All @@ -113,6 +114,15 @@ const DeviceOnboardingForm = () => {
delete mac_state.current_parameters
}

// Obtain the device ID from authenticated identifiers when claiming.
if (isClaiming) {
cleanedValues.ids = {
...cleanedValues.ids,
dev_eui: values.authenticated_identifiers.dev_eui,
device_id: values.target_device_id,
}
}

const endDevice = await dispatch(attachPromise(createDevice(appId, cleanedValues)))
switch (_registration) {
case REGISTRATION_TYPES.MULTIPLE:
Expand Down
10 changes: 3 additions & 7 deletions sdk/js/src/service/devices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class Devices {

// Initiate claiming, if the device is claimable.
const hasAuthenticatedIdentifiers = Boolean(authenticated_identifiers)
const claimInfoResponse = await this._api.EndDeviceClaimingServer.GetInfoByJoinEUI({
const claimInfoResponse = await this._api.EndDeviceClaimingServer.GetInfoByJoinEUI(undefined, {
join_eui: ids.join_eui,
})
const claim = Marshaler.payloadSingleResponse(claimInfoResponse)
Expand Down Expand Up @@ -521,12 +521,8 @@ class Devices {
application_id: applicationId,
},
}
try {
kschiffer marked this conversation as resolved.
Show resolved Hide resolved
const claimResponse = await this._api.EndDeviceClaimingServer.Claim(undefined, claimPayload)
claimDeviceIds = Marshaler.payloadSingleResponse(claimResponse)
} catch (error) {
throw new Error('Unable to claim end device', { cause: error })
}
const claimResponse = await this._api.EndDeviceClaimingServer.Claim(undefined, claimPayload)
claimDeviceIds = Marshaler.payloadSingleResponse(claimResponse)
}

let newFieldmasks = mask
Expand Down