Peer-to-Peer#

This module includes provisional functions for the Thread P2P link.

Note

  • The functions in this module require OPENTHREAD_CONFIG_P2P_ENABLE=1.

Modules#

otP2pRequest

Enumerations#

enum
OT_P2P_EVENT_LINKED = 0
OT_P2P_EVENT_UNLINKED = 1
}

Defines events of the P2P link.

Typedefs#

typedef struct otP2pRequest

Represents a request for establishing P2P links.

typedef void(*
otP2pLinkDoneCallback)(void *aContext)

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

typedef void(*
otP2pUnlinkDoneCallback)(void *aContext)

Notifies the caller that the P2P link tear down process has ended.

typedef enum otP2pEvent

Defines events of the P2P link.

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

Callback function pointer to signal events of the P2P link.

Functions#

otP2pWakeupAndLink(otInstance *aInstance, const otP2pRequest *aP2pRequest, otP2pLinkDoneCallback aCallback, void *aContext)

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

otP2pUnlink(otInstance *aInstance, const otExtAddress *aExtAddress, otP2pUnlinkDoneCallback aCallback, void *aContext)

Tears down the P2P link specified by the Extended Address.

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

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

Enumeration Documentation#

otP2pEvent#

otP2pEvent

Defines events of the P2P link.

Enumerator
OT_P2P_EVENT_LINKED

The P2P link has been established.

OT_P2P_EVENT_UNLINKED

The P2P link has been torn down.


Typedef Documentation#

otP2pRequest#

typedef struct otP2pRequest otP2pRequest

Represents a request for establishing P2P links.


otP2pLinkDoneCallback#

typedef void(* otP2pLinkDoneCallback) (void *aContext) )(void *aContext)

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

Parameters
TypeDirectionArgument NameDescription
[in]aContext

A pointer to the application-specific context.


otP2pUnlinkDoneCallback#

typedef void(* otP2pUnlinkDoneCallback) (void *aContext) )(void *aContext)

Notifies the caller that the P2P link tear down process has ended.

Parameters
TypeDirectionArgument NameDescription
[in]aContext

A pointer to application-specific context.


otP2pEvent#

typedef enum otP2pEvent otP2pEvent

Defines events of the P2P link.


otP2pEventCallback#

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

Callback function pointer to signal events of the P2P link.

Parameters
TypeDirectionArgument NameDescription
[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.


Function Documentation#

otP2pWakeupAndLink#

otError otP2pWakeupAndLink (otInstance * aInstance, const otP2pRequest * aP2pRequest, otP2pLinkDoneCallback aCallback, void * aContext)

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

Parameters
TypeDirectionArgument NameDescription
otInstance *[in]aInstance

The OpenThread instance.

const otP2pRequest *[in]aP2pRequest

A pointer to P2P request.

otP2pLinkDoneCallback[in]aCallback

A pointer to the function that is called when the P2P link establishment process ends .

void *[in]aContext

A pointer to the callback application-specific context.

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


otP2pUnlink#

otError otP2pUnlink (otInstance * aInstance, const otExtAddress * aExtAddress, otP2pUnlinkDoneCallback aCallback, void * aContext)

Tears down the P2P link specified by the Extended Address.

Parameters
TypeDirectionArgument NameDescription
otInstance *[in]aInstance

The OpenThread instance.

const otExtAddress *[in]aExtAddress

A pointer to the P2P peer's Extended Address.

otP2pUnlinkDoneCallback[in]aCallback

A pointer to function that is called when the P2P link tear down process has ended.

void *[in]aContext

A pointer to callback application-specific context.


otP2pSetEventCallback#

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

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

Parameters
TypeDirectionArgument NameDescription
otInstance *[in]aInstance

The OpenThread instance.

otP2pEventCallback[in]aCallback

The callback function pointer.

void *[in]aContext

A pointer to the callback application-specific context.

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