We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesOneHop EngineDevice Integrationdriver_adapt.h

driver_adapt.h

File info
driver_adapt.h
Contains device-level driver APIs. You will need to implement the detailed driver adaptation on your own. The driver_adapt.h file is a general device adaptation API file, and this page introduces only those APIs related to OneHop Engine.

Constant Summary

Type Name Desc
Macro NFC_DRIVER_NAME NFC driver name

Constants

Constant
NFC_DRIVER_NAME
"nfc"

Structs

Struct
FcDriverAdaptOps
A general driver adaptation callback structure. This page only describes the callbacks related to OneHop Engine.

Members

Member name Member desc
const char name Device driver name. For example, to adapt to the NFC API of OneHop Engine, the name must be the predefined value NFC_DRIVER_NAME.
const char desc Device driver description.
Init Initializes the driver.
Deinit Deinitializes the driver.
SendData Sends data to be written into the NFC tag to the upper-layer app. The upper-layer app will then write the data to the NFC tag.
GetParam Obtains device parameters.
Struct
GetParamsType
Queries the parameter type.

Members

Member name Member desc
GET_DEV_MAC = 0 Queries the device MAC address.
GET_MODEL_ID = 1 Queries the corresponding device ID.
GET_DEV_NAME = 2 Queries the device name.

Callback Methods

Method
int (Init)(void ctx, const char* ifName);
Initializes the driver.

Parameters

Parameter name Parameter desc
ctx Information required for driver initialization. This parameter can be left blank.
ifName API name. This parameter can be left blank.

Return

type desc
int 0: Succeeded. -1: Failed.
Method
int (Deinit)(void priv);
Deinitializes the driver.

Parameters

Parameter name Parameter desc
priv The device parameter. The void keyword is used to match the parameter structures of different devices. This parameter can be left blank.

Return

type desc
int 0: Succeeded. -1: Failed.
Method
int (SendData)( unsigned char data, int dataLen, void* priv);
Sends data. The OneHop service uses this callback  to send the data to be written into the NFC tag to the upper-layer app. The upper-layer app writes the data into the NFC tag.

Parameters

Parameter name Parameter desc
data Data to be written into the NFC tag.
dataLen Length of the data to be sent. The value ranges from 0 to 256.
priv Pointer to the data structure for sending data. The void keyword is used to match the parameter structures of different devices.

Return

type desc
int 0: Succeeded. -1: Failed.
Method
int (GetParam)(GetParamsType paramType, void result);
Obtains device parameters. The OneHop service uses this callback to obtain parameter information about the device from the upper-layer app, and identifies the type of the parameter to be obtained via the input parameter paramType. Currently, paramType can only be GET_DEV_NAME, indicating to obtain the device name. The upper-layer app should return the device name via the result parameter.

Parameters

Parameter name Parameter desc
paramType Enumeration of the parameter type to be obtained. For details, see section 3.4.2.
result Pointer to the structure for obtaining parameter values. The void keyword is used to match the parameter structures of different devices. The maximum length is 256 bytes.

Return

type desc
int 0: Succeeded. -1: Failed.
Search in References
Enter a keyword.