Integrate pc-nrfprog-js in an electron app

Hi,

I am trying to develop an electron app to program the DFU with *.zip firmware file generated by nrfutil. I looked at the nrfprog-js api and want to use the following function

nrfjprog.programDFU(
    device.serial,
    downloadLocation,
    device.path,
    15000,
    progress => {
      console.log(progress);
    },
    err => {
      if (err) throw err;
    }
  );

I have a few questions:

1. What are the requirements to add this library to my electron project? When I did `yarn add pc-nrfprog-js` I wasn't able to package it. Later when I looked at pc-nrfconnect-programmer and pc-nrfconnect-core then I realised there were lot of boilerplate codes to integrate this library with electron. I need help with setup. The app source code can be found here - https://github.com/baymac/cypherock-live-desktop/ 

2. I want user to do a simple one click download of the app and not install any external tools like Jlink. Is it possible to use pc-nrfprog-js without the tool?

PS - Refrain from suggesting to start from pc-nrfconnect-boilerplate.

Thanks.

  • Considering the complexity of pc-nrfjprog-js with electron, I am trying to add `pc-nrf-dfu-js` in my project. I am trying to run the following code in my project:

    DfuUpdates.fromZipFilePath(fimrwareLocation)
          .then(updates => {
            const serialTransport = new DfuTransportSerial(serialPort, 16)
            const dfuOperation = new DfuOperation(updates, serialTransport)
            console.log('Starting Bootloader DFU')
            dfuOperation.start(true)
          })
          .then(() => {
            console.log('Bootloader DFU completed successfully!')
          })

    I get the following error:

    DfuError: Error message: Timeout while reading from serial transport. 

    Any hint on what could be the issue? What am I doing wrong here?