OpenThread_app
Loading...
Searching...
No Matches
Device Pairing

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

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...

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.

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

Detailed Description

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

This module handles the core logic of the "Pairing" phase. It maintains a list of known devices (otapp_pair_DeviceList_t), handles the logic of adding/removing devices based on rules, and parses CoAP responses containing device capabilities (URIs). Key Features:

  • Device List Management: Add, remove, and search for devices by name or IP.
  • Rule-based Pairing: Filters incoming devices based on allowed types (defined in driver).
  • TLV Parsing: Decodes Type-Length-Value payloads to extract supported URIs.
  • Observer Pattern: Notifies the application when a new device is successfully paired.
Version
0.1
Date
19-08-2025
Author
Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)

Macro Definition Documentation

◆ OTAPP_PAIR_DEVICE_NAME_EXIST

#define OTAPP_PAIR_DEVICE_NAME_EXIST   (-6)

Device name collision.

◆ OTAPP_PAIR_DEVICE_NAME_TO_LONG

#define OTAPP_PAIR_DEVICE_NAME_TO_LONG   (-7)

Name exceeds buffer size.

◆ OTAPP_PAIR_DEVICE_NO_SPACE

#define OTAPP_PAIR_DEVICE_NO_SPACE   (-8)

Device list is full.

◆ OTAPP_PAIR_DEVICES_MAX

#define OTAPP_PAIR_DEVICES_MAX   OTAPP_PAIRED_DEVICES_MAX

Max number of paired devices (from ot_app.h).

◆ OTAPP_PAIR_END_OF_RULES

#define OTAPP_PAIR_END_OF_RULES   OTAPP_END_OF_DEVICE_TYPE

◆ OTAPP_PAIR_ERROR

#define OTAPP_PAIR_ERROR   (-4)

Generic error.

◆ OTAPP_PAIR_IS

#define OTAPP_PAIR_IS   (1)

Objects are identical.

◆ OTAPP_PAIR_IS_NOT

#define OTAPP_PAIR_IS_NOT   (2)

Objects are different.

◆ OTAPP_PAIR_NAME_FULL_SIZE

#define OTAPP_PAIR_NAME_FULL_SIZE   OTAPP_DEVICE_NAME_FULL_SIZE

◆ OTAPP_PAIR_NO_ALLOWED

#define OTAPP_PAIR_NO_ALLOWED   OTAPP_NO_DEVICE_TYPE

◆ OTAPP_PAIR_NO_EXIST

#define OTAPP_PAIR_NO_EXIST   (-5)

Device not found in list.

◆ OTAPP_PAIR_NO_NEED_UPDATE

#define OTAPP_PAIR_NO_NEED_UPDATE   (-3)

Device exists and data is current.

◆ OTAPP_PAIR_NO_RULES

#define OTAPP_PAIR_NO_RULES   (OTAPP_END_OF_DEVICE_TYPE + 1)

◆ OTAPP_PAIR_NO_URI

#define OTAPP_PAIR_NO_URI   OTAPP_URI_NO_URI_INDEX

◆ OTAPP_PAIR_OBSERVER_PAIRE_DDEVICE_CALLBACK_SIZE

#define OTAPP_PAIR_OBSERVER_PAIRE_DDEVICE_CALLBACK_SIZE   10

◆ OTAPP_PAIR_OK

#define OTAPP_PAIR_OK   (-1)

Operation successful.

◆ OTAPP_PAIR_QUEUE_LENGTH

#define OTAPP_PAIR_QUEUE_LENGTH   10

Depth of the pairing event queue.

◆ OTAPP_PAIR_RULES_ALLOWED_ITEM_MAX_SIZE

#define OTAPP_PAIR_RULES_ALLOWED_ITEM_MAX_SIZE   OTAPP_END_OF_DEVICE_TYPE

◆ OTAPP_PAIR_RULES_ALLOWED_SIZE

#define OTAPP_PAIR_RULES_ALLOWED_SIZE   10

◆ OTAPP_PAIR_TASK_PRIORITY

#define OTAPP_PAIR_TASK_PRIORITY   5

Priority of the pairing RTOS task.

◆ OTAPP_PAIR_TASK_STACK_DEPTH

#define OTAPP_PAIR_TASK_STACK_DEPTH   (128 * 17)

Stack size for the pairing RTOS task.

◆ OTAPP_PAIR_UPDATED

#define OTAPP_PAIR_UPDATED   (-2)

Device data was updated (e.g. new IP).

◆ OTAPP_PAIR_URI_INIT

#define OTAPP_PAIR_URI_INIT   OTAPP_URI_END_OF_INDEX

◆ OTAPP_PAIR_URI_MAX

#define OTAPP_PAIR_URI_MAX   OTAPP_PAIRED_URI_MAX

Max number of URIs per device (from ot_app.h).

◆ OTAPP_PAIR_URI_MAX_VAL

#define OTAPP_PAIR_URI_MAX_VAL   OTAPP_URI_END_OF_INDEX

◆ OTAPP_PAIR_URI_RESOURCE_BUFFER_MAX_SIZE

#define OTAPP_PAIR_URI_RESOURCE_BUFFER_MAX_SIZE   (OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE * OTAPP_PAIR_URI_MAX)

◆ OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE

#define OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE   (OTAPP_URI_MAX_NAME_LENGHT + sizeof(otapp_deviceType_t) + sizeof(uint8_t))

Typedef Documentation

◆ otapp_pair_DeviceList_t

typedef struct otapp_pair_DeviceList_t otapp_pair_DeviceList_t

Opaque handle for the device list.

The actual definition is hidden in the source file to encapsulate the list storage.

◆ otapp_pair_observerCallback_t

typedef void(* otapp_pair_observerCallback_t) (otapp_pair_Device_t *newDevice)

Prototype for observer callback function.

Parameters
[out]newDevicePointer to the structure of the newly paired device.

◆ otapp_pair_resUrisBuffer_t

typedef uint8_t otapp_pair_resUrisBuffer_t[OTAPP_PAIR_URI_RESOURCE_BUFFER_SIZE]

Enumeration Type Documentation

◆ otapp_pair_QueueDataType_t

Queue event types.

Enumerator
OTAPP_PAIR_CHECK_AND_ADD_TO_DEV_LIST 

Event: Check rules and potentially add device.

Function Documentation

◆ otapp_pair_addToQueue()

int8_t otapp_pair_addToQueue ( otapp_pair_queueItem_t * queueItem)

Adds an item to the pairing processing queue.

Parameters
queueItemPointer to the item to add.
Returns
int8_t OTAPP_PAIR_OK on success.

◆ otapp_pair_DeviceAdd()

int8_t otapp_pair_DeviceAdd ( otapp_pair_DeviceList_t * pairDeviceList,
const char * deviceNameFull,
otIp6Address * ipAddr )

Adds a new device to the pairing list.

Parameters
pairDeviceList[in] Handle to the device list (use otapp_pair_getHandle).
deviceNameFull[in] Full device name string.
ipAddr[in] Pointer to the device's IPv6 address.
Returns
int8_t Index of the added device, or error code (OTAPP_PAIR_ERROR, etc.).

◆ otapp_pair_DeviceDelete()

int8_t otapp_pair_DeviceDelete ( otapp_pair_DeviceList_t * pairDeviceList,
const char * deviceNameFull )

Removes a device from the pairing list.

Parameters
pairDeviceListHandle to the device list.
deviceNameFullFull device name string.
Returns
int8_t Index of the deleted device, or error code.

◆ otapp_pair_DeviceDeleteAll()

int8_t otapp_pair_DeviceDeleteAll ( otapp_pair_DeviceList_t * pairDeviceList)

Clears all devices from the pairing list.

Parameters
pairDeviceListHandle to the device list.
Returns
int8_t OTAPP_PAIR_OK.

◆ otapp_pair_DeviceGet()

otapp_pair_Device_t * otapp_pair_DeviceGet ( otapp_pair_DeviceList_t * pairDeviceList,
const char * deviceNameFull )

Retrieves a pointer to the device structure by name.

Parameters
pairDeviceListHandle to the device list.
deviceNameFullFull device name string.
Returns
otapp_pair_Device_t* Pointer to the device, or NULL if not found.

◆ otapp_pair_DeviceIndexGet()

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.

Parameters
pairDeviceList[in] Handle to the device list.
deviceNameFull[in] Full device name string.
Returns
int8_t Device index (0 to Max-1) or OTAPP_PAIR_NO_EXIST.

◆ otapp_pair_DeviceNameGet()

char * otapp_pair_DeviceNameGet ( otapp_pair_DeviceList_t * pairDeviceList,
uint8_t indexDevice )

Retrieves the full name of a device at a specific index.

Parameters
pairDeviceListHandle to the device list.
indexDeviceIndex of the device.
Returns
char* Pointer to the name string, or NULL on error.

◆ otapp_pair_devicePrintData()

void otapp_pair_devicePrintData ( otapp_pair_DeviceList_t * pairDeviceList,
uint8_t indexDevice )

Prints debug information about a paired device to the log.

Parameters
pairDeviceListHandle to the device list.
indexDeviceIndex of the device to print.

◆ otapp_pair_getHandle()

otapp_pair_DeviceList_t * otapp_pair_getHandle ( void )

Gets the singleton handle to the global device list.

Returns
otapp_pair_DeviceList_t* Pointer to the list structure.

◆ otapp_pair_init()

int8_t otapp_pair_init ( ot_app_devDrv_t * driver)

Initializes the pairing module.

Creates the RTOS task and queue responsible for processing discovery events and managing the device list. Registers the initial observer callback.

Parameters
driverPointer to the main application driver instance.
Returns
int8_t OTAPP_PAIR_OK on success.

◆ otapp_pair_ipAddressGet()

otIp6Address * otapp_pair_ipAddressGet ( otapp_pair_DeviceList_t * pairDeviceList,
uint8_t indexDevice )

Retrieves the IPv6 address of a device at a specific index.

Parameters
pairDeviceListHandle to the device list.
indexDeviceIndex of the device.
Returns
otIp6Address* Pointer to the IP address, or NULL on error.

◆ otapp_pair_ipAddressIsSame()

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.

Parameters
pairDeviceListHandle to the device list.
indexDeviceIndex of the device.
ipAddrPointer to the IPv6 address to compare.
Returns
int8_t OTAPP_PAIR_IS (match), OTAPP_PAIR_IS_NOT (different).

◆ otapp_pair_ipAddressUpdate()

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.

Parameters
pairDeviceListHandle to the device list.
indexDeviceIndex of the device.
ipAddrNewPointer to the new IPv6 address.
Returns
int8_t OTAPP_PAIR_UPDATED if changed, OTAPP_PAIR_NO_NEED_UPDATE if same.

◆ otapp_pair_observerPairedDeviceRegisterCallback()

int8_t otapp_pair_observerPairedDeviceRegisterCallback ( otapp_pair_observerCallback_t callback)

Registers a callback to be notified when a new device is paired.

Parameters
callbackFunction pointer to the handler.
Returns
int8_t OTAPP_PAIR_OK on success.

◆ otapp_pair_subSendUpdateIP()

int8_t otapp_pair_subSendUpdateIP ( otapp_pair_DeviceList_t * pairDeviceList)

Resends subscription updates to all paired devices (e.g. after IP change).

Parameters
pairDeviceListHandle to the device list.
Returns
int8_t Count of updated devices or error code.

◆ otapp_pair_tokenGetUriIteams()

otapp_pair_uris_t * otapp_pair_tokenGetUriIteams ( otapp_pair_DeviceList_t * pairDeviceList,
const oacu_token_t * token )

Finds a URI item in the list by its token.

Parameters
pairDeviceListHandle to the device list.
tokenToken to search for.
Returns
otapp_pair_uris_t* Pointer to the URI item or NULL.

◆ otapp_pair_uriAdd()

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.

Parameters
deviceUrisListPointer to the destination slot in the device structure.
uriDataPointer to the parsed source data.
tokenOptional CoAP token if subscription is active.
Returns
int8_t OTAPP_PAIR_OK on success.

◆ otapp_pair_uriGetIdList()

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.

Parameters
deviceHandle[in] Pointer to the device structure.
uriDevType[in] Function type to look for (e.g. LIGHTING_ON_OFF).
Returns
int8_t Index in urisList or OTAPP_PAIR_NO_EXIST.

◆ otapp_pair_uriParseMessage()

otapp_pair_resUrisParseData_t * otapp_pair_uriParseMessage ( uint8_t * inBuffer,
uint16_t inBufferSize,
int8_t * result,
uint16_t * outParsedDataSize )

Parses the payload of a CoAP response containing URI resources.

Extracts TLV data from the buffer and populates an array of otapp_pair_resUrisParseData_t.

Parameters
[in]inBufferPointer to the raw TLV buffer.
[in]inBufferSizeSize of the buffer.
[out]resultOperation result (OTAPP_PAIR_OK / ERROR).
[out]outParsedDataSizeNumber of URI items found.
Returns
otapp_pair_resUrisParseData_t* Pointer to the start of the parsed structures (inside the buffer).

◆ otapp_pair_uriParseMessageCalculateBufSize()

uint16_t otapp_pair_uriParseMessageCalculateBufSize ( uint16_t aMessagePayloadSize)

Calculates the required buffer size to hold a message with URI resources.

Parameters
aMessagePayloadSizeSize of the raw payload.
Returns
uint16_t Total bytes needed.

◆ otapp_pair_uriResourcesCalculateBufSize()

uint16_t otapp_pair_uriResourcesCalculateBufSize ( otapp_coap_uri_t * uri,
uint8_t uriSize )

Calculates the buffer size needed to serialize a list of URIs.

Parameters
uriPointer to array of URIs.
uriSizeNumber of URIs.
Returns
uint16_t Size in bytes.

◆ otapp_pair_uriResourcesCreate()

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.

This function takes an array of CoAP resources and packs them into a user-provided buffer using the TLV Message Buffer module. It is primarily used during the device discovery and pairing phase to inform other nodes about available endpoints. TLV Memory Layout:

┌───────────────────────────────────────────────────────────────────────────────┐
│ TLV MESSAGE BUFFER │
├─────────────┬──────┬─────┬─────┬──────┬─────┬───────┬──────┬──────┬───────┬───│
│ 2B │Key0 │Len0 │Val0 │Key1 │Len1 │Val1 │Key2 │Len2 │Val2 │ │
│writtenBytes │0xAA00│1B │URIs │0xAA01│ 4B │devType│0xAA02│strlen│UriPath│...│
└─────────────┴──────┴─────┴─────┴──────┴─────┴───────┴──────┴──────┴───────┴───┘
Key 0xAA00: uriSize (uint8_t)
Key 0xAA01: uri_1.devType (uint32_t, 4B)
Key 0xAA02: uri_1.mUriPath (char[], variable)
Key 0xAA03: uri_2.devType (uint32_t, 4B)[1]
Key 0xAA04: uri_2.mUriPath (char[], variable)[1]
Key 0xAA05: uri_3.devType (uint32_t, 4B)[2]
Key 0xAA06: uri_3.mUriPath (char[], variable)[2]
...

Encoding Logic:

  • Base key: 0xAA00
  • Key 0xAA00: Total number of URIs (uriSize)
  • For each URI i (0 to uriSize-1):
  • Key 0xAA00 + 2*i + 1: uri[i].devType (4 bytes)
  • Key 0xAA00 + 2*i + 2: uri[i].resource.mUriPath (string length)
    Parameters
    [in]uriPointer to the array of URI resource structures.
    [in]uriSizeNumber of URIs to serialize (max OTAPP_PAIR_URI_MAX).
    [out]bufferOutPointer to the destination buffer (usually acquired via otapp_buf_getWriteOnly_ptr).
    [in,out]bufferSizeInOut[in] Total capacity of the buffer; [out] Actual number of bytes written.
    Returns
    int8_t
  • OTAPP_PAIR_OK on success.
  • OTAPP_PAIR_ERROR if parameters are invalid or buffer space is insufficient.
    Note
    This function automatically updates bufferSizeInOut by calling otapp_msg_tlv_getBufferTotalUsedSpace at the end of the process.

◆ otapp_pair_uriStateSet()

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.

Parameters
pairDeviceList[in] Handle to Pair devices list.
token[in] Token of the URI (from Observe notification).
uriState[in] New state value (max uint32_t).
Returns
int8_t OTAPP_PAIR_OK or OTAPP_PAIR_ERROR.