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

Feat/imei programming #466

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
},
"nrfConnectForDesktop": {
"nrfutil": {
"91": [
"0.4.1"
],
"device": [
"2.1.1"
]
Expand Down Expand Up @@ -46,7 +49,7 @@
"prepare": "husky install"
},
"devDependencies": {
"@nordicsemiconductor/pc-nrfconnect-shared": "^170.0.0"
"@nordicsemiconductor/pc-nrfconnect-shared": "^171.0.0"
},
"eslintConfig": {
"extends": "./node_modules/@nordicsemiconductor/pc-nrfconnect-shared/config/eslintrc"
Expand Down
Binary file added resources/firmware/mfw_nrf91x1_2.0.1.zip
Binary file not shown.
Binary file added resources/firmware/pti.zip
Binary file not shown.
4 changes: 3 additions & 1 deletion src/components/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as jlinkTargetActions from '../actions/jlinkTargetActions';
import * as settingsActions from '../actions/settingsActions';
import * as targetActions from '../actions/targetActions';
import * as usbsdfuTargetActions from '../actions/usbsdfuTargetActions';
import ImeiProgramming from '../features/ImeiProgramming';
import {
getDeviceDefinition,
getDeviceIsBusy,
Expand All @@ -42,7 +43,7 @@ import { getIsWritable } from '../reducers/targetReducer';
import { convertDeviceDefinitionToCoreArray } from '../util/devices';

const useRegisterDragEvents = () => {
const dispatch = useDispatch();
const dispatch = useDispatch<AppDispatch>();
useEffect(() => {
const onDragover = (event: DragEvent) => {
if (!event.dataTransfer) return;
Expand Down Expand Up @@ -404,6 +405,7 @@ Are you sure you want to continue?`,
<span className="mdi mdi-refresh" />
Read
</Button>
<ImeiProgramming />
</Group>
<Group heading="J-Link Settings">
<Toggle
Expand Down
43 changes: 43 additions & 0 deletions src/features/ImeiProgramming/fetchIMEI.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

interface ImeiAllocationResource {
createdAt: string;
id: string;
imeis: string;
product: 'nRF9131' | 'nRF9151' | 'nRF9161';
scope: 'DEVELOPMENT' | 'PRODUCTION';
}

export default async (
product: 'nRF9131' | 'nRF9151' | 'nRF9161',
scope: 'DEVELOPMENT' | 'PRODUCTION',
apiKey: string
) => {
const response = await fetch(
'https://api.imei.nrfcloud.com/v1/imei-management/allocations',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({ scope, product, count: 1 }),
}
);

if (response.status !== 200) {
throw new Error(
`Error fetching IMEI: ${response.status}.${
response.statusText ? `statusText: ${response.statusText}` : ''
}. Make sure the API key is valid.`
);
}

const imei = ((await response.json()) as ImeiAllocationResource).imeis[0];
return imei;
};
Loading