|
OpenThread_app
|
Main API for OpenThread hardware application device driver. More...
Classes | |
| struct | ot_app_drv_nvs_t |
| NVS Non-Volatile Storage functions. More... | |
| struct | ot_app_drv_pair_t |
| struct | ot_app_drv_devName_t |
| struct | ot_app_drv_coap_t |
| struct | ot_app_devDrvAPI_t |
| struct | ot_app_devDrv_t |
Typedefs | |
| typedef struct ot_app_drv_nvs_t | ot_app_drv_nvs_t |
| NVS Non-Volatile Storage functions. | |
| typedef struct ot_app_drv_pair_t | ot_app_drv_pair_t |
| typedef struct ot_app_drv_devName_t | ot_app_drv_devName_t |
| typedef struct ot_app_drv_coap_t | ot_app_drv_coap_t |
| typedef struct ot_app_devDrvAPI_t | ot_app_devDrvAPI_t |
| typedef uint8_t | ot_app_size_t |
| typedef otapp_pair_rule_t *(* | pairRuleGet_callback_t) (void) |
| typedef otapp_coap_uri_t *(* | uriGet_callback_t) (void) |
| typedef void(* | subscribedUris_callback_t) (oac_uri_dataPacket_t *dataPacket) |
| typedef void(* | mainTask_callback_t) (void) |
| typedef struct ot_app_devDrv_t | ot_app_devDrv_t |
Functions | |
| ot_app_devDrv_t * | ot_app_drv_getInstance (void) |
| void | ot_app_drv_task (void) |
Variables | |
| int8_t(* | ot_app_drv_nvs_t::saveString )(const char *inData, const uint8_t keyId) |
| save data into NVS partition | |
| int8_t(* | ot_app_drv_nvs_t::readString )(char *outBuff, uint8_t outBuffSize, const uint8_t keyId) |
| read data from NVS partition | |
| int8_t(* | ot_app_drv_nvs_t::init )(void) |
| NVS init function. | |
| otapp_pair_DeviceList_t *(* | ot_app_drv_pair_t::getHandle )(void) |
| get ptr of otapp_pair_DeviceList_t handle | |
| int8_t(* | ot_app_drv_pair_t::uriStateSet )(otapp_pair_DeviceList_t *pairDeviceList, const oacu_token_t *token, const uint32_t *uriState) |
| set uri state on the pair device list. Max data per uri = uint32_t | |
| int8_t(* | ot_app_drv_pair_t::uriGetIdList )(otapp_pair_Device_t *deviceHandle, otapp_deviceType_t uriDevType) |
| looking for ID of urisList in urisList | |
| int8_t(* | ot_app_drv_devName_t::devNameFullToEUI )(const char *deviceNameFull, uint8_t stringLength, char **outEuiChrPtr) |
| decode EUI from deviceNameFull | |
| int8_t(* | ot_app_drv_devName_t::devNameEuiIsSame )(const char *deviceNameFull, const char *eui) |
| compare EUI from deviceNameFull with given EUI | |
| void(* | ot_app_drv_coap_t::sendBytePut )(const otIp6Address *peer_addr, const char *aUriPath, const uint8_t *payloadMsg, const uint16_t payloadMsgSize, otCoapResponseHandler responseHandler, void *aContext) |
| send coap message bytes using the PUT method | |
| void(* | ot_app_drv_coap_t::sendByteGet )(const otIp6Address *peer_addr, const char *aUriPath, otCoapResponseHandler responseHandler, void *aContext) |
| send coap request using the GET method. Response will contain bytes | |
| void(* | ot_app_drv_coap_t::sendResponse )(otMessage *requestMessage, const otMessageInfo *aMessageInfo, const uint8_t *responceContent, uint16_t responceLength) |
| send coap response to device | |
| int8_t(* | ot_app_drv_coap_t::readPayload )(otMessage *aMessage, uint8_t *bufferOut, uint16_t bufferSize, uint16_t *readBytesOut) |
| read incoming message and save them to in buffer | |
| int8_t(* | ot_app_drv_coap_t::processUriRequest )(otMessage *aMessage, const otMessageInfo *aMessageInfo, oacu_uriIndex_t uriId, uint8_t *bufOut, uint16_t bufSize) |
| main function for HARDWARE DEVICE URIS. This function processing incoming request. Request can be concern adding device to subscribe list or general uri request to next processing. If it is general uri request, then the given bufOut contains data to processing. | |
| ot_app_drv_pair_t | ot_app_devDrvAPI_t::pair |
| ot_app_drv_devName_t | ot_app_devDrvAPI_t::devName |
| ot_app_drv_nvs_t | ot_app_devDrvAPI_t::nvs |
| ot_app_drv_coap_t | ot_app_devDrvAPI_t::coap |
| subscribedUris_callback_t | ot_app_devDrv_t::obs_subscribedUri_clb |
| otapp_pair_observerCallback_t | ot_app_devDrv_t::obs_pairedDevice_clb |
| it will be called when new device has been properly paired. All data are saved in otapp_pair_DeviceList_t. | |
| pairRuleGet_callback_t | ot_app_devDrv_t::pairRuleGetList_clb |
| Callback function to retrieve the list of pairing rules. *. | |
| uriGet_callback_t | ot_app_devDrv_t::uriGetList_clb |
| Callback function to retrieve the list of URIs. | |
| char * | ot_app_devDrv_t::deviceName |
| Device name group identifier for network pairing. | |
| const otapp_deviceType_t * | ot_app_devDrv_t::deviceType |
| Pointer to the device type identifier. | |
| ot_app_size_t | ot_app_devDrv_t::uriGetListSize |
| Number of URIs in the URI list. | |
| mainTask_callback_t | ot_app_devDrv_t::task |
| Main task callback for periodic device processing. | |
| ot_app_devDrvAPI_t | ot_app_devDrv_t::api |
| Application device driver API structure. | |
Main API for OpenThread hardware application device driver.
Main API for OpenThread hardware application device driver.
Provides unified interface for managing hardware devices in Thread networks:
Key Features:
Example Initialization:
Pairing Requirements:
Framework automatically calls registered callbacks during:
| typedef void(* mainTask_callback_t) (void) |
| typedef struct ot_app_devDrv_t ot_app_devDrv_t |
| typedef struct ot_app_devDrvAPI_t ot_app_devDrvAPI_t |
| typedef struct ot_app_drv_coap_t ot_app_drv_coap_t |
| typedef struct ot_app_drv_devName_t ot_app_drv_devName_t |
| typedef struct ot_app_drv_nvs_t ot_app_drv_nvs_t |
NVS Non-Volatile Storage functions.
| typedef struct ot_app_drv_pair_t ot_app_drv_pair_t |
| typedef uint8_t ot_app_size_t |
| typedef otapp_pair_rule_t *(* pairRuleGet_callback_t) (void) |
| typedef void(* subscribedUris_callback_t) (oac_uri_dataPacket_t *dataPacket) |
| typedef otapp_coap_uri_t *(* uriGet_callback_t) (void) |
| ot_app_devDrv_t * ot_app_drv_getInstance | ( | void | ) |
| void ot_app_drv_task | ( | void | ) |
| ot_app_devDrvAPI_t ot_app_devDrv_t::api |
Application device driver API structure.
This structure contains function pointers that define the full API for interacting with the OpenThread device driver. It provides organized access to key subsystems:
This centralized API structure aids modular and flexible device driver design, allowing easy interaction with all key OpenThread application features.
Internal callbacks such as obs_pairedDevice_clb, obs_subscribedUri_clb, and pairing rules callback pairRuleGetList_clb are maintained here alongside device properties (deviceName, deviceType), URI management, and main task pointer.
The instance is statically allocated and accessed via ot_app_drv_getInstance().
| ot_app_drv_coap_t ot_app_devDrvAPI_t::coap |
| char* ot_app_devDrv_t::deviceName |
Device name group identifier for network pairing.
Pointer to the device name group string used for network pairing.
This string identifies the device on the OpenThread network and filters pairing – only devices with a matching name group can pair together.
Enables logical grouping of devices (e.g., by room or function).
Buffer Properties:
The buffer for this pointer is allocated and initialized by the application. In the reference implementation, it is set in the ad_button_Init() function, which copies the provided group name into an internal static buffer and assigns its address to this field (example initialization).
| const otapp_deviceType_t* ot_app_devDrv_t::deviceType |
Pointer to the device type identifier.
Points to a constant device type identifier used to classify the device. This type typically indicates the device category or role within the OpenThread network, such as switch, light, sensor, etc.
The device type helps the pairing rules and other network management logic determine the kind of device and apply appropriate filters or actions.
The pointer refers to a static, application-defined constant, for example, OTAPP_SWITCH for a button or switch device.
The type otapp_deviceType_t represents the full supported list of device types recognized by the framework, allowing classification across all supported device categories.
| ot_app_drv_devName_t ot_app_devDrvAPI_t::devName |
| int8_t(* ot_app_drv_devName_t::devNameEuiIsSame) (const char *deviceNameFull, const char *eui) |
compare EUI from deviceNameFull with given EUI
| deviceNameFull | [in] string ptr to device name full |
| eui | [in] ptr to EUI |
| int8_t(* ot_app_drv_devName_t::devNameFullToEUI) (const char *deviceNameFull, uint8_t stringLength, char **outEuiChrPtr) |
decode EUI from deviceNameFull
| deviceNameFull | [in] string ptr to device name full |
| stringLength | [in] string lenght |
| outEuiChrPtr | [out] ptr to EUI from string. It looks for EUI string from deviceNameFull and return ptr to first element of EUI string. |
| otapp_pair_DeviceList_t *(* ot_app_drv_pair_t::getHandle) (void) |
get ptr of otapp_pair_DeviceList_t handle
| int8_t(* ot_app_drv_nvs_t::init) (void) |
NVS init function.
| ot_app_drv_nvs_t ot_app_devDrvAPI_t::nvs |
| otapp_pair_observerCallback_t ot_app_devDrv_t::obs_pairedDevice_clb |
it will be called when new device has been properly paired. All data are saved in otapp_pair_DeviceList_t.
| [out] | newDevice | ptr to data struct otapp_pair_Device_t |
| subscribedUris_callback_t ot_app_devDrv_t::obs_subscribedUri_clb |
| ot_app_drv_pair_t ot_app_devDrvAPI_t::pair |
| pairRuleGet_callback_t ot_app_devDrv_t::pairRuleGetList_clb |
Callback function to retrieve the list of pairing rules. *.
This callback is used by the OpenThread device driver to obtain the current set of pairing rules that determine which devices are allowed to pair.
When invoked, the callback returns a pointer to an array of pairing rules (otapp_pair_rule_t) specifying device types allowed or disallowed for pairing.
The application should assign this callback to provide dynamic or static pairing rules depending on the system's pairing policy.
Configuration:
| int8_t(* ot_app_drv_coap_t::processUriRequest) (otMessage *aMessage, const otMessageInfo *aMessageInfo, oacu_uriIndex_t uriId, uint8_t *bufOut, uint16_t bufSize) |
main function for HARDWARE DEVICE URIS. This function processing incoming request. Request can be concern adding device to subscribe list or general uri request to next processing. If it is general uri request, then the given bufOut contains data to processing.
| aMessage | [in] ptr to incoming message |
| aMessageInfo | [in] ptr to message info |
| uriId | [in] specific HARDWARE DEVICE URI ID that was passed in uriGetListSize callback |
| bufOut | [out] ptr to buffer. Incomming data will be saved there. |
| bufSize | [in] size of bufOut |
| int8_t(* ot_app_drv_coap_t::readPayload) (otMessage *aMessage, uint8_t *bufferOut, uint16_t bufferSize, uint16_t *readBytesOut) |
read incoming message and save them to in buffer
| aMessage | [in] ptr to incoming message |
| bufferOut | [out] ptr to out buffer |
| bufferSize | [in] size of bufferOut |
| readBytesOut | [out] ptr to the uint16_t variable, where the size of the read bytes will be saved |
| int8_t(* ot_app_drv_nvs_t::readString) (char *outBuff, uint8_t outBuffSize, const uint8_t keyId) |
read data from NVS partition
| outData | [out] ptr to data |
| outDataSize | [out] ptr to the size of the data that was read |
| keyId | [in] it is id for saved data. It will be necessary for update or read data |
| int8_t(* ot_app_drv_nvs_t::saveString) (const char *inData, const uint8_t keyId) |
save data into NVS partition
| inData | [in] ptr to data |
| keyId | [in] it is id for saved data. It will be necessary for update or read data |
| void(* ot_app_drv_coap_t::sendByteGet) (const otIp6Address *peer_addr, const char *aUriPath, otCoapResponseHandler responseHandler, void *aContext) |
send coap request using the GET method. Response will contain bytes
| peer_addr | [in] ptr to device IPv6 address |
| aUriPath | [in] string ptr to uri |
| responseHandler | [in] callback to response handler |
| aContext | [in] content will be provided with responseHandler |
| void(* ot_app_drv_coap_t::sendBytePut) (const otIp6Address *peer_addr, const char *aUriPath, const uint8_t *payloadMsg, const uint16_t payloadMsgSize, otCoapResponseHandler responseHandler, void *aContext) |
send coap message bytes using the PUT method
| peer_addr | [in] ptr to device IPv6 address |
| aUriPath | [in] string ptr to uri |
| payloadMsg | [in] ptr to payload data |
| payloadMsgSize | [in] payload size |
| responseHandler | [in] callback to response handler |
| aContext | [in] content will be provided with responseHandler |
| void(* ot_app_drv_coap_t::sendResponse) (otMessage *requestMessage, const otMessageInfo *aMessageInfo, const uint8_t *responceContent, uint16_t responceLength) |
send coap response to device
| requestMessage | [in] ptr to request message |
| aMessageInfo | [in] ptr to message info |
| responceContent | [in] ptr to response data |
| responceLength | [in] size of response data |
| mainTask_callback_t ot_app_devDrv_t::task |
Main task callback for periodic device processing.
Pointer to the main task function that should be called periodically from the main loop or RTOS task to process device events and state updates.
This callback handles non-blocking processing of:
The framework calls this function regularly (e.g., every main loop iteration) to keep the device responsive and process pending work.
Example usage in reference implementation:
Set during initialization: drv->task = ad_button_task; [file:1]
| int8_t(* ot_app_drv_pair_t::uriGetIdList) (otapp_pair_Device_t *deviceHandle, otapp_deviceType_t uriDevType) |
looking for ID of urisList in urisList
| deviceHandle | [in] ptr to otapp_pair_Device_t |
| uriDevType | [in] type of device, we will be looking for in the uriList |
| uriGet_callback_t ot_app_devDrv_t::uriGetList_clb |
Callback function to retrieve the list of URIs.
This callback is used to obtain the list of supported URIs exposed by the device. The URIs typically represent accessible CoAP resource endpoints for network interaction.
When called, the callback returns a pointer to a list or array holding the URIs that the device registers or supports for remote access or commands.
This allows the framework or application to discover and interact with device capabilities dynamically.
| ot_app_size_t ot_app_devDrv_t::uriGetListSize |
Number of URIs in the URI list.
Returns the count of URIs supported by the device, corresponding to the size of the array returned by uriGetList_clb callback.
This value informs the framework how many CoAP resource endpoints the device exposes for network interaction and remote control.
Used during device registration and pairing to properly allocate resources for URI handling and subscription management.
| int8_t(* ot_app_drv_pair_t::uriStateSet) (otapp_pair_DeviceList_t *pairDeviceList, const oacu_token_t *token, const uint32_t *uriState) |
set uri state on the pair device list. Max data per uri = uint32_t
| pairDeviceList | [in] ptr to Pair devices list. |
| token | [in] ptr to token of uri |
| uriState | [in] ptr to uri state. Max uint32_t |