Serial APIs November 6, 2017

Overview

This page describes the low-level serial APIs used to manage UbiBot devices such as WS1 and WS1PRO model.  There are currently two ways to access the APIs:

1. USB serial port

Please note the following when connecting to your device:

  • Use the supplied Micro-USB cable or a compatible cable with four wires inside (positive, negative, data transfer & data receive). Some cheap cables only offer charging.
  • Switch off the device before connecting it to the PC using the Micro-USB cable.
  • Make sure the correct USB serial port is selected and turned on for connection.
  • Serial port settings:
    • Baudrate: 115200
    • Data bits: 8
    • Parity: none
    • Stop Bits: 1
    • Receive&Send: Text format
2. Direct TCP connection through device’s WiFi
  • Please first put the device into AP mode
  • Connect the UbiBot device’s WiFi SSID from your PC or Mobile phone.
  • TCP Destination IP: 192.168.1.1 (UbiBot Device will be the TCP server)
  • TCP Destination Port: 5001
  • Receive&Send: Text format

Serial APIs for Reading Information About the Device


The following APIs read information from the connected device.

Read device firmware information

This returns details of the firmware version, channel ID, user ID and serial number of the device.

Request:

{"command": "ReadProduct"}

Response:

Read device WiFi configuration

This returns the SSID and password of the Wi-Fi access point the device is configured to use.

Request:

{"command": "ReadWifi"}

Response:

Read device sensor configuration (metadata)

This returns the SSID and password of the Wi-Fi access point the device is configured to use.

Request:

{"command": "ReadMetaData"}
Response:

Read stored sensor data from device

This returns the sensor data that is stored on the device. The WS1 can hold over 300,000 sensor readings.

Request:
{"command": "ReadData"}

Response:

Read error log

Request:

{"command": "GetLastError"}

Scan nearby WiFi access points

This returns the sensor data that is stored on the device. The WS1 can hold over 300,000 sensor readings.

Request:

{"command": "ScanWifiList"}

Response:

Run device diagnostics test

This command triggers the device to read all the sensors and return the results.

Request:

{"command": "CheckSensors"}

Response:


Serial APIs for Making Changes to the Device (Make sure you have backed up all the data)


The following commands are used to change the device settings. Please make sure you have backed up or synced all data before running these commands.

Delete all stored data

This command deletes the data stored internally on the device. It can take up to 30 seconds to run.

NB the data is deleted permanently.

Request:

{"command": "ClearData"}

Change device sensor configuration

This command is used to change the sensor metadata.

NB the new metadata sent with the request must be supplied in JSON format as show in the example.

Request:

Response (if successful):

Change WiFi configuration

This command updates the Wi-Fi configuration of the device. It takes the following parameters:

SSID: SSID of the new Wi-Fi access point
Password: The password for the access point (plain text)
Type: WPA, WEP or OPEN
Backup IP: IP address to use if DNS isn’t working

Request:
{"command": "SetupWifi",”SSID”: "XXXXX",”password”: "XXXXX","backup_ip":"101.201.30.5", "type":"wpa"}

Response if successful:

Change device host endpoint address

This command will change the address of the endpoint that the device will contact when syncing data.

NB If you change this from the default it could interrupt data synchronisation. Please contact us for advice if you would like to run devices within your own private domain.

Request:
{"command": "SetupHost","Host": "api.ubibot.io"}

Response (if successful):