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:
-
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
andProductId
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
andProductId
are irrelevant in this case. -
port
is a COMx-format string. -
twoWire
is a Boolean parameter, set totrue
for a two-wire serial link to the device orfalse
for a one-wire link.
-
-
-
Wait for the
OnDeviceConnection()
event, which indicates that full DFRD connection was established between the factory tool and the device. -
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>
istrue
if the device is a charger, orfalse
if the device is a holder.<ubool write>
istrue
.<ushort parameterId>
is0x100
or0x101
.<byte[] payload>
is the Secure Factory CLI response to the factory tool'snew_device
request.
-
Receive the device response:
-
In this delegate:
LocalMessageResponse(dpnId, isCharger, writeResponse, parameterId, payload)
Where:
<byte dpnId>
is the DFRD private network ID.<ubool isCharger>
istrue
if the response is from a charger, orfalse
if the response is from a holder.<ubool writeResponse>
istrue
.<ushort parameterId>
is0x100
or0x101
<byte[] payload>
is the Secure Factory CLI response to the factory tool'snew_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>
istrue
if the response is from a charger, orfalse
if the response is from a holder.<ubool isInternal>
indicates whether theerrorCode
status is internal.<ubool writeResponse>
istrue
.<ushort parameterId>
is0x100
or0x101
<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:
-
The factory tool sends a
new_device
request to Secure Factory CLI. -
Secure Factory CLI responds with a payload.
-
Create a new instance of the SDK RSF class.
-
The factory tool sends the device a Factory Init message by calling the
Rsf.SendLocalMessageRequest()
method. -
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. -
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)
-
The factory tool sends a
get_device_configuration
request to Secure Factory CLI. -
Secure Factory CLI sends back a provisioning payload in the response.
-
The factory tool sends the device Factory Data message by calling the
Rsf.SendLocalMessageRequest()
method using the existing instance of the SDK RSF class. -
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. -
The factory tool sends Secure Factory CLI a
verify_device_response
message with the<byte[] payload>
.
Factory Disconnect (command: 0x102)
- 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.