Seeker#
This module includes functions for the Thread Seeker role.
Note
The functions in this module require
OPENTHREAD_CONFIG_SEEKER_ENABLE.
Enumerations#
Represents a verdict returned from the otSeekerScanEvaluator callback when evaluating a Discover Scan result.
Typedefs#
Represents a Discover Scan result.
Represents a verdict returned from the otSeekerScanEvaluator callback when evaluating a Discover Scan result.
Represents the callback function type used to evaluate a scan result or report the end of a scan.
Functions#
Starts the Seeker operation.
Stops the Seeker operation.
Indicates whether or not the Seeker is running.
Gets the Seeker UDP port (unsecure port).
Sets the Seeker UDP port (unsecure port).
Selects the next best candidate and prepares the connection.
Enumeration Documentation#
otSeekerVerdict#
otSeekerVerdict
Represents a verdict returned from the otSeekerScanEvaluator callback when evaluating a Discover Scan result.
| Enumerator | |
|---|---|
| OT_SEEKER_ACCEPT | The scan result is acceptable. |
| OT_SEEKER_ACCEPT_PREFERRED | The scan result is acceptable and preferred. |
| OT_SEEKER_IGNORE | The scan result should be ignored. |
Typedef Documentation#
otSeekerVerdict#
typedef enum otSeekerVerdict otSeekerVerdict
Represents a verdict returned from the otSeekerScanEvaluator callback when evaluating a Discover Scan result.
otSeekerScanEvaluator#
typedef otSeekerVerdict(* otSeekerScanEvaluator) (void *aContext, const otSeekerScanResult *aResult) )(void *aContext, const otSeekerScanResult *aResult)
Represents the callback function type used to evaluate a scan result or report the end of a scan.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| [in] | aContext | A pointer to the callback context. | |
| [in] | aResult | A pointer to the scan result to evaluate, or |
Returns
The verdict for the scan result (Accept, AcceptPreferred, or Ignore). If
aResultisNULL(scan complete), the return value is ignored.
Function Documentation#
otSeekerStart#
otError otSeekerStart (otInstance * aInstance, otSeekerScanEvaluator aScanEvaluator, void * aContext)
Starts the Seeker operation.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | The OpenThread instance. |
| otSeekerScanEvaluator | [in] | aScanEvaluator | The callback function to evaluate scan results. |
| void * | [in] | aContext | An arbitrary context pointer to use with |
The Seeker generates and sets a random MAC address for anonymity, then initiates an MLE Discover Scan to find Joiner Router candidates.
Found candidates are reported to the aScanEvaluator callback. Based on the returned otSeekerVerdict, the Seeker maintains a prioritized list of candidates for future connection attempts.
otSeekerStop#
void otSeekerStop (otInstance * aInstance)
Stops the Seeker operation.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | The OpenThread instance. |
This function stops any ongoing discovery or connection process, unregisters the unsecure Joiner/Seeker UDP port, and clears internal state. If the Seeker is already stopped, this method has no effect.
If the join process succeeds after a call to otSeekerSetUpNextConnection(), the caller MUST call this method to stop the Seeker and, importantly, unregister the Seeker UDP port as an unsecure port.
Note
If
otSeekerSetUpNextConnection()returnsOT_ERROR_NOT_FOUND(indicating the candidate list is exhausted), the Seeker stops automatically.
otSeekerIsRunning#
bool otSeekerIsRunning (otInstance * aInstance)
Indicates whether or not the Seeker is running.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | The OpenThread instance. |
otSeekerGetUdpPort#
uint16_t otSeekerGetUdpPort (otInstance * aInstance)
Gets the Seeker UDP port (unsecure port).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | The OpenThread instance. |
Returns
The Seeker UDP port.
otSeekerSetUdpPort#
otError otSeekerSetUdpPort (otInstance * aInstance, uint16_t aUdpPort)
Sets the Seeker UDP port (unsecure port).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [in] | aInstance | The OpenThread instance. |
| uint16_t | [in] | aUdpPort | The Seeker UDP port. |
This UDP port can only be changed when the Seeker is not running.
otSeekerSetUpNextConnection#
otError otSeekerSetUpNextConnection (otInstance * aInstance, otSockAddr * aSockAddr)
Selects the next best candidate and prepares the connection.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| otInstance * | [out] | aInstance | A pointer to a socket address to output the candidate's address. |
| otSockAddr * | N/A | aSockAddr |
This function MUST be called after the discovery scan has completed (indicated by the otSeekerScanEvaluator callback receiving NULL). Calling it before scan completion will result in OT_ERROR_INVALID_STATE.
This function iterates through the discovered Joiner Router candidates in order of priority. For the selected candidate, it configures the radio channel and PAN ID, and populates aSockAddr with the candidate's address. It also registers the Seeker UDP port otSeekerGetUdpPort() as an unsecure port to allow a UDP connection to the candidate. The next layer code can start sending UDP messages to the given otSockAddr ensuring to use the unsecure Seeker UDP port as the source port. These messages are then forwarded by the Joiner Router onward to a Commissioner/Enroller connected via a Border Agent/Admitter.
If the list is exhausted, this function returns OT_ERROR_NOT_FOUND and automatically calls otSeekerStop(), which removes the unsecure port and clears internal state.