Read Device Version Information and Battery Level


⚠️ Note: This document describes how to use the SDK's API to operate the scanning device and provides sample code in C language. Please note that the API is a synchronous operation and may block the main thread when used.

⚠️ Note: Before using the API, you need to connect the device first. For specific steps, please refer to Connect Device.

1. Read Device Bluetooth Version Information

Read the device Bluetooth version information. The method is as follows:

const char* result = inateck_scanner_ble_get_hardware_version(device_id);

The return result is in JSON format. If the call is successful, result will return:

{
    "status": 0,
    "error": "",
    "version": "OTA_D_V0.1.8"
}

If the call fails, result will return:

{
    "status": 1,
    "error": "error message",
    "version": ""
}

version is the device Bluetooth version information. For example: OTA_D_V0.1.8, where V0.1.8 is the version number.

2. Read Device Firmware Version Information

Read the device firmware version information. The method is as follows:

const char* result = inateck_scanner_ble_get_software_version(device_id);

The return result is in JSON format. If the call is successful, result will return:

{
    "status": 0,
    "error": "",
    "version": "BCST-75 V1.1.0 AI"
}

If the call fails, result will return:

{
    "status": 1,
    "error": "error message",
    "version": ""
}

version is the device firmware version information. For example: BCST-75 V1.1.0 AI,

3. Read Device Battery Information

Read the device battery information. The method is as follows:

const char* result = inateck_scanner_ble_get_battery(device_id);

The return result is in JSON format. If the call is successful, result will return:

{
    "status": 0,
    "error": "",
    "battery": 100
}

If the call fails, result will return:

{
    "status": 1,
    "error": "error message",
    "battery": 0
}

battery is the device battery information. For example: 100, indicating the battery level is 100%.

4. Sample Code

Here is a complete sample code:

#include <stdio.h>
#include <string.h>
#include "inateck_scanner_ble.h"

int main() {
    const char* device_id = "device_id";
    const char* result = inateck_scanner_ble_get_hardware_version(device_id);
    if (result) {
        printf("Hardware version: %s\n", result);
    } else {
        printf("Failed to get hardware version\n");
    }

    result = inateck_scanner_ble_get_software_version(device_id);
    if (result) {
        printf("Software version: %s\n", result);
    } else {
        printf("Failed to get software version\n");
    }

    result = inateck_scanner_ble_get_battery(device_id);
    if (result) {
        printf("Battery: %s\n", result);
    } else {
        printf("Failed to get battery\n");
    }

    return 0;
}

5. Sample Code in Other Languages