OpenThread_app
Loading...
Searching...
No Matches
ot_app_pair.h File Reference

Manages the list of discovered devices, pairing logic, and URI resource parsing. More...

#include "hro_utils.h"
#include "ot_app_coap_uri_obs.h"
#include "ot_app_coap.h"
#include "string.h"
#include "ot_app.h"

Go to the source code of this file.

Classes

struct  otapp_pair_resUrisParseData_t
 Structure holding temporary parsed data from a URI resource. More...
struct  otapp_pair_uris_t
 Represents a single URI endpoint belonging to a paired device. More...
struct  otapp_pair_Device_t
 Represents a fully paired remote device. More...
struct  otapp_pair_rule_t
 Rules structure defining which device types are allowed to pair. More...
struct  otapp_pair_queueItem_t
 Structure for the pairing event queue. More...

Macros

Comparison Results
#define OTAPP_PAIR_IS   (1)
 Objects are identical.
#define OTAPP_PAIR_IS_NOT   (2)
 Objects are different.
Return Codes
#define OTAPP_PAIR_OK   (-1)
 Operation successful.
#define OTAPP_PAIR_UPDATED   (-2)
 Device data was updated (e.g. new IP).
#define OTAPP_PAIR_NO_NEED_UPDATE   (-3)
 Device exists and data is current.
#define OTAPP_PAIR_ERROR   (-4)
 Generic error.
#define OTAPP_PAIR_NO_EXIST   (-5)
 Device not found in list.
#define OTAPP_PAIR_DEVICE_NAME_EXIST   (-6)
 Device name collision.
#define OTAPP_PAIR_DEVICE_NAME_TO_LONG   (-7)
 Name exceeds buffer size.
#define OTAPP_PAIR_DEVICE_NO_SPACE   (-8)
 Device list is full.
Buffer & Limits Configuration
#define OTAPP_PAIR_DEVICES_MAX   OTAPP_PAIRED_DEVICES_MAX
 Max number of paired devices (from ot_app.h).
#define OTAPP_PAIR_URI_MAX   OTAPP_PAIRED_URI_MAX
 Max number of URIs per device (from ot_app.h).
#define OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE   (OTAPP_URI_MAX_NAME_LENGHT + sizeof(otapp_deviceType_t) + sizeof(uint8_t))
#define OTAPP_PAIR_URI_RESOURCE_BUFFER_MAX_SIZE   (OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE * OTAPP_PAIR_URI_MAX)
#define OTAPP_PAIR_URI_MAX_VAL   OTAPP_URI_END_OF_INDEX
#define OTAPP_PAIR_NAME_FULL_SIZE   OTAPP_DEVICE_NAME_FULL_SIZE
#define OTAPP_PAIR_NO_URI   OTAPP_URI_NO_URI_INDEX
#define OTAPP_PAIR_URI_INIT   OTAPP_URI_END_OF_INDEX
Task & Queue Configuration
#define OTAPP_PAIR_QUEUE_LENGTH   10
 Depth of the pairing event queue.
#define OTAPP_PAIR_TASK_STACK_DEPTH   (128 * 17)
 Stack size for the pairing RTOS task.
#define OTAPP_PAIR_TASK_PRIORITY   5
 Priority of the pairing RTOS task.
Pairing Rules Configuration
#define OTAPP_PAIR_RULES_ALLOWED_SIZE   10
#define OTAPP_PAIR_RULES_ALLOWED_ITEM_MAX_SIZE   OTAPP_END_OF_DEVICE_TYPE
#define OTAPP_PAIR_NO_RULES   (OTAPP_END_OF_DEVICE_TYPE + 1)
#define OTAPP_PAIR_NO_ALLOWED   OTAPP_NO_DEVICE_TYPE
#define OTAPP_PAIR_END_OF_RULES   OTAPP_END_OF_DEVICE_TYPE
#define OTAPP_PAIR_OBSERVER_PAIRE_DDEVICE_CALLBACK_SIZE   10

Typedefs

typedef uint8_t otapp_pair_resUrisBuffer_t[OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE]
typedef struct otapp_pair_DeviceList_t otapp_pair_DeviceList_t
 Opaque handle for the device list.
typedef void(* otapp_pair_observerCallback_t) (otapp_pair_Device_t *newDevice)
 Prototype for observer callback function.

Enumerations

enum  otapp_pair_QueueDataType_t { OTAPP_PAIR_CHECK_AND_ADD_TO_DEV_LIST }
 Queue event types. More...

Functions

int8_t otapp_pair_init (ot_app_devDrv_t *driver)
 Initializes the pairing module.
int8_t otapp_pair_observerPairedDeviceRegisterCallback (otapp_pair_observerCallback_t callback)
 Registers a callback to be notified when a new device is paired.
int8_t otapp_pair_DeviceAdd (otapp_pair_DeviceList_t *pairDeviceList, const char *deviceNameFull, otIp6Address *ipAddr)
 Adds a new device to the pairing list.
int8_t otapp_pair_DeviceIndexGet (otapp_pair_DeviceList_t *pairDeviceList, const char *deviceNameFull)
 Retrieves the index of a device in the list by its name.
otapp_pair_Device_totapp_pair_DeviceGet (otapp_pair_DeviceList_t *pairDeviceList, const char *deviceNameFull)
 Retrieves a pointer to the device structure by name.
char * otapp_pair_DeviceNameGet (otapp_pair_DeviceList_t *pairDeviceList, uint8_t indexDevice)
 Retrieves the full name of a device at a specific index.
int8_t otapp_pair_DeviceDelete (otapp_pair_DeviceList_t *pairDeviceList, const char *deviceNameFull)
 Removes a device from the pairing list.
int8_t otapp_pair_DeviceDeleteAll (otapp_pair_DeviceList_t *pairDeviceList)
 Clears all devices from the pairing list.
otapp_pair_DeviceList_totapp_pair_getHandle (void)
 Gets the singleton handle to the global device list.
otIp6Addressotapp_pair_ipAddressGet (otapp_pair_DeviceList_t *pairDeviceList, uint8_t indexDevice)
 Retrieves the IPv6 address of a device at a specific index.
int8_t otapp_pair_ipAddressIsSame (otapp_pair_DeviceList_t *pairDeviceList, uint8_t indexDevice, otIp6Address *ipAddr)
 Checks if the stored IP address matches the provided one.
int8_t otapp_pair_ipAddressUpdate (otapp_pair_DeviceList_t *pairDeviceList, uint8_t indexDevice, otIp6Address *ipAddrNew)
 Updates the IP address of a paired device if it has changed.
void otapp_pair_devicePrintData (otapp_pair_DeviceList_t *pairDeviceList, uint8_t indexDevice)
 Prints debug information about a paired device to the log.
int8_t otapp_pair_addToQueue (otapp_pair_queueItem_t *queueItem)
 Adds an item to the pairing processing queue.
otapp_pair_resUrisParseData_totapp_pair_uriParseMessage (uint8_t *inBuffer, uint16_t inBufferSize, int8_t *result, uint16_t *outParsedDataSize)
 Parses the payload of a CoAP response containing URI resources.
uint16_t otapp_pair_uriParseMessageCalculateBufSize (uint16_t aMessagePayloadSize)
 Calculates the required buffer size to hold a message with URI resources.
int8_t otapp_pair_uriAdd (otapp_pair_uris_t *deviceUrisList, const otapp_pair_resUrisParseData_t *uriData, const oacu_token_t *token)
 Adds a parsed URI to a specific slot in a device's URI list.
int8_t otapp_pair_uriResourcesCreate (otapp_coap_uri_t *uri, uint8_t uriSize, uint8_t *bufferOut, uint16_t *bufferSizeInOut)
 Serializes a list of device URI resources into a TLV-encoded byte buffer.
uint16_t otapp_pair_uriResourcesCalculateBufSize (otapp_coap_uri_t *uri, uint8_t uriSize)
 Calculates the buffer size needed to serialize a list of URIs.
int8_t otapp_pair_uriStateSet (otapp_pair_DeviceList_t *pairDeviceList, const oacu_token_t *token, const uint32_t *uriState)
 Sets the state (value) of a URI based on its token.
int8_t otapp_pair_subSendUpdateIP (otapp_pair_DeviceList_t *pairDeviceList)
 Resends subscription updates to all paired devices (e.g. after IP change).
otapp_pair_uris_totapp_pair_tokenGetUriIteams (otapp_pair_DeviceList_t *pairDeviceList, const oacu_token_t *token)
 Finds a URI item in the list by its token.
int8_t otapp_pair_uriGetIdList (otapp_pair_Device_t *deviceHandle, otapp_deviceType_t uriDevType)
 Searches for a specific device function type within a device's URI list.

Detailed Description

Manages the list of discovered devices, pairing logic, and URI resource parsing.

see more information in section: Device Pairing