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 CloudSync for GCP
  • NEQTO Engine Firmware List
  • Support Guidelines

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. Utils
    • 14. nqLinux
    • 15. nqService
    • 16. nqMqtt
    • 17. nqFOTA
    • 18. 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
    • 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
  • SAP Cloud Platform Internet of Things
  • Splunk
  • Niagara

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

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:

  • It can be used only in the script for Machine Driver.
  • The maximum size of one firmware image file is up to 1536KB.



Abstracts

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

{nqFOTA} Instance

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



Details

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

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.
dlRetrynumberoptionalSpecify the number of download communication retries.
The default value is 2.
return{nqFOTA}-{nqFOTA} : Generated {nqFOTA}

.fileDownload()

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
returnnumber-Size of the downloaded file [byte]If the download fails, 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

Sample 1

This is a sample firmware update process for the user device.
The firmware update part is a dummy.
The execution time monitoring timer value is changed to 5 minutes. (01.00.01+)

var FW_FILE = 'sammple.bin';
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 fs_timeout = fota.setFailsafeTimer(300); //5minutes (01.00.01+)
print('fs_timeout:' + fs_timeout);

var dl_data_len = fota.fileDownload();

var updateReading = function(totalLen ,cbToRead)
{
  var ab2Hex_00 = function(ab) {
    ret_str = '';
    uint8_a = new Uint8Array(ab);
    for(i=0; i<uint8_a.length; i++) {
      ret_str += ('00' + uint8_a[i].toString(16).toUpperCase()).substr(-2);
    }
    return ret_str;
  }
  while(1) {
    var buff = cbToRead();
    if(buff != null) {
      print('updating...currently only print: ' + ab2Hex_00(buff));
    } else {
      break;
    }
  }
  print('done');
  return 1;
}

if(dl_data_len > 0) {
    var result = updateReading(dl_data_len, function(){ return fota.binRead(); });

    if(result != 1) {
      fota.reportResult('update fail ', TARGET_VER);
    } else { //success
      fota.reportResult('update done ', TARGET_VER);
    }
}


Related resources

  • Machine Driver

Updated: 2022-09-09
← 21. nqMqtt23. nqWiFi →
  • Abstracts
    • {nqFOTA} Instance
  • Details
    • new nqFOTA(fileName[,readChunk[,dlTimeout[,dlRetry]]])
    • .fileDownload()
    • .binRead()
    • .reportResult(message,version[,eventType])
    • .setFailsafeTimer(timeout)
  • Object Usage Examples
    • Sample 1
  • Related resources
AboutNewsProductsFAQPrivacy 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.
© 2023 JIG-SAW INC.