NEQTO Docs
  • Languages iconEnglish
    • 日本語
  • Docs
  • API
  • FAQ

›neqto.js

Getting Started

  • NEQTO Hello World!
  • Tutorial Step 1. NEQTO Console Setting
  • Tutorial Step 2. Device Settings & Launching Service (NEQTO Bridge)
  • Tutorial Step 2. Device Settings & Launching Service (STM32 Discovery)
  • Tutorial Step 2. Device Settings & Launching Service (SPRESENSE)
  • Tutorial Step 3. Application development using scripts

NEQTO

  • NEQTO Account Registration
  • Sub-accounts
  • API Usage
  • NEQTO Engine Firmware List
  • Support Guidelines
  • For safe and secure use of the NEQTO products
  • Vulnerability Disclosure Policy

NEQTO Console

  • Introduction
  • Fundamentals
  • Administrative Actions
  • Device Management
  • Linux-based Device Management
  • Batch Registration
  • Scripts
  • Actions and Contacts
  • View Data from the Console
  • NEQTO Apps

    • About NEQTO Apps
    • NEQTO Infinitypool
    • NEQTO Insights
    • NEQTO Custodia
    • NEQTO Flow
  • Machine Driver
  • Recommended Browsers
  • Billing Information

SPRESENSE

    Hardware Specifications

    • 01. About Spresense

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. Spresense Wi-Fi Initial Setup
    • 04. Spresense LTE-M Initial Setup
    • 05. Debug Log Acquisition
    • 06. System LED Indications
    • 07. Event Messages
    • 08. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. GPIO
    • 12. UART
    • 13. SPI
    • 14. I2C
    • 15. ADC
    • 16. GNSS
    • 17. Camera
    • 18. Utils
    • 19. nqSpresense
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte

STM32 Discovery

    Hardware Specifications

    • 01. About STM32 Discovery Kit (B-L4S5I-IOT01A)

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. STM32 Discovery Wi-Fi Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 18. Utils
    • 19. nqDiscovery
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi

NEQTO Bridge

    Hardware Specifications

    • 01. NEQTO Bridge Module
    • 02. NEQTO Bridge Wi-Fi Module
    • 03. NEQTO Bridge LTE-1 Module
    • 04. NEQTO Bridge LTE-M/NB Module
    • 05. NEQTO Bridge IO Board
    • 06. NEQTO Bridge Digital IO Board
    • 07. NEQTO Bridge Connector Board

    Software Specifications

    • 01. Operational Flow
    • 02. NEQTO Bridge Wi-Fi Module Initial Setup
    • 03. NEQTO Bridge LTE Module Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 17. BLE
    • 18. Utils
    • 19. nqBridge
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte
    • 25. nqLAN
    • 26. nqEx

Linux-based device

    Software Specifications

    • 01. System Requirements
    • 02. Installation
    • 03. Software Configurations
    • 04. Operational Flow
    • 05. Debug Log Acquisition
    • 06. Event Messages
    • 07. Updating Software

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. RTC
    • 10. UNIXSocket
    • 11. FileSystem
    • 12. SubProcess
    • 13. SubTask
    • 14. Queue
    • 15. Utils
    • 16. nqLinux
    • 17. nqService
    • 18. nqMqtt
    • 19. nqFOTA
    • 20. nqLAN

neqto.js Libraries

  • About neqto.js Libraries
  • UART

    • GM65 Barcode Reader
    • SRF Ultrasonic Range Finder - Serial Mode

    I2C

    • HTS221 v2 Temperature and Humidity Sensor
    • LIS2DW12 v2 Accelerometer
    • SRF Ultrasonic Range Finder - I2C Mode
    • [Archive] HTS221 Temperature and Humidity Sensor
    • [Archive] LIS2DW12 Accelerometer

    Utils

    • RTC Alarm Synchronized Scheduler

    Integration

    • AWS S3 v2
    • AWS IoT Core v2
    • Azure IoT v2
    • [Archive] GCP IoT Core
    • [Archive] AWS S3
    • [Archive] AWS IoT Core

neqto.js Snippets

  • About neqto.js Snippets
  • DataDog
  • Dropbox
  • Google Sheets
  • InfluxDB
  • Oracle Cloud Object Storage
  • Salesforce
  • Splunk
  • Niagara
  • [Archive] SAP Cloud Platform Internet of Things

Release Notes

  • NEQTO Console Updates
  • NEQTO Firmware (Bridge Wi-Fi/LTE Module) Releases
  • NEQTO Firmware (STM32 Discovery Wi-Fi) Releases
  • NEQTO Firmware (Spresense Wi-Fi/LTE-M) Releases
  • NEQTO Engine for Linux Releases
  • neqto.js Libraries Releases

22. nqFOTA

The nqFOTA object is a built-in object that provides the functionality to update the firmware of the user device using the NEQTO Machine Driver.

Functional overview:

  • Provides the function of downloading the firmware image file of the user device and reading the download data.
  • Provides a function to notify the firmware update result of the user device to NEQTO Console.

Limitations:

  • This object can only be used on the Machine Driver dedicated scripts.
  • The maximum size of one firmware image file is up to 2040KB.



Abstracts

Methods()/PropertiesSummaryVersionNote
new nqFOTA()Creates an nqFOTA instance.

{nqFOTA} Instance

Methods()/PropertiesSummaryVersionNote
.fileDownload()Downloads the specified file.
.binRead()Reads the downloaded data.
.reportResult()Notifies the firmware update result to NEQTO Console.
.setFailsafeTimer()Changes the value of the execution time monitoring timer for the script.



Details

new nqFOTA(fileName[,readChunk[,dlTimeout[,dlMaxTry]]])

Creates an nqFOTA instance.

NameTypeM/OSummary                                        Note
fileNamestringmandatorySpecify the file name to download.
readChunknumberoptionalSpecify the read unit [byte] of the download data.
Range: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024
The default value is 1024.
If the out-of-range setting value is specified, the default value is used.
dlTimeoutnumberoptionalSpecify the timeout value [ms] for download communication.
The default value is 30000.
dlMaxTrynumberoptionalSpecify the maximum number of download communication attempts.
Range: 1 -
The default value is 2.
return{nqFOTA}-{nqFOTA} : Generated {nqFOTA}

.fileDownload([callback])

Downloads the specified file.
This method is executed by blocking.

One file can be downloaded by one nqFOTA instance.
If you want to download multiple files, create a new nqFOTA instance and execute the download again. At that time, the previously downloaded file will be discarded.

NameTypeM/OSummaryNote                 
callback(len,total)functionoptionalNotifies the status of download progress. Executes callback processing periodically in synchronization with internal download processing timing.
len: {number}
Downloaded Size [Byte]
total: {number}
Download Size [Byte]
Version 02.02.00+
returnnumber, undefined-Size of the downloaded file [byte]If the download fails, it will be undefined. (Version 02.04.00+)
(Previous version: It will be 0)

.binRead()

Reads the downloaded data.
The data size to be read at one time is specified by readChunk when creating the nqFOTA instance.

NameTypeM/OSummaryNote
returnArrayBuffer, null-ArrayBuffer : Read data
null : No data to read

.reportResult(message,version[,eventType])

Notifies the firmware update result to NEQTO Console.
This method is executed by blocking.

NameTypeM/OSummary                                        Note
messagestringmandatorySpecify any message that indicates the result.Example: 'Success','failure', ...
versionstringmandatorySpecify any message that indicates the version.Example: 'v1.0.0','001','APP-1.0','APP_1_0_0', ...
eventTypestringoptionalSpecify the event message type.
'info','warn','error','fatal'
The default value is 'info'.
Version 02.00.00+
returnnumber-Status code of the HTTP response
200: Success
Other than: Failure
When an error occurs, an exception is raised.

.setFailsafeTimer(timeout)

Changes the value of the execution time monitoring timer for the script.
The NEQTO Machine Driver has a timer that monitors the execution time if the script does not finish as expected.
This timer always starts at the begining of the script.
When timeout occurs, an exception is raised and the script is forcibly ended.

NameTypeM/OSummary                                        Note
timeoutnumbermandatorySpecify the timeout value [s].
Range: 0 - 86400
The default value is 10800.
If the out-of-range setting value is specified, the default value is used. If 0 is set, the timer will be disabled.
returnnumber-Set valueWhen an error occurs, an exception is raised.



Object Usage Examples

The following sample is an operating script dedicated to the Machine Driver.

Sample 1

This is a sample for updating the firmware of a user device.
The firmware update part is a dummy.
The execution time monitoring timer value is changed to 5 minutes.

For FW_FILE, specify any file uploaded in the Machine Driver package.

var FW_FILE = 'sample.bin'; //Specify the file to be downloaded
var TARGET_VER = '0.0.1';

//Download parameter
var READ_CHUNK = 1024; //same as default
var DL_TIMEOUT = 30000; //same as default
var DL_RETRY = 2; //same as default

var fota = new nqFOTA(FW_FILE, READ_CHUNK, DL_TIMEOUT, DL_RETRY);

var fsTimer = fota.setFailsafeTimer(300); //5minutes
print('failsafeTimer: ' + fsTimer + 's');

var dlProg = 0;
print('Download start (' + FW_FILE + ')');
var dlFileSize = fota.fileDownload(function(len, total) {
    var percent = Math.round(len/total*100);
    if(dlProg != percent) {
        print('Downloading...' + percent + '%');
        dlProg = percent;
    }
});
print('Download completed!', dlFileSize);

var fwUpdate = function(fwSize) {
    var offset = 0;
    print('Update start');
    while(1) {
        var buf = fota.binRead(); //ArrayBuffer
        if(!buf) break;

        //FW write processing
        print('Updating...' + offset + '/' + fwSize);

        offset += buf.byteLength;
    }
    print('Update completed!', offset + '/' + fwSize);
    return true;
}

var getFwVersion = function() {
    return TARGET_VER; //dummy
}

var sendFotaResult = function(result, message, version) {
    var ret = fota.reportResult(message, version, result ? 'info' : 'error');
    print('reportResult:', result, '[' + version + '][' + message + ']', ret == 200 ? 'sendOK' : 'sendError');
}

if(dlFileSize) {
    if(fwUpdate(dlFileSize)) sendFotaResult(true, 'OK', getFwVersion());
    else sendFotaResult(false, 'Update failed', getFwVersion());
} else sendFotaResult(false, 'Download failed', getFwVersion());



Updated: 2025-03-19
← 21. nqMqtt23. nqWiFi →
  • Abstracts
    • {nqFOTA} Instance
  • Details
    • new nqFOTA(fileName[,readChunk[,dlTimeout[,dlMaxTry]]])
    • .fileDownload([callback])
    • .binRead()
    • .reportResult(message,version[,eventType])
    • .setFailsafeTimer(timeout)
  • Object Usage Examples
    • Sample 1
AboutNewsProductsFAQPrivacy PolicyVulnerability Disclosure Policy
NEQTO Console
IntroductionFundamentalsAdministrative ActionsDevice Management NEQTO Apps
NEQTO Bridge
NEQTO Bridge ModuleNEQTO Bridge Wi-Fi ModuleNEQTO Bridge LTE-1 ModuleError Logging Event Messages
API Documentation
API UsageGlobal APIRegional APIAPI Terms of Service
Jigsaw, Inc.
© 2025 JIG-SAW INC.