TCP/IP
NUBISON IoT's standard TCP/IP protocol.
This is a guide for connecting a device that sends TCP/IP packet data to the Nubison IoT platform.
Before proceeding with the process below, Getting Startedthe steps written must be completed first.
Server Connection
Information for connecting to the TCP/IP packet communication socket of the Nubison IoT platform.
Server URL: Provided during integration
Terminology
Session ID: The session ID is a value to distinguish each transaction; it is a randomly generated string by the requester and is returned unchanged by the responder to distinguish the transaction.
Access Token: The access token issued when the device requests login to the Nubison IoT cloud. You must send a login packet before requests such as data transmission. And for all subsequent requests, you must include the issued access token in the packet data for proper processing.
Client ID & Client Secret: Getting Started Section > Issue Authentication Key These are the client ID and client secret strings issued in the part.
Product Code: Getting Started Section > Create Product Model This is the code string issued to the product model created in the part.
Device Identifier Key: Getting Started Section > Add Device This is the identifier key of the device created in the part.
Packet Type
When a device sends packet data to the Nubison IoT cloud,
put the packet type in the first byte of the packet data Packet Typeand send it; this allows determining what kind of request the device sent and processing the received data accordingly.
The types used by Nubison IoT Packet Typeare as follows.
L
Login.
The device connects to the Nubison IoT cloud to receive a token.
O
Logout.
The device logs out from the Nubison IoT cloud.
D
Data Transmission
Sends data to the Nubison IoT cloud.Sends data to the Nubison IoT cloud.
C
Send control command The Nubison IoT cloud sends a control command to the device.
H
Heartbeat
Sends a heartbeat (connection maintenance packet) to the Nubison IoT cloud.
R
Response
Used when sending response data device -> Nubison IoT cloud, or Nubison IoT cloud -> device.
At this time, the session ID must be the same as the session ID received earlier.
Login
[ Device -> Nubison IoT Cloud ]
1 byte
8 bytes
20 bytes
20 bytes
8 bytes
1 byte
any
string
string
string
string
string
int8
string
"L"
Session ID
Client ID
Client Secret
Product Code
Device identifier key length
Device Identifier Key
[ Nubison IoT Cloud -> Device ]
Success Response
1 byte
8 bytes
1 byte
24 bytes
1 byte (optional)
any (optional)
string
string
byte
string
int8
string
"R"
Session ID
0x01
Access Token
Encryption Key Length
Encryption Key
Failure Response
Logout
[ Device -> Nubison IoT Cloud ]
1 byte
8 bytes
24 bytes
string
string
string
"O"
Session ID
Access Token
[ Nubison IoT Cloud -> Device ]
Success Response
1 byte
8 bytes
1 byte
string
string
byte
"R"
Session ID
0x01
Data Transmission
[ Device -> Nubison IoT Cloud ]
1 byte
8 bytes
24 bytes
2 bytes
any
string
string
string
UInt16BE
any
"D"
Session ID
Access Token
Total payload length
Payload
Default Payload Format
When using an auto-generated driver in the Nubison IoT platform, construct and send the payload as a sequence of strings separated by "|". The Nubison IoT platform server will split the data by "|" and store the data in order according to unit numbers.
For example, if you set the product model units as follows
Unit 0: Temperature
Unit 1: Humidity
Unit 2: Acceleration
and send the data as follows
Unit 0 "Temperature" data value: 32
Unit 1 "Humidity" data value: 84
Unit 2 "Acceleration" data value: 43
construct the payload as follows.
payload = "32|84|43"
For more details about automatic driver generation, Create Driverplease refer to. If you need a more detailed discussion and composition of data payloads, please contact us.
[ Nubison IoT Cloud -> Device ]
Success Response
1 byte
8 bytes
1 byte
string
string
byte
"R"
Session ID
0x01
Failure Response
Send Control Command
[Nubison IoT Cloud -> Device]
1 byte
8 bytes
24 bytes
2 bytes
any
string
string
string
UInt16BE
any
"C"
Session ID
Access Token
Total payload length
Payload
[Device -> Nubison IoT Cloud]
Success Response
1 byte
8 bytes
1 byte
string
string
Int8
"R"
Session ID
1
Failure Response
1 byte
8 bytes
1 byte
string
string
Int8
"R"
Session ID
Any number other than 1
Heartbeat
[ Device -> Nubison IoT Cloud ]
1 byte
8 bytes
24 bytes
string
string
string
"H"
Session ID
Access Token
[ Nubison IoT Cloud -> Device ]
Success Response
1 byte
8 bytes
1 byte
string
string
byte
R
Session ID
0x01
Failure Response
Default data format when using auto driver
If you use the auto driver, compose the data as follows.
Convert the string separated by "|" into packet data and send it. (When using an auto-generated driver, the Nubison IoT platform server will split the data by "|" and store the data in order according to unit numbers.)
Numeric and location data in numeric format,
text data in text format,
numeric array data as numbers joined by ",",
text array data as text joined by ","
For example, if you set the product model units as follows
Unit 0: Temperature (number)
Unit 1: Humidity (number)
Unit 2: Mode (text)
Unit 3: Latitude (location)
Unit 4: Longitude (location)
Unit 5: Temperature data array (number array)
Unit 6: Mode data array (text array)
and send the data as follows
Unit 0 "Temperature" data value: 32
Unit 1 "Humidity" data value: 46
Unit 2 "Mode" data value: "default"
Unit 3 "Latitude" data value: 38.23
Unit 4 "Longitude" data value: 128.34
Unit 5 "Temperature data array" data value: [27,28,24,23,25]
Unit 6 "Mode data array" data value: ["default", "sleep", "mood"]
After composing the payload as follows, send it as a packet.
payload = "32|46|default|38.23|128.34|27,28,24,23,25|default,sleep,mood";
Buffer.from(payload)
Appendix A: Error Codes
Error Code
Description
Note
0x0001
Packet Type is not valid.
The Packet Type is not valid.Please refer to this document.
0x0002
Packet structure is not valid.
The packet structure according to the Packet Type is not valid.
0x0003
Client ID or Client Secret is not valid.
Please check again on the NUBISON IoT cloud.
0x0004
Device is not registered.
Pleaseregister the device first in the NUBISON IoT cloud before connecting.
0x0005
Access Token is not valid.
The Access Token is not valid.
0x0006
Payload structure is not valid.
The payload structure in the NUBISON IoT cloudis different from the registered device driver.
0x9999
Server Error
This is a server error. Please contact the person in charge.
Last updated