-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModemProgramming.cs
58 lines (39 loc) · 1.55 KB
/
ModemProgramming.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using NrfjprogAPI.NetCore;
using System;
using static NrfjprogAPI.NetCore.NrfProgrammer;
namespace NrfProgApi
{
public class ModemProgramming
{
private msg_callback logCallback;
private static msg_callback progressCallback;
public ModemProgramming()
{
nrfProgrammer = new NrfProgrammer();
logCallback = (message) =>
{
Console.WriteLine(message);
};
progressCallback = (message) =>
{
ProgressObject jsonObject = JsonConvert.DeserializeObject<ProgressObject>(message);
Console.WriteLine(jsonObject);
};
}
public void Program()
{
var dllVersion = nrfProgrammer.ReadDllVersion();
var connectedDevices = nrfProgrammer.ListConnectedDevices(logCallback);
HardwareList = connectedDevices.Where(x => x != 0).Select(x => x.ToString()).ToList();
var deviceId = uint.Parse(HardwareList[0]);
var connectResult = nrfProgrammer.ProgramModem(deviceId,
Path.Combine($"{FIRMWAREDOWNLOAD_PATH}\\{Firmware}\\mfw_nrf9160_1.3.5.zip"), // Path to modem firmware zip file from https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK/Download
Path.Combine($"{FIRMWAREDOWNLOAD_PATH}\\{Firmware}\\{Firmware}.hex"), // Path to your hex file
progressCallback, logCallback);
if (connectResult != "SUCCESS")
{
return;
}
}
}
}