Read Device Mac Address¶
⚠️ Note: This document describes how to use the SDK's API to perform scanning operations and provides sample code in C. Please note that the API is synchronous and may block the main thread when used.
⚠️ Note: Before using the API, you need to connect the device first. For detailed steps, please refer to Connect Device.
1. Read Device Mac Address¶
Read the device Mac address. The method is as follows:
const char* result = inateck_scanner_ble_get_mac(device_id);
The return result is in JSON
format. If the call is successful, result
will return:
{
"status": 0,
"error": "",
"mac": "00:11:22:33:44:55"
}
If the call fails, result
will return:
{
"status": 1,
"error": "error message",
"mac": ""
}
mac
is the device Mac address. For example: 00:11:22:33:44:55
.
2. 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* result = inateck_scanner_ble_get_mac(device_id);
if (result) {
printf("result: %s\n", result);
} else {
printf("result is null\n");
}
}