General Configuration¶
⚠️ Note: This document describes how to use the SDK's API to operate scanning devices and provides sample code in C language. Please note that the API performs synchronous operations, which may block the main thread during use.
⚠️ Note: Before using the API, you need to connect the device first. For detailed steps, please refer to Connecting the Device.
1. Configuration¶
Configure the general settings of the scanning device. The usage is as follows:
const char* result = inateck_scanner_ble_set_setting_info(device_id, cmd, device_type);
The return result is in JSON format. If the call is successful, result will return:
{
"status": 0,
"error": "",
"info": [
{
"name": "volume",
"flag": 1001,
"value": 0
},
{
"name": "vibration",
"flag": 1002,
"value": 0
}
]
}
If the call fails, result will return:
{
"status": 1,
"error": "error message"
}
Input parameters:
device_idis the device ID.cmdis the configuration command array, containing the identifiers and values of the configuration items. The value range is Configuration List. Each configuration item is aJSONobject containing the following fields:flagis the identifier of each configuration item, which is an integer value. For example, theflagofvolumeis1001.valueis the value of the configuration item. For example, thevalueofvolumeis0, which means the sound is turned off.
device_typeis the device type, and the value range is Device Type List.
For example, if you need to set the volume of the BCST-21 device to 0 and the vibration to 0, then cmd is [{"flag":1001,"value":0},{"flag":1002,"value":0}], and device_type is 12.
Return parameters:
infois the configuration information list, containing the name, identifier, and value of the configuration items.nameis the name of the configuration item.flagis the identifier of the configuration item.valueis the value of the configuration item.
2. Get Configuration¶
Get the general settings of the scanning device. The usage is as follows:
const char* result = inateck_scanner_ble_get_setting_info(device_id, device_type);
The return result is in JSON format. If the call is successful, result will return:
{
"status": 0,
"error": "",
"info": [
{
"name": "volume",
"flag": 1001,
"value": 0
},
{
"name": "vibration",
"flag": 1002,
"value": 0
}
]
}
If the call fails, result will return:
{
"status": 1,
"error": "error message"
}
Input parameters:
device_idis the device ID.device_typeis the device type, and the value range is Device Type List.
Return result:
infois the configuration information list, containing the name, identifier, and value of the configuration items.nameis the name of the configuration item.flagis the identifier of the configuration item.valueis the value of the configuration item.
3. Sample Code¶
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include "inateck_scanner_ble.h"
int main() {
const char* device_id = "device id";
const char* cmd = "[{\"flag\":1001,\"value\":0},{\"flag\":1002,\"value\":0}]";
// BCST-21
const char* device_type = 12;
const char* result = inateck_scanner_ble_set_setting_info(device_id, cmd, device_type);
printf("result: %s\n", result);
result = inateck_scanner_ble_get_setting_info(device_id, device_type);
printf("result: %s\n", result);
return 0;
}