Skip to content

Commit

Permalink
feat: add imei programming feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Pickel authored and Pascal Pickel committed Apr 16, 2024
1 parent 6368b33 commit a6af456
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 7 deletions.
10 changes: 5 additions & 5 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": "^167.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/pcm.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

0 comments on commit a6af456

Please sign in to comment.