SDK to JSON format - r4reejh/kai-nodejs GitHub Wiki
Some Rules for communicating with the SDK:
- Every module must be authenticated
- During authentication, module must send: a. it's moduleId b. the moduleSecret provided by vicara.
- SDK will send response for requests of type:
authentication
- SDK will not send response for setCapabilities
- SDK Websocket Server Listens on port 2203
- ERROR CODES are not final
Request:
{
"type": "authentication",
"moduleId": "<uuid>",
"moduleSecret": "an encrypted string" (use "qwerty" as a placeholder, for now)
}
Response:
{
"type": "authentication",
"success": true
}
Request:
{
"type":"setCapabilities",
"kaiId": <int> | "default" | "defaultLeft" | "defaultRight",
"gestureData": true / false,
"pyrData": true / false,
"fingerShortcutData": true / false,
"linearFlickData": true / false,
"fingerPositionData": true / false,
"quaternionData": true / false,
"pyrData": true / false,
"accelerometerData": true / false,
"gyroscopeData": true / false,
"magnetometerData": true / false
}
Response:
{
"type": "setCapabilities",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"success": true
}
Request:
{
"type": "getCapabilities",
"kaiId": <int> | "default" | "defaultLeft" | "defaultRight"
}
Response:
{
"success": true,
"type": "getCapabilities",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"gestureData":true / false,
"pyrData": true / false,
"fingerShortcutData": true / false,
"linearFlickData": true / false,
"fingerPositionData": true / false,
"quaternionData": true / false,
"pyrData": true / false,
"accelerometerData": true / false,
"gyroscopeData": true / false,
"magnetometerData": true / false
}
Request:
{
"type": "fingerCalibration",
"kaiId": <int> | "default" | "defaultLeft" | "defaultRight"
}
Response:
{
"type": "fingerCalibration",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"success": true
}
Request:
{
"type": "imuCalibration",
"kaiId": <int> | "default" | "defaultLeft" | "defaultRight"
}
Response:
{
"type": "imuCalibration",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"success": true
}
Request:
{
"type": "listConnectedKais"
}
Response:
{
"type": "listConnectedKais",
"kais": [
{
"kaiId": <int>,
"hand": "left" / "right",
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"kairialNumber": 1023912084102841023820941 // 64-bit long number
}
]
}
Request:
{
"type": "getKaiData",
"kaiId": <int> | "default" | "defaultLeft" | "defaultRight"
}
Response:
{
"type": "getKaiData",
"kai": {
"kaiId": <int>,
"hand": "left" / "right",
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"kairialNumber": 1023912084102841023820941 // 64-bit long number
}
}
Request:
{
"type": "switchHand",
"kai": <kaiId> | "default" | "defaultLeft" | "defaultRight",
"hand": "left" / "right"
}
Response:
{
"type": "switchHand",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"success": true
}
Response:
{
"type": "incomingData",
"kaiId": <int>,
?"defaultKai": true / false,
?"defaultLeftKai": true / false,
?"defaultRightKai": true / false,
"foregroundProcess": "chrome",
"data": [
{
"type": "gestureData",
"gesture": "swipeUp"
},
{
"type": "linearFlickData",
"flick": <string>
},
{
"type": "fingerShortcutData",
"fingers": [
true,
false,
false,
true
]
},
{
"type": "fingerPositionalData",
"fingers": [
0,
0,
255,
0
]
},
{
"type": "pyrData",
"pitch": 0.0,
"yaw": 0.0,
"roll": 0.0
},
{
"type":"quaternionData",
"quaternion": {
"w": 0,
"x": 0,
"y": 0,
"z": 0
}
},
{
"type":"accelerometerData",
"accelerometer": {
"x": 0,
"y": 0,
"z": 0
}
},
{
"type":"gyroscopeData",
"gyroscope": {
"x": 0,
"y": 0,
"z": 0
}
},
{
"type":"magnetometerData",
"magnetometer": {
"x": 0,
"y": 0,
"z": 0
}
}
]
}
if a request is sent with an unknown type, an error response will be sent:
{
"success": false,
"error": "unknownType",
"errorCode": 2,
"message": "Unknown type recieved"
}
For any requests sent before authentication, the following error response will be sent:
{
"success": false,
"error": "unauthorized",
"errorCode": 0,
"message": "the module has not been successfully authenticated"
}
This is the standard error response format:
{
"success": false,
"error": <string>, // represents the error in a short, minified version, useful for modules
"errorCode": <int>, // represents the error code
"message": <string> // represents a user-formatted string with the error, useful for displaying to the users
}