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_id
is the device ID.cmd
is the configuration command array, containing the identifiers and values of the configuration items. The value range is Configuration List. Each configuration item is aJSON
object containing the following fields:flag
is the identifier of each configuration item, which is an integer value. For example, theflag
ofvolume
is1001
.value
is the value of the configuration item. For example, thevalue
ofvolume
is0
, which means the sound is turned off.
device_type
is 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:
info
is the configuration information list, containing the name, identifier, and value of the configuration items.name
is the name of the configuration item.flag
is the identifier of the configuration item.value
is 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_id
is the device ID.device_type
is the device type, and the value range is Device Type List.
Return result:
info
is the configuration information list, containing the name, identifier, and value of the configuration items.name
is the name of the configuration item.flag
is the identifier of the configuration item.value
is 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;
}