Mistake on this page? Email us

Integrating the factory tool with the device using DFRD

The factory tool sends data to the device and receives data from it using the DFRD protocol.

Izuma has created an SDK that implements the DFRD protocol and a reference implementation of an application that uses the SDK in the factory. For more information about the SDK and reference implementation of the factory tool application, please contact us.

Note that you must compile the application with the Release solution configuration in Visual Studio.

Factory tool and device interface

Each time the factory tool communicates with the device, the tool must use the SDK APIs to:

  1. Create a new instance of the RSF SDK class:

    • To communicate with the device over USB:

      Rsf Rsf = new Rsf(VendorId, ProductId, LocalMessageRequest, LocalMessageResponse, LocalMessageError, OnDpnConnection, OnDpnDisconnection, OnDeviceConnection, OnDeviceDisconnection);
      

      The VendorID and ProductId values must match the values of these parameters in the device.

    • To communicate with the device over UART:

      Rsf Rsf = new Rsf(VendorId, ProductId, LocalMessageRequest, LocalMessageResponse, LocalMessageError, OnDpnConnection, OnDpnDisconnection, OnDeviceConnection, OnDeviceDisconnection);
      
      SerialPort serialPort = new SerialPort(port);
      serialPort.BaudRate = 38400;
      serialPort.ReadTimeout = 1000;
      serialPort.WriteTimeout = 1000;
      Rsf.setTwoWireMode(twoWire);
      Rsf.ConnectHolder(serialPort);
      
      • The values of VendorId and ProductId are irrelevant in this case.

      • port is a COMx-format string.

      • twoWire is a Boolean parameter, set to true for a two-wire serial link to the device or false for a one-wire link.

  2. Wait for the OnDeviceConnection() event, which indicates that full DFRD connection was established between the factory tool and the device.

  3. Send a message to the device by calling:

    Rsf.SendLocalMessageRequest(dpnId, isCharger, write, parameterId, payload)
    

    Where:

    • <byte dpnId> is the DFRD private network ID.
    • <ubool isCharger> is true if the device is a charger, or false if the device is a holder.
    • <ubool write> is true.
    • <ushort parameterId> is 0x100 or 0x101.
    • <byte[] payload> is the Secure Factory CLI response to the factory tool's new_device request.
  4. Receive the device response:

    • In this delegate:

      LocalMessageResponse(dpnId, isCharger, writeResponse, parameterId, payload)
      

      Where:

      • <byte dpnId> is the DFRD private network ID.
      • <ubool isCharger> is true if the response is from a charger, or false if the response is from a holder.
      • <ubool writeResponse> is true.
      • <ushort parameterId> is 0x100 or 0x101
      • <byte[] payload> is the Secure Factory CLI response to the factory tool's new_device request.
    • Or, if there is an error that is unrelated to the factory tool request, in this delegate:

      LocalMessageError(dpnId, isCharger, isInternal, writeResponse, parameterId, errorCode)
      

      Where:

      • <byte dpnId> is the DFRD private network ID.
      • <ubool isCharger> is true if the response is from a charger, or false if the response is from a holder.
      • <ubool isInternal> indicates whether the errorCode status is internal.
      • <ubool writeResponse> is true.
      • <ushort parameterId> is 0x100 or 0x101
      • <byte errorCode> provides insight into the cause of the error.

For additional related information, see Using the Secure Factory CLI commands and Integrating Secure Factory CLI with your factory tool.

For more information about the SDK APIs, please contact us.

Factory provisioning flow

The factory provisioning flow consists of three interactions with the device: Factory Init, Factory Data and Factory Disconnect. The SDK expects a single connection to the device for the entire provisioning flow; therefore, the factory tool must handle all three interactions in a single run.

Factory Init (command: 0x100)

For each new device:

  1. The factory tool sends a new_device request to Secure Factory CLI.

  2. Secure Factory CLI responds with a payload.

  3. Create a new instance of the SDK RSF class.

  4. The factory tool sends the device a Factory Init message by calling the Rsf.SendLocalMessageRequest() method.

  5. The device sends the factory tool a Factory Init Response message.

    The factory tool receives the message in the LocalMessageResponse() delegate.

    If there is an error that is unrelated to the factory tool request, the factory tool receives the related error message in the LocalMessageError() delegate.

  6. When the factory tool receives the device response, it sends Secure Factory CLI a get_device_configuration message with the device <byte[] payload>.

Factory Data (command: 0x101)

  1. The factory tool sends a get_device_configuration request to Secure Factory CLI.

  2. Secure Factory CLI sends back a provisioning payload in the response.

  3. The factory tool sends the device Factory Data message by calling the Rsf.SendLocalMessageRequest() method using the existing instance of the SDK RSF class.

  4. The device sends the factory tool a Factory Data Response message.

    The factory tool receives the message in the LocalMessageResponse() delegate.

    If there is an error that is unrelated to the factory tool request, the factory tool receives the related error message in the LocalMessageError() delegate.

  5. The factory tool sends Secure Factory CLI a verify_device_response message with the <byte[] payload>.

Factory Disconnect (command: 0x102)

  1. The factory tool sends the device a Factory Disconnect message by calling the Rsf.SendLocalMessageRequest() method using the existing instance of the SDK RSF class. The Factory Disconnect message indicates to the device that the factory flow has ended and the device can safely disconnect from the DFRD network. The device does not respond to the Factory Disconnect message.