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 11, 2024
1 parent 6368b33 commit fc77bdd
Show file tree
Hide file tree
Showing 7 changed files with 535 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.
5 changes: 4 additions & 1 deletion src/components/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
logger,
preventAppCloseUntilComplete,
selectedDevice,
selectedDeviceInfo,
SidePanel,
Toggle,
truncateMiddle,
Expand All @@ -27,6 +28,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 +44,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 +406,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: 'nRF9160' | 'nRF9161';
scope: 'DEVELOPMENT' | 'PRODUCTION';
}

export default async (
product: 'nRF9160' | '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 fc77bdd

Please sign in to comment.