OpenThread_app
Loading...
Searching...
No Matches
Core Definitions & Init

Core types, global configuration macros, and framework initialization routines. More...

Typedefs

typedef struct ot_app_devDrv_t ot_app_devDrv_t

Enumerations

enum  otapp_deviceType_t {
  OTAPP_NO_DEVICE_TYPE = 0 , OTAPP_CONTROL_PANEL = 1 , OTAPP_SWITCH , OTAPP_LIGHTING ,
  OTAPP_LIGHTING_ON_OFF , OTAPP_LIGHTING_DIMM , OTAPP_LIGHTING_RGB , OTAPP_THERMOSTAT ,
  OTAPP_THERMOSTAT_SET_TEMP , OTAPP_THERMOSTAT_READ_SET_TEMP , OTAPP_THERMOSTAT_READ_CURRENT_TEMP , OTAPP_SENSOR ,
  OTAPP_DOOR_LOCK , OTAPP_MOTION_DETECTOR , OTAPP_REMOTE_CONTROL , OTAPP_ENERGY_METER ,
  OTAPP_SMART_PLUG , OTAPP_ENVIRONMENT_SENSOR , OTAPP_DOOR_SENSOR , OTAPP_ALARM ,
  OTAPP_END_OF_DEVICE_TYPE
}
 Supported Device Types. Identifies the functional role of the device within the OpenThread network. This enum is used during the discovery phase to filter devices (e.g., a Switch looking for Lights). More...

Functions

ot_app_devDrv_totapp_getDevDrvInstance (void)
 Retrieves the singleton instance of the Device Driver.
otInstanceotapp_getOpenThreadInstancePtr (void)
 Retrieves the global OpenThread instance pointer.
const otIp6Addressotapp_multicastAddressGet (void)
 Gets the framework-defined multicast address. Used for group communication or discovery.
const otIp6Addressotapp_ip6AddressGet (void)
 Gets the current Mesh-Local EID (IPv6 address) of this device.
void otapp_ip6AddressPrint (const otIp6Address *aAddress)
 Prints an IPv6 address to the log output.
const otIp6Addressotapp_ip6AddressRefresh (void)
 Refreshes and returns the current Mesh-Local EID. Updates the internal cache of the device's IP address from the OpenThread stack.
const otExtAddressotapp_macAddrGet (void)
 Gets the Factory Assigned IEEE EUI-64 address.
int8_t otapp_init (void)
 Main initialization of the OpenThread Application Framework. Initializes the driver instance, OpenThread instance (port), pairing module, and shared buffers.
void otapp_network_init (void)
 Initializes the network layer components. Sets up the operational dataset, device name, CoAP services, and SRP client. Typically called within the OpenThread task context.
void otapp_setDataset_tlv (void)
 Applies the Operational Dataset TLV to the OpenThread stack. Configures network parameters like Channel, PANID, Network Key, etc.

Logging Configuration

#define OTAPP_LOG_ENABLE
#define OTAPP_PRINTF   HRO_PRINTF

Network Configuration

#define OTAPP_CCA_THRESHOLD   (-70)
 Clear Channel Assessment threshold in dBm.
#define OTAPP_UDP_PORT   12345
 Default UDP port for application traffic.

Return Codes

#define OTAPP_OK   (-1)
 Operation successful.
#define OTAPP_ERROR   (-2)
 Generic error.

Buffer & Limits definitions

#define OTAPP_CHAR_BUFFER_SIZE   1024
 Size for temporary string buffers.
#define OTAPP_PAIRED_DEVICES_MAX   10
 Max number of devices to save from DNS query results.
#define OTAPP_PAIRED_URI_MAX   3
 Max number of URIs per paired device.
#define OTAPP_URI_MAX_NAME_LENGHT   24
 Max length of URI string name (e.g. "light/dimm").
#define OTAPP_DNS_SRV_NAME_SIZE   64
 OT_DNS_MAX_NAME_SIZE full service name: "_coap._udp.default.service.arpa.".
#define OTAPP_DNS_SRV_LABEL_SIZE   32
 OT_DNS_MAX_LABEL_SIZE host name: "device1_1_588c81fffe301ea4".
#define OTAPP_DNS_SRV_TXT_SIZE   512
 DNS TXT record buffer size.
#define OTAPP_DEVICE_NAME_FULL_SIZE   OTAPP_DNS_SRV_LABEL_SIZE

Detailed Description

Core types, global configuration macros, and framework initialization routines.

This module defines the fundamental structures used across the framework, including the supported device types (otapp_deviceType_t) and global accessors for OpenThread instances and network addresses.

Author
Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)
Version
0.1
Date
14-07-2025

Macro Definition Documentation

◆ OTAPP_CCA_THRESHOLD

#define OTAPP_CCA_THRESHOLD   (-70)

Clear Channel Assessment threshold in dBm.

◆ OTAPP_CHAR_BUFFER_SIZE

#define OTAPP_CHAR_BUFFER_SIZE   1024

Size for temporary string buffers.

◆ OTAPP_DEVICE_NAME_FULL_SIZE

#define OTAPP_DEVICE_NAME_FULL_SIZE   OTAPP_DNS_SRV_LABEL_SIZE

◆ OTAPP_DNS_SRV_LABEL_SIZE

#define OTAPP_DNS_SRV_LABEL_SIZE   32

OT_DNS_MAX_LABEL_SIZE host name: "device1_1_588c81fffe301ea4".

◆ OTAPP_DNS_SRV_NAME_SIZE

#define OTAPP_DNS_SRV_NAME_SIZE   64

OT_DNS_MAX_NAME_SIZE full service name: "_coap._udp.default.service.arpa.".

◆ OTAPP_DNS_SRV_TXT_SIZE

#define OTAPP_DNS_SRV_TXT_SIZE   512

DNS TXT record buffer size.

◆ OTAPP_ERROR

#define OTAPP_ERROR   (-2)

Generic error.

◆ OTAPP_LOG_ENABLE

#define OTAPP_LOG_ENABLE

◆ OTAPP_OK

#define OTAPP_OK   (-1)

Operation successful.

◆ OTAPP_PAIRED_DEVICES_MAX

#define OTAPP_PAIRED_DEVICES_MAX   10

Max number of devices to save from DNS query results.

◆ OTAPP_PAIRED_URI_MAX

#define OTAPP_PAIRED_URI_MAX   3

Max number of URIs per paired device.

◆ OTAPP_PRINTF

#define OTAPP_PRINTF   HRO_PRINTF

◆ OTAPP_UDP_PORT

#define OTAPP_UDP_PORT   12345

Default UDP port for application traffic.

◆ OTAPP_URI_MAX_NAME_LENGHT

#define OTAPP_URI_MAX_NAME_LENGHT   24

Max length of URI string name (e.g. "light/dimm").

Typedef Documentation

◆ ot_app_devDrv_t

typedef struct ot_app_devDrv_t ot_app_devDrv_t

Enumeration Type Documentation

◆ otapp_deviceType_t

Supported Device Types. Identifies the functional role of the device within the OpenThread network. This enum is used during the discovery phase to filter devices (e.g., a Switch looking for Lights).

Enumerator
OTAPP_NO_DEVICE_TYPE 

Undefined device type.

OTAPP_CONTROL_PANEL 

Central control panel or gateway.

OTAPP_SWITCH 

Physical button or switch.

OTAPP_LIGHTING 

Generic lighting device.

OTAPP_LIGHTING_ON_OFF 

Simple On/Off light.

OTAPP_LIGHTING_DIMM 

Dimmable light.

OTAPP_LIGHTING_RGB 

Color changing light (RGB).

OTAPP_THERMOSTAT 

Generic thermostat.

OTAPP_THERMOSTAT_SET_TEMP 

Thermostat: Set point control.

OTAPP_THERMOSTAT_READ_SET_TEMP 

Thermostat: Read set point.

OTAPP_THERMOSTAT_READ_CURRENT_TEMP 

Thermostat: Read ambient temp.

OTAPP_SENSOR 

Generic sensor (output only).

OTAPP_DOOR_LOCK 

Smart door lock.

OTAPP_MOTION_DETECTOR 

PIR or microwave motion sensor.

OTAPP_REMOTE_CONTROL 

Handheld remote.

OTAPP_ENERGY_METER 

Power consumption meter.

OTAPP_SMART_PLUG 

Smart socket/plug.

OTAPP_ENVIRONMENT_SENSOR 

Environmental sensor (Humidity, Air Quality, etc.).

OTAPP_DOOR_SENSOR 

Reed switch / door open sensor.

OTAPP_ALARM 

Siren or alarm system.

OTAPP_END_OF_DEVICE_TYPE 

Sentinel value.

Function Documentation

◆ otapp_getDevDrvInstance()

ot_app_devDrv_t * otapp_getDevDrvInstance ( void )

Retrieves the singleton instance of the Device Driver.

Returns
ot_app_devDrv_t* Pointer to the driver instance containing hardware callbacks and config.

◆ otapp_getOpenThreadInstancePtr()

otInstance * otapp_getOpenThreadInstancePtr ( void )

Retrieves the global OpenThread instance pointer.

Returns
otInstance* Pointer to the OpenThread stack instance.

◆ otapp_init()

int8_t otapp_init ( void )

Main initialization of the OpenThread Application Framework. Initializes the driver instance, OpenThread instance (port), pairing module, and shared buffers.

Returns
int8_t OTAPP_OK on success.

◆ otapp_ip6AddressGet()

const otIp6Address * otapp_ip6AddressGet ( void )

Gets the current Mesh-Local EID (IPv6 address) of this device.

Returns
const otIp6Address* Pointer to the IPv6 address.

◆ otapp_ip6AddressPrint()

void otapp_ip6AddressPrint ( const otIp6Address * aAddress)

Prints an IPv6 address to the log output.

Parameters
aAddressPointer to the IPv6 address to print.

◆ otapp_ip6AddressRefresh()

const otIp6Address * otapp_ip6AddressRefresh ( void )

Refreshes and returns the current Mesh-Local EID. Updates the internal cache of the device's IP address from the OpenThread stack.

Returns
const otIp6Address* Pointer to the refreshed IPv6 address.

◆ otapp_macAddrGet()

const otExtAddress * otapp_macAddrGet ( void )

Gets the Factory Assigned IEEE EUI-64 address.

Returns
const otExtAddress* Pointer to the hardware MAC address.

◆ otapp_multicastAddressGet()

const otIp6Address * otapp_multicastAddressGet ( void )

Gets the framework-defined multicast address. Used for group communication or discovery.

Returns
const otIp6Address* Pointer to the multicast IPv6 address.

◆ otapp_network_init()

void otapp_network_init ( void )

Initializes the network layer components. Sets up the operational dataset, device name, CoAP services, and SRP client. Typically called within the OpenThread task context.

◆ otapp_setDataset_tlv()

void otapp_setDataset_tlv ( void )

Applies the Operational Dataset TLV to the OpenThread stack. Configures network parameters like Channel, PANID, Network Key, etc.