TFTP
Push or pull firmware via TFTP client or collector-hosted server.
D.device.tftpClient.download
Section titled “D.device.tftpClient.download”Retrieves a file content from a remote server using TFTP.
Signature
D.device.tftpClient.download(options, callback)Parameters
options· `Object`- The TFTP download execution options.
options.filePath· `string`- The source file path on the device. It defines the location of the file to be downloaded. Relative to the TFTP server configuration.
options.port· `string` · optional, default `69`- The port number of the TFTP server.
options.blockSize· `number` · optional, default `1468`- The size of each DATA block in bytes. Must be between 8 and 65464.
options.windowSize· `number` · optional, default `4`- The number of blocks that can be sent or received without waiting for an acknowledgment. Valid values range from 1 to 65535.
options.retries· `number` · optional, default `3`- The maximum number of retry attempts before an error is triggered.
options.timeout· `number` · optional, default `3000`- The time in milliseconds to wait before retrying a failed request.
options.md5· `string` · optional- An optional MD5 checksum to verify the file's integrity.
options.sha1· `string` · optional- An optional SHA1 checksum to verify the file's integrity.
options.userExtensions· `object` · optional- Custom extensions that the server may or may not support. These extensions depend on server capabilities. Note: The TFTP algorithm itself cannot be modified. For example, a simple authentication mechanism can be implemented by sending `user` and `password` as extensions, allowing the server to validate credentials and accept or reject the request. However, all extensions are transmitted in plain text. Reserved extensions (`timeout`, `tsize`, `blksize`, `windowsize`, and `rollover`) cannot be used.
callback· `callback`- The TFTP download execution callback
callback.output· `Object` · optional- The tftp download execution result
callback.output.content· `string`- The content of file downloaded from the device, if the execution did not result in an error
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.tftpClient.download(options, callback)D.device.tftpClient.upload
Section titled “D.device.tftpClient.upload”Transfers a file content to a remote server using TFTP.
Signature
D.device.tftpClient.upload(options, callback)Parameters
options· `object`- The tftpClient upload execution options
options.filePath· `string`- The destination path on the device where the file will be stored, relative to the TFTP server configuration on the device.
options.content· `string`- The data to be written to the file on the device.
options.port· `number` · optional, default `69`- The port number of the TFTP server.
options.blockSize· `number` · optional, default `1468`- The size of each DATA block in bytes. Must be between 8 and 65464.
options.windowSize· `number` · optional, default `4`- The number of blocks that can be sent or received without waiting for an acknowledgment. Valid values range from 1 to 65535.
options.retries· `number` · optional, default `3`- The maximum number of retry attempts before an error is triggered.
options.timeout· `number` · optional, default `3000`- The time in milliseconds to wait before retrying a failed request.
options.md5· `string` · optional- An optional MD5 checksum to verify the file's integrity.
options.sha1· `string` · optional- An optional SHA1 checksum to verify the file's integrity.
options.userExtensions· `object` · optional- Custom extensions that the server may or may not support. These extensions depend on server capabilities. Note: The TFTP algorithm itself cannot be modified. For example, a simple authentication mechanism can be implemented by sending `user` and `password` as extensions, allowing the server to validate credentials and accept or reject the request. However, all extensions are transmitted in plain text. Reserved extensions (`timeout`, `tsize`, `blksize`, `windowsize`, and `rollover`) cannot be used.
callback· `callback`- The tftpClient upload execution callback
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.tftpClient.upload(options, callback)D.tftpServer.accept
Section titled “D.tftpServer.accept”Start a TFTP server on network collector that is able to receive a single PUT request from a TFTP client on a file
Signature
D.tftpServer.accept(options, onReady, onUploadEnd)Parameters
options· `Object`- The tftpServer accept options
options.filePath· `string`- The file path against which a TFTP client will execute a PUT request
options.port· `string` · optional, default `69`- The port number of the TFTP server.
options.blockSize· `number` · optional, default `1468`- The size of each DATA block in bytes. Must be between 8 and 65464.
options.windowSize· `number` · optional, default `4`- The number of blocks that can be sent or received without waiting for an acknowledgment. Valid values range from 1 to 65535.
options.timeout· `number` · optional, default `3000`- The time in milliseconds after which the file will be not accepted anymore by the TFTP server.
options.strictIpCheck· `boolean` · optional- A boolean value if the TFTP server shall ensure only D.device.ip can execute PUT over this file.
onReady· `callback`- The tftpServer onReady callback
onReady.error· `ErrorResult` · optional- Will be present if the TFTP server failed to start
onReady.host· `string` · optional- The TFTP server IP address
onReady.port· `string` · optional- The TFTP server port
onUploadEnd· `callback`- The tftpServer onUploadEnd callback
onUploadEnd.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
onUploadEnd.content· `string` · optional- The content received with the PUT request
Returns
void
Example
D.tftpServer.accept(options, onReady, onUploadEnd)D.tftpServer.serve
Section titled “D.tftpServer.serve”Start a TFTP server on network collector that is able to receive a single GET request from a TFTP client on a file
Signature
D.tftpServer.serve(options, onReady)Parameters
options· `object`- The tftpServer serve options
options.filePath· `string`- The file path against which a TFTP client will execute a GET request
options.content· `string`- The content of the file the TFTP clients will receive with a GET request
options.port· `string` · optional, default `69`- The port number of the TFTP server.
options.blockSize· `number` · optional, default `1468`- The size of each DATA block in bytes. Must be between 8 and 65464.
options.windowSize· `number` · optional, default `4`- The number of blocks that can be sent or received without waiting for an acknowledgment. Valid values range from 1 to 65535.
options.timeout· `number` · optional, default `3000`- The time in milliseconds after which the file will be not accepted anymore by the TFTP server.
options.strictIpCheck· `boolean` · optional- A boolean value if the TFTP server shall ensure only D.device.ip can execute GET over this file.
onReady· `callback`- The tftpServer onReady callback
onReady.error· `ErrorResult` · optional- Will be present if the TFTP server failed to start
onReady.host· `string` · optional- The TFTP server IP address
onReady.port· `string` · optional- The TFTP server port
Returns
void
Example
D.tftpServer.serve(options, onReady)