Peer-to-Peer

This module includes provisional functions for the Thread P2P link.

Summary

Enumerations

otP2pEvent{
  OT_P2P_EVENT_LINKED = 0,
  OT_P2P_EVENT_UNLINKED = 1
}
enum
Defines events of the P2P link.

Typedefs

otP2pEvent typedef
enum otP2pEvent
Defines events of the P2P link.
otP2pEventCallback)(otP2pEvent aEvent, const otExtAddress *aExtAddress, void *aContext) typedef
void(*
Callback function pointer to signal events of the P2P link.
otP2pLinkDoneCallback)(void *aContext) typedef
void(*
Notifies the caller that the P2P link establishment process has ended.
otP2pRequest typedef
struct otP2pRequest
Represents a request for establishing P2P links.

Functions

otP2pSetEventCallback(otInstance *aInstance, otP2pEventCallback aCallback, void *aContext)
void
Sets the callback function to notify event changes of P2P links.
otP2pWakeupAndLink(otInstance *aInstance, const otP2pRequest *aP2pRequest, otP2pLinkDoneCallback aCallback, void *aContext)
Attempts to wake up peers and establish P2P links with peers.

Structs

otP2pRequest

Represents a request for establishing P2P links.

Enumerations

otP2pEvent

 otP2pEvent

Defines events of the P2P link.

Properties
OT_P2P_EVENT_LINKED

The P2P link has been established.

OT_P2P_EVENT_UNLINKED

The P2P link has been torn down.

Typedefs

otP2pEvent

enum otP2pEvent otP2pEvent

Defines events of the P2P link.

otP2pEventCallback

void(* otP2pEventCallback)(otP2pEvent aEvent, const otExtAddress *aExtAddress, void *aContext)

Callback function pointer to signal events of the P2P link.

Details
Parameters
[in] aEvent
The P2P link event.
[in] aExtAddress
A pointer to the peer's Extended Address of the P2P link.
[in] aContext
A pointer to the application-specific context.

otP2pLinkDoneCallback

void(* otP2pLinkDoneCallback)(void *aContext)

Notifies the caller that the P2P link establishment process has ended.

Details
Parameters
[in] aContext
A pointer to the application-specific context.

otP2pRequest

struct otP2pRequest otP2pRequest

Represents a request for establishing P2P links.

Functions

otP2pSetEventCallback

void otP2pSetEventCallback(
  otInstance *aInstance,
  otP2pEventCallback aCallback,
  void *aContext
)

Sets the callback function to notify event changes of P2P links.

A subsequent call to this function will replace any previously set callback.

Details
Parameters
[in] aInstance
The OpenThread instance.
[in] aCallback
The callback function pointer.
[in] aContext
A pointer to the callback application-specific context.
otError otP2pWakeupAndLink(
  otInstance *aInstance,
  const otP2pRequest *aP2pRequest,
  otP2pLinkDoneCallback aCallback,
  void *aContext
)

Attempts to wake up peers and establish P2P links with peers.

If the aP2pRequest indicates a group wake-up, this method establishes multiple P2P links with peers. Otherwise, it establishes at most one P2P link.

Details
Parameters
[in] aInstance
The OpenThread instance.
[in] aP2pRequest
A pointer to P2P request.
[in] aCallback
A pointer to the function that is called when the P2P link establishment process ends .
[in] aContext
A pointer to the callback application-specific context.
Return Values
OT_ERROR_NONE
Successfully started to establish P2P links.
OT_ERROR_BUSY
Establishing a P2P link was in progress.
OT_ERROR_INVALID_STATE
Device was disabled or not fully configured.
OT_ERROR_NO_BUFS
Insufficient buffer space to establish a P2P link.

Resources

OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.