Handles network service browsing, hostname resolution, and initiates the device pairing sequence.
More...
|
| #define | OTAPP_DNS_OK (-1) |
| | Operation successful.
|
| #define | OTAPP_DNS_ERROR (-2) |
| | Generic error (e.g., invalid arguments or buffer allocation fail).
|
Handles network service browsing, hostname resolution, and initiates the device pairing sequence.
This module acts as the entry point for finding other devices on the Thread network. It utilizes the OpenThread DNS Client API to browse for specific service types (e.g., _coap._udp). Workflow:
- Browse: Scans the network for services matches the provided service name.
- Resolve: For every discovered service instance, it resolves the hostname to an IPv6 address.
- Queue: Once resolved, the device information (Name + IP) is added to the pairing queue via otapp_pair_addToQueue.
Discovery & Pairing Log Sequence
The following log output demonstrates a successful discovery cycle where the DNS module finds devices, resolves them, and passes them to the Pairing and CoAP modules for verification:
$$ ot_app_dns --> DNS client browse. Checked reported services:
$$ ot_app_dns --> DNS browse response for _coap._udp.default.service.arpa.
$$ ot_app_dns --> Device full name (label): device1_2_588c81fffe3029f0
$$ ot_app_dns -->
$$ ot_app_dns --> Device full name (label): device1_3_588c81fffe3035a4
$$ ot_app_dns -->
$$ ot_app_dns --> Device full name (label): device1_2_588c81fffe301ea4
$$ ot_app_dns -->
$$ ot_app_dns --> DNS: Add item to queue
$$ ot_app_pair --> Pairing device: device1_2_588c81fffe3029f0
$$ ot_app_pair --> = current device, or NOT allowed
$$ ot_app_dns --> DNS: Add item to queue
$$ ot_app_pair --> Pairing device: device1_3_588c81fffe3035a4
$$ ot_app_coap --> CoAP sentGetByte to .well-known/core
$$ ot_app_coap --> CoAP sent WELL KNOWN URI
$$ ot_app_pair --> success paired on index 0
$$ ot_app_dns --> DNS: Add item to queue
$$ ot_app_pair --> Pairing device: device1_2_588c81fffe301ea4
$$ ot_app_pair --> = current device, or NOT allowed
$$ ot_app_pair --> responseHandlerUriWellKnown IN
$$ ot_app_coap --> CoAP sent SubscribeRequest
$$ ot_app_coap --> CoAP sent SubscribeRequest
$$ ot_app_coap --> CoAP sent SubscribeRequest
$$ ad_button --> Dev Button detect DEVICE! device1_3_588c81fffe3035a4
$$ ad_button --> uri 0: light/on_off
$$ ad_button --> uri 1: light/dimm
$$ ad_button --> uri 2: light/rgb
- Version
- 0.1
- Date
- 05-09-2025
- Author
- Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)
- Copyright
- © 2025 MIT LICENCE
◆ OTAPP_DNS_ERROR
| #define OTAPP_DNS_ERROR (-2) |
Generic error (e.g., invalid arguments or buffer allocation fail).
◆ OTAPP_DNS_OK
| #define OTAPP_DNS_OK (-1) |
◆ otapp_dnsClientBrowse()
| int8_t otapp_dnsClientBrowse |
( |
otInstance * | instance, |
|
|
const char * | serviceName ) |
Initiates a DNS-SD browse operation for a specific service.
This function starts the browsing process. When services are found, the internal callback chain is triggered: otapp_dnsClientBrowseResponseCallback -> otapp_dnsClientResolve -> otapp_dnsPairDevice. This ultimately pushes discovered devices into the pairing queue.
- Parameters
-
| [in] | instance | Pointer to the OpenThread instance structure. |
| [in] | serviceName | The service to browse for (e.g., "_coap._udp.default.service.arpa"). |
- Returns
- int8_t